-->
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: Help/ why this behaviour when lazy loading=true
PostPosted: Wed Apr 18, 2007 4:12 am 
Beginner
Beginner

Joined: Thu Apr 29, 2004 4:31 am
Posts: 42
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1.2
Mapping documents:

<class name="Batch" table="Batch" lazy="false">
<id name="id" access="field">
<generator class="identity"/>
</id>

<property name="message" access="field"/>
<property name="creationDate" access="field"/>


<list name="messages" lazy="true" cascade="all,delete-orphan" inverse="true">
<key column="batchId"/>
<index column="seq_idx"/>
<one-to-many class="Message"/>
</list>
</class>
<class name="Message" table="Message" lazy="false">
<id name="id" access="property">
<generator class="identity"/>
</id>
<property name="xml" lazy="true"/>
<many-to-one name="batch" column="batchId" access="field" not-null="true"/>


Name and version of the database you are using:

The generated SQL (show_sql=true):
Hibernate: select batc0_.id as id35_, batc0_.message as message35_, batc0_.creationDate as creation3_35_ from Batch batc0_ where batc0_.creationDate<?
Hibernate: select messsage0_.batchId as Ba6_1_, message0_.id as id1_, message0_.seq_idx as seq7_1_, message0_.id as id36_0_, message0_.ISIN as ISIN36_0_, message0_.productId as productId36_0_, message0_.xml as xml36_0_, message0_.processDate as processD5_36_0_, message0_.batchId as sierraBa6_36_0_ from Message message0_ where message0_.batchId=?
....

Hi all,
i am encountering problems with lazy loading in my code..
first, here's my code
Code:
List<Batch> list = getHibernateTemplate().find(
                "from Batch  where creationDate < ?", new Object[]{archivedDate});
getHibernateTemplate().deleteAll(list);


Now, as you can see from my mapping doc, the column 'messages' in my Batch class should be lazy loaded, and the field 'xml' in the Message class should be lazy loaded too..

However, as you can see from the output of hibernate sql, it turns out that somehow Hibernate is treating classes like is lazy="false", loading everything all the time...

Can anyone explain me why i got this behaviour? how can i fix it?

With kindest regards
Marco


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.