org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
1、报错信息
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
建议:No operator matches the given name and argument types. You might need to add explicit type casts.
位置:334
### The error may exist in org/springblade/develop/mapper/ModelPrototypeMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id, model_id, jdbc_name, jdbc_type, property_name, property_type, property_entity, comment, is_list, is_form, is_row, component_type, dict_code, is_required, is_query, query_type, create_user, create_dept, create_time, update_user, update_time, status, is_deleted FROM blade_model_prototype WHERE is_deleted = 0 AND (model_id = ?)
### Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
建议:No operator matches the given name and argument types. You might need to add explicit type casts.
位置:334
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
建议:No operator matches the given name and argument types. You might need to add explicit type casts.
位置:334
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:101)
2、问题分析
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
场景:在一次开发过程中,使用 Mybatis-plus 自动生成的代码时,生成完成后调试过程中出现的报错信息。
此问题出现的原因:部分数据库在执行 sql 过程中,不支持部分字段类型的自动转换。
使用过程中实际报错的场景:使用的数据库是 postgresql 数据库,报错字段是 modelId (数据库中是 model_id), 在数据库中是 int8 类型的。
而在controller 层接收参数 modelId 是 String 类型的,所以在执行 新增的操作时,出现了数据库层面的报错。
实际就是 modelId 字段类型与数据库不一致错误。
3、解决方案
我解决问题的处理,就是在 controller 层,将参数 id 改为 Long 类型,报错就解决了。
实际解决问题的过程,要排查 controller 中的参数类型,并排查中间操作的是否有类型转换的操作,以及 实体类 entity 中的类型与数据库是否一致。
org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying的更多相关文章
- pg数据库org.postgresql.util.PSQLException: ERROR: "xxx" is not a sequence
问题场景 对pg数据表执行插入语句的时候,报错如下: { "timestamp": 1587012576734, "status": 500, "er ...
- 【hibernate postgresql】注解@TypeDef/@Enumerated/数据库字段gender为枚举类型,从前台接受到实体后进行保存报错:org.postgresql.util.PSQLException: ERROR: column "gender" is of type gender but expression is of type character varying
数据库字段gender为枚举类型,从前台接受到实体后进行保存报错:org.postgresql.util.PSQLException: ERROR: column "gender" ...
- Cause: org.postgresql.util.PSQLException: ERROR: cached plan must not change result type的前因后果
首先说明一下遇到的问题: PG数据库,对其中的某张表增加一列后,应用报错,信息如下: 应用使用相关框架如下:SpringBoot.MyBatis. ### Cause: org.postgresql. ...
- Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = integer
Springboot项目,使用postgresql数据库,mybatis做持久层框架, <select id="select" resultMap="BaseRes ...
- 一次org.springframework.jdbc.BadSqlGrammarException ### Error querying database Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException问题排查过程
先说结论: 因为在表设计中有一个商品描述字段被设置为desc,但desc是mysql中的关键字,如select id,name,desc,price from product;这条sql语句在查询时的 ...
- org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manu
这个是sql 语句 错误 仔细检查 SQL语句是否写错了 org.apache.ibatis.exceptions.PersistenceException: ### Error queryi ...
- org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent succ
数据库 没有开启 连接失败 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause ...
- org.springframework.jdbc.BadSqlGrammarException
org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: java.sql.SQLExc ...
- Error querying database. Cause: java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名
今天调试程序是遇到了,下面的一个问题.我将对应的SQL语句拿到Toad下也能正常的执行,感觉有点莫名其妙,根据异常信息的提示查看对应的映射结果集也没发现错误,然后百度了一下,也有许多朋友也遇到过这样的 ...
- 使用Oracle数据库时的org.springframework.jdbc.BadSqlGrammarException:
org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: java.sql.SQLExc ...
随机推荐
- NetworkPolicy网络策略以及举例说明
网络策略(NetworkPolicy)是一种关于pod间及pod与其他网络端点间所允许的通信规则的规范.NetworkPolicy 资源使用标签选择pod,并定义选定pod所允许的通信规则. 前提 网 ...
- Linux实例常用内核网络参数介绍与常见问题处理---重要
文章转载自:https://help.aliyun.com/knowledge_detail/41334.html 本文主要介绍如下几点内容,您可以根据实际需要选择. 查看和修改Linux实例内核参数 ...
- ELK 性能优化实践
文章转载自:https://mp.weixin.qq.com/s?__biz=MzI5MTU1MzM3MQ==&mid=2247489814&idx=1&sn=6916f8b7 ...
- python csv写入多列
import csv import os def main(): current_dir = os.path.abspath('.') file_name = os.path.join(current ...
- 基于python的RSA解密算法
摘要 网上有很多关于RSA的解密脚本,欧拉函数.欧几里得函数什么的,对于一个大专生的我来说,一窍不通,至此经历了三天三夜,我翻阅了RSA的加密原理,以及其底层算法,专研出了一套我自己的解密算法,尚有不 ...
- Optional 常用方法总结
转载请注明出处: Optional 类是 JAVA 8 提供的判断程序是否为空提供的包装工具类:可以减少代码中的 是否为空的判断,以及减少 NullPointerExceptions:使得程序变得更为 ...
- C++面向对象编程之point-like classes的智能指针和迭代器、function-like classes即仿函数
1.智能指针 智能指针里面包含其他指针的形式和 委托 感觉比较像; 智能指针一定都需要重载 * 和 -> 操作符 ; 这个符号它作用后还能再继续作用下去; 2.迭代器: 这里主要关注 * 和 - ...
- springboot的注解声明过滤器配置错误导致拦截所有请求。
究其原因, 原来spring 扫包时候 扫了Webfilter 注解,注册了一次过滤匹配路径,扫了Component注解(又注册了一次过滤匹配路径,默认是全路径). Component注解后于WebF ...
- The project was not built due to "Could not delete '/XXX/WebRoot/WEB-INF/classes/library'.". Fix the problem, then try refreshing this project and building
在构建插件时提示如下错误: Description Resource Path Location Type The project was not built due to "Could n ...
- mitmproxy抓包工具
中文官网 https://ptorch.com/docs/10/mitmproxy-concepts-options mitmproxy抓包工具 1. mitmproxy 介绍与安装 需要安装pyth ...