pgsql timestamp without time zone > character varying解决方案

问题背景

最近给一个项目从mysql迁移到pgsql中去,mysql中的日期大于小于等于操作符可以直接对string生效,会进行自动转换,但是在pgsql下不行,并且会触发"Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: timestamp without time zone >= character varying",项目是springboot2+mybatis plus框架,该任务由定时任务执行。

报错信息:

shell 复制代码
org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: timestamp without time zone >= character varying
  建议:No operator matches the given name and argument types. You might need to add explicit type casts.
  位置:64
### The error may exist in com/common/mapper/SysDictTypeMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT COUNT(*) AS total FROM sys_dict_type WHERE (create_time BETWEEN ? AND ?)
### Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: timestamp without time zone >= character varying
  建议:No operator matches the given name and argument types. You might need to add explicit type casts.
  位置:64
; bad SQL grammar []

解决方案

  • 传入参数时把数据格式转换为date类型,不可以是string类型
相关推荐
本喵是FW1 分钟前
C语言手记1
java·c语言·算法
洛阳泰山10 分钟前
MaxKB4j Docker Compose 部署指南
java·docker·llm·springboot·rag·maxkb4j
森林里的程序猿猿26 分钟前
垃圾收集器G1和ZGC
java·jvm·算法
weixin_4041576829 分钟前
Java高级面试与工程实践问题集(五)
java·开发语言·面试
fengci.34 分钟前
ctfshow(web入门)295-300
java·开发语言·学习
重庆小透明1 小时前
【面试问题】java字节八股部分
java·面试·职场和发展
小王不爱笑1321 小时前
Java 对象拷贝(浅拷贝 / 深拷贝)
java·开发语言·python
架构师沉默1 小时前
程序员真的要失业了吗?
java·后端·架构
小王不爱笑1321 小时前
SpringBoot 自动装配深度解析:从底层原理到自定义 starter 实战(含源码断点调试)
java·spring boot·mybatis
森林里的程序猿猿1 小时前
Spring Aop底层源码实现(一)
java·后端·spring