1 25 package org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.entitymanager; 26 27 import javax.ejb.Remote ; 28 import javax.ejb.Stateless ; 29 import javax.ejb.TransactionAttribute ; 30 import javax.ejb.TransactionAttributeType ; 31 import javax.persistence.EntityManager; 32 import javax.persistence.PersistenceContext; 33 34 import org.objectweb.easybeans.tests.common.ejbs.entity.ebstore.EBStore; 35 36 41 @Stateless 42 @Remote (ItfTransactionContextTester.class) 43 public class SLSBTransactionContextTester implements ItfTransactionContextTester { 44 45 48 @PersistenceContext 49 private EntityManager em; 50 51 55 @PersistenceContext 56 private EntityManager emDelete; 57 58 61 @TransactionAttribute (TransactionAttributeType.REQUIRED) 62 public void deleteBean() { 63 EBStore ebstore = emDelete.find(EBStore.class, new Integer (ID)); 64 if (ebstore != null) { 65 emDelete.remove(ebstore); 66 } 67 emDelete.flush(); 68 } 69 70 74 @TransactionAttribute (TransactionAttributeType.REQUIRED) 75 public void createBeanRequiresNewWithClientTransaction() { 76 deleteBean(); 77 EBStore ebstore = new EBStore(); 78 ebstore.setId(ID); 79 ebstore.setName(NAME); 80 persistRequiresNew(ebstore); 81 } 82 83 87 @TransactionAttribute (TransactionAttributeType.NOT_SUPPORTED) 88 public void createBeanRequiresNewWithoutClientTransaction() { 89 deleteBean(); 90 EBStore ebstore = new EBStore(); 91 ebstore.setId(ID); 92 ebstore.setName(NAME); 93 persistRequiresNew(ebstore); 94 } 95 99 @TransactionAttribute (TransactionAttributeType.REQUIRED) 100 public void createBeanRequired() { 101 deleteBean(); 102 EBStore ebstore = new EBStore(); 103 ebstore.setId(ID); 104 ebstore.setName(NAME); 105 persistRequired(ebstore); 106 } 107 108 112 @TransactionAttribute (TransactionAttributeType.REQUIRES_NEW) 113 public void persistRequiresNew(final EBStore entity) { 114 em.persist(entity); 115 } 116 117 121 @TransactionAttribute (TransactionAttributeType.REQUIRED) 122 public void persistRequired(final EBStore entity) { 123 em.persist(entity); 124 } 125 126 } 127 | Popular Tags |