I have a small test application built that uses link tables for one to many relationship. The User object can have many roles so jpa builds the following:
private Set<UserApplicationrole> userApplicationroles = new HashSet<UserApplicationrole>(0);
When run, the application User objects appear to have this ‘set’ populated correctly. The problem comes when I try to change the users role. Say the initial role is guest and the new role is admin. I remove the guest UserApplicationrole from the above ‘set’ and add a admin UserApplicationrole to the userApplicationroles ‘set’. When I update using
EntityManagerHelper.beginTransaction();
updatedUser = new UserDAO().update(user);
EntityManagerHelper.commit();
The db has the new admin role but the old guest role was not removed. Remember I removed the guest role from the userApplicationroles set. I must be missing something basic but can’t figure out what it is.
This behavior is the same with toplink and hibernate. I have other issues with hibernate. I think it is a pilot error but don’t know for sure. Is there a sample app that uses link table for one to many that might show me the way IF my mistake is not obvious.
Any help is appreciated.
I’m running…
fedora: 2.6.27.21-78.2.41.fc9.i686
MyEclipse Version: 8.0M2 installed using pulse