sboulay wrote:
yes this is correct , however , when u access the the collection to add the child the collection still needs to be intialized.
Parent.addChild(new Child());
with inverse="true" .. the child will do the insert but hibernate will still initialize the collection of the parent. What I am doing now is just saving the child by and pointing it to the parent.
What you do is correct (according to me).
* insert the child and point it to the parent (using a many-to-one);
* in the parent, you can still have a collection of the children (as an unindexed collection - set or bag) mapped with the *inverse* keyword. This keyword actually says the relationship between parent and child is actually managed by the child...
Using this strategy, you don't access the parent's children collection - so Hibernate shouldn't initialize it.