Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JPA将Java对象/Json列表存储到Postgres Jsonb中?_Java_Jpa_Postgresql 9.4_Jsonb - Fatal编程技术网

如何使用JPA将Java对象/Json列表存储到Postgres 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

我们如何使用JPA将对象列表定义为Postgres9.6JSONB数据类型?我试图将产品列表放入order表的products列中,该列应该是jsonb类型

用例:

 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;
私有字符串产品名称;
}