개요
postgresql 에서 jsonb 타입으로 데이터를 저장하고 있었다.
spring boot 2.7.6 버전을 사용중이었고 spring boot 3.2.3 로 버전업을 하게 되면서 @Type, @TypeDef 가 deprecated 되었다.
해결
@JdbcTypeCode(SqlTypes.JSON) 또는 AttributeConverter 를 새로 만들어주면 된다는데 postgresql 에서는 dependency 만 새로 바꿔주면 된다!
https://github.com/vladmihalcea/hypersistence-utils
GitHub - vladmihalcea/hypersistence-utils: The Hypersistence Utils library (previously known as Hibernate Types) gives you Sprin
The Hypersistence Utils library (previously known as Hibernate Types) gives you Spring and Hibernate utilities that can help you get the most out of your data access layer. - vladmihalcea/hypersist...
github.com
위 github 주소로 들어가서 README 를 읽으면 엄청 친절하게 설명이 되어있다.
Spring Boot 3.2 Release Notes 를 들어가면 Hibernate 6.3 을 지원하는 것을 볼 수 있다.
따라서 프로젝트에 hibernate6.3 에 대응하는 의존성을 설치해주면 된다.
implementation 'io.hypersistence:hypersistence-utils-hibernate-63:3.7.3'
설치 후 github 페이지에서 조금 더 설명을 살펴보면 hibernate6 에서는 @TypeDef 까지는 하지 않아도 되도록 바뀐 모양이다.
(hibernate5 에서는 기존 사용하던 방식 그대로 사용해야 한다.)
어노테이션과 괄호안에 들어가는 내용도 좀 더 간단하게 바뀌었다.
@Type(JsonBinaryType.class)
jsonb 타입으로 지정하고 싶은 컬럼에 해당 어노테이션을 달아준 후 테스트 해보면 jsonbinary 타입으로 잘 insert 된 것을 볼 수 있다.