-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Persistent set in inconsistent state
PostPosted: Thu Nov 12, 2009 10:44 pm 
Newbie

Joined: Thu Nov 12, 2009 10:17 pm
Posts: 2
Hibernate version: 3.2.1.ga

Hi,

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.


Top
 Profile  
 
 Post subject: Re: Persistent set in inconsistent state
PostPosted: Mon Nov 16, 2009 5:17 pm 
Newbie

Joined: Thu Nov 12, 2009 10:17 pm
Posts: 2
This was a problem with the child element. The hashcode of the item in the set relies on it's parent's id, which of course changes when the parent is saved.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.