I have a class called Relationship, and a class called Party. A party can have 1+ relationships, and a relationship is between two parties. So mapping looks like:
Party kind of looks like:
I can persist the Relationship, and both parties make it into the database, and the database is populated correctly. However, when I retrieve the toParty it does NOT know about the relationship it's involved in. The fromParty however does know about the Relationship, and the Relationship knows about both parties.
Anybody have any ideas on how to get the toParty to have the relationship list populated correctly?
You're going to need to make the relationship bidirectional. I have a free tutorial on creating one to many and many-to-one mappings that use a Player and a Team - similar to your scenario. Here are the annotations on each side:
Joined: Jun 05, 2008
It is a bi-directional mapping. That's not the question. The question is that I have TWO fields pointing to the SAME class, and ONE of the fields is not getting populated on the other side correctly. The from field is not getting it's list of relationships populated at all. The to field however is getting populated correctly. The database is populated correctly. And, as an added note it is whatever field I declare second, the first field always gets populated.