In my OpenXava application, the @Calculation annotation does not work.
Here my coding for my @Embeddable that uses @Calculation:
import java.math.*;
import java.time.*;
import javax.persistence.*;
import org.openxava.annotations.*;
import lombok.*;
@Getter @Setter
@Embeddable
public class Payment {
@ManyToOne(fetch=FetchType.EAGER)
@DescriptionsList
Paymentfrequency paymentFrequency;
LocalDate firstPaymentDate;
@Stereotype("MONEY")
BigDecimal paymentAmount;
@ManyToOne(fetch=FetchType.LAZY)
@DescriptionsList
Methodofpayment methodOfPayment;
@ReadOnly
@Stereotype("MONEY")
@Calculation("paymentAmount * paymentFrequency.frequencyPerYear")
BigDecimal annualContribution;
}
And this the code for the entity with the collection of embeddables:
import javax.persistence.*;
import lombok.*;
@Entity @Getter @Setter
public class Paymentfrequency extends GenericType {
int frequencyPerYear;
// Payment is used as collection
@ElementCollection
@ListProperties("firstPaymentDate, paymentAmount, paymentFrequency,
methodOfPayment, annualContribution")
Collection<Payment> payments;
}
And this the result:
Note as the last column (annualContribution) is not recalculated when the operands change.
Why does not work @Calculation in this case?