I have a many-to-many association which is bidirectional.
Here is the scenario.

I have a User class which has a collection of Group objects.
The Group class has a collection of User objects.

When I save a user object, the save cascades and saves the group
objects too.
Same with the other way saving a group object.
The deletes also work fine by cascading the deletes only to the
association table.

The problem happens in this situation:
I have a User object which has 3 groups in its "Groups" collection.
when I remove a group from this collection and save the user object,
the Association table data does not get cleared.

This works fine from the Group side. It is a problem only from the
Users side, which is declared with inverse="true".

The mapping is as follows:

(Section from User mapping file)
<bag name="Groups"
        inverse="true"
        table="Association" schema="MetadataUseCases_UseCase11"
        cascade="save-update" generic="true" batch-size="10">
        <key column="UserId" />
        <many-to-many column="GroupId" class="Group" />
</bag>

(Section from Group mapping file)
<bag name="Users"
        table="Association" schema="MetadataUseCases_UseCase11"
        cascade="save-update" generic="true" batch-size="10">
        <key column="GroupId" />
        <many-to-many column="UserId" class="User" />
</bag>

The Association table has the columns UserId and GroupId.

Any help is appreciated!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to