org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'requestMap.cpmodel != null and requestMap.cpmodel != '''. Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "cpmodel")
问题出现的愿意:我在mapper.xml中的查询方法中<if></if>中的test里使用了requestMap
代码如下:
<select id="countdoid" resultMap="detailsout">
select count(doid) from details_out,orders_need_supplyofgoods_details,position,orders_need,product,customer
where orders_need_supplyofgoods_details.status != 6
AND details_out.positionid = position.positionid
AND orders_need_supplyofgoods_details.nid = orders_need.nid
AND orders_need.cpid = product.cpid
AND position.cid = customer.cid
AND details_out.onsdid = orders_need_supplyofgoods_details.onsdid
<if test="requestMap.cpmodel != null and requestMap.cpmodel != ''">
AND product.cpmodel = #{requestMap.cpmodel}
</if>
<if test="requestMap.cname != null and requestMap.cname != ''">
AND customer.cname = #{requestMap.cname}
</if>
<if test="requestMap.weiyibiaoshi != null and requestMap.weiyibiaoshi != ''">
AND orders_need_supplyofgoods_details.weiyibiaoshi = #{requestMap.weiyibiaoshi}
</if>
<if test="requestMap.status != null and requestMap.status != ''">
AND orders_need_supplyofgoods_details.status = #{requestMap.status}
</if>
</select>
问题解决:我在mapper层中的方法里没有添加@Param("requestMap")Map<String, Object> requestMap,
解决方法:
/**
*
* @Title: countdoid
* @Description: TODO(物资闲置,计算已分发物资的数量)
* @return
*/
int countdoid();
添加参数后为
/**
*
* @Title: countdoid
* @Description: TODO(物资闲置,计算已分发物资的数量)
* @return
*/
int countdoid(@Param("requestMap")Map<String, Object> requestMap);
这样在mapper.xml的语句中就不会出问题了