-->
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 - 3.2.4sp1 and 3.2.6 -no Session
PostPosted: Fri Mar 21, 2008 9:38 pm 
Newbie

Joined: Thu Oct 02, 2003 2:38 pm
Posts: 7
Location: Charlotte, NC
Code:
Caused by: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
   at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
   at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
   at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:166)


I'm in the process of migrating to 3.2.x and have encountered a strange LIE when walking the object graph.

I re-attach object A.
openSession.lock(a, LockMode.NONE);

I iterate through A's children of type B.

from there, I walk a chain of 3 many-to-one relationships: C, D, E.
(Note: all have no lazy attribute defined.)

Any invokation on E, will throw the LIE.

C & D's proxies seem to be fine, but E is hosed. This same code has been working for years on Hibernate 2.x and I did not find any migration note that would suggest that I cannot walk my hibernate graph as I used to.

Any help is much appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 25, 2008 12:56 pm 
Newbie

Joined: Thu Oct 02, 2003 2:38 pm
Posts: 7
Location: Charlotte, NC
I was able to determine that sometimes part of this graph had been loaded in a previous session and was still detached.

Not sure why this works in Hibernate 2.x, but checking to see if each entity is currently attached to the session, and then re-attaching it using
the session.lock(entity, LockMode.NONE) seemed to do the trick.


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.