Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ManyToMany assoicate delete join table entry  RSS feed

Johnny Cheng
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use these two entities to create a new user and groups it associates:

On the database:
usertable (id, userId, name)
grouptable (id, description)
usergroup(userid, groupid, groupkey)

It's very satisfying to add Group to list of groups, call save method on User and watch hibernate save the usergoup togehter. However, I have a big problem of hibernate automatically deleting entry from the usergroup table automatically when even I retrieve the User after a save(User) operation.

Here is the test sequence that generation the deletion of usergroup

1. save new user
2. save new group
3. And group to list in user
4. save user
5. get user from email

While before executing step 5, usergroup with automatically removed like


A few thing i wonder;
1. userid is NOT the pk of user object.
2. The manyTomany mapping in usergroup mapped by userid and groupid

How can I stop the automatic deletion of usergroup. Usergroup is very important table and should not be deleted. Any help would be much appreciated. Thank you.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!