Error querying database. Cause: org.postgresql.util.PSQLException: 错误: 操作符不存在: smallint = character

2022-04-20 08:40:27.664 [http-nio-8080-exec-4] ERROR
o.jeecg.common.exception.JeecgBootExceptionHandler:58 -

### Error querying database. Cause:
org.postgresql.util.PSQLException: 错误: 操作符不存在: smallint = character
varying 建议:没有匹配指定名称和参数类型的操作符. 您也许需要增加明确的类型转换. 位置:1469

postgresql对变量类型比较敏感,对相应的变量进行类型转换之后就可以了

修改前

<if test="lx !=null and  lx.size>0 ">
            AND t.lx in
            <foreach collection="lx" item="lxItem" separator="," open="(" close=")">
            #{lxItem} 
            foreach>
        if>

修改后

<if test="lx !=null and  lx.size>0 ">
            AND t.lx in
            <foreach collection="lx" item="lxItem" separator="," open="(" close=")">
                CAST(#{lxItem} AS SMALLINT)
            foreach>
        if>

参考资料:

  1. https://blog.csdn.net/CS_370682/article/details/108484152
  2. http://www.zzvips.com/article/144729.html

你可能感兴趣的:(使用Java遇到的问题,java,postgresql)