-->
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 join a select ?
PostPosted: Mon Dec 07, 2009 11:41 am 
Newbie

Joined: Mon Dec 07, 2009 11:20 am
Posts: 4
Hello,
I have a problem for generate a criteria query, and even in HQL i don't knwo how to do it.

I have a table Action (#ActionId, ActionDate, ActionGroup), and the associated class ActionVO (AcnId, AdnDate, AcnGroup)

I want to retrieve the last action of each group.
So in sql should be something like:
SELECT A.* from Action A
JOIN (select ActionGroupe, max(ActionDate) as dt_action from Action group by ActionGroupe) B
ON A.ActionGroupe = B.ActionGroupe AND A.ActionDate = B.ActionDate;

Any idea of how to do this in Criteria ?
Thank you very much.


Last edited by hibernatus09 on Tue Dec 08, 2009 12:18 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Help for transform this sql in criteria or hql
PostPosted: Tue Dec 08, 2009 5:38 am 
Newbie

Joined: Mon Dec 07, 2009 11:20 am
Posts: 4
I have looked in the book "Java Persistence with Hibernate" but with my knowledges i'm still not able to find a solution :(


Top
 Profile  
 
 Post subject: Re: How to join a select ?
PostPosted: Wed Dec 09, 2009 6:59 am 
Newbie

Joined: Mon Dec 07, 2009 11:20 am
Posts: 4
any idea please ?
Is my question not explained fine ?


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.