Hello,
I'm using Spring 3.0, Hibernate 3, and annotation to mapping bean with table; my application throws next exception when it try to access at LAZY collection.
Code:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ..., no session or session was closed
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:272)
I'm sure session is open e connected because I'm using OpenSessionInVievFilter configured like this:
Code:
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>hibernateSessionFactory</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
the problem should be bound to next statement:
Code:
session.getPersistenceContext().containsCollection(this)
into
AbstractPersistentCollection class, method
isConnectedToSession()I thought the collection was not initialized before effective loading (LAZY=true), any suggestions?