Alex Rivera | Logout

Using sum() in hibernate criteria

Asked 2011-01-07T11:02:07.797
19

How can I write the sql query select sum(amount * direction) from transactions into hibernate criteria ?

Edit
Report

1 Answer

1

Projections is the key word to use aggregate functions with hibnerate criteria.

roseindia has a short example for implementing a SELECT SUM(...) query. Looks pretty close to your problem.


Here's another forum topic that includes a working example for a SUM(col1 * col2) expression and the original poster had similiar problems with exceptions before.

answered 2011-01-07T11:26:07.150

Your Answer