-->
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.  [ 3 posts ] 
Author Message
 Post subject: periodically : LazyInitializationException
PostPosted: Thu Sep 18, 2008 4:04 am 
Newbie

Joined: Wed Jan 23, 2008 9:57 am
Posts: 13
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.2.5

Here's the thing.
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role

It occurs on very rare occasions, and i cannot reproduce it, it just pops up on a rare occasion.

Basicly, in the same class im iterating over a collection of entities, based on some conditions i store some of these entities in a list and just after i do some datamanipulation on those entities (all entities are persisted) and it is this manipulation that fails, rarely, with LazyInitializationException.

I am just wondering if this is a known 'issue' with a know workaround! I suppose I could store the entities unique keys in the list instead of the entites themselves and look them up with a criteria instead, but thats not quite how its supposed to work i'm sure.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 9:17 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Generally, that happens when Hibernate is trying to retrieve extra information about a bean (which has been loaded "lazily"), but then discovers that the session that originated that bean is closed.

This might occur because you are either failing to keep the session alive, or because you are accidentally generating many sessions and using the wrong one to display the bean.

In this post, I give you a small checklist of things that might be causing the problem, especially if it is a web application.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 19, 2008 4:19 am 
Newbie

Joined: Wed Jan 23, 2008 9:57 am
Posts: 13
Thanks

I've been pingpong'ing this with a few of the local hibernate residents, and get the same fine answer you provide here .. and i cannot completely deny that on some level of abstraction in the framework that _that_ is may be what is indeed happening. I just have a very very hard time imagining it.
This is code that runs fine 99 times and fails 1.

class a{
method b{
1.iterate over entities, store a few in a new List c
2.iterate over c and do stuff on 'lazy' loaded associates
}
}

and it's 2. that blows up 1 in 100

Well, thats not the WHOLE truth I suppose.
I have never experienced this locally while developing, on a tomcat, but the testserver is running the code on a WAS wich again is running in a virtual machine. I suppose there's a whole magnitude of other issues that could arise from this, difference in connection pooling, virtual machines copping tcp connections and whatnot!
I guess I was just hoping that this might me a somewhat know issue with hib ernate.. guess ill have to look elsewhere for the culprit (if it ever happens again!)

thanks again.


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