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的更多相关文章

  1. pg数据库org.postgresql.util.PSQLException: ERROR: "xxx" is not a sequence

    问题场景 对pg数据表执行插入语句的时候,报错如下: { "timestamp": 1587012576734, "status": 500, "er ...

  2. 【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" ...

  3. Cause: org.postgresql.util.PSQLException: ERROR: cached plan must not change result type的前因后果

    首先说明一下遇到的问题: PG数据库,对其中的某张表增加一列后,应用报错,信息如下: 应用使用相关框架如下:SpringBoot.MyBatis. ### Cause: org.postgresql. ...

  4. Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = integer

    Springboot项目,使用postgresql数据库,mybatis做持久层框架, <select id="select" resultMap="BaseRes ...

  5. 一次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语句在查询时的 ...

  6. 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 ...

  7. 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 ...

  8. org.springframework.jdbc.BadSqlGrammarException

    org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: java.sql.SQLExc ...

  9. Error querying database. Cause: java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名

    今天调试程序是遇到了,下面的一个问题.我将对应的SQL语句拿到Toad下也能正常的执行,感觉有点莫名其妙,根据异常信息的提示查看对应的映射结果集也没发现错误,然后百度了一下,也有许多朋友也遇到过这样的 ...

  10. 使用Oracle数据库时的org.springframework.jdbc.BadSqlGrammarException:

    org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: java.sql.SQLExc ...

随机推荐

  1. ProxySQL Cluster 概述

    文章转载自:https://blog.csdn.net/n88Lpo/article/details/79608639 前言 在ProxySQL 1.4.2 之前,ProxySQL 单点的解决方法有配 ...

  2. kvm使用桥接的方法

    什么是桥接 桥接就是把物理机的网卡模拟成交换机,虚拟机的网卡直接连在虚拟的网桥即交换机上.这样kvm虚拟机分配的IP地址,就应该和物理机在同一网段,可以对外进行服务. 在KVM下运行的VM默认的网卡采 ...

  3. JDK19新特性使用详解

    前提 JDK19于2022-09-20发布GA版本,本文将会详细介绍JDK19新特性的使用. 新特性列表 新特性列表如下: JPE-405:Record模式(预览功能) JPE-422:JDK移植到L ...

  4. while循环控制

    基本语法 例(输出五句hello): int i = 1; //循环变量初始化 while(i<=5){ //循环条件 printf("\n hello!"); //循环语句 ...

  5. Mysql三种日志(binlog,redolog,undolog)的作用和区别

    Mysql有三种很重要的日志也是面试经常涉及到的考点,分别是 binlog .redo log和undo log, 这里面binlog 是server层实现的日志,而redo log 和undo lo ...

  6. 220702 T1 玩具 (图的同构,全排列判定)

    [题目描述] Tom和Jerry各有一个玩具,每个玩具都是由M根绳子连接到N个球上制成的. 在Tom的玩具中,球的编号为1,-,N,第i条绳子将球Ai和Bi连接起来. 类似地,在Jerry的玩具中,球 ...

  7. 洛谷P2880 [USACO07JAN] Balanced Lineup G(树状数组/线段树)

    维护区间最值的模板题. 1.树状数组 1 #include<bits/stdc++.h> 2 //树状数组做法 3 using namespace std; 4 const int N=5 ...

  8. 220514 T1 查询 (二分查找+vector)

    用vector记录每个数出现的位置,对于要查询的X,要找他落在L~R的个数有几个,用lower_bound和upper_bound查找,相减就是答案. 1 #include<bits/stdc+ ...

  9. 周末IT入门锦鲤

    周末总结 第一小节 typora软件 是目前最火的文本编辑器 下载安装 路径尽量不要安装C盘,安装其他盘路径尽量简单方便后续查找使用. 文件路径 路径:计算机上一个文件资源的坐标,C:\XX文件\a. ...

  10. Java代码审计之实战某博客

    对某博客的代码审计 在gitee上面找了一个个人博客项目,来进行实战代码审计,主要还是学习为主 技术菜菜,哪里错误希望师傅们指正 1.SQL注入 先了解Java Web中的数据传输流程 graph T ...