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