一、报错信息
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = bigint
二、报错原因
项目用到了 PostgreSQL
数据库,使用 SpringBoot + Mybatis 进行整合,在进行多表查询的时候就遇到该报错。
原因是 PostgreSQL
在数据类型转换过程中,对传入的参数类型匹配
相当严格。
eg:select * from student id = #{userId}
假设 id
的数据类型为 varchar 类型,而传入的 userId
为 bigint 类型。此时,PostgreSQL 就会报错。
三、解决方案
转换为数据库中相应的数据类型即可。
依据实际需求修改!!