I have some problems with storing this simple mapping:
@Entity
public class Account extends UUIDBase {
private Profile profile;
@OneToOne(cascade = CascadeType.ALL, optional = false)
public Profile getProfile() {
return profile;
}
public void setProfile(Profile profile) {
this.profile = profile;
}
}
@Entity
public class Profile extends UUIDBase {
...
}
Our entities have all the attribute "creationDate" and "lastUpdated". These attributes are placed in the mapped superclass UUIDBase. When a entity is persisted or updated both fields will be updated in @PrePersist and @PreUpdate callback. This works fine except in the case of cascading.
When we store the Account the Profile will always be stored, too. The creationDate and lastUpdated attribute of the account will be initialized through the callback methods. The callbacks methods for the Profile will not be called. Do you have a hint what´s going wrong?