68 lines
1.6 KiB
Java
68 lines
1.6 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")
|
|
public class Product implements Serializable {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long productId;
|
|
|
|
private String productName;
|
|
private double price;
|
|
|
|
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) {
|
|
this.productId=productId;
|
|
this.productName=productName;
|
|
this.price=price;
|
|
this.orderDetails=orderDetails;
|
|
}
|
|
|
|
// @JsonManagedReference
|
|
@JsonProperty("orderDetails")
|
|
@OneToMany(fetch = FetchType.EAGER,mappedBy = "product")
|
|
private List<OrderDetail> orderDetails;
|
|
}
|