标签:start class gid ini app detail count 传递 where
概述:
在使用XML写SQL语句的时候,遇到参数传递的两种方式,也就是Mapper里面带@Param注解和不带的情况,对应XML的写法也不相同,使用的时候要注意对照,汇总举例如下:
Mapper代码:
List<InIncome101Report> queryListByPeriod(Page<InIncome101Report> page, Map<String,Object> params);//非注解@Param List<InIncome101Report> queryListByVoucherdata(Page<InIncome101Report> page, @Param("params") Map<String,Object> params);//带注解的
XML内容
<select id="queryListByPeriod" resultType="com.dbgo.acme.report.domain.model.InIncome101Report"> SELECT T.supplier_name supplierName, T.supplier_tax_code supplierTaxcode, COUNT (0) sumCount FROM tbl_in_incomedetail T WHERE T.org_id = #{orgId} <if test="_parameter.containsKey(‘periodstart‘)"> AND T.tax_period>= #{periodstart} </if> <if test="_parameter.containsKey(‘periodend‘)"> AND T.tax_period <![CDATA[<=]]>#{periodend} </if> GROUP BY T.supplier_name, T.supplier_tax_code </select>
方法2:
<select id="queryListByVoucherdata" resultType="com.dbgo.acme.report.domain.model.InIncome101Report"> SELECT T.suppliername supplierName, T.suppliertax_code supplierTaxcode, FROM tbl_in_incomedetail T WHERE T.org_id = #{params.orgId} AND T.vouchedata >=#{params.start} AND T.vouchedata <![CDATA[<=]]>#{params.end} GROUP BY T.suppliername , T.suppliertax_code </select>
标签:start class gid ini app detail count 传递 where
原文地址:https://www.cnblogs.com/xibei666/p/10320379.html