本文主要是介绍mybatis查询PostgreSQL报错:无法确定参数 $1 的数据类型,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
错误信息
### Cause: org.postgresql.util.PSQLException: 错误: 无法确定参数 $1 的数据类型
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: 错误: 无法确定参数 $1 的数据类型] with root cause
org.postgresql.util.PSQLException: 错误: 无法确定参数 $1 的数据类型
Mapper.xml配置
where 1=1<if test="name != null and name != ''">AND name like concat('%', #{name} , '%')</if>
问题
排查发现是第一个if条件中的like参数出现无法识别数据类型的异常,将其强转一下类型即可
方式一修改
where 1=1<if test="name != null and name != ''">AND name like concat('%', #{name}::text , '%')</if>
方式二修改
where 1=1<if test="name != null and name != ''">AND name like '%'||#{name}||'%'</if>
这篇关于mybatis查询PostgreSQL报错:无法确定参数 $1 的数据类型的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!