-->
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: Lazy loading while using any mapping
PostPosted: Thu Jun 07, 2007 1:46 am 
Newbie

Joined: Mon Jul 10, 2006 1:47 am
Posts: 8
Hibernate version:
Hibernate 3.2.2

Mapping documents:

Contract class hbm extract...

<any name="with" meta-type="string" id-type="integer"
cascade="save-update" lazy="true">
<meta-value value="G" class="my.Group" />
<meta-value value="I"
class="my.User" />
<column name="TYPE" not-null="true" />
<column name="WITH_ID" not-null="true" />
</any>

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

Contract c = (Contract)session.load(Contract.class, 96);

Full stack trace of any exception that occurs:

None

Name and version of the database you are using:

MySQL 5.0

The generated SQL (show_sql=true):
(abridged for readability)

select * from CONTRACT where CONTRACT_ID=? [loads the contract]

select * from GROUP where GROUP_ID=? [loads the groups from the any association]

select * from USER where IDENTITY_ID=? [loads the group owner]

select * from USER where IDENTITY_ID=? [loads the user who owns this contract]



Debug level Hibernate log excerpt:

This trace shows how after loading the first select it loads the object specified in the any association too wven though the load is specified as lazy="true" in the <any> element

2007-06-07 11:06:06,779 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
2007-06-07 11:06:06,795 [main] DEBUG org.hibernate.type.IntegerType - binding '90' to parameter: 1
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.loader.Loader - processing result set
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.loader.Loader - result set row: 0
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.loader.Loader - result row: EntityKey[my.Contract#90]
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [my.Contract#90]
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Hydrating entity: [my.Contract#90]
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.type.IntegerType - returning '10' as column: IDENTITY2_6_0_
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.type.IntegerType - returning null as column: REVERSE3_6_0_
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.type.IntegerType - returning null as column: GROUP4_6_0_
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.type.StringType - returning 'G' as column: TYPE6_0_
2007-06-07 11:06:06,811 [main] DEBUG org.hibernate.type.IntegerType - returning '4' as column: WITH6_6_0_
2007-06-07 11:06:06,826 [main] DEBUG org.hibernate.type.TimestampType - returning '2007-06-06 13:18:52' as column: VALID7_6_0_
2007-06-07 11:06:06,826 [main] DEBUG org.hibernate.type.TimestampType - returning '2007-06-06 13:18:52' as column: VALID8_6_0_
2007-06-07 11:06:06,826 [main] DEBUG org.hibernate.type.IntegerType - returning '1' as column: STATUS6_0_
2007-06-07 11:06:06,826 [main] DEBUG org.hibernate.type.StringType - returning '' as column: INVITATION10_6_0_
2007-06-07 11:06:06,826 [main] DEBUG org.hibernate.type.StringType - returning null as column: GIVEN11_6_0_
2007-06-07 11:06:06,826 [main] DEBUG org.hibernate.type.StringType - returning null as column: GIVEN12_6_0_
2007-06-07 11:06:06,826 [main] DEBUG org.hibernate.type.BooleanType - returning null as column: GROUP13_6_0_
2007-06-07 11:06:06,826 [main] DEBUG org.hibernate.type.BooleanType - returning null as column: GROUP14_6_0_
2007-06-07 11:06:06,826 [main] DEBUG org.hibernate.type.StringType - returning null as column: RSS15_6_0_
2007-06-07 11:06:06,842 [main] DEBUG org.hibernate.loader.Loader - done processing result set (1 rows)
2007-06-07 11:06:06,842 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
2007-06-07 11:06:06,842 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2007-06-07 11:06:06,842 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
2007-06-07 11:06:06,842 [main] DEBUG org.hibernate.loader.Loader - total objects hydrated: 1

2007-06-07 11:06:06,842 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [my.Contract#90]
2007-06-07 11:06:06,842 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - loading entity: [my.User#10]
2007-06-07 11:06:06,842 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - creating new proxy for entity
2007-06-07 11:06:06,842 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - loading entity: [my.Group#4]1



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.