-->
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: admin APP exception while lazy="true"
PostPosted: Mon Apr 19, 2004 7:50 am 
Newbie

Joined: Fri Feb 20, 2004 4:56 pm
Posts: 14
Hi all,

In order to map a many to many with association class,
I take a closer look to the implementation provided within
Admin app application:

I noticed the following at runtime :

public UserRole addRole(Role role) {
if ( getRoles().indexOf(role)>=0 ) {
throw new RuntimeException("role already assigned");
}
getRoles().add(role);
role.getUsers().add(this);
UserRole ur = new UserRole(this, role);
getUserRoles().add(ur);
return ur;
}

getRoles().add(role) used an java.util.Arraylist and
role.getUsers().add(this); use an net.sf.hibernate.collection.Bag

and following exception occured :


13:48:02,610 ERROR LazyInitializationException:25 - Failed to lazily initialize a collection - no session or session was closed
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:214)
at net.sf.hibernate.collection.PersistentCollection.write(PersistentCollection.java:84)
at net.sf.hibernate.collection.Bag.add(Bag.java:281)


If someone has any idea,
Thanks in advance.
zoeeoz.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 6:52 am 
Newbie

Joined: Fri Feb 20, 2004 4:56 pm
Posts: 14
Hi all,

In order to clarify my question, I would like to add the following

It seems that when lasy is activated for Role object and only when,
(User use lazy or not)

getRoles().add(role); work fine but,
role.getUsers().add(this) raised exception below.

In my case user is not already persisted and role is comming
from object cache
.

If someone has any idea regarding this,
Thanks in advance.
Ph.


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.