1 7 package org.jboss.tutorial.secondary.bean; 8 9 import java.util.List ; 10 import javax.ejb.Remote ; 11 import javax.ejb.Stateless ; 12 import javax.persistence.EntityManager; 13 import javax.persistence.PersistenceContext; 14 import javax.persistence.PersistenceContext; 15 16 @Stateless 17 @Remote (CustomerDAO.class) 18 public class CustomerDAOBean implements CustomerDAO 19 { 20 @PersistenceContext 21 private EntityManager manager; 22 23 24 public int create(String first, String last, String street, String city, String state, String zip) 25 { 26 Customer customer = new Customer(first, last, street, city, state, zip); 27 manager.persist(customer); 28 return customer.getId(); 29 } 30 31 public Customer find(int id) 32 { 33 return manager.find(Customer.class, id); 34 } 35 36 public List findByLastName(String name) 37 { 38 return manager.createQuery("from Customer c where c.last = :name").setParameter("name", name).getResultList(); 39 } 40 41 public void merge(Customer c) 42 { 43 manager.merge(c); 44 } 45 } 46 | Popular Tags |