Now I have two classes
class A{ @Column(name="num1") private BigDecimal num1; private B b; //getter and setter } And
class B{ @Column(name="num2") private BigDecimal num2; //getter and setter } I have tried to add a new field called total in class A and add the getter in AView.
class A{ @Column(name="num1") private BigDecimal num1; // a custom field that does not exist in db private BigDecimal total; //suppose we have joined two entity using @join annotation private B b; public getTotal(){ return this.num1.add(b.num2); } // other getter and setter } public interface AView{ // add num1 and num2 BigDecimal total(); } But it showed error message.
I have found a solution but it does not work. https://www.baeldung.com/spring-data-jpa-projections#2-open-projections Are there any other solutions? Thank you!
https://stackoverflow.com/questions/65608941/how-to-add-custom-field-in-model-with-spring-boot-projection January 07, 2021 at 04:28PM
没有评论:
发表评论