-->
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: how to generate a left join when using a criteria query?
PostPosted: Thu May 31, 2007 11:12 am 
Newbie

Joined: Wed May 30, 2007 2:18 pm
Posts: 14
How can I generate the following HQL using a criteria query?
Code:
select mother, mate.Name
from Eg.DomesticCat as mother
    left outer join mother.Mate as mate


When I try to use a criteria query it always uses an inner join. But I need it to use a left join because a cat may not always have a mate but I still want that cat returned.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 12:22 pm 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
The CreateCriteria method has an overload that supports setting the JoinType.

Cheers,

Syn


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 12:28 pm 
Newbie

Joined: Wed May 30, 2007 2:18 pm
Posts: 14
I didn't find such an overload on CreateCritera. But I did find one on CreateAlias.

Problem solved.
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 2:00 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It's there in NHibernate 1.2. If you are not using it yet, you should upgrade.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 8:34 am 
Newbie

Joined: Wed May 30, 2007 2:18 pm
Posts: 14
sergey wrote:
It's there in NHibernate 1.2. If you are not using it yet, you should upgrade.


Okay, I found it. I was only looking at session.CreateCriteria which doesn't have this overload.

Thanks.


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.