1 22 package org.jboss.ejb3.test.hbm; 23 24 import java.util.List ; 25 import javax.ejb.Remote ; 26 import javax.ejb.Stateless ; 27 import javax.persistence.EntityManager; 28 import javax.persistence.PersistenceContext; 29 30 35 @Stateless 36 @Remote (EntityTest.class) 37 public class EntityTestBean implements EntityTest 38 { 39 @PersistenceContext private EntityManager em; 40 @PersistenceContext(unitName="hbm2-test") private EntityManager em2; 41 42 public void createBoth() 43 { 44 Annotated an = new Annotated(); 45 an.setName("Bill"); 46 47 HBM hbm = new HBM(); 48 hbm.setName("Gavin"); 49 50 an.setHbm(hbm); 51 52 em.persist(an); 53 54 HBM2 hbm2 = new HBM2(); 55 hbm2.setName("Bill"); 56 em2.persist(hbm2); 57 } 58 59 public List findAnnotated() 60 { 61 return em.createQuery("from Annotated an").getResultList(); 62 } 63 64 public List findHBM() 65 { 66 return em.createQuery("from HBM hbm").getResultList(); 67 } 68 } 69 | Popular Tags |