wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Possible to create this HQL equivalent using Hibernate Criteria? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Possible to create this HQL equivalent using Hibernate Criteria?" Watch "Possible to create this HQL equivalent using Hibernate Criteria?" New topic
Author

Possible to create this HQL equivalent using Hibernate Criteria?

James Cheng
Greenhorn

Joined: Mar 09, 2008
Posts: 1
I have two following classes mapped in hibernate mappings

Class A1 {
long ID;
String t1;
String t2;
}
Class B1 {
long ID;
String t3;
String t4;
}

I am wondering if it's possible to create a HQL equivalent using criteria API
SELECT {a.*}
FROM A1 AS a, B1 AS b
WHERE a.t1 = b.t3 AND a.t2 = b.t4

I looked up "correlated subqueries" but I can't seem to figure out a correct way to do this as A1 and B1 are not linked by any FK constraints.
[ March 09, 2008: Message edited by: James Cheng ]
Ravi Kakani
Greenhorn

Joined: Mar 10, 2008
Posts: 2
Hibernate doesn't support outer joins on dynamic associations (not presented in mapping).

Look at Hibernate 3.1 - it is introduced new 'with' keyword:

You may supply extra join conditions using the HQL with keyword.

Hope this helps!
Allen Yu
Greenhorn

Joined: May 07, 2006
Posts: 1
Thanks for the reply but what I need is to build such HQL using criteria, the HQL example works fine. I just want to create it using Criteria interface because I need to use this as a subquery for another Criteria.
 
Consider Paul's rocket mass heater.
 
subject: Possible to create this HQL equivalent using Hibernate Criteria?
 
Similar Threads
Problem with Hibernate Criteria, Projections and associations
fwd or backward ,don't know which reference??
JOIN syntax for HQL . Need help!
choosing method
narrowing the reference