-->
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.  [ 1 post ] 
Author Message
 Post subject: Lazy and List mapping, no session or session was closed
PostPosted: Fri Sep 15, 2006 4:59 pm 
Regular
Regular

Joined: Wed Sep 21, 2005 1:37 pm
Posts: 53
Location: Montpellier - France
Hibernate version: 3.1

Mapping documents: annotations

Full stack trace of any exception that occurs:

GRAVE: failed to lazily initialize a collection of role: UserBean.groups, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: UserBean.groups, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97)
at org.hibernate.collection.PersistentList.size(PersistentList.java:91)
at tests.UserTest.testGroup(UserTest.java:393)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
...
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: UserBean.groups, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97)
at org.hibernate.collection.PersistentList.size(PersistentList.java:91)
at tests.UserTest.testGroup(UserTest.java:393)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
...
Name and version of the database you are using: mysql innodb

code

ite = users.iterator();

while (ite.hasNext()) {
user = mgr.findByName(ite.next().getName(), null).iterator().next();
assertTrue("One of the associated groups has been not found", user.getGroups().size() > 0);
group = user.getGroups().get(0);
results = mgr.findGroupByUser(user, mgr.newCriteriaInstance());
assertNotNull("One of the associated groups has been not found", results);
assertTrue("One of the associated groups has been not found", results.size() > 0);
assertTrue("The associated groups has been not found", results.contains(group));
}
error is on :
user.getGroups().size()

Thanks for your help


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

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.