-->
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 question
PostPosted: Thu Jun 24, 2010 3:13 pm 
Newbie

Joined: Thu Jun 24, 2010 2:59 pm
Posts: 1
I'm new to both this board and Hibernate and wanted to know how I can mimic the following type of query in either HQL or using an instance of DetachedCriteria:


Select a.field1, b.field2

From TableA a, TableB b, TableC c

Where someCriteria = otherCriteria

And b.idField In(
select max(idField)
from TableB b1
where b1.theField = b.theField
and b1.anotherField = b.anotherField
)

Basically, in my Java code I have an instance of what represent TableB b, but am not sure if I can reference it inside the subquery, or whether I need to list both instances in the same subquery. I did try and search the forum, but did not find what I was looking for. So any help with this would be appreciated.

Thanks


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.