Problem
The set with objects defined in Dossier gets initialized although lazy="true" is set.
Hibernate version:
2.1.6
Mapping documents:
Code:
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/vikieedi</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- Mapping files -->
<mapping resource="nl/dgoexpress/server/hibernate/mapping/Dossier.hbm.xml"/>
<mapping resource="nl/dgoexpress/server/hibernate/mapping/Order.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Dossier.hbm.xmlCode:
<hibernate-mapping package="nl.dgoexpress.vikie.bbo">
<class name="Dossier" table="dossiers">
<id name="id" type="int"
column="id" unsaved-value="-1">
<generator class="identity"/>
</id>
<set name="orders" lazy="true" table="orders" >
<key column="dossierid"/>
<one-to-many class="Order" />
</set>
</class>
</hibernate-mapping>
Order.hbm.xmlCode:
<hibernate-mapping default-cascade="none" package="nl.dgoexpress.vikie.bbo">
<class name="Order" table="orders">
<id name="id" type="int" column="id" unsaved-value="-1">
<generator class="identity"/>
</id>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Using Webwork. Retrieving the session through a servlet filter, similar to adminapp example.
Code:
String hql = "from Dossier";
List dossiers = getSession().createQuery(hql).list();
Name and version of the database you are using:MySQL 4.0.15
Debug level Hibernate log excerpt:612 [thread-pool-102] DEBUG net.sf.hibernate.hql.QueryTranslator - HQL: from nl.dgoexpress.vikie.bbo.Dossier
8612 [thread-pool-102] DEBUG net.sf.hibernate.hql.QueryTranslator - SQL: select dossier0_.id as id from dossiers dossier0_
8612 [thread-pool-102] DEBUG net.sf.hibernate.impl.BatcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets
8612 [thread-pool-102] DEBUG net.sf.hibernate.SQL - select dossier0_.id as id from dossiers dossier0_
8612 [thread-pool-102] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
8692 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - processing result set
8692 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '7' as column: id
8692 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - result row: 7
8692 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 7
8702 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Hydrating entity: nl.dgoexpress.vikie.bbo.Dossier#7
8712 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - done processing result set (1 rows)
8712 [thread-pool-102] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets
8712 [thread-pool-102] DEBUG net.sf.hibernate.impl.BatcherImpl - closing statement
8712 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - total objects hydrated: 1
8722 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolving associations for [nl.dgoexpress.vikie.bbo.Dossier#7]
8722 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - creating collection wrapper:[nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8753 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - initializing collection [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8753 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - checking second-level cache
8753 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - collection not cached
8753 [thread-pool-102] DEBUG net.sf.hibernate.impl.BatcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets
8753 [thread-pool-102] DEBUG net.sf.hibernate.SQL - select orders0_.dossierid as dossierid__, orders0_.id as id__, orders0_.id as id0_ from orders orders0_ where orders0_.dossierid=?
8753 [thread-pool-102] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
8763 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - binding '7' to parameter: 1
8763 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - result set contains (possibly empty) collection: [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8763 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - uninitialized collection: initializing
8773 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - processing result set
8773 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16454' as column: id0_
8773 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - result row: 16454
8773 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 16454
8773 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Hydrating entity: nl.dgoexpress.vikie.bbo.Order#16454
8773 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '7' as column: dossierid__
8773 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - found row of collection: [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8773 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - reading row
8773 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16454' as column: id__
8773 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - loading [nl.dgoexpress.vikie.bbo.Order#16454]
8773 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - attempting to resolve [nl.dgoexpress.vikie.bbo.Order#16454]
8773 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolved object in session cache [nl.dgoexpress.vikie.bbo.Order#16454]
8773 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16455' as column: id0_
8773 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - result row: 16455
8773 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 16455
8773 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Hydrating entity: nl.dgoexpress.vikie.bbo.Order#16455
8773 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '7' as column: dossierid__
8773 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - found row of collection: [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8773 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - reading row
8773 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16455' as column: id__
8773 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - loading [nl.dgoexpress.vikie.bbo.Order#16455]
8773 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - attempting to resolve [nl.dgoexpress.vikie.bbo.Order#16455]
8773 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolved object in session cache [nl.dgoexpress.vikie.bbo.Order#16455]
8773 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16456' as column: id0_
8773 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - result row: 16456
8783 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 16456
8783 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Hydrating entity: nl.dgoexpress.vikie.bbo.Order#16456
8783 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '7' as column: dossierid__
8783 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - found row of collection: [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8783 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - reading row
8783 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16456' as column: id__
8783 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - loading [nl.dgoexpress.vikie.bbo.Order#16456]
8783 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - attempting to resolve [nl.dgoexpress.vikie.bbo.Order#16456]
8783 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolved object in session cache [nl.dgoexpress.vikie.bbo.Order#16456]
8783 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16457' as column: id0_
8783 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - result row: 16457
8783 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 16457
8783 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Hydrating entity: nl.dgoexpress.vikie.bbo.Order#16457
8783 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '7' as column: dossierid__
8783 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - found row of collection: [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8783 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - reading row
8783 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16457' as column: id__
8783 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - loading [nl.dgoexpress.vikie.bbo.Order#16457]
8783 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - attempting to resolve [nl.dgoexpress.vikie.bbo.Order#16457]
8823 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolved object in session cache [nl.dgoexpress.vikie.bbo.Order#16457]
8823 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16458' as column: id0_
8823 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - result row: 16458
8823 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 16458
8823 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Hydrating entity: nl.dgoexpress.vikie.bbo.Order#16458
8823 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '7' as column: dossierid__
8823 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - found row of collection: [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8823 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - reading row
8823 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16458' as column: id__
8823 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - loading [nl.dgoexpress.vikie.bbo.Order#16458]
8823 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - attempting to resolve [nl.dgoexpress.vikie.bbo.Order#16458]
8823 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolved object in session cache [nl.dgoexpress.vikie.bbo.Order#16458]
8823 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16459' as column: id0_
8823 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - result row: 16459
8823 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 16459
8823 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Hydrating entity: nl.dgoexpress.vikie.bbo.Order#16459
8823 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '7' as column: dossierid__
8823 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - found row of collection: [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8823 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - reading row
8823 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16459' as column: id__
8823 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - loading [nl.dgoexpress.vikie.bbo.Order#16459]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - attempting to resolve [nl.dgoexpress.vikie.bbo.Order#16459]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolved object in session cache [nl.dgoexpress.vikie.bbo.Order#16459]
8833 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16460' as column: id0_
8833 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - result row: 16460
8833 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 16460
8833 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - Hydrating entity: nl.dgoexpress.vikie.bbo.Order#16460
8833 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '7' as column: dossierid__
8833 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - found row of collection: [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - reading row
8833 [thread-pool-102] DEBUG net.sf.hibernate.type.IntegerType - returning '16460' as column: id__
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - loading [nl.dgoexpress.vikie.bbo.Order#16460]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - attempting to resolve [nl.dgoexpress.vikie.bbo.Order#16460]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolved object in session cache [nl.dgoexpress.vikie.bbo.Order#16460]
8833 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - done processing result set (7 rows)
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.BatcherImpl - closing statement
8833 [thread-pool-102] DEBUG net.sf.hibernate.loader.Loader - total objects hydrated: 7
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolving associations for [nl.dgoexpress.vikie.bbo.Order#16454]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [nl.dgoexpress.vikie.bbo.Order#16454]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolving associations for [nl.dgoexpress.vikie.bbo.Order#16455]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [nl.dgoexpress.vikie.bbo.Order#16455]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolving associations for [nl.dgoexpress.vikie.bbo.Order#16456]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [nl.dgoexpress.vikie.bbo.Order#16456]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolving associations for [nl.dgoexpress.vikie.bbo.Order#16457]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [nl.dgoexpress.vikie.bbo.Order#16457]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolving associations for [nl.dgoexpress.vikie.bbo.Order#16458]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [nl.dgoexpress.vikie.bbo.Order#16458]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolving associations for [nl.dgoexpress.vikie.bbo.Order#16459]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [nl.dgoexpress.vikie.bbo.Order#16459]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - resolving associations for [nl.dgoexpress.vikie.bbo.Order#16460]
8833 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [nl.dgoexpress.vikie.bbo.Order#16460]
8843 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - 1 collections were found in result set
8843 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - collection fully initialized: [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
8843 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - 1 collections initialized
8843 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - collection initialized
8843 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [nl.dgoexpress.vikie.bbo.Dossier#7]
8843 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - initializing non-lazy collections
8843 [thread-pool-102] DEBUG nl.dgoexpress.server.action.AbstractAction - aantal gevonden dossiers: HOORAY!!
8843 [thread-pool-102] DEBUG nl.dgoexpress.server.action.AbstractAction - customerid: 137
9163 [thread-pool-102] DEBUG nl.dgoexpress.server.webwork.component.HibernateSession - disposing
9163 [thread-pool-102] DEBUG nl.dgoexpress.server.webwork.component.HibernateSession - committing
9163 [thread-pool-102] DEBUG net.sf.hibernate.transaction.JDBCTransaction - commit
9163 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - flushing session
9173 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - Flushing entities and processing referenced collections
9193 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - Collection found: [nl.dgoexpress.vikie.bbo.Dossier.orders#7], was: [nl.dgoexpress.vikie.bbo.Dossier.orders#7]
9203 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - Processing unreferenced collections
9203 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - Scheduling collection removes/(re)creates/updates
9203 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 8 objects
9203 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections
9203 [thread-pool-102] DEBUG net.sf.hibernate.impl.Printer - listing entities:
9213 [thread-pool-102] DEBUG net.sf.hibernate.impl.Printer - nl.dgoexpress.vikie.bbo.Dossier{orders=[Order#16457, Order#16458, Order#16454, Order#16455, Order#16459, Order#16456, Order#16460], id=7}
9213 [thread-pool-102] DEBUG net.sf.hibernate.impl.Printer - nl.dgoexpress.vikie.bbo.Order{id=16460}
9213 [thread-pool-102] DEBUG net.sf.hibernate.impl.Printer - nl.dgoexpress.vikie.bbo.Order{id=16458}
9223 [thread-pool-102] DEBUG net.sf.hibernate.impl.Printer - nl.dgoexpress.vikie.bbo.Order{id=16459}
9223 [thread-pool-102] DEBUG net.sf.hibernate.impl.Printer - nl.dgoexpress.vikie.bbo.Order{id=16455}
9223 [thread-pool-102] DEBUG net.sf.hibernate.impl.Printer - nl.dgoexpress.vikie.bbo.Order{id=16456}
9223 [thread-pool-102] DEBUG net.sf.hibernate.impl.Printer - nl.dgoexpress.vikie.bbo.Order{id=16454}
9223 [thread-pool-102] DEBUG net.sf.hibernate.impl.Printer - nl.dgoexpress.vikie.bbo.Order{id=16457}
9223 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - executing flush
9223 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - post flush
9223 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - transaction completion
9223 [thread-pool-102] DEBUG net.sf.hibernate.transaction.JDBCTransaction - re-enabling autocommit
9223 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - closing session
9223 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - disconnecting session
9233 [thread-pool-102] DEBUG net.sf.hibernate.impl.SessionImpl - transaction completion[/code]