Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = in...

Springboot项目,使用postgresql数据库,mybatis做持久层框架,

1 <select id="select" resultMap="BaseResultMap" parameterType="com.vo.TestVo">
2         select 
3             <include refid="Base_Column_List" />
4         from test
5         where state='2'
6         <if test="comCode != null" >
7             and com_code=${comCode}
8         </if>
9     </select>

comcode的形式如:'1100'

执行查询时报错:

### The error may exist in file [D:\workspaceAll\eclipseWorkspace\test\target\classes\mapper\custom\test\QcTestDao.xml]
### The error may involve com.dao.TestDao.select-Inline
### The error occurred while setting parameters
### SQL: select          id, comcode,name   from test   where state='2'        and com_code=00000000
### Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = integer
  建议:No operator matches the given name and argument type(s). You might need to add explicit type casts.
  位置:286
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = integer
  建议:No operator matches the given name and argument type(s). You might need to add explicit type casts.
  位置:286] with root cause
org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = integer
  建议:No operator matches the given name and argument type(s). You might need to add explicit type casts.
  位置:286

 解决方法:

1 <if test="comCode != null" >
2       and com_code=#{comCode,jdbcType=VARCHAR}
3 </if>

 

转载于:https://www.cnblogs.com/mySummer/p/9262628.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值