Hibernate version: 3.2.1.gaHi,
I have a situation where a set of entities become inconsistent with the database and I am not sure why.
I add a subset of some entities to the set, and save it. I then add the remaining slightly more complicated entities to the set that I require, and save it. This occurs during a single transaction. If I look at the database after the first save (with NOLOCK), it contains the first set. Upon the second save, a delete call is made for each entity in the first set and adds the new entities, without re-adding the old entities.
After the transaction, the entities that were added in the beginning are missing, but the other entities are there. Unusually, while debugging, all elements are in the persistent set, and the set is not dirty.
The entity which contains the set, is a site and it contains a set of data streams:
Code:
<subclass name="BasicSite" discriminator-value="1">
<set name="Channels" table="SiteDataStreamLink" cascade="all-delete-orphan">
<key column="IE2SiteID"/>
<many-to-many column="DataStreamID"
class="com.energyintellect.manage.datastream.DataStream"/>
</set>
Each data stream, contains a reference back to it's site:
Code:
<class name="DataStream" table="DataStream">
...
<join table="SiteDataStreamLink" optional="true" inverse="true">
<key column="DataStreamID" unique="true"/>
<many-to-one name="Site" lazy="proxy" column="IE2SiteID"
class="com.energyintellect.manage.site.impl.BasicSite"/>
</join>
</class>
Thanks,
Wayne.