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类型
相关推荐
sanggou1 小时前
大数据量查询处理方案 - 内存优化与高效展示
java
没有bug.的程序员2 小时前
Java 字节码:看懂 JVM 的“机器语言“
java·jvm·python·spring·微服务
-大头.2 小时前
深入理解 Java 内存区域与 JVM 运行机制
java·jvm
没有bug.的程序员2 小时前
JVM 整体架构:一套虚拟机的心脏与血管
java·jvm·spring boot·spring cloud·架构
晨枫阳2 小时前
不同语言的元组对比
java·前端·javascript
悟能不能悟2 小时前
怎么在idea合并2个个branch
java·ide·intellij-idea
i02083 小时前
SpringBoot 项目配置
java·spring boot·后端
计算机毕业设计小途3 小时前
计算机毕业设计推荐:基于springboot的快递物流仓库管理系统【Java+spring boot+MySQL、Java项目、Java毕设、Java项目定制定
java·spring boot·mysql
苹果醋33 小时前
VueX(Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式)
java·运维·spring boot·mysql·nginx