에러모음집
[오늘의 에러] Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
📍 Error 내용
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
다음과 같은 오류 메시지가 발생하였다.
에러 내용을 살펴보면 bigint타입의 데이터에 character varying하는 operator가 존재하지 않는다고 되어있다.
📍 Error 발생 원인
PostgreSQL 8.4 이후 버전부터는 자동으로 타입캐스팅을 해주는 기능이 사라졌기 때문이다.
📍 Error 해결 방법
DB에 있는 데이터 타입과 쿼리문 시 대입하는 파라미터 타입을 일치시켜줘야한다.
타입을 일치시켜주기 위해 타입 변환을 해주었다.
-- 수정 전
SELET *
FROM sample_table
WHERE seq = #{seq}
-- 수정 후
SELET *
FROM sample_table
WHERE seq = CAST(#{seq} AS INTEGER)