I have a problem with a simple unidirectional mapping. Here are my entities:
@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 {
...
}
Each account must have a Profile assigned. The account should be the owning side of the mapping. Where is the best place to initialize the dependendt Profile attribute? I tried to initialize the profile in the constructor of the Account entity but this doesn´t work.
You could initialize it in the constructor, but setting it in the application or a factory may be better.
What does not work, what error do you get?