suryavijayk wrote:
letap wrote:
JustKeith wrote:
The mapping you propose is legal and actually works. I just modified one of my small test programs to match that mapping and was able to both save and retreive data. Hibernate has no objections to uni-directional associations though I seem to remember a comment in the manual that in SOME cases they might not perform well.
I tried doing it but was unable to insert into child table! how did u do that?/
I have had this issue while deleting. I tried to delete the parent with a mapping on the parent class link to the child as
<set
name="childProps"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="PARENT_ID" />
</key>
<one-to-many
class="ChildClass"
/>
</set>
and it tries to delete from the parent without deleting the children which causes the database to throw a child record found error because the child not being deleted.
Thanks for any help!!
Surya
I'm not sure, but maybe cascade="all,delete-orphans" might help.
The question that arises is whether a child object that is not in the set any more should be deleted. I don't think that Hibernate does that per default.
Reference Chapter 11 wrote:
If the child object's lifespan is bounded by the lifespan of the of the parent object make it a lifecycle object by specifying cascade="all,delete-orphan".
hth,
Heinz
Don't forget to rate if this helped