DataJPA/src/main/kotlin/com/chantha/jdbc/jpa/model/Product.java
2020-05-17 13:35:32 +07:00

80 lines
1.8 KiB
Java

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<OrderDetail> getOrderDetails() {
return orderDetails;
}
public void setOrderDetails(List<OrderDetail> orderDetails) {
this.orderDetails = orderDetails;
}
public Product(Long productId, String productName, double price, List<OrderDetail> 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<OrderDetail> orderDetails;
}