-->
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.  [ 1 post ] 
Author Message
 Post subject: Bi-direction Many-to-many relationship?
PostPosted: Wed Jun 08, 2005 9:18 pm 
Regular
Regular

Joined: Thu Dec 02, 2004 10:42 am
Posts: 54
I have a mapping like this:
Code:
<class name="Group" table="GROUPS">
   <id name="id" column="GROUPID" type="AnsiString">
            <generator class="assigned" />
   </id>
   <property name="name" column="NAME" type="AnsiString" />
   <bag name ="users" table ="GROUP_MEMBER">
      <key column="GROUPID" />
      <many-to-many class="User" column ="MEMBERID"/>
   </bag>
</class>

<class name="User" table="USERS">
   <id name="id" column="LOGONID" type="AnsiString">
        <generator class="assigned" />
   </id>
   <property name="name" column="NAME" type="AnsiString" length="40" />
   <bag name ="groups" table ="GROUP_MEMBER"  inverse="true">
      <key column="MEMBERID" />
      <many-to-many class="Group"  column ="GROUPID"/>
   </bag>
</class>


When I load GroupA, which has UserA, and in UserA, I can link back to GroupA object instance. But when I delete UserA from GroupA's "bag", and Save GroupA, I can still find GroupA from UserA?

If I add a new relationship, it has similar problem to add the other direction.

For Bi-direction link, can Hibernate automatically make the 2-way consistent without re-load the object? Especially when I use 2nd level cache, I have to explicitly Evict, otherwise there is no way I can make them right.


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

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.