1 22 package org.jboss.ejb3.test.standalone.flushmodenever; 23 24 import org.jboss.annotation.IgnoreDependency; 25 26 import javax.ejb.EJB ; 27 import javax.ejb.Remote ; 28 import javax.ejb.Stateless ; 29 import javax.persistence.EntityManager; 30 import javax.persistence.EntityManagerFactory; 31 import javax.persistence.PersistenceContext; 32 import javax.persistence.PersistenceUnit; 33 34 40 @Stateless 41 @Remote (Session2.class) 42 public class Session2Bean implements Session2 43 { 44 @PersistenceContext(unitName="manager2") EntityManager manager2; 45 @PersistenceContext(unitName="../flushmodenever-session1.jar#manager1") EntityManager manager1; 46 @PersistenceUnit(unitName="manager2") EntityManagerFactory factory2; 47 @PersistenceUnit(unitName="../flushmodenever-session1.jar#manager1") EntityManagerFactory factory1; 48 @EJB @IgnoreDependency Session1 session1; 49 50 52 public Entity1 find1FromManager(int id) 53 { 54 return manager1.find(Entity1.class, id); 55 } 56 public void find1FromFactory(int id) 57 { 58 EntityManager m = factory1.createEntityManager(); 59 Entity1 one = m.find(Entity1.class, id); 60 try 61 { 62 if (one == null) throw new RuntimeException ("NOT FOUND"); 63 } 64 finally 65 { 66 m.close(); 67 } 68 69 } 70 public Entity2 find2FromManager(int id) 71 { 72 return manager2.find(Entity2.class, id); 73 } 74 public void find2FromFactory(int id) 75 { 76 EntityManager m = factory2.createEntityManager(); 77 Entity2 two = m.find(Entity2.class, id); 78 if (two == null) throw new RuntimeException ("NOT FOUND"); 79 } 81 82 public Util findUtil1FromManager(int id) 83 { 84 return manager1.find(Util.class, id); 85 } 86 87 public Util findUtil2FromManager(int id) 88 { 89 return manager2.find(Util.class, id); 90 } 91 } 92 | Popular Tags |