1 package ejava.examples.blpurchase.bo; 2 3 import javax.persistence.Column; 4 import javax.persistence.Entity; 5 import javax.persistence.GeneratedValue; 6 import javax.persistence.Id; 7 import javax.persistence.NamedQuery; 8 import javax.persistence.Table; 9 10 @Entity 11 @Table(name="BLPURCHASE_PRODUCT") 12 @NamedQuery(name="blPurchasing.getProducts", query="select p from Product p") 13 public class Product { 14 public static final String GET_PRODUCTS_QUERY ="blPurchasing.getProducts"; 15 @Id @GeneratedValue 16 private int id; 17 @Column(nullable=false) 18 private String name; 19 @Column(nullable=false) 20 private double price; 21 @Column(nullable=false) 22 private int count; 23 24 public Product(){} 25 public Product(String name, double price, int count) { 26 this.name = name; 27 this.price = price; 28 this.count=count; 29 } 30 public int getId() { 31 return id; 32 } 33 protected void setId(int id) { 34 this.id = id; 35 } 36 public String getName() { 37 return name; 38 } 39 public void setName(String name) { 40 this.name = name; 41 } 42 public double getPrice() { 43 return price; 44 } 45 public void setPrice(double price) { 46 this.price = price; 47 } 48 public int getCount() { 49 return count; 50 } 51 public void setCount(int count) { 52 this.count = count; 53 } 54 }