1 package info.ejava.examples.ejb.tx.bo; 2 3 import java.io.Serializable; 4 5 import javax.persistence.Column; 6 import javax.persistence.Entity; 7 import javax.persistence.GeneratedValue; 8 import javax.persistence.Id; 9 import javax.persistence.NamedQueries; 10 import javax.persistence.NamedQuery; 11 import javax.persistence.Table; 12 13 @SuppressWarnings("serial") 14 @Entity 15 @Table(name="EJBTx_SHIPMENT") 16 @NamedQueries({ 17 @NamedQuery(name="EJBTxShipment.getCount", 18 query="select count(s) from Shipment s where s.productId = :productId") 19 }) 20 public class Shipment implements Serializable { 21 @Id @GeneratedValue 22 @Column(name="SHIPMENT_ID") 23 private int id; 24 25 @Column(name="PRODUCT_ID", nullable=false, updatable=false) 26 private int productId; 27 28 @Column(name="LOCATION", length=16, nullable=false, updatable=false) 29 private String location; 30 31 protected Shipment() {} 32 public Shipment(String location) { 33 this.location = location; 34 } 35 36 public int getId() { return id; } 37 public int getProductId() { return productId; } 38 public void setProductId(int productId) { 39 this.productId = productId; 40 } 41 public String getLocation() { return location; } 42 43 @Override 44 public String toString() { 45 StringBuilder builder = new StringBuilder(); 46 builder.append("Shipment [id=").append(id) 47 .append(", productId=").append(productId) 48 .append(", location=").append(location) 49 .append("]"); 50 return builder.toString(); 51 } 52 }