90 lines
2.1 KiB
Java
90 lines
2.1 KiB
Java
package com.chantha.jdbc.jpa.model;
|
|
|
|
|
|
import com.chantha.jdbc.utils.CustomDateDeserializer;
|
|
import com.chantha.jdbc.utils.CustomDateSerializer;
|
|
import com.fasterxml.jackson.annotation.*;
|
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
|
|
import javax.persistence.*;
|
|
import java.io.Serializable;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
@Entity
|
|
@Table(name = "tbOrder")
|
|
public class Order implements Serializable {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long orderId;
|
|
|
|
@JsonSerialize(using = CustomDateSerializer.class)
|
|
@JsonDeserialize(using = CustomDateDeserializer.class)
|
|
private Date orderDate;
|
|
|
|
private double amount;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JsonBackReference
|
|
@JoinColumn(name = "cusId",nullable = false,referencedColumnName = "id")
|
|
private Customer customer;
|
|
|
|
@JsonManagedReference
|
|
@OneToMany(mappedBy = "order")
|
|
private List<OrderDetail> orderDetails;
|
|
|
|
public Long getOrderId() {
|
|
return orderId;
|
|
}
|
|
|
|
public void setOrderId(Long orderId) {
|
|
this.orderId = orderId;
|
|
}
|
|
|
|
public Date getOrderDate() {
|
|
return orderDate;
|
|
}
|
|
|
|
public void setOrderDate(Date orderDate) {
|
|
this.orderDate = orderDate;
|
|
}
|
|
|
|
public double getAmount() {
|
|
return amount;
|
|
}
|
|
|
|
public void setAmount(double amount) {
|
|
this.amount = amount;
|
|
}
|
|
|
|
|
|
public Customer getCustomer() {
|
|
return customer;
|
|
}
|
|
|
|
public void setCustomer(Customer customer) {
|
|
this.customer = customer;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public List<OrderDetail> getOrderDetails() {
|
|
return orderDetails;
|
|
}
|
|
|
|
public void setOrderDetails(List<OrderDetail> orderDetails) {
|
|
this.orderDetails = orderDetails;
|
|
}
|
|
|
|
public Order() {
|
|
}
|
|
|
|
public Order(Long orderId,Date orderDate,double amount,Customer customer,List<OrderDetail> orderDetails) {
|
|
this.orderId=orderId;
|
|
this.orderDate=orderDate;
|
|
this.amount=amount;
|
|
this.orderDetails=orderDetails;
|
|
}
|
|
}
|