Using sum() in hibernate criteria

前端 未结 3 1001
猫巷女王i
猫巷女王i 2020-12-03 13:42

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

3条回答
  •  执笔经年
    2020-12-03 14:40

    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.

提交回复
热议问题