-->
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: failed to lazily initialize a collection... no session
PostPosted: Mon Aug 30, 2010 11:08 am 
Newbie

Joined: Mon Aug 30, 2010 10:56 am
Posts: 2
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?


Top
 Profile  
 
 Post subject: Re: failed to lazily initialize a collection... no session
PostPosted: Tue Aug 31, 2010 7:15 am 
Newbie

Joined: Mon Aug 30, 2010 10:56 am
Posts: 2
Any tips?


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.