-->
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: Is this query feasible - Hibrernate criteria
PostPosted: Mon Feb 27, 2012 5:03 pm 
Newbie

Joined: Tue Dec 13, 2011 4:50 pm
Posts: 6
Is it possible to combine an entity with aggregate query results?
example :
Criteria userCrit = session.createCriteria(Topic.class);

userCrit.createAlias("userTopics", "userTopics");
userCrit.createAlias("userTopics.user", "user");

userCrit.setProjection(Projections.count("user.userId").as("numInterested"));
userCrit.setProjection(Projections.groupProperty("topicId"));

This query should include all attributes of Topic class plus the count value using the group by clause


Top
 Profile  
 
 Post subject: Re: Is this query feasible - Hibrernate criteria
PostPosted: Tue Feb 28, 2012 4:57 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I never tried such thing but I think,
if it is possible at all, then by implementing and using a custom result-transformer
Quote:
session.createCriteria(...).setResultTransformer(yourResultTransformerImpl)


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.