1 22 package org.jboss.ejb3.test.wls.embeddedwar; 23 24 import javax.ejb.Stateless ; 25 import javax.persistence.PersistenceContext; 26 import javax.persistence.EntityManager; 27 28 34 @Stateless 35 public class CustomerDAOBean implements CustomerDAOLocal, CustomerDAORemote 36 { 37 @PersistenceContext(unitName="custdb") private EntityManager em; 38 39 public int createCustomer(String name) 40 { 41 try 42 { 43 java.lang.reflect.Method [] methods = EntityManager.class.getDeclaredMethods(); 44 Customer cust = new Customer(); 45 cust.setName(name); 46 em.persist(cust); 47 return cust.getId(); 48 } 49 catch (Exception e) 50 { 51 e.printStackTrace(); 52 } 53 54 return -1; 55 } 56 57 public Customer findCustomer(int id) 58 { 59 return em.find(Customer.class, id); 60 } 61 } 62 | Popular Tags |