First i want to precised that i have read all possible posts on this problem in this forum but i didn't find any fix.
My settings:
Hibernate version: 3.0.5 JDK 1.5.0_03
Name and version of the database: hsqldb
mapping
Code:
<class name="BookingBO" table="booking" proxy="BookingBO">
<id name="bkgnum" type="string">
<generator class="assigned"/>
</id>
<set name="rooms" lazy="false" inverse="true" cascade="all-delete-orphan">
<key column="bkgnum"/>
<one-to-many class="RoomStayBO" />
</set>
</class>
Code:
<class name="RoomStayBO" table="roomstay" proxy="RoomStayBO">
<id name="roomstayid" type="integer">
<generator class="identity"/>
</id>
<property name="bkgnum" type="string" />
</class>
The generated SQL (show_sql=true):I have an object "booking" with two objects "roomstay" in a set.
i try to delete one of this roomstay and update another field in booking object.
Because user is using a swing UI to make changes, roomstay displayed are "cloned" to allow user to cancel it's change using a cancel button on dialog:
->a mainpanel is displaying booking with a list of room stays
->user can select a roomstay to edit it (in such case, room stay is cloned)
->if user validate his change, room stay edited replace old one in Booking object Set.
->When user validate change on booking, hibernate is called with booking to update. The Set in booking object to update is not a new one:
Code:
booking1.getRooms().clear();
List<RoomStayBO> roomStays = this.roomStayPN.getRoomStays();
booking1.getRooms().addAll(roomStays);;
The generated SQL (show_sql=true):
Hibernate: update booking set leadpaxid=?, (...)
Hibernate: update roomstay set bkgnum=?, (...)
The orphan roomstay is neither updated, nor deleted. In debugging mode, i notice that getOrphans() from PersistentSet is called but never returns a collection containing my deleted object.
Any idea?
Thanks.