-->
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: insertion doesnot happening when using many-to-many mapping
PostPosted: Thu Jul 12, 2007 6:54 am 
Newbie

Joined: Thu Jul 12, 2007 6:29 am
Posts: 1
Location: Chennai
I am using Hibernate 3.2.1 and hibernate-annotations 3.2.1.

I am having Three tables namely

1. User 2.Role 3.User_Role_Map

In my User pojo , i am having a property java.util.Set<Role> roles for roles assosiated to the user. And in my Role pojo, i have java.util.Set<User> users property for bidirectional mapping.

I donot have any pojo for User_Role_Map table.

when i query for getUser(id), it returns me User object with all mapped roles. But when i modify the roles and save the user, modified roles are not updated in the User_Role_Map table.

------- User.java ------
@ManyToMany(targetEntity=org.appfuse.model.Role.class,
fetch = FetchType.EAGER,
cascade = {CascadeType.PERSIST,CascadeType.MERGE})
@JoinTable(
name="user_role_map",
joinColumns = { @JoinColumn( name="user_id") },
inverseJoinColumns = @JoinColumn( name="role_id")
)
public Set<Role> getRoles() {
return roles;
}

-------- Role.java -------

@ManyToMany(fetch = FetchType.EAGER,
cascade = {CascadeType.PERSIST,CascadeType.MERGE},
targetEntity = org.appfuse.model.User.class,
mappedBy = "roles")
public Set<User> getUsers() {
return users;
}

can any one help me in this issue?


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.