-->
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.  [ 1 post ] 
Author Message
 Post subject: Lazy load failed on a property?
PostPosted: Thu Apr 19, 2007 5:16 pm 
Newbie

Joined: Fri Oct 08, 2004 1:12 pm
Posts: 4
I have a MainObject class, which has a many-to-one mapping relationship to the ChildObject class, I've also created a property mapping for the ChildObject's ID in the MainObject besides the reference, so as you can see below the "ChildObject_ID" column is mapped twice, once for the reference and once for the ID. This mapping has been working fine.

At some point I ran into the following exception (see below) - it seems Hibernate is trying to do a lazy load when I call MainObject.getChildObjectID, even this ID is part of the MainObject's own property. I thought lazy loading is involved only when a referenced object is being loaded? Am I wrong or there's something else going on?

Thanks!

Ken

Hibernate version: 3.2.0GA

Mapping documents:
Quote:
<many-to-one name="objects" access="field" class="com.company.model.ChildObject" fetch="join" insert="false" update="false">
<column name="ChildObject_ID" />
</many-to-one>
<property name="childObjectID" type="java.lang.Long">
<column name="ChildObject_ID"/>
</property>


Code between sessionFactory.openSession() and session.close():
Using Spring transaction manager so I don't deal with sessions directly.

Full stack trace of any exception that occurs:
Quote:
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:60)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:172)
at com.company.model.MainObject$$EnhancerByCGLIB$$8c501d04.getChildObjectID(<generated>)
......
at java.util.TimerThread.mainLoop(Timer.java:432)
at java.util.TimerThread.run(Timer.java:382)



Name and version of the database you are using:
MS SQL server 2003.

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

Quote:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.