postgresql mybatis like查询报错:org.postgresql.util.PSQLException: 栏位索引超过许可范围:1,栏位数:0
折磨过程
最开始写法:... like '%#{code}%' ...,报错
改成:... like CONCAT('%',#{code},'%') ...,报错
又改成:... like CONCAT('%','#{code}','%') ...,报错
又又改成:... like CONCAT('%','#{code,javaType=String,jdbcType=VARCHAR}','%') ...,报错
又又又改成:... like CONCAT('%',#{code,javaType=String,jdbcType=VARCHAR},'%') ...,还是报错(org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $1)
然后参考Postgresql like错误的坑(ERROR: could not determine data type of parameter $7) ,是数据库版本问题,修改为:
... like CONCAT('%',#{code,javaType=String,jdbcType=VARCHAR}::text,'%') ...
终于好了
参考文章
org.postgresql.util.PSQLException: 栏位索引超过许可范围:1,栏位数:0。
Postgresql like错误的坑(ERROR: could not determine data type of parameter $7)

浙公网安备 33010602011771号