-->
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: How to map or assign the result of a group by to a property?
PostPosted: Tue Dec 28, 2010 3:53 pm 
Newbie

Joined: Sat Mar 13, 2010 11:56 pm
Posts: 3
Domain Object:
class Project {
private int numberOfWorkers;
private String name;
}
class Worker {
private Project project;
}

The usual mapping is done in hbm.xml's. I am running the following query:
SELECT project, COUNT(worker) FROM Worker worker GROUP BY worker.project;

I want to assign COUNT(worker) to Project.numberOfWorkers through mapping, the query itself or some other mechanism preferably not looping through the results.

How can this be done in Hibernate? 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.