-->
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: flushing objects with lazy associations
PostPosted: Thu Sep 04, 2003 8:13 am 
Newbie

Joined: Wed Aug 27, 2003 2:43 am
Posts: 19
Location: Paris
Hello,

I have a very simple scenario:

* I Session.find() an object from the db using Hibernate.
* This object has lazy one-to-many sets (associations) which, of course, are not "really" initialized yet
* I do a "flush" -- (I made no modification)

Result: after enabling debug-level logging, I see that what happens is: Hibernate tries to see if nothing has been modified. In order to do that, it actually loads the lazy sets which also have other lazy associations and so on.

So, in my case, a find-flush, whitout any change to the object, generates an enormous series of SELECTs (as my objects are quite interconnected).

Is this normal behavior of Hibernate ? I use Hibernate 2.0.2.

Thanks for the ideas,
Adrian.



Here is the mapping of my original object (there are lots more of the associated objects).

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
default-cascade="save-update">

<class
name="com.kertel.kercash.core.types.Partner"
table="partenaire">

<id name="id" column="part_id" type="long" unsaved-value="0">
<generator class="com.kertel.kercash.serialization.MaxIdGenerator" >
<param name="table-name">partenaire</param>
<param name="table-id">part_id</param>
</generator>
</id>

<property
name="name"
type="string"
column="part_nom" />

<set
name="sites"
table="site"
lazy="true"
cascade="save-update">

<key column="part_id" />
<one-to-many
class="com.kertel.kercash.core.types.Site" />
</set>

<one-to-one
name="details"
class="com.kertel.kercash.core.types.PartnerDetails"
cascade="all"
outer-join="false"
/>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 10:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
NO this is not how Hibernate behaves. You are obviously doing something "funny". Like initializing the sets in a getter method or something.


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.