Hi,
i have a general question in understanding something.
I set up a manytomany relation in my project. (unidirectional).
A user has several roles.
Datatables:
User(Username)(PK))
UserRole(Rolename(PK))
UserToRole((Username(FK),Rolename(FK))(PK))
My join:
@ManyToMany
| @JoinTable(name="USERTOROLE",
joinColumns=@JoinColumn(name="username"),
| inverseJoinColumns=@JoinColumn(name="rolename"))
| public List<UserRole> getUserRoles()
| {
| return userRoles;
| }
So i get the list of the user roles in the entity object and i can access it. by Removing
something from this list hibernate also deletes it from the database, as it should be.
My problem is the following:
Hibernate first of all deletes everything in in my "UserToRole" Table where the
current "username" occurs. After this it deletes it also from the list and
inserts everything again to this table so that the list and the table are consistent
again.
Is there a way to switch this behaviour that it just deletes this one entry without
deleting all entries and then inserting the rest again?
| 10:53:19,095 INFO [STDOUT] Hibernate: delete from dci6fe.USERTOROLLE where
username=?
| 10:53:19,111 INFO [STDOUT] Hibernate: insert into USERTOROLE (username, ROLENAME)
values (?, ?)
| 10:53:19,111 INFO [STDOUT] Hibernate: insert into USERTOROLE (username, ROLENAME)
values (?, ?)
|
as you can see i had three entries... all deleted and 2 inserted again.
Thank you.
Christian
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4080762#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...