如何使用JPA将Java对象/Json列表存储到Postgres Jsonb中?
我们如何使用JPA将对象列表定义为Postgres9.6JSONB数据类型?我试图将产品列表放入order表的products列中,该列应该是jsonb类型 用例:如何使用JPA将Java对象/Json列表存储到Postgres Jsonb中?,java,jpa,postgresql-9.4,jsonb,Java,Jpa,Postgresql 9.4,Jsonb,我们如何使用JPA将对象列表定义为Postgres9.6JSONB数据类型?我试图将产品列表放入order表的products列中,该列应该是jsonb类型 用例: public class Order implements Serializable{ @Id @GeneratedValue private Long orderId; @Column(name = "products", nullable = false, columnD
public class Order implements Serializable{
@Id
@GeneratedValue
private Long orderId;
@Column(name = "products", nullable = false, columnDefinition = "jsonb")
private List<Product> products;
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
}
public class Product{
private String productId;
private String productName;
}
公共类顺序实现可序列化{
@身份证
@生成值
私有长orderId;
@列(name=“products”,nullable=false,columnDefinition=“jsonb”)
私人上市产品;
公共列表产品(){
退货产品;
}
公共产品(列出产品){
这一点。产品=产品;
}
}
公共类产品{
私有字符串productId;
私有字符串产品名称;
}