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类型
相关推荐
毕设源码-朱学姐7 小时前
【开题答辩全过程】以 公务员考试在线测试系统为例,包含答辩的问题和答案
java
serendipity_hky7 小时前
【SpringCloud | 第2篇】OpenFeign远程调用
java·后端·spring·spring cloud·openfeign
RwTo7 小时前
【源码】-Java线程池ThreadPool
java·开发语言
SadSunset7 小时前
(15)抽象工厂模式(了解)
java·笔记·后端·spring·抽象工厂模式
兮动人7 小时前
EMT4J定制规则版:Java 8→17迁移兼容性检测与规则优化实战
java·开发语言·emt4j
一点★7 小时前
Java中的常量池和字符串常量池
java·开发语言
问君能有几多愁~8 小时前
C++ 日志实现
java·前端·c++
菜鸟plus+8 小时前
Java 接口的演变
java·开发语言
李慕婉学姐8 小时前
【开题答辩过程】以《基于springboot的地铁综合服务管理系统的设计与实现》为例,不知道这个选题怎么做的,不知道这个选题怎么开题答辩的可以进来看看
java·spring boot·后端
IT空门:门主8 小时前
Spring AI的教程,持续更新......
java·人工智能·spring·spring ai