当前位置:   article > 正文

【PostgreSQL】已解决Spring Boot中Mybatis模糊查询时出现 could not determine data type of parameter $1

could not determine data type of parameter $1

问题

### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $1 ### The error may exist in class path resource [mapper/bladexsql/BladexsqlMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT * FROM blade_user WHERE role_id LIKE concat('%', ?, '%') ### Cause: org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $1 ; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $1

在这里插入图片描述

<select id="getUserByRoleId" resultType="com.yutu.water.vo.BladeUserVo">
    select * from blade_user where role_id like concat('%', #{roleId}, '%')
</select>
  • 1
  • 2
  • 3

解决

检查你的模糊查询参数是什么类型!!!一定要是字符串类型!!!

我看了一下我的roleId居然是Long类型的,导致出现could not determine data type of parameter $1的问题,我们需要把你类型转一下就好了!

serviceImpl

在这里插入图片描述

mapper

在这里插入图片描述


转成字符串类型

serviceImpl

在这里插入图片描述

mapper

在这里插入图片描述

这样子修改完之后就不会出现这个问题了

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号