[jboss-user] [EJB 3.0] - Re: Many to Many realtionship question

EladKatz do-not-reply at jboss.com
Thu Aug 13 14:03:18 EDT 2009


Hi jaikiran,
Thanks for the quick reply, I have actually read this article before and indeed in my implementation I use Sets instead of a Collection as is recommended there.
However, that article doesn't address my issue directly though it does say this:
anonymous wrote : 
  | For a @ManyToMany relationship, it might look like this:
  | 
  |           LeftBean left = ...;    
  |   |      RightBean right = ...;
  |   |      left.getRights().add(right);
  |   |      right.getLefts().add(left);
  |   |      
  |   |      this.entityManager.merge(left);
  | 
which means that if I want to add multiple records to the left bean i would have to add it once in the right bean and for each of the left records i'm going to have to add this right bean to them, and then only commit (merge) one of them.
that will work, but feels wrong - is this really the case? 

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

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



More information about the jboss-user mailing list