1 22 package org.jboss.ejb3.test.composite2; 23 24 import javax.ejb.Remote ; 25 import javax.ejb.Stateless ; 26 import javax.persistence.EntityManager; 27 import javax.persistence.PersistenceContext; 28 import javax.persistence.PersistenceContext; 29 import javax.persistence.PersistenceContext; 30 31 37 @Stateless 38 @Remote (EntityTest.class) 39 public class EntityTestBean implements EntityTest 40 { 41 private @PersistenceContext EntityManager manager; 42 private static long genid = 0; 43 44 public Composite createComposite() 45 { 46 Composite composite = new Composite(); 47 long id1 = genid++; 48 long id2 = genid++; 49 50 CompositePK pk = new CompositePK(); 51 pk.setId1(id1); 52 pk.setId2(id2); 53 composite.setPk(pk); 54 55 CompositeContainer container = new CompositeContainer(); 56 container.setId(id2); 57 manager.persist(container); 58 composite.setContainer(container); 59 manager.persist(composite); 60 return composite; 61 } 62 63 public Composite findComposite(CompositePK pk) 64 { 65 return manager.find(Composite.class, pk); 66 } 67 68 } 69 | Popular Tags |