-->
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: my promblem with Hibernate3 upgrade
PostPosted: Mon Apr 04, 2005 4:15 am 
Newbie

Joined: Sat Oct 30, 2004 10:47 pm
Posts: 15
I want to update my Hibernate 2.1 lib to Hibernate3 lib. And I have met a confusing
problem.
When I operate on a detached object , I often met an exception of

ERROR org.hibernate.LazyInitializationException:(LazyInitializationException.java:19)
- could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at com.hs.battlegame.domain.Player$$EnhancerByCGLIB$$98e3ec06.toString(<generated>)


From the stack trace, you know I have a POJO naming of com.hs.battlegame.Player, and now it has been detached
from hibernate session. When I make a log using something like player.toString(), it will produce the
stack trace above.

I found it is because of the attribute "target" of AbstractLazyInitialzer is null and should be
initialized, but it is a detached object and the session has been closed. I wonder why
the "target" attribute has not been initialized when the persistent object detached from hibernate
session?

I have enabled using query cache, and the first time the Player object loaded from database,
it is always a normal object of Player, but when I refresh the IE browser and load the Player object from StandardQueryCache
with EHCache,I always get a Player$$EnhancerByCGLIB, and throw the exception above.

During my testing process , only few occasion the "target" attribute is not null.

I have changed the Hibernate3 package reference of my dao code and the XML DOCTYPE of my hibernate mapping files.

Do I need to make any more changes in my hibernate mapping file or java code?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 6:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read the migration guide on the hibernate.org wiki.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: The problem solved
PostPosted: Mon Apr 04, 2005 6:11 am 
Newbie

Joined: Sat Oct 30, 2004 10:47 pm
Posts: 15
I changed my Hibernate mapping file, and set default-lazy="false".
It seemed that the problem had been solved.

sorry for your time.


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.