Mybatis的细节问题

1、

同一个变量 @RequestParam和@PathVariable不能同时使用
@PathVariable(参数名可以不匹配)

2、invalid comparison: java.util.Date and java.lang.String
<if test="modifyDate!=null and modifyDate!=''">
modifyDate=#{modifyDate}
</if>

因为modifyDate为Date类型不能使用 modifyDate!=’’,删掉就好了

3、Cause: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found

在使用count(*) 时记得加上 resultType=“int”

4、org.apache.ibatis.exceptions.PersistenceException: Error querying database. Cause: org.apache.ibatis.binding.BindingException: Parameter ‘productName’ not found. Available parameters are [arg0, pageSize, param3, param1, currentPageNo, param2] Cause: org.apache.ibatis.binding.BindingException: Parameter ‘productName’ not found. Available parameters are [arg0, pageSize, param3, param1, currentPageNo, param2]
public List<Bill> getBillList(Bill bill,@Param("currentPageNo") Integer currentPageNo,@Param("pageSize") Integer pageSize)throws Exception;

<select id="getBillList" resultType="bill">
select b.*,p.proName as providerName from smbms_bill b,smbms_provider p
where b.providerId = p.id
<if test="productName!=null and productName!=''">
and productName like #{productName}
</if>
<if test="providerId!=null and providerId!=0">
and providerId = #{providerId}
</if>
<if test="isPayment!=null and isPayment!=0">
and isPayment =#{isPayment}
</if>
<if test="currentPageNo!=null and currentPageNo!=0 and pageSize!=null and pageSize!=0">
limit #{currentPageNo},#{pageSize}
</if>
</select>

public List getBillList(Bill bill,@Param(“currentPageNo”) Integer currentPageNo,@Param(“pageSize”) Integer pageSize)throws Exception;这里不能同时使用除了基本类型的数据

正确: public List getBillList(@Param(“productName”) String productName,@Param(“providerId”) Integer providerId,@Param(“isPayment”)Integer isPayment,@Param(“currentPageNo”) Integer currentPageNo,@Param(“pageSize”) Integer pageSize)throws Exception

5、Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘currentPageNo’ in 'class cn.smbms.pojo.Bill’Cause:org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘currentPageNo’ in 'class cn.smbms.pojo.Bil`
public List<Bill> getBillList(Bill bill)throws Exception;
<select id="getBillList" resultType="bill">
select b.*,p.proName as providerName from smbms_bill b,smbms_provider p
where b.providerId = p.id
<if test="productName!=null and productName!=''">
and productName like #{productName}
</if>
<if test="providerId!=null and providerId!=0">
and providerId = #{providerId}
</if>
<if test="isPayment!=null and isPayment!=0">
and isPayment =#{isPayment}
</if>
<if test="currentPageNo!=null and currentPageNo!=0 and pageSize!=null and pageSize!=0">
limit #{currentPageNo},#{pageSize}
</if>
</select>

要删掉 <if test="currentPageNo!=null and currentPageNo!=0 and pageSize!=null and pageSize!=0"> limit #{currentPageNo},#{pageSize} </if>不然会找不到这两个参数报错

Mybatis的细节问题_apache