1 package net.sumaris.core.model.technical.extraction;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import lombok.Data;
26 import lombok.experimental.FieldNameConstants;
27 import net.sumaris.core.model.administration.user.Department;
28 import net.sumaris.core.model.administration.user.Person;
29 import net.sumaris.core.model.data.IWithRecorderDepartmentEntity;
30 import net.sumaris.core.model.data.IWithRecorderPersonEntity;
31 import net.sumaris.core.model.referential.IItemReferentialEntity;
32 import net.sumaris.core.model.referential.Status;
33 import org.hibernate.annotations.Cascade;
34
35 import javax.persistence.*;
36 import java.util.ArrayList;
37 import java.util.Date;
38 import java.util.List;
39
40 @Data
41 @FieldNameConstants
42 @Entity
43 @Cacheable
44 @Table(name = "extraction_product")
45 public class ExtractionProduct implements IItemReferentialEntity,
46 IWithRecorderPersonEntity<Integer, Person>,
47 IWithRecorderDepartmentEntity<Integer, Department> {
48
49 @Id
50 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EXTRACTION_PRODUCT_SEQ")
51 @SequenceGenerator(name = "EXTRACTION_PRODUCT_SEQ", sequenceName="EXTRACTION_PRODUCT_SEQ")
52 private Integer id;
53
54 @ManyToOne(fetch = FetchType.LAZY)
55 @JoinColumn(name = "status_fk", nullable = false)
56 private Status status;
57
58 @Column(name = "creation_date", nullable = false)
59 @Temporal(TemporalType.TIMESTAMP)
60 private Date creationDate;
61
62 @Column(name = "update_date")
63 @Temporal(TemporalType.TIMESTAMP)
64 private Date updateDate;
65
66 @Column(nullable = false, length = LENGTH_LABEL)
67 private String label;
68
69 @Column(nullable = false, length = LENGTH_NAME)
70 private String name;
71
72 private String description;
73
74 @Column(length = LENGTH_COMMENTS)
75 private String comments;
76
77 @Column(name = "is_spatial")
78 private Boolean isSpatial;
79
80 @ManyToOne(fetch = FetchType.LAZY)
81 @JoinColumn(name = "recorder_person_fk")
82 private Person recorderPerson;
83
84 @ManyToOne(fetch = FetchType.LAZY)
85 @JoinColumn(name = "recorder_department_fk", nullable = false)
86 private Department recorderDepartment;
87
88 @ManyToOne(fetch = FetchType.LAZY)
89 @JoinColumn(name = "parent_extraction_product_fk")
90 private ExtractionProduct parent;
91
92 @OneToMany(fetch = FetchType.EAGER, targetEntity = ExtractionProductStrata.class, mappedBy = ExtractionProductStrata.Fields.PRODUCT)
93 @Cascade(org.hibernate.annotations.CascadeType.DELETE)
94 private List<ExtractionProductStrata> stratum;
95
96 @OneToMany(fetch = FetchType.LAZY, targetEntity = ExtractionProductTable.class, mappedBy = ExtractionProductTable.Fields.PRODUCT)
97 @Cascade(org.hibernate.annotations.CascadeType.DELETE)
98 private List<ExtractionProductTable> tables = new ArrayList<>();
99
100 }