FileDocCategorySizeDatePackage
EntityTestBean.javaAPI DocJBoss 4.2.13050Fri Jul 13 20:55:04 BST 2007org.jboss.tutorial.relationships.bean

EntityTestBean

public class EntityTestBean extends Object implements EntityTest
Comment
author
Bill Burke
version
$Revision: 57207 $

Fields Summary
private EntityManager
manager
Constructors Summary
Methods Summary
public FlightfindFlightById(java.lang.Long id)

      return manager.find(Flight.class, id);
   
public voidmanyToManyCreate()


      Flight firstOne = new Flight();
      firstOne.setId(new Long(1));
      firstOne.setName("AF0101");
      manager.persist(firstOne);
      Flight second = new Flight();
      second.setId(new Long(2));
      second.setName("US1");

      Set<Customer> customers1 = new HashSet<Customer>();
      Set<Customer> customers2 = new HashSet<Customer>();


      Customer bill = new Customer();
      bill.setName("Bill");
      Address address = new Address();
      address.setStreet("Clarendon Street");
      address.setCity("Boston");
      address.setState("MA");
      address.setZip("02116");
      bill.setAddress(address);
      customers1.add(bill);

      Customer monica = new Customer();
      monica.setName("Monica");
      address = new Address();
      address.setStreet("Beach Street");
      address.setCity("Somerville");
      address.setState("MA");
      address.setZip("02116");
      monica.setAddress(address);
      customers1.add(monica);

      Customer molly = new Customer();
      molly.setName("Molly");
      address = new Address();
      address.setStreet("Main Street");
      address.setCity("Billerica");
      address.setState("MA");
      address.setZip("02116");
      customers2.add(molly);

      firstOne.setCustomers(customers1);
      second.setCustomers(customers2);

      manager.persist(second);