package com.chantha.jdbc.jpa.model; import com.fasterxml.jackson.annotation.*; import javax.persistence.*; import java.io.Serializable; import java.util.List; @Entity //@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "productId") @JsonPropertyOrder({"productId"}) public class Product implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long productId; private String productName; private double price; public String getImg() { return img; } public void setImg(String img) { this.img = img; } private String img; public Product() { } public Long getProductId() { return productId; } public void setProductId(Long productId) { this.productId = productId; } public String getProductName() { return productName; } public void setProductName(String productName) { this.productName = productName; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } @JsonBackReference public List getOrderDetails() { return orderDetails; } public void setOrderDetails(List orderDetails) { this.orderDetails = orderDetails; } public Product(Long productId, String productName, double price, List orderDetails,String img) { this.productId=productId; this.productName=productName; this.price=price; this.orderDetails=orderDetails; this.img=img; } // @JsonManagedReference @JsonProperty("orderDetails") @OneToMany(fetch = FetchType.EAGER,mappedBy = "product") private List orderDetails; }