86 lines
1.8 KiB
Java
86 lines
1.8 KiB
Java
package com.chantha.jdbc.jpa.model;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonBackReference;
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
import javax.persistence.*;
|
|
import java.io.Serializable;
|
|
|
|
@Entity
|
|
public class OrderDetail implements Serializable {
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long orderDetailId;
|
|
|
|
private int qty;
|
|
|
|
private double price;
|
|
|
|
|
|
@JsonBackReference
|
|
@ManyToOne(fetch = FetchType.EAGER)
|
|
@JoinColumn(name = "orderId",nullable = false)
|
|
private Order order;
|
|
|
|
@JsonManagedReference
|
|
@ManyToOne(fetch = FetchType.EAGER)
|
|
@JoinColumn(name = "productId",nullable = false)
|
|
private Product product;
|
|
|
|
|
|
public OrderDetail() {
|
|
}
|
|
|
|
public Long getOrderDetailId() {
|
|
return orderDetailId;
|
|
}
|
|
|
|
public void setOrderDetailId(Long orderDetailId) {
|
|
this.orderDetailId = orderDetailId;
|
|
}
|
|
|
|
public int getQty() {
|
|
return qty;
|
|
}
|
|
|
|
public void setQty(int qty) {
|
|
this.qty = qty;
|
|
}
|
|
|
|
public double getPrice() {
|
|
return price;
|
|
}
|
|
|
|
public void setPrice(double price) {
|
|
this.price = price;
|
|
}
|
|
|
|
@JsonBackReference
|
|
public Order getOrder() {
|
|
return order;
|
|
}
|
|
|
|
@JsonBackReference
|
|
public Product getProduct() {
|
|
return product;
|
|
}
|
|
|
|
public void setProduct(Product product) {
|
|
this.product = product;
|
|
}
|
|
|
|
public void setOrder(Order order) {
|
|
this.order = order;
|
|
}
|
|
|
|
public OrderDetail(Long orderDetailId, int qty, double price, Order order,Product product) {
|
|
this.order=order;
|
|
this.orderDetailId=orderDetailId;
|
|
this.price=price;
|
|
this.qty=qty;
|
|
this.product=product;
|
|
}
|
|
}
|