mybatis异常 bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorE

这个错误是自己开发过程中不细心导致的,特记下来,作为警惕。

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' at line 14

mysql分页 limit中需要整数,结果自己 dao层写成了String 类型,(低级错误)

<select id="queryPastLimit" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from  hui_app_lottery_past 
where lotterytype = #{lotterytype} 
<if test="issuenumber != null and '' !=issuenumber">
<![CDATA[ and issuenumber < #{issuenumber} ]]>
</if>
order by issuenumber desc limit #{pageSize}

</select>

dao层: public List<LotteryPast> queryPastLimit(@Param("issuenumber")String issuenumber,@Param("lotterytype")String lotterytype,@Param("pageSize") String pageSize);

正确写法为 :public List<LotteryPast> queryPastLimit(@Param("issuenumber")String issuenumber,@Param("lotterytype")String lotterytype,@Param("pageSize") int pageSize);

猜你喜欢

转载自blog.csdn.net/m0_37846887/article/details/80349613