MyBatis 基本数据类型条件判断问题

1.判断参数使用:_parameter

<select id="findCount" parameterType="int" resultType="int">
     SELECT COUNT(id) FROM vote 
     <where>
         <if test="_parameter != null">isuse=#{isuse}</if>
     </where>
 </select>

2.或者修改接口:

int findCount(int isuse);

改为:

int findCount(@Param(value="cmpid") int isuse);

3.一般出错原因:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取Integer.cmpid。Integer对象没有cmpid属性。如果不解析参数,mybatis自动识别传入的参数,不会报错。

原文地址:https://www.cnblogs.com/qingyibusi/p/6112329.html