-->
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: refresh and lazy loading
PostPosted: Mon Jan 22, 2007 11:52 am 
Newbie

Joined: Mon Jan 22, 2007 7:23 am
Posts: 1
Since I migrate from Hibernate 2.1.7 to 3.1.3, I have problems with refresh.
I have noticed that refresh behavior have changed (migration note) :
- in 2.1.7, it refreshed only the object
- in 3.1.3, it refresh all the object graph

It seems that the refresh operate also on lazy collections even if they wasn't initialized before refresh. Is it normal ?

Here is my mapping :

Code:
...
    <class table="TDPUDOSSIERDROIT" name="DossierDroit" lazy="false">
        <id name="idDossierDroit" type="string">
            <generator class="fr.dao.hibernate.HibernateUuidGenerator" />
        </id>
        <property name="dateDernierCalcul" type="timestamp" />
        <set name="elementReference" lazy="true" sort="natural" inverse="true" cascade="all-delete-orphan">
            <key column="idDossierDroit" />
            <one-to-many class="ElementReference" />
        </set>
    </class>


    <class table="TDPUELEMENTREFERENCE" name="ElementReference" lazy="false">
        <id name="idElementReference" type="string">
            <generator class="fr.dao.hibernate.HibernateUuidGenerator" />
        </id>
        <property name="campagne" type="int" />
        <many-to-one name="dossierDroit" column="idDossierDroit" class="DossierDroit" not-null="true" />
    </class>
...



My test :
Code:
DossierDroit dossier = (DossierDroit) this.getHibernateTemplate().load( DossierDroit.class, "02400002");
this.getHibernateTemplate().refresh(dossier);


And generated SQL (traces SQL hibernate) :
- Before refresh :
2007-01-22 16:26:03,421|DEBUG||select dossierdro0_.idDossierDroit as idDossie1_127_0_, dossierdro0_.dateDernierCalcul as dateDern2_127_0_ from TDPUDOSSIERDROIT dossierdro0_ where dossierdro0_.idDossierDroit=?

- After refresh :
2007-01-22 16:26:03,765|DEBUG||select dossierdro0_.idDossierDroit as idDossie1_127_1_, dossierdro0_.dateDernierCalcul as dateDern2_127_1_, elementref1_.idDossierDroit as idDossie3_3_, elementref1_.idElementReference as idElemen1_3_, elementref1_.idElementReference as idElemen1_121_0_, elementref1_.campagne as campagne121_0_, elementref1_.idDossierDroit as idDossie3_121_0_ from TDPUDOSSIERDROIT dossierdro0_ left outer join TDPUELEMENTREFERENCE elementref1_ on dossierdro0_.idDossierDroit=elementref1_.idDossierDroit where dossierdro0_.idDossierDroit=?


My problem is that for another object graph, refresh loads the whole database because all my objects are in relationship by traversing lazy loaded collections.
Is there a solution to refresh only the actual object on which I perform refresh and not collections as in Hibernate 2.1.7 ?

Thanks for your help.


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.