1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.tapas.evidence.entity;
20
21 import javax.persistence.CascadeType;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.EnumType;
25 import javax.persistence.Enumerated;
26 import javax.persistence.FetchType;
27 import javax.persistence.GeneratedValue;
28 import javax.persistence.GenerationType;
29 import javax.persistence.Id;
30 import javax.persistence.JoinColumn;
31 import javax.persistence.Lob;
32 import javax.persistence.NamedQueries;
33 import javax.persistence.NamedQuery;
34 import javax.persistence.OneToOne;
35 import javax.persistence.Table;
36
37 import lombok.Getter;
38 import lombok.NoArgsConstructor;
39 import lombok.Setter;
40 import lombok.ToString;
41
42 import com.tapas.evidence.fe.ApplicationConstants;
43
44
45
46
47
48 @Entity
49 @Table(name = "RESPONSIBLE_PERSON")
50 @ToString
51 @NoArgsConstructor
52 @NamedQueries(value = {
53 @NamedQuery(name = ResponsiblePerson.QUERY_NAME_FIND_ALL_BY_DELETED_FLAG, query = ResponsiblePerson.QUERY_FIND_ALL_BY_DELETED_FLAG),
54 @NamedQuery(name = ResponsiblePerson.QUERY_NAME_FIND_BY_KINDERGARTEN_ID_AND_DELETED_FLAG, query = ResponsiblePerson.QUERY_FIND_BY_KINDERGARTEN_ID_AND_DELETED_FLAG),
55 @NamedQuery(name = ResponsiblePerson.QUERY_NAME_FIND_BY_KINDERGARTEN_ID_AND_TYPE_AND_DELETE_FLAG, query = ResponsiblePerson.QUERY_FIND_BY_KINDERGARTEN_ID_AND_TYPE_AND_DELETE_FLAG)
56 })
57 public class ResponsiblePerson extends Person {
58
59 private static final long serialVersionUID = ApplicationConstants.VERSION;
60
61 public static final String QUERY_NAME_FIND_ALL_BY_DELETED_FLAG = "ResponsiblePerson.finaAllByDeletedFlag";
62 public static final String QUERY_FIND_ALL_BY_DELETED_FLAG = "SELECT r FROM ResponsiblePerson r " +
63 "WHERE r.deleted = :deleted AND r.tenant.id = :tenantId";
64
65 public static final String QUERY_NAME_FIND_BY_KINDERGARTEN_ID_AND_DELETED_FLAG = "ResponsiblePerson.finaByKindergartenIdAndDeletedFlag";
66 public static final String QUERY_FIND_BY_KINDERGARTEN_ID_AND_DELETED_FLAG = "SELECT r FROM ResponsiblePerson r " +
67 "WHERE r.kindergarten.id = :kindergartenId AND r.deleted = :deleted AND r.tenant.id = :tenantId";
68
69 public static final String QUERY_NAME_FIND_BY_KINDERGARTEN_ID_AND_TYPE_AND_DELETE_FLAG = "ResponsiblePerson.finalByKindergartenIdAndTypeAndDeletedFlag";
70 public static final String QUERY_FIND_BY_KINDERGARTEN_ID_AND_TYPE_AND_DELETE_FLAG = "SELECT r FROM ResponsiblePerson r " +
71 "WHERE r.kindergarten.id = :kindergartenId AND r.type = :type AND r.deleted = :deleted AND r.tenant.id = :tenantId";
72
73 @Getter @Setter
74 @Id @GeneratedValue(strategy = GenerationType.AUTO)
75 private Long id;
76
77 @Getter @Setter
78 @OneToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, optional = false)
79 @JoinColumn(name = "CONTACT_ID")
80 private Contact contact;
81
82 @Getter @Setter
83 @Enumerated(value = EnumType.STRING)
84 private ResponsibilityType type;
85
86 @Getter @Setter
87 @Lob
88 @Column(name = "PHOTO", length = 102400)
89 private byte[] photo;
90
91 public ResponsiblePerson(final Long id) {
92 this.id = id;
93 }
94 }