1 22 package org.jboss.ejb3.test.txexceptions; 23 24 import javax.ejb.Remote ; 25 import javax.ejb.Stateless ; 26 import javax.ejb.TransactionAttributeType ; 27 import javax.ejb.TransactionAttribute ; 28 import javax.persistence.EntityManager; 29 import javax.persistence.PersistenceContext; 30 31 import org.jboss.logging.Logger; 32 33 39 @Stateless 40 @Remote (Dao.class) 41 public class DaoBean implements Dao 42 { 43 private static final Logger log = Logger 44 .getLogger(DaoBean.class); 45 46 @PersistenceContext EntityManager manager; 47 48 @TransactionAttribute (TransactionAttributeType.NOT_SUPPORTED) 49 public void testRequiresNewWithLookedUpEntityManager() throws Exception 50 { 51 RequiresNewTest.doit(); 52 } 53 54 public SimpleEntity get(int id) 55 { 56 SimpleEntity en = manager.find(SimpleEntity.class, id); 57 return en; 58 } 59 60 public void remove(int id) 61 { 62 SimpleEntity en = manager.find(SimpleEntity.class, id); 63 manager.remove(en); 64 } 65 66 public void createThrowAnnotatedAppException(int id) throws AnnotatedAppException 67 { 68 persist(id); 69 throw new AnnotatedAppException(); 70 } 71 72 public void createThrowDeploymentDescriptorAppException(int id) throws DeploymentDescriptorAppException 73 { 74 persist(id); 75 throw new DeploymentDescriptorAppException(); 76 } 77 78 private void persist(int id) 79 { 80 SimpleEntity entity = new SimpleEntity(); 81 entity.setId(id); 82 entity.setStuff("stuff"); 83 manager.persist(entity); 84 } 85 86 public void createThrowAppException(int id) throws AppException 87 { 88 persist(id); 89 throw new AppException(); 90 } 91 92 public void createThrowCheckedRollbackException(int id) throws CheckedRollbackException 93 { 94 persist(id); 95 throw new CheckedRollbackException(); 96 } 97 98 public void createThrowDeploymentDescriptorCheckedRollbackException(int id) throws DeploymentDescriptorCheckedRollbackException 99 { 100 persist(id); 101 throw new DeploymentDescriptorCheckedRollbackException(); 102 } 103 104 public void createThrowNoRollbackRemoteException(int id) throws NoRollbackRemoteException 105 { 106 persist(id); 107 throw new NoRollbackRemoteException(); 108 } 109 110 public void createThrowNoRollbackRuntimeException(int id) throws NoRollbackRuntimeException 111 { 112 persist(id); 113 throw new NoRollbackRuntimeException(); 114 } 115 116 public void createThrowRollbackRemoteException(int id) throws RollbackRemoteException 117 { 118 persist(id); 119 throw new RollbackRemoteException(); 120 } 121 122 public void createThrowRollbackRuntimeException(int id) throws RollbackRuntimeException 123 { 124 persist(id); 125 throw new RollbackRuntimeException(); 126 } 127 } 128 | Popular Tags |