I need someone to correct my understanding of one-to-many.
I have a many to one unidirectional relationship between two objects.
person is the parent and address is the child.
The id for person is auto generated. person has a list of addresses mapped as ont-to-many with person as the owner.
I create a new person, then create 2 new addresses and add them to the list.
Then I call persist on the new person record.
Jboss creates the person record, and generates the id (the object returned from persist has the id created by the database). Sadly the join column in the address table does not get populated with the id from the person. I would expect JBoss to populate the children (address) records with the id of the parent before persisting them.
What am I missing here?
Any references to documentation would be appreciated.
Is this just me or is this the expected behavior?
Thanks in advance.
What annotations are you using? Some detail would be helpful in analyzing the problem. If you have everything set up correctly then the required id should be persisted to the database.
Specifically what, if any, cascade is set in your OneToMany annotation? Also, a code snippet showing your creation process would be helpful.