org.hibernate.HibernateException: The propertyClass in JsonTypeDescriptor is null, hence it doesn't know to what Java Object type to map the JSON column value that was read from the database!
spring.jpa.hibernate.ddl-auto=create로 설정해서 실행하면 테이블이 생성된다.
JSON 필드가 있는 테이블이 잘 생성되길래 문제가 없을 줄 알았는데..
DB에서 읽어올 때 문제가 생김~
해결 과정
1. 버전 변경
Hibernate 5.1.2 버전을 사용중이었다.
implementation 'io.hypersistence:hypersistence-utils-hibernate-5:3.1.1'
hypersistence-utils-hibernate는 이렇다.
https://github.com/vladmihalcea/hypersistence-utils
이걸 보고 버전을 바꿨다.(공식 문서를 잘 읽자^^)
2. @TypeDef 어노테이션 추가
버전을 변경하는 것만으로는 해결되지 않았다.
스택오버플로우를 보고 해결방안을 찾았다. 😀
@TypeDef(name = "json", typeClass = JsonType.class)
JSON을 사용하는 해당 클래스 위에 어노테이션 추가
참고 👇
Serializing stored json object gives null pointer hibernate vladmihalcea / hibernate-types
I'm saving a java object as json in my db. For this implementation when I save it, it works fine and I can find the new row in my db. However whenever I try to fetch the same object I stored, I get...
stackoverflow.com
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. - GitHub - vladmihalcea/...
github.com
'Framework > Spring Boot' 카테고리의 다른 글
Swagger 에러 (0) | 2023.02.15 |
---|---|
[Error] com.fasterxml.jackson.databind.exc.InvalidDefinitionException (0) | 2023.02.01 |
엔티티의 필드 타입으로 JSON 사용하기 (0) | 2023.01.24 |
[Error] Failed to start bean 'documentationPluginsBootstrapper' (0) | 2023.01.21 |
[Error] "The specified key byte array is 128 bits which is not secure enough for any JWT HMAC-SHA algorithm. (0) | 2022.12.09 |