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