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.