FileDocCategorySizeDatePackage
EntityTestBean.javaAPI DocJBoss 4.2.12704Fri Jul 13 20:54:56 BST 2007org.jboss.tutorial.composite.bean

EntityTestBean

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

Fields Summary
private EntityManager
manager
private static long
genid
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();
      CustomerPK pk = new CustomerPK(genid++, "Bill");
      bill.setPk(pk);
      customers1.add(bill);

      Customer monica = new Customer();
      CustomerPK moPK = new CustomerPK(genid++, "Monica");
      monica.setPk(moPK);
      customers1.add(monica);

      Customer molly = new Customer();
      CustomerPK mollyPK = new CustomerPK(genid++, "Molly");
      molly.setPk(mollyPK);
      customers2.add(molly);

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

      manager.persist(second);