天天看點

hibernate使用DetachedCriteria案例

版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。 https://blog.csdn.net/hans201507/article/details/51073891

1.查詢一列的和

detachedCriteria.setProjection(Projections.sum("payAmount"));

2.查詢兩列積的和

detachedCriteria.setProjection(Projections.sqlProjection("sum(amount*price) as result", new String[] { "result" }, new Type[] { new DoubleType() }));