hibernate 用sql查询
String sql = "SELECT SUM(f.price) FROM rm_supplier as s, fi_final_pay_detail as f,fi_voucher_entry as v,fi_ledger as l where f.fpdCode = v.detailCode and f.ledgerId= l.ledgerId and l.isSettlement = 1 and f.supplierId = s.supplierId and f.submitStatus = 7 and f.price !=0 and f.costBelongTo = 1 and f.costName NOT IN ('定金','订金')
我目前是把几张表的字段创建了一个java实体类 但是查询的时候要把所有的字段查询出来 而且sum(f.price) 没有返回
求一个能在hibernate 中用的方法
hibernate 多表查询sum总和
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
6条回答 默认 最新
- Windcharger 2016-11-03 09:46关注
首先,查询的时候只需要将你要的字段查询即可,不一定要全部;没写的其他字段是null,你这样写最好把select sum...这段用括号括起来
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报