1 package ejava.examples.orm.ejbql.annotated; 2 3 import javax.persistence.*; 4 5 @Entity @Table(name="ORMQL_CUSTOMER") 6 @NamedQueries({ 7 @NamedQuery(name="getCustomersByName", 8 query="select c from Customer c " + 9 "where c.firstName like :first AND c.lastName like :last"), 10 @NamedQuery(name="getCustomerPurchases", 11 query="select s from Sale s " + 12 "where s.buyerId=:custId") 13 }) 14 public class Customer { 15 private long id; 16 private String firstName; 17 private String lastName; 18 19 @Id @GeneratedValue @Column(name="CUSTOMER_ID") 20 public long getId() { 21 return id; 22 } 23 @SuppressWarnings("unused") 24 private void setId(long id) { 25 this.id = id; 26 } 27 28 public String getFirstName() { 29 return firstName; 30 } 31 public void setFirstName(String firstName) { 32 this.firstName = firstName; 33 } 34 public String getLastName() { 35 return lastName; 36 } 37 public void setLastName(String lastName) { 38 this.lastName = lastName; 39 } 40 41 public String toString() { 42 StringBuilder text = new StringBuilder(); 43 text.append("id=" + id); 44 text.append(", firstName=" + firstName); 45 text.append(", lastName=" + lastName); 46 return text.toString(); 47 } 48 49 }