-->
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: Criteria API and left outer join
PostPosted: Mon Feb 28, 2005 7:47 pm 
Newbie

Joined: Thu Feb 24, 2005 10:50 pm
Posts: 7
Hi!

Using the Criteria API I'm trying to load all the object graph in one SQL select using outer joins but it seems that all associated objects are all loaded in the first query but also each one individually:

<hibernate-mapping package="sondage">
<class name="SondageInfo" table="Sondage" mutable="false">
<cache usage="read-only"/>
<id name="sondageGPK" type="long" unsaved-value="null">
<generator class="GPKGenerator">
...
</generator>
</id>
<property name="organisationId"/>
...

<one-to-one name="marchandiseTransporteur"
class="MarchandiseTransporteur"
property-ref="sondageGPK"
cascade="none" outer-join="true"/>
...


</hibernate-mapping>

The code:

Criteria c = session.createCriteria(SondageInfo.class);
c.add(Expression.eq("sondageGPK", new Long(4980736)));

Hibernate result output:

1st query:

select this.sondageGPK as sondageGPK1_, ... from Sondage this left outer join MarchandiseTransporteur marchandis1_ on this.sondageGPK=marchandis1_.sondageGPK where this.sondageGPK=?

2nd query:

select marchandis0_.marchandiseTransporteurGPK ...from MarchandiseTransporteur marchandis0_ where marchandis0_.sondageGPK=?

As you can see the first query loads everything for table "Sondage" but also for table "MarchandiseTransporteur" using a left outer join, but there is a second query issued by Hibernate which loads "MarchandiseTransporteur" again? The association is loaded twice why???

Thanks

Regards,

Christian


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 2:28 pm 
Newbie

Joined: Thu Feb 24, 2005 10:50 pm
Posts: 7
I've tested the same code using H3RC1 and it works as desired...

Christian


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.