1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sourceforge.mystique.domain.entity;
22
23 import java.util.Date;
24
25 import javax.persistence.Column;
26 import javax.persistence.Entity;
27 import javax.persistence.GeneratedValue;
28 import javax.persistence.GenerationType;
29 import javax.persistence.Id;
30 import javax.persistence.JoinColumn;
31 import javax.persistence.ManyToOne;
32 import javax.persistence.NamedQueries;
33 import javax.persistence.NamedQuery;
34 import javax.persistence.SequenceGenerator;
35 import javax.persistence.Table;
36 import javax.persistence.Temporal;
37 import javax.persistence.TemporalType;
38 import javax.persistence.Transient;
39
40
41
42
43 @Entity
44 @Table(name = "TB_CONFIRMATION")
45 @SequenceGenerator(name = "confirmationIdSeq", sequenceName = "CONFIRMATION_ID_SEQ", initialValue = 1, allocationSize = 1)
46 @NamedQueries( {
47 @NamedQuery(name = "Confirmation.findByTicket", query = "SELECT c FROM Confirmation c WHERE c.ticket = :ticket ORDER BY c.created"),
48 @NamedQuery(name = "Confirmation.findByTicketAndResponsible", query = "SELECT c FROM Confirmation c WHERE c.ticket = :ticket AND c.responsible = :responsible") })
49 public class Confirmation {
50
51 @Id
52 @GeneratedValue(generator = "confirmationIdSeq", strategy = GenerationType.SEQUENCE)
53 @Column(name = "ID")
54 private Long id;
55
56 @Temporal(TemporalType.TIMESTAMP)
57 @Column(name = "CREATED", nullable = false)
58 private Date created;
59
60 @ManyToOne
61 @JoinColumn(name = "RESPONSIBLE_USER_ID", nullable = false)
62 private User responsible;
63
64 @ManyToOne
65 @JoinColumn(name = "TICKET_ID", nullable = false)
66 private Ticket ticket;
67
68 public Confirmation() {
69 setCreated(new Date());
70 }
71
72 @Transient
73 public boolean isNew() {
74 return (id == null);
75 }
76
77 public Long getId() {
78 return id;
79 }
80
81 public void setId(Long id) {
82 this.id = id;
83 }
84
85 public Date getCreated() {
86 return created;
87 }
88
89 public void setCreated(Date created) {
90 this.created = created;
91 }
92
93 public User getResponsible() {
94 return responsible;
95 }
96
97 public void setResponsible(User responsible) {
98 this.responsible = responsible;
99 }
100
101 public Ticket getTicket() {
102 return ticket;
103 }
104
105 public void setTicket(Ticket ticket) {
106 this.ticket = ticket;
107 }
108
109 @Override
110 public int hashCode() {
111 final int prime = 31;
112 int result = 1;
113 result = prime * result + ((id == null) ? 0 : id.hashCode());
114 return result;
115 }
116
117 @Override
118 public boolean equals(Object obj) {
119 if (this == obj)
120 return true;
121 if (obj == null)
122 return false;
123 if (getClass() != obj.getClass())
124 return false;
125 Confirmation other = (Confirmation) obj;
126 if (id == null) {
127 if (other.id != null)
128 return false;
129 } else if (!id.equals(other.id))
130 return false;
131 return true;
132 }
133
134 }