I have class Money which is an @Embeddable
@Embeddable
public class Money implements Serializable, Comparable<Money> {
@Column(name = "amount", precision = 15, scale = 2)
private BigDecimal amount;
}
When I useit multiple time inside entity, everything works fine. For example
@Entity
public class SomeEntity implements Serializable {
@Embedded
@AttributeOverride(name = "amount", column = @Column(name = "entry"))
private Money entryValue;
@Embedded
@AttributeOverride(name = "amount", column = @Column(name = "leave"))
private Money leaveValue;
}
Code above works perfectly.
Now the problem occurs when I have another @Embeddable that I want to have Money instances in it and that @Embeddable is used by an entity multiple times. Example:
Embeddable
@Embeddable public class ReportCostValues implements Serializable { @Embedded @AttributeOverride(name = "amount", column = @Column(name = "covered_by_grant")) private Money coveredByGrant; @Embedded @AttributeOverride(name = "amount", column = @Column(name = "own_resources")) private Money foundedFromOwnResources; @Embedded @AttributeOverride(name = "amount", column = @Column(name = "personal_contribution")) private Money personalContribution;
Entity
@Entity public class ReportCostEntity implements Identifiable<Long>, Serializable { @Id private Long id; @Embedded private ReportCostValues contracted; @Embedded private ReportCostValues current; @Embedded private ReportCostValues previousReport;
This code above will not work. Any ideas how to approach this problem?