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类型
相关推荐
CC.GG12 分钟前
【Linux】进程概念(五)(虚拟地址空间----建立宏观认知)
java·linux·运维
以太浮标1 小时前
华为eNSP模拟器综合实验之- AC+AP无线网络调优与高密场景
java·服务器·华为
Mr__Miss1 小时前
JAVA面试-框架篇
java·spring·面试
小马爱打代码1 小时前
SpringBoot:封装 starter
java·spring boot·后端
STARSpace88881 小时前
SpringBoot 整合个推推送
java·spring boot·后端·消息推送·个推
码农幻想梦1 小时前
实验八 获取请求参数及域对象共享数据
java·开发语言·servlet
a努力。2 小时前
2026 AI 编程终极套装:Claude Code + Codex + Gemini CLI + Antigravity,四位一体实战指南!
java·开发语言·人工智能·分布式·python·面试
Dylan的码园2 小时前
功能包介绍 : calendar
java·jvm·eclipse
二川bro2 小时前
Java集合类框架的基本接口有哪些?
java·开发语言·python
菜鸟233号2 小时前
力扣213 打家劫舍II java实现
java·数据结构·算法·leetcode