JPA둜 PostgreSQL의 JSONB 컬럼의 JSON 데이터λ₯Ό μ²˜λ¦¬ν•˜κ³ μž ν• λ•Œ Hypersistance Utilsλ₯Ό μ μš©ν•˜μ—¬ μ‰½κ²Œ ν•΄κ²°ν•  수 μžˆλ‹€.

@Type(JsonType.class)

곡식 λ¬Έμ„œμ— μ„€λͺ…λ˜μ–΄μžˆλŠ” λŒ€λ‘œ JsonType κ³Ό JsonBinaryType 을 μ‚¬μš©ν•  수 μžˆλ‹€.

@Type(JsonBinaryType.class)
@Column(nullable = false, columnDefinition = "jsonb")
private Map<String, Object> metadata = new HashMap<>();

λ§Œμ•½, μ»¬λŸΌμ— λŒ€ν•œ columnDefinitionλ₯Ό μ§€μ •ν•˜μ§€ μ•ŠμœΌλ©΄ μ•„λž˜μ™€ 같은 맀핑 였λ₯˜κ°€ λ°œμƒν•  수 μžˆλ‹€.

Caused by: org.hibernate.MappingException: Unable to determine SQL type name for column 'metadata' of table 'users' because there is no type mapping for org.hibernate.type.SqlTypes code: 1111 (OTHER)

@JdbcTypeCode(SqlTypes.JSON)

JsonType κ³Ό JsonBinaryType λ₯Ό μ‚¬μš©ν•˜λŠ” 것보닀 JdbcTypeCode의 νƒ€μž…μ„ JSON 으둜 μ§€μ •ν•˜λŠ”κ²Œ 더 κ°„λ‹¨ν•˜λ‹€.

@JdbcTypeCode(SqlTypes.JSON)
private Metadata metadata;

@Data
public class Metadata {
    private boolean active;
}

μžλ§€ν’ˆμœΌλ‘œ PostgreSQL μ—μ„œμ˜ Enum μ»¬λŸΌμ— λŒ€ν•œ @JdbcType(PostgreSQLEnumJdbcType::class)도 확인해봐야겠넀?