Hi,
I have a load of entities persisted in my tables, now I need to sum some of the values in these tables to come up some totals. Previously I don't it like so: select o from Account where .. Then process each of the objects to get their values and add them all up to come up with the total value of all these records. It's pretty slow since there are hundreds of thousand of records and pretty inefficient of course. In SQL I would use something like this: Select Name, sum(total) from account But how can I do this in JPA, since the return type of the query is expected to by an entity. I guess I could define a new entity which has Name and Total members and then use the native query functionality and map that to returned results. Is this the best approach or is there a better way to do this? Thanks for any pointers! Chris
