I've got an interesting problem I hope someone can help me out with. I have an object that exists in two different locations simultaneously. The "home" object consists of only the base object (BasicItem, in this case). The "remote" object is identical except that it may contain a collection of override objects. Occasionally, the home objects are pushed to the remote location and synchronized carefully with the current set of objects. Here's where the trouble begins. Since the home objects do not contain the collection of overrides, they have an empty collection. So, when we push them into the database on the remote side, all of our overrides get deleted.
What I'd like to do is use the same object/mapping on both ends, but somehow be able to prevent that deletion of overrides from occurring when we're synchronizing the objects. I do understand why the delete is occuring right now (the cascade on the collection is all-delete-orphan). I just would like to find a way to temporarily suspend that action.
The subclass mapping is listed below. Any suggestions?
Thanks,
Dave
Hibernate version: 3.0.5
Code:
<subclass name="com.enttek.concessions.common.model.BasicItem" discriminator-value="B">
<component name="caseSleeveUnit" class="com.enttek.concessions.common.model.CaseSleeveUnit" access="field">
<component name="caseUnits" class="com.enttek.concessions.common.model.component.Quantity" access="field">
<property name="value" type="java.math.BigDecimal" update="true" insert="true" access="field"
column="case_units"/>
</component>
<component name="sleeveUnits" class="com.enttek.concessions.common.model.component.Quantity" access="field">
<property name="value" type="java.math.BigDecimal" update="true" insert="true" access="field"
column="sleeve_units"/>
</component>
<set name="overrides" inverse="false" cascade="all-delete-orphan" sort="unsorted" access="field">
<key column="basic_item_id"/>
<one-to-many class="com.enttek.concessions.common.model.ItemOverride"/>
</set>
<property name="itemId" type="string" access="field" update="false" insert="false" column="id"/>
</component>
</subclass>