-->
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.  [ 2 posts ] 
Author Message
 Post subject: ejb3 bidirectional ManyToMany
PostPosted: Fri Nov 24, 2006 12:17 pm 
Newbie

Joined: Tue Oct 10, 2006 2:38 pm
Posts: 17
Please help me, I don't know why many to many is not bidirectional

After room1.getGroups().add(group1) and group2.getAreas().add(room1),
I check to see in what groups is room1 and I get only group1.


thanks for any ideea
serj

Code:
@Entity
public class Room {

private Collection<RoomGroup> groups = new LinkedList<RoomGroup>();   

   @ManyToMany(cascade={CascadeType.ALL})
   public Collection<RoomGroup> getGroups(){
      return groups;
   }
   
   public void setGroups(Collection<RoomGroup> groups){
      this.groups = groups;
   }



Code:
@Entity
public class RoomGroup {
....   
   private Collection<Room> areas = new LinkedList<Room>();


   @ManyToMany(mappedBy="groups",cascade={CascadeType.ALL})
   public Collection<Room> getAreas(){
      return areas;
   }
   
   public void setAreas(Collection<Room> areas){
      this.areas = areas;
   }

}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 24, 2006 2:13 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Those are still plain objects - no auto magic behind it - so that the group2 would pop out from room1.groups right after you've added room1 to group2.

But when you look at the room1 in a next PC (after current PC is commited) or DB, there will be a join information between room1 and group2 present in database.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.