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: