-->
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: How to set lazy initialization to false?
PostPosted: Fri Jan 07, 2005 3:21 pm 
Beginner
Beginner

Joined: Wed May 05, 2004 12:45 pm
Posts: 21
Hibernate version: 2.1.2

Mapping documents:

<class name="Climate" table="CLIMATE" schema="BAH" lazy="false">
<composite-id>
<key-property name="climateDate" column="CLIMATE_DATE" type="timestamp"/>
<key-property name="id" column="ID" type="long"/>
</composite-id>
<property name="windDir" column="WIND" type="long"/>
<component name="hasSkyCondition" class="HasSkyCondition" insert="false" update="false">
<bag name="SkyConditionList" inverse="true" lazy="false" cascade="all">
<key>
<column name="CLIMATE_DATE"/>
<column name="ID"/>
</key>
<one-to-many class="SkyCondition"/>
</bag>
</component>
</class>

<class name="SkyCondition" table="SKY_CONDITION" schema="NRVIS" lazy="false">
<composite-id>
<key-property name="climateDate" column="CLIMATE_DATE" type="timestamp"/>
<key-property name="id" column="ID" type="long"/>
<key-property name="skyCover" column="SKY_COVER" type="string"/>
</composite-id>
</class>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

I am trying to set it to lazy initialization to false because we are always getting a lazy initialization exception since we are accessing the content of collections after closing the session statement. I am not sure why object representing this class is not being fully initialized since I am puttint lazy="false" everywhere.

Thanks for your help


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 8:55 pm 
Regular
Regular

Joined: Thu Jul 29, 2004 11:55 pm
Posts: 75
Are you loading the climate class into a collection? If so, you need to place the lazy="false" in the collection mapping. Hope this helps. I am not sure if this answers your question. Please provide more details.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 2:35 pm 
Beginner
Beginner

Joined: Wed May 05, 2004 12:45 pm
Posts: 21
Thank you for responding.

Climate is the top object and it fails when trying to iterate through SkyConditionList bag. I have bunch of other classes and all of them are a joined subclasses. I don't have a problem with lazy initialization for those classes. It seems only for Climate when I try to traverse to the SkyCondition


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.