Mybatis处理多个Sum()结果返回null

如下面代码所示,sql可以正常返回求和信息,mybatis为什么会回null ,是不是我的mapper映射有问题???

  • dao

https://img4.mukewang.com/5b98bb89000175ec02990759.jpg

  • sql语句,正常返回求和

    https://img1.mukewang.com/5b98bb990001b81d02180258.jpg

  • Mappr 文件

  • https://img.mukewang.com/5b98bbb00001d85205740374.jpg

  • https://img1.mukewang.com/5b98bbbf0001c2da06240375.jpg


慕无忌1623718
浏览 1837回答 1
1回答

至尊宝的传说

查询的结果集与result的column名对不上,可以在sum(...)添加别名。mapper中的sql改为:SELECT id, court_name, depart_name, SUM(info_1) info_1, SUM(info_2) info_2, SUM(info_3) info_3, SUM(info_4) info_4, SUM(info_5) info_5, SUM(info_6) info_6, SUM(info_7) info_7, SUM(info_8) info_8, SUM(info_9) info_9, SUM(info_10) info_10, SUM(info_11) info_11, SUM(info_12) info_12, s_month, s_year FROM caselist_info <where> <if test="courtName != null"> and court_name = #{courtName} </if> </where> GROUP BY court_name, depart_name
打开App,查看更多内容
随时随地看视频慕课网APP