-->
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: Left Join with Criteria
PostPosted: Mon Mar 12, 2007 11:25 am 
Newbie

Joined: Thu Dec 07, 2006 12:26 pm
Posts: 3
Hibernate version:
3.2.0.ga

Name and version of the database you are using:
PostgreSQL 8.1.3

I need to create a left join in a Criteria query. I've searched in the forum, but I didn't find anything...
In google search, some people say to use:
Code:
criteria.setFetchMode("table2",FetchMode.EAGER)


but FetchMode.EAGER ia deprecated, and the solution didn't work.

I needsomething like this:

Code:
Criteria criteriaTable1 = session.createCriteria(Table1.class);
Criteria criteriaTable2 = criteriaTable1.createCriteria("table2");
criteriaTable2setFetchMode("table3", FetchMode.EAGER);
Criteria criteriaTable3 = criteriaTable2.createCriteria("table3");


I need a left join between the Table2 and Table3, cause I'll put some orders in the criteriaTable3

thanks
Robson


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 12, 2007 11:56 am 
Beginner
Beginner

Joined: Mon Aug 22, 2005 9:57 pm
Posts: 27
Criteria criteriaTable1 = session.createCriteria(Table1.class);
Criteria criteriaTable2_3 = criteriaTable1.createCriteria("table2.table3");


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 12, 2007 12:27 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Code:
Criteria criteriaTable1 = session.createCriteria(Table1.class);
Criteria criteriaTable2 = criteriaTable1.createCriteria("table2", CriteriaSpecification.LEFT_JOIN);
Criteria criteriaTable3 = criteriaTable2.createCriteria("table3",CriteriaSpecification.LEFT_JOIN);


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 12, 2007 1:08 pm 
Newbie

Joined: Thu Dec 07, 2006 12:26 pm
Posts: 3
thanks stewchicken

thanks Ananasi, your answer solved my problem (rated) .


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.