1 22 package org.jboss.ejb3.test.regression.ejbthree316; 23 24 import java.io.Serializable ; 25 import javax.ejb.Stateful ; 26 import javax.persistence.PersistenceContext; 27 import javax.persistence.EntityManager; 28 import javax.persistence.PersistenceContextType; 29 import org.jboss.annotation.ejb.cache.simple.CacheConfig; 30 31 37 @Stateful 38 @CacheConfig(idleTimeoutSeconds = 2) 39 public class StatefulBean implements Serializable , StatefulRemote 40 { 41 @PersistenceContext(type= PersistenceContextType.EXTENDED) 42 EntityManager manager; 43 44 public int doit() 45 { 46 Customer cust = new Customer(); 47 cust.setName("Bill"); 48 manager.persist(cust); 49 return cust.getId(); 50 } 51 52 public void find(int id) 53 { 54 if (manager.find(Customer.class, id) == null) throw new RuntimeException ("not found"); 55 } 56 } 57 | Popular Tags |