34 lines
833 B
Java
34 lines
833 B
Java
package com.chantha.jdbc.jpa.model;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonBackReference;
|
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Data;
|
|
import lombok.NoArgsConstructor;
|
|
|
|
import javax.persistence.*;
|
|
import java.util.List;
|
|
|
|
@Entity
|
|
@Data
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public class Staff {
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
private String name;
|
|
private Gender gender;
|
|
private double salary;
|
|
|
|
|
|
@JsonManagedReference
|
|
@OneToMany(mappedBy = "staff")
|
|
private List<Order> orderList;
|
|
|
|
@JsonBackReference
|
|
@ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
|
|
@JoinColumn(name = "posId",nullable = false,referencedColumnName = "id")
|
|
private Position position;
|
|
}
|