I have two entities:
Account {
@Id
Long id;
}
Preference {
...
@ManyToOne
private Account account;
}
When saving a Preference, I have the accountId, but I don't have an Account entity. How should I save the preference in this situation?
Load the Account entity and set it on the preference? To me, that seems like an erroneous trip to the database.
Have an accountId field that is persistable and make the Account field read-only? Having both an accountId field and an Account field seems redundant?
Use a NamedQuery to persist the Preference? I was hoping to just generically save an entity without special logic for.