-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to force outer joins in Criteria?
PostPosted: Mon Apr 04, 2011 2:37 am 
Newbie

Joined: Mon Apr 04, 2011 2:28 am
Posts: 2
Hi,

I was trying to force outer joins in Criteria queries by setting the fetch mode as JOIN, still it is not working, but when I manually give the fetch="join" in the mapping files, this looks to be working.

Any clues how it can be made to work by setting the fetch mode?

Thanks in advance for the answers.


Top
 Profile  
 
 Post subject: Re: How to force outer joins in Criteria?
PostPosted: Tue Apr 05, 2011 5:41 pm 
Beginner
Beginner

Joined: Sat Sep 24, 2005 11:04 pm
Posts: 21
Think you can use .createAlias(<propertyName>,<alias>,<join mode>) to specify the join conditions for collections or associations...

For example:
Code:
createCriteria(Person.class)
   .createAlias("vehicles", "vehicles", Criteria.LEFT_JOIN)
   .list();

would basically generate a SQL statement along the lines of:

select ... from tblPerson this_
left outer join tblVehicle vehicles1_ on this_.id = vehicles1_.personId


Top
 Profile  
 
 Post subject: Re: How to force outer joins in Criteria?
PostPosted: Tue Apr 05, 2011 11:04 pm 
Newbie

Joined: Mon Apr 04, 2011 2:28 am
Posts: 2
Thanks for the reply and suggestion, I was able to get the outer joins, but was using
Code:
createCriteria(Person.class)
   .createAlias("vehicles", "vehicles", CriteriaSpecification.LEFT_JOIN)
   .list();


Top
 Profile  
 
 Post subject: Re: How to force outer joins in Criteria?
PostPosted: Wed Apr 06, 2011 2:06 am 
Beginner
Beginner

Joined: Mon Apr 04, 2011 3:31 am
Posts: 41
hi check this

http://docs.jboss.org/hibernate/core/3. ... ryhql.html

_________________
Thanks
Niki


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