i have an object with a list of references to different concrete implementations of an abstract base class. when i try to remove a reference from the collection and saveOrUpdate() the object, the operation isn't cascaded and the referenced object isn't removed from the database. The referenced objects are ONLY removed if i remove all refernces from the list, but just one, doesn't work.
Mapping:
Code:
<composite-id access="property">
<key-property name="key1" column="key_col1"/>
<key-property name="key2" column="key_col2"/>
</composite-id>
<list name="values"
lazy="false"
cascade="save-update,delete,delete-orphan">
<key not-null="true">
<column name="key_col1"/>
<column name="key_col2"/>
</key>
<list-index base="0" column="pos"/>
<one-to-many class="AbstractAttributeValueObject"/>
</list>
Here, AbstractAttributeValueObject is the abstract base class. There exists several implementations mapped as <subclass> using the Table per Class Hiearchy - strategy.
What do i have to do so that the remove operation is cascaded and the refernced object is deleted from the database?
Right now i perform the following steps:
0. obtain session
1. load object
2. detach object, put it into user session
3. remove references from list
4. call saveOrUpdate() on a different hibernate session
chris