-->
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.  [ 2 posts ] 
Author Message
 Post subject: Lazy-loading doesn't work with load but is ok with find
PostPosted: Tue Feb 22, 2005 1:57 pm 
Beginner
Beginner

Joined: Tue Oct 07, 2003 11:36 am
Posts: 46
Location: Rennes, France
Hi,

I am experiencing a very strange problem: the size of a lazy-loaded Set varies upon how I instantiate the main object.

Here is the code:

Code:
ActeTechnique at = (ActeTechnique) context.getSession().find("from ActeTechnique where id='"+idActeTechnique+"'").iterator().next();

colElementDeSaisies = at.getElementDeSaisies();
Iterator iterElementDeSaisies = colElementDeSaisies.iterator();


When I fetch this iterator, i get the right results: a hundred of objects.

But let's have a look at another (and much more readable) way for the ActeTechnique instantiation :

Code:
ActeTechnique at = (ActeTechnique)context.getSession().load(ActeTechnique.class,idActeTechnique);


This time, the list contains no values !!!

It is very difficult to debug and compare these behaviors cause the lazy loading is automatically triggering while I enter the Hibernate PersistentCollection.read() method in debug mode.


Hibernate version: 2.1.8

Mapping documents: (excerpt)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name="entity.ActeTechnique" table="ACTE_TECHNIQUE">
      <id column="ID" name="id" type="java.lang.String">
         <generator class="dao.hibernate.id.SQLServerGenerator" />
      </id>

      <version column="NO_VERSION" name="noVersion" type="integer" />

<set name="elementDeSaisies" lazy="true" inverse="true" cascade="all" sort="unsorted" outer-join="auto" batch-size="1" access="property">
         <key column="ACTE_TECHNIQUE_ID" />
         <one-to-many class="entity.ElementDeSaisie" />
      </set>
   </class>
</hibernate-mapping>


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

Full stack trace of any exception that occurs:

Name and version of the database you are using:
SQL Server 2000 SP3

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Problem Fixed
PostPosted: Wed Feb 23, 2005 6:23 am 
Beginner
Beginner

Joined: Tue Oct 07, 2003 11:36 am
Posts: 46
Location: Rennes, France
Hi folks,

I use the UUID type to identify the objects (SQL Server).
Some developers use this identifer under its lowercase format... but this seems not compliant with the Hibernate way of dealing with the Lazy loading collections.

We'll try to use uppercase id from now on.

Yann


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.