-->
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: ManyToMany Bidirectional Association Deletion Headaches
PostPosted: Tue Apr 10, 2007 8:16 pm 
Newbie

Joined: Tue Apr 10, 2007 7:40 pm
Posts: 1
I have four classes [User, Group, Role and Application] that have many to many relationships between them.

I have followed the reference manual and made one side of each relationship the owner (with @JoinTable) and one side the non-owning side (with @ManyToMany(mappedBy="xxx").

There are then three relationships between these classes which I explain like this:

User(owner), Group [USER_GROUP association table]
Group(owner), Role [GROUP_ROLE association table]
Role(owner), Application [ROLE_APPLICATION association table]

When I attempt to delete a Group 'getHibernateTemplate.delete(group);' it appears to remove the associations in the GROUP_ROLE table however does not remove the associations in the USER_GROUP table as I am expecting it to. I am having to iterate through the group.getUsers SET and remove the group manually from each User.

When you have a class mapping between two ManyToMany relationships how are you supposed to set up the annotations. I have searched far and wide and find no examples of same. Can hibernate manage the two association tables automatically and if so how does that work?

Your help much appreciated,
Luke.


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.