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.
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat: