-->
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: LazyInitializationException when changing session
PostPosted: Wed Aug 11, 2004 11:47 am 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
Hibernate version: 2.1.6

[b]Full stack trace of any exception that occurs:
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed

void net.sf.hibernate.collection.PersistentCollection.initialize(boolean)

PersistentCollection.java:209

void net.sf.hibernate.collection.PersistentCollection.read()

PersistentCollection.java:71

java.util.Iterator net.sf.hibernate.collection.Bag.iterator()

Bag.java:256

com.tcs.cms.AreaVersion com.tcs.cms.Area.getVersion(java.lang.String)

Area.java:153

void com.tcs.cms.test.TestCmsSession.testArea1()

TestCmsSession.java:54

void com.tcs.cms.test.TestCmsSession.main(java.lang.String[])

TestCmsSession.java:20



[b]Name and version of the database you are using:Oracle 9.2

Hi I'm getting LazyInitializationException when I query an object that has a collection with lazy relationship, I close the session, I open a new session and try to query the same object and access the collection.

When I get the object in the new session and debug the collection the session associated with the collection is null. It seems that the object was put in the global cache and when I close and open the new session and query the object it was not associated with the new session.

Any help will be greatly appreciated.

Regards,

N


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 1:37 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
read about detached object in the reference guide

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.