-->
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.  [ 1 post ] 
Author Message
 Post subject: Subquery in detached criteria
PostPosted: Tue Oct 28, 2014 4:26 am 
Newbie

Joined: Tue Oct 28, 2014 2:25 am
Posts: 1
Hi,

I am new to criteria. below is my situation explained.

Table structure

Header
|_Lines(1 - many)
|_SKU(1 - many)

My query is to get Header object based on some conditions and most important is the latest revision number. All the tables have a column called rev_Nbr. I am searching PO's for a specific customer, the query will fetch all the PO's based on the customer but i need to fetch only latest PO's with the help of max revision number.

select * from header where poNbr in (select max(revNbr) from header where custId = ?) AND custId = ?;

How to achieve this using detached criteria. i am using detached criteria to run the query but i dont know how to add subquery to each detached criteria? Header, Lines, Sku each and every model respective criteria i have created but i dont know how to add subquery to each of the criteria?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.