/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.ejb3.test.hbm;

import java.util.List;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * comment
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 */
@Stateless
@Remote(EntityTest.class)
public class EntityTestBean implements EntityTest
{
   @PersistenceContext private EntityManager em;
   @PersistenceContext(unitName="hbm2-test") private EntityManager em2;

   public void createBoth()
   {
      Annotated an = new Annotated();
      an.setName("Bill");

      HBM hbm = new HBM();
      hbm.setName("Gavin");

      an.setHbm(hbm);

      em.persist(an);

      HBM2 hbm2 = new HBM2();
      hbm2.setName("Bill");
      em2.persist(hbm2);
   }

   public List findAnnotated()
   {
      return em.createQuery("from Annotated an").getResultList();
   }

   public List findHBM()
   {
      return em.createQuery("from HBM hbm").getResultList();
   }
}
