-->
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.  [ 3 posts ] 
Author Message
 Post subject: how to make DetachedCriteria left outer join
PostPosted: Fri Feb 10, 2006 4:45 am 
Newbie

Joined: Thu Dec 15, 2005 4:55 am
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3

I want use the DetachedCriteria to query sth , I want to change the relation between the master records and detail records to left outer join, but when I execute the following code, I find it cannot work ,the relation is still inner join ! , thanks for help !

Below is the code :


//declare a detachedCriteria, root class is A01 and it has a36s ,a02s,a08s ... collection properties.
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(A01.class,
"a01").setResultTransformer(DetachedCriteria.
DISTINCT_ROOT_ENTITY);

//create the alias , and want to make the detachedCriteria left outer join the a36s.
detachedCriteria.setFetchMode("a36s", org.hibernate.FetchMode.JOIN);
detachedCriteria.createAlias("a36s","a36");
detachedCriteria.add(Restrictions.eq("a36.gb4761.code","11"));


//create the alias , and want to make the detachedCriteria left outer join the a36s.
detachedCriteria.setFetchMode("a03s", org.hibernate.FetchMode.JOIN);
detachedCriteria.createAlias("a03s","a03");
detachedCriteria.add(Restrictions.eq("a03.code","12"));


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 07, 2006 8:14 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:54 am
Posts: 28
I am facing the same problem in my current project. Do you have in the mean time found a solution to the stated problem ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 10, 2008 1:03 pm 
Newbie

Joined: Mon Mar 10, 2008 12:55 pm
Posts: 2
Location: Gurgaon, India
I know this post is pretty old but since I spent quite some time trying to arrive at a solution, I think a reply here would help others who have the same issue...

DetachedCriteria does not have all methods that the Criteria has up until Hibernate 3.2.6

See http://opensource.atlassian.com/project ... At9ftUvEzI

The alterative is to use Criteria instead and use the createAlias(String associationPath, String alias, int joinType) method. This allows the join type to be explicitly mentioned while creating the alias.


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