在入参对象中定义了 tradeDirections 和 ids 两个list;
调用该方法。入参为对象
分别以tradeDirections 和 ids作为查询条件
<select id="listByTradeDicDate" parameterType="com.win.dfbp.biz.outside.other.pledgedrepo.vo.request.RepoConstructionListReqVO"
resultType="com.win.dfbp.biz.outside.other.pledgedrepo.entity.BooRepoContractInstruction">
SELECT <include refid="Base_Column_List"/>
FROM boo_repo_contract_instruction
WHERE delete_flag = '0'
<if test='null != tradeDirections and tradeDirections.size() > 0'>
AND trade_direction IN
<foreach collection="tradeDirections" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test='null != ids and ids.size() > 0'>
AND id IN
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
如果出现了The expression 'xxx' evaluated to a null value 这样的错误。解决方法如下:
1.查看if test 语句是否正确,注意 if test= ' ' 后面跟的是单引号, 如果是if test = " " 则不会生效,导致该判断list是否为空失败。从而出现错误。
2.确定入参类型 ,如上,我的入参类型 parameterType 后面是对象的引用。