-->
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.  [ 2 posts ] 
Author Message
 Post subject: Using a subquery as a projection in a criteria
PostPosted: Mon Jun 09, 2008 12:12 pm 
Newbie

Joined: Wed May 28, 2008 1:42 pm
Posts: 2
This should be fairly simple but I haven't been able to find any examples for how to do this. Basically, I want to do the equivalent of the following in a Criteria and ResultTransformer it into a custom bean. Is a query like this supported by the Criteria API?

Code:
select p.name, (select sum(t.amount) from p.transactions t) from person p

I know that I could transform this into a join-and-group-by query, but the subselect version is significantly faster.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 4:50 pm 
Newbie

Joined: Fri Jun 30, 2006 7:00 pm
Posts: 6
I don't believe that this is currently supported. Your best bet is to use Projections.sqlProjection() or implementing the Projection interface to support what you need.

David


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.