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类型
相关推荐
ANnianStriver3 小时前
PetLumina-02-后端开发与前后端联调
java·ai·sa-token
杨了个杨89824 小时前
Keepalived + Nginx + HAProxy 高可用架构部署实战案例
java·nginx·架构
马士兵教育6 小时前
Java还有前景吗?Java+AI大模型学习路线及项目?
java·人工智能·python·学习·机器学习
snow@li7 小时前
Java:理解 Gradle / 后端项目的管家 / 打包SpringBoot 应用 / 完成编译、下载依赖、运行测试、打包 JAR/WAR / 速查表
java
云烟成雨TD7 小时前
Spring AI 1.x 系列【57】动态工具发现:Tool Search Tool
java·人工智能·spring
zfoo-framework7 小时前
[修改代码使用]codex官方app中使用中转(不需要cc-switch) 1.config.toml 2.sk方式登录
java
逍遥德7 小时前
MQTT教程详解-05.SpringBoot集成mqtt client 性能分析
java·spring boot·spring·mt
云烟成雨TD7 小时前
Spring AI 1.x 系列【54】Retry 机制分析
java·人工智能·spring
weixin_523185327 小时前
Collections.unmodifiableMap详解:真的不可修改吗?
java·linux·前端
点燃大海8 小时前
SpringAI构建智能体
java·spring boot·spring·springai智能体