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

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>
 * @version $Revision: 1.6.2.4 $
 */
@Stateless
@Remote(EntityTest.class)
public class EntityTestBean implements EntityTest
{
   @PersistenceContext
   private EntityManager manager;

   public Customer createCustomer()
   {
      Customer c = new Customer();
      c.setName("Bill");
      Address address = new Address();
      address.setStreet("Landsdown Street");
      address.setCity("Boston");
      address.setState("MA");
      address.setZip("02114");
      c.setAddress(address);
      FieldAddress faddress = new FieldAddress();
      faddress.street = "Boston Road";
      faddress.city = "Bedford";
      faddress.state = "MA";
      faddress.zip = "01811";
      c.setAddress2(faddress);
      manager.persist(c);
      return c;
   }

   public Customer findByCustomerId(Long id)
   {
      return manager.find(Customer.class, id);
   }

   public FieldCustomer createFieldCustomer()
   {
      FieldCustomer c = new FieldCustomer();
      c.setName("Bill");
      Address address = new Address();
      address.setStreet("Landsdown Street");
      address.setCity("Boston");
      address.setState("MA");
      address.setZip("02114");
      c.setAddress(address);
      FieldAddress faddress = new FieldAddress();
      faddress.street = "Boston Road";
      faddress.city = "Bedford";
      faddress.state = "MA";
      faddress.zip = "01811";
      c.setAddress2(faddress);
      manager.persist(c);
      return c;
   }

   public FieldCustomer fieldFindByCustomerId(Long id)
   {
      return manager.find(FieldCustomer.class, id);
   }
}
