File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Criteria equivalent for select function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Criteria equivalent for select function" Watch "Criteria equivalent for select function" New topic

Criteria equivalent for select function

Mark Baldwin

Joined: Aug 04, 2011
Posts: 9
Hello masters,

I'd like to know if there is a Criteria equivalent for this SQL:

select * from productCategories where businessId = (select business_id from businesses where domain = ?) order by name desc limit ?, ?;

I think I know how to do it in HQL but if there's some way to do it with Criteria I would prefer that. Thanks

Kind regards,
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
You should be able to write anything you can write in JPQL in Criteria.

Here is some examples of sub-queries using the Criteria API.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
subject: Criteria equivalent for select function
jQuery in Action, 3rd edition