[jboss-user] [EJB 3.0] - Re: many to many mapping exception in EJB3

Wolfgang Knauf do-not-reply at jboss.com
Fri Oct 24 11:09:45 EDT 2008


Hi,

bi-directional mappings are a bit tricky: you always have to update BOTH sides of the mapping.

So, if you want to map a Skill to an User, this will NOT work:

user.getSkills().add ( mySkill);
  | entityManager.merge(user);

You will have to do something like this:
myUser.getSkills().add ( mySkill);
  | mySkill.getUsers().add (myUser);
  | entityManager.merge(myUser);

Hope this helps

Wolfgang

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4184503#4184503

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4184503



More information about the jboss-user mailing list