DataJPA/src/main/kotlin/com/chantha/jdbc/jpa/model/OrderDetail.java
2020-05-15 17:20:27 +07:00

83 lines
1.7 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 javax.persistence.*;
@Entity
public class OrderDetail {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long orderDetailId;
private int qty;
private double price;
@JsonManagedReference
@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;
}
}