美文网首页
mybatis-plus自定义sql使用like查询报错

mybatis-plus自定义sql使用like查询报错

作者: pumpdev | 来源:发表于2022-04-06 10:49 被阅读0次

使用mybatis-plus查询报错:

TypeException: Error setting non null for parameter #5 with JdbcType null
TypeException: Could not set parameters for mapping: ParameterMapping{property='size', mode=IN, javaType=class

排查了半天发现是因为用了like查询,我之前的写法是

 where state like '%#{state}%' ;

正确的写法是需要用concat方法拼接

 where state like CONCAT(’%’,#{state},’%’) ;

相关文章

网友评论

      本文标题:mybatis-plus自定义sql使用like查询报错

      本文链接:https://www.haomeiwen.com/subject/xndrsrtx.html