I have 3 classes A, B and C. And there relationships are:
- One to many bi-directional from A to B.
- C extends B.
I am able to add new records and edit existing records of address collection, but i am not able to remove any existing record.
Code to update Object
currentObj = getSession().merge(currentObj);
Mappings:
Address.hbm.xml
<joined-subclass name="test.domain.ParticipantAddress" table="PARTICIPANT_ADDRESS" dynamic-update="false" dynamic-insert="false" lazy="true" > <key column="IDENTIFIER" /> <many-to-one name="participant" class="test.domain.Participant" column="PARTICIPANT_ID" not-null="false" cascade="none" unique="true"/> <property name="sortOrder" type="long" update="true" insert="true" column="sortOrder" length="255" /> </joined-subclass>
Participant.hbm.xml
<list name="addressCollection" table="PARTICIPANT_ADDRESS" lazy="false" inverse="true" cascade="all"> <cache usage="read-write"/> <key column="PARTICIPANT_ID"/> <list-index column="sortOrder"/> <one-to-many class="test.domain.ParticipantAddress"/> </list>
I also tried using cascade="all,delete-orphan" but it's also throwing error "A collection with cascade=”all-delete-orphan” was no longer referenced by the owning entity instance"