-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmail.java
133 lines (104 loc) · 2.54 KB
/
Email.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.example;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "EMAIL", schema = "test@twingo")
@NamedQueries({
@NamedQuery(name="EMAIL.findAll",
query="SELECT m FROM Email m"),
@NamedQuery(name="EMAIL.findBySubject",
query="SELECT c FROM Email c WHERE c.subject LIKE :subject"),
})
/*
* ,
@NamedQuery(name="findBySubject",
query="SELECT c FROM MAIL c WHERE c.subject LIKE :subject"),
*/
public class Email
{
public Email() {
init();
}
@Id
@Column(name="MESSAGE_ID")
private String messageId;
@Column(name = "SUBJECT")
private String subject;
@Column(name = "BODY")
private String body;
@Column(name = "zipcode")
private int zipcode;
@Embedded
private Contact from;
@ElementCollection
@CollectionTable(name = "TO")
private List<Contact> to;
@OneToMany (cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
@JoinColumn(name="MESSAGE_ID")
private List<Attachment> attachments;
private void init() {
to = new ArrayList<Contact>();
attachments = new ArrayList<Attachment>();
}
public String getMessageId() {
return messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
public int getZipcode() {
return zipcode;
}
public void setZipcode( int zipcode ) {
this.zipcode = zipcode;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public Contact getFrom() {
return from;
}
public void setFrom(Contact from) {
this.from = from;
}
public List<Contact> getTo() {
return to;
}
public void setTo(List<Contact> to) {
this.to = to;
}
public List<Attachment> getAttachments() {
return attachments;
}
public void setAttachments(List<Attachment> attachments) {
this.attachments = attachments;
}
public void addTo(Contact contact) {
to.add(contact);
}
public void addAttachment(Attachment attachment) {
attachments.add(attachment);
}
}