I have a weird problem with a child entity with composite id , containing the parents primary key.
Mapping:
In Parent:
<id name="parentId" type="integer">
<generator class="sequence"/>
</id>
<set name="children" cascade="all-delete-orphan" inverse="true">
<key column="parent"/>
<one-to-many class="Child"/>
</set>
In Child:
<composite-id>
<key-property name="name" />
<key-many-to-one name="parent" class="Parent" column="parentId" />
</composite-id>
<version column="version" name="version" type="integer" unsaved-value="negative"/>
In my code I wish to delete a few children for a parent and call a update on the parent to cascade the effect onto the chidlren. More precisely, heres what I do:
Code:
Parent p = getParent();
p.getChildren().remove(someChild);
p.update();
All work fine with my tests.. they all reflect exactly the desired behaviour.
Code:
update parent ...;
update child....;
delete from child ...;
But when the same api is called from a GUI client (I have a RMI Client Server architecture), Hibernate wouldnt issue the delete query on the children.
Code:
update parent...;
update child ...;
I doubly verified if the GUI code actually removes the desired child from the Set (Client shares the wrapped Hibernate Set class). It does so.. there is no difference between the code in my tests and the GUI client... but clearly the queries executing during the calls are different!
I hope my problem is clearly defined.. I guess the problem is with the composite id mapping, because I have successfully executed similar parent child mappings that dont need a composite id. Whats going wrong?
--
Thanks.
Code: