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>
|