Caused by: java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1

来源:互联网 发布:人工智能图像理解 编辑:程序博客网 时间:2024/05/20 04:31

情景:

mybatis语句

AND (p.times_limited='NO' OR (p.times_limited='YES' AND times LIKE '%#{times}%'))

异常信息:

Caused by: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='times', mode=IN, javaType=class java.lang.Integer, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).

解决方法:
需要将like 拼接一下否则 解析不了 出现异常

CONCAT('%',#{times},'%'))
阅读全文
0 0
原创粉丝点击