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