66 lines
1.5 KiB
Java
66 lines
1.5 KiB
Java
package com.chantha.jdbc.jpa.model;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonBackReference;
|
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
|
|
|
import javax.persistence.*;
|
|
import java.util.List;
|
|
|
|
@Entity
|
|
public class Product {
|
|
|
|
@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
|
|
@OneToMany(fetch = FetchType.EAGER,mappedBy = "product")
|
|
private List<OrderDetail> orderDetails;
|
|
}
|