1 package net.sumaris.core.model.administration.user;
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.data.ImageAttachment;
28 import net.sumaris.core.model.referential.IItemReferentialEntity;
29 import net.sumaris.core.model.referential.Status;
30 import net.sumaris.core.model.referential.location.Location;
31
32 import javax.persistence.*;
33 import java.util.Date;
34 import java.util.Objects;
35
36 @Data
37 @FieldNameConstants
38 @Entity
39 @Table(name = "department")
40 @Cacheable
41 public class Department implements IItemReferentialEntity {
42
43 @Id
44 @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "DEPARTMENT_SEQ")
45 @SequenceGenerator(name = "DEPARTMENT_SEQ", sequenceName="DEPARTMENT_SEQ")
46 private Integer id;
47
48 @ManyToOne(fetch = FetchType.LAZY)
49 @JoinColumn(name = "status_fk", nullable = false)
50 private Status status;
51
52 @Column(name = "creation_date", nullable = false)
53 @Temporal(TemporalType.TIMESTAMP)
54 private Date creationDate;
55
56 @Column(name = "update_date")
57 @Temporal(TemporalType.TIMESTAMP)
58 private Date updateDate;
59
60 @Column(nullable = false, length = LENGTH_LABEL)
61 private String label;
62
63 @Column(nullable = false, length = LENGTH_NAME)
64 private String name;
65
66 @Column(name = "site_url")
67 private String siteUrl;
68
69 @ManyToOne(fetch = FetchType.LAZY)
70 @JoinColumn(name = "logo_fk")
71 private ImageAttachment logo;
72
73 private String description;
74
75 @Column(length = LENGTH_COMMENTS)
76 private String comments;
77
78 @ManyToOne(fetch = FetchType.EAGER, targetEntity = Location.class)
79 @JoinColumn(name = "location_fk")
80 private Location location;
81
82 public String toString() {
83 return label;
84 }
85
86 public int hashCode() {
87 return Objects.hash(label);
88 }
89 }