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. MinIO Client完全指南

    官方文档地址:http://docs.minio.org.cn/docs/master/minio-client-complete-guide 下载,添加云存储服务参考这篇文章:https://www ...

  2. 解决zeal离线文档下载慢问题

    zeal简介 编程过程中难免会遇到不会用的关键字和方法,对我而言,在windows下,我使用Zeal这个软件进行离线文档查询. 问题 但是,在软件中下载DocSet(文档)会出现下载慢,或者下载不了的 ...

  3. windows系统下使用bat脚本文件设置MySQL系统环境变量

    说明:在一个bat文件中设置tomcat环境变量后,不能直接使用,需要另起一个bat文件才能使用 号开头的行不要写在bat文件中 # 这个bat文件实现的功能:设置环境变量 @echo off set ...

  4. typescript中对象属性可选属性与只读属性与索引签名

    可选属性 type类型别名 type 会给一个类型起个新名字. type 有时和 interface 很像,但是可以作用于原始值(基本类型),联合类型,元组以及其它任何你需要手写的类型. interf ...

  5. PAT乙级 1024 科学计数法

    思路 1.尝试失败:一开始想打算把结果直接存在一个字符串中,后来发现当指数大于0的时候还需要分别考虑两种情况,工程量巨大,尝试失败,于是借鉴了其他大佬思路,写出了ac代码 2.ac思路:首先取指数的绝 ...

  6. Linux+Proton without Steam玩红警3指南

    首先你需要Proton5.13 without Steam,使用说明和下载链接看这里https://www.cnblogs.com/tubentubentu/p/16716612.html 然后在/e ...

  7. Allure的简单使用

    Allure的简单使用 1.Allure简介 简单的理解下,可以把Allure当成一个用于生成美观测试报告的开源工具,配合Pytest测试框架使用更佳. 也就是说,Allure是在Pytest执行测试 ...

  8. Do not use “@ts-ignore” because it alters compilation errors的解决办法

    在@ts-ignore上面添加一行代码: // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore

  9. POJ1655 Balancing Act (树的重心)

    求树的重心的模板题,size[u]维护以u为根的子树大小,f[u]表示去掉u后的最大子树. 1 #include<cstdio> 2 #include<iostream> 3 ...

  10. 驱动开发:内核中实现Dump进程转储

    多数ARK反内核工具中都存在驱动级别的内存转存功能,该功能可以将应用层中运行进程的内存镜像转存到特定目录下,内存转存功能在应对加壳程序的分析尤为重要,当进程在内存中解码后,我们可以很容易的将内存镜像导 ...