1 package ejava.examples.ejbwar.customer.bo;
2
3 import javax.json.bind.annotation.JsonbAnnotation;
4 import javax.persistence.Column;
5 import javax.persistence.Entity;
6 import javax.persistence.GeneratedValue;
7 import javax.persistence.GenerationType;
8 import javax.persistence.Id;
9 import javax.persistence.NamedQueries;
10 import javax.persistence.NamedQuery;
11 import javax.persistence.Table;
12 import javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.XmlAttribute;
15 import javax.xml.bind.annotation.XmlElement;
16 import javax.xml.bind.annotation.XmlRootElement;
17 import javax.xml.bind.annotation.XmlType;
18
19 @XmlRootElement(name="customer", namespace=CustomerRepresentation.NAMESPACE)
20 @XmlType(name="Customer", namespace=CustomerRepresentation.NAMESPACE, propOrder={
21 "firstName",
22 "lastName"
23 })
24 @XmlAccessorType(XmlAccessType.PROPERTY)
25
26
27 @JsonbAnnotation
28
29 @Entity
30 @Table(name="WEBEJB_CUSTOMER")
31 @NamedQueries({
32 @NamedQuery(name=Customer.FIND_BY_NAME,
33 query="select c from Customer c where " +
34 "c.firstName like :firstName and " +
35 "c.lastName like :lastName"),
36 })
37 public class Customer extends CustomerRepresentation {
38 private static final long serialVersionUID = 2886191800865680970L;
39 public static final String FIND_BY_NAME="Customer.findByName";
40
41 @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
42 @Column(name="ID")
43 private int id;
44
45 @Column(name="FIRST_NAME", nullable=false)
46 private String firstName;
47
48 @Column(name="LAST_NAME", nullable=false)
49 private String lastName;
50
51 public Customer() {}
52 public Customer(String firstName, String lastName) {
53 this.firstName = firstName;
54 this.lastName = lastName;
55 }
56
57 @XmlAttribute
58 public int getId() { return id; }
59 public void setId(int id) {
60 this.id = id;
61 }
62
63 @XmlElement
64 public String getFirstName() { return firstName; }
65 public void setFirstName(String firstName) {
66 this.firstName = firstName;
67 }
68
69 @XmlElement
70 public String getLastName() { return lastName; }
71 public void setLastName(String lastName) {
72 this.lastName = lastName;
73 }
74 }