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
|