【问题标题】:how to map json field with jpa or hibernate in pojo?如何在pojo中用jpa或hibernate映射json字段?
【发布时间】:2019-10-03 09:23:18
【问题描述】:

我正在使用 MySQL 和 jpa/hibernate。
所以我希望列作为 JPA 中的 Json 数据类型,但它不支持。
因此,我也无法在标准查询中使用。
有哪些合适的处理方法?

【问题讨论】:

标签: java mysql json hibernate jpa


【解决方案1】:

这对我有用

@Entity
@Table
@TypeDef(
    name = "jsonb",
    typeClass = JsonBinaryType.class
)
public class Blah{

 //add your fields

    @Type(type = "jsonb")
    @Column(columnDefinition = "jsonb")
    private String jsonField;

 //add your getters and setters

}

【讨论】:

    猜你喜欢
    • 2021-12-04
    • 1970-01-01
    • 2017-01-29
    • 1970-01-01
    • 1970-01-01
    • 2017-01-02
    • 1970-01-01
    • 2020-04-14
    • 1970-01-01
    相关资源
    最近更新 更多