Hibernate 6 и общее поле JSONJAVA

Программисты JAVA общаются здесь
Anonymous
Hibernate 6 и общее поле JSON

Сообщение Anonymous »


I am using PostgreSQL and Hibernate 6, and I have a JSONB type column - values.

The question is, how can I define an entity with generic type for this field? Also, is there any way to map the correct class during deserialization based on the second ENUM field - type?

Something like:

@Getter @Setter @Entity @Table(name = "setting") public class SettingEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Enumerated(EnumType.STRING) private SettingType type; @JdbcTypeCode(SqlTypes.JSON) private T values; } I can't find a clear explanation of how to do that. Thanks for any assistance.


Источник: https://stackoverflow.com/questions/772 ... json-field

Вернуться в «JAVA»