On Fri, Jan 8, 2010 at 10:39 AM, C N Davies <[email protected]> wrote:

> Hi,
> But how can I do this in JPA, since the return type of the query is
> expected
> to by an entity.


The return type can be an entity, even any old object, or an array of Object
values. To get total salary paid by department:

select sum(e.salary), e.dept
from Employee e
group by e.dept

I did not run this nor have I ever done a sum() but you should get the idea
if it's not quite right. This returns an Object[] (say, results) where
results[0] is a number and results[1] is a Department.

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:[email protected]

Reply via email to