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. linux中通过date命令获取昨天或明天时间的方法

    date命令可以获取当前的时间,通过man,可以看到date有很多参数可以用,很容易做到格式化 # 获取当前日期 date +"%F" 或者 date +"%Y-%m-% ...

  2. haproxy + keeplived

    两台主机: 192.168.2.163 192.168.2.165 # yum安装haproxy yum install haproxy # cat /etc/haproxy/haproxy.cfg ...

  3. 我是加工厂,想管理生产财务采购销售这块,什么样的ERP会好用点??

    最能够贴合你的业务需求和自己员工的使用习惯的才会更好用,最好能简单快捷的进行低成本个性化定制的那种应该比较适合你这种加工厂,没有完全相同的两家企业,更别说他们的发展走向,即使同一家企业不同发展阶段.时 ...

  4. 详解平衡二叉树(AVL tree)平衡操作(图+代码)

    * 左左就右旋,右右就左旋 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int max ...

  5. HQL中出现XXX is not mapped的错误

    我的代码如下 @Test public void testCollection(){ String hql = "from Order where orderItems is not emp ...

  6. GMOJ3284 [GDOI2013] 重构 题解

    Description 给你一个有向图,要求重新建出一张点数相同有向图,使得点的联通关系和原图一致且边数最小. Solution 显然对于图上的一个强连通分量跑个缩点然后把每个强连通分量都变成一个环即 ...

  7. Go 互斥锁Mutex

    Mutex是一个互斥锁,可以创建为其他结构体的字段:零值为解锁状态.Mutex类型的锁和线程无关,可以由不同的线程加锁和解锁.互斥锁的作用是保证共享资源同一时刻只能被一个 Goroutine 占用,一 ...

  8. MYSQL创建分区时候报错

    第一种:ERROR 1064 (42000): Partitioning can not be used stand-alone in query near  不能单独创建分区.创建分区时要创建分区表 ...

  9. 【神经网络】softmax回归

    前言 softmax回归为一种分类模型. 基本原理 由于softmax回归也是一种线性叠加算法,且需要输出离散值. 很自然地想到,可以取值最大的输出为置信输出.更进一步想到,如果有三个人A.B.C分别 ...

  10. Python基础部分:2、 对计算机的认识和python解释器

    目录 一.计算机五大组成部分 1.控制器 2.运算器 3.储存器 4.输入设备 5.输出设备 二.计算机三大核心硬件 1.cpu 2.内存 3.硬盘 三.操作系统 四.编程与编程语言 1.编程语言 2 ...