-->
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: Map identity indexes not updated upon persistence: bug?
PostPosted: Wed Jun 29, 2005 2:16 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Given: class A (parent) and class B (child). B's id is mapped to an SQL identity column. Parent-child relationship management is relegated to a dictionary class, BMap, which is mapped as a component of A, and is indexed on B's id.

Relevant mapping sections:
Code:
<class name="A" ... >
...
   <component name="Bs" class="BMap" >
      <map name="map" inverse="true" cascade="all-delete-orphan" >
         <key column="AID" />
         <index column="ID" />
         <one-to-many class="B" />
      </map>
   </component>
</class>

...

<class name="B" ... >
   <id name="ID" type="Int32" ... >
      <generator class="identity" />
   </id>
...
</class>


Now suppose I add a B to an A...

Code:
ISession session ...

A ana = (A)session.Load( typeof(A), ... );

B ab = new B(...);
ana.Bs.Add(ab);


At this point, ab.ID will carry the default value and can be retrieved from ana.Bs (that is, ab == ana.Bs[ab.ID]). Now if I flush the session:
Code:
session.Flush();

everything is persisted nicely, and ab.ID is updated to the DB generated identity, but it's map index is not (so, now ana.Bs[ab.ID] == null).

Of course, this issue isn't pathalogical; the next time ana is retrieved from the DB everything is correct, but I'd rather not have to pull it up after each add in order to synchronize the index and IDs. Also, this could be compensated for within the BMap wrapper class, but that gets pretty ugly.

So: bug or feature?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 4:41 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Bumping.


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.