-->
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.  [ 5 posts ] 
Author Message
 Post subject: LazyInitializationException if object is evicted
PostPosted: Tue Mar 23, 2004 8:40 pm 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
I'm using jdk1.3.1_09 with Hibernate 2.1.2.

I'm adding a child object to a collection that has lazy="true" and I get:

20:36:01,812 ERROR LazyInitializationException:? - Failed to lazily initialize a collection - no session or session was closed

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:214

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

PersistentCollection.java:84

boolean net.sf.hibernate.collection.List.add(java.lang.Object)

List.java:129

void mypackage.Prueba.main(java.lang.String[])

Prueba.java:45


This happens because I'm running evict on the parent object. If I comment the session.evict line it works.

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 24, 2004 12:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Of course. This is correct behavior.


Top
 Profile  
 
 Post subject: Problem with LazyInitialization
PostPosted: Wed Mar 24, 2004 6:58 am 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
The error message is wrong.

The session is not closed. And I want to evict the object because I don't want Hibernate to serialize the object everytime I make changes and flush. Also I don't want to evict because I get problems serializing Oracle CLOBs and BLOBs. I already fixed this problem and part of the solution was to evict the objects.

So now I have two choices:

1.- I don't work with CLOBs or BLOBs, let Hibernate serialize everytime I flush and I can use lazy initialization.
2.- I work with CLOBs or BLOBs, I serialize when I want the application to serialize and I don't use lazy initialization.


Top
 Profile  
 
 Post subject: LaziInitialization Problem
PostPosted: Wed Mar 24, 2004 7:16 am 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
I think that this problem can be solved if the application developer has some way to disable the mechanism that Hibernate uses to persist objects when they are updated. If I disable this mechanism I can store CLOBs and BLOB in Oracle without calling evict and still have lazy initialization.


Top
 Profile  
 
 Post subject: Reply from Hibernate team?
PostPosted: Wed Mar 24, 2004 1:08 pm 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
Any reply from the Hibernate team?

Sorry about the rush but I'm in the middle of a project and this issue is important.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.