-->
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.  [ 5 posts ] 
Author Message
 Post subject: Outer join with Criteria
PostPosted: Tue Aug 30, 2005 2:02 pm 
Newbie

Joined: Tue Aug 30, 2005 1:53 pm
Posts: 1
Is it possible to use outer join in Criteria??

session.createCriteria(City.class)
.createCriteria("country", "country")
.setFetchMode("country", FetchMode.JOIN)
.addOrder(Order.asc("country.code"))
.list();

The sql generated always use inner join between City and country. Here is the mapping file in City:

<many-to-one name="country" class="Country" column="country_id"
fetch="join" not-null="false" />

Am I missing something??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 10:40 am 
Beginner
Beginner

Joined: Wed Sep 14, 2005 9:11 am
Posts: 22
you ever get any resolution on this? I'm running into the same thing right now.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 11:50 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
try
Code:
outer-join="true"

and see if that has any effect.

and if it isn't supported in criteria, try just using hql

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 11:56 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
from the online documentation
http://www.hibernate.org/hib_docs/v3/re ... teria.html
Section 16.5

Quote:
You may specify association fetching semantics at runtime using setFetchMode().

List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "Fritz%") )
.setFetchMode("mate", FetchMode.EAGER)
.setFetchMode("kittens", FetchMode.EAGER)
.list();

This query will fetch both mate and kittens by outer join. See Section 20.1, “Fetching strategies” for more information.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 1:11 pm 
Beginner
Beginner

Joined: Wed Sep 14, 2005 9:11 am
Posts: 22
Thanks for the response... to your first solution - I'm trying to keep specific fetching strategies out of my hbm file because I'm doing that in my individual DAO's. Which addresses your second solution as well. I'm already doing that with no such luck. Any other ideas?
Thanks
Ben


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.