[jboss-user] [JBoss Seam] - Updating a many to many relationship from the inverse side

rganogork do-not-reply at jboss.com
Thu Dec 20 10:01:10 EST 2007


Hi.

I have been trying to update a many to many realationship from the inverse entity and i am getting a 'org.hibernate.LazyInitializationException: illegal access to loading collection'.


  |     @ManyToMany(mappedBy = "fleets", fetch = FetchType.EAGER)
  |     public List<User> getUsers() {
  |         return users;
  |     }
  | 
  |     public void setUsers(List<User> users) {
  |         // Add users to relation
  |         if (users != null) {
  |             for (User u : users) {
  |                 u.getFleets().add(this);
  |             }
  |         }
  |         
  |         this.users = users;
  |     }
  | 

The offending line is u.getFleets().add(this). The user fleets seems to be lazy loaded (i specified EAGER loading on the User entity class) and the Hibernate session discarded.. However i don't know why would the hibernate session be discarded.

Doing the same with many to one and one to one relationships worked fine.

Also pointers on how else i could be doing this, or pointers to further documentation will be largely apreciated.

Thank you,
Adrian.

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

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



More information about the jboss-user mailing list