Grails projection on arithmetic expression with executeQuery()?

前端 未结 4 1491
栀梦
栀梦 2021-01-14 09:26

I need to get a sum of all items sold per order per store. I am running a sum() on expression using executeQuery(). It works fine as shown below but I wanted to know if ther

4条回答
  •  逝去的感伤
    2021-01-14 10:00

    As of Grails 2.2, SQL projections are supported without having to drop down to the Hibernate Criteria API. Note that a formula mapping may still be more desirable, but with this you can directly implement the sum('soldPrice * soldQuantity') style projection as per your question.

    http://grails.org/doc/latest/guide/single.html#criteria

提交回复
热议问题