Hello,
is there a way that lifecycle events like prepersist or preupdate are also fired for embeddable classes, not just for entities?
My case looks as follows:
@Entity public class Foo { @Id @GeneratedValue private Long id; private String description; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) private List<Bar> barList; @Temporal(TemporalType.TIMESTAMP) private Timestamp modifyDate; @PrePersist @PreUpdate void onPreUpdate() { modifyDate = new Timestamp(System.currentTimeMillis()); }} @Embeddable public class Bar { @Temporal(TemporalType.TIMESTAMP) private Timestamp modifyDate; private Integer priority; private String comment; @PrePersist @PreUpdate void onPreUpdate() { modifyDate = new Timestamp(System.currentTimeMillis()); }}
When i update oder create Entity Foo AND Bar, onPreUpdate() is triggered on Foo, but not on Bar (even if priority or comment have changed)
Is there a solution to this problem? What does the JPA standard say?
Greetings
ObjectArts