Program: 51766
Project: 51766
Buggy source:
/** 
 * Create an order with contents of a shopping cart.
 * @param customerID customer's ID
 * @param billName billing name
 * @param billAddr1 billing address line 1
 * @param billAddr2 billing address line 2
 * @param billCity billing address city
 * @param billState billing address state
 * @param billZip billing address zip code
 * @param billPhone billing phone
 * @param shipName shippng name
 * @param shipAddr1 shippng address line 1
 * @param shipAddr2 shippng address line 2
 * @param shipCity shippng address city
 * @param shipState shippng address state
 * @param shipZip shippng address zip code
 * @param shipPhone shippng phone
 * @param creditCard credit card
 * @param ccNum credit card number
 * @param ccExpireMonth credit card expiration month
 * @param ccExpireYear credit card expiration year
 * @param cardHolder credit card holder name
 * @param shippingMethod int of shipping method used
 * @param items vector of StoreItems ordered
 * @return OrderInfo
 */
public OrderInfo createOrder(String customerID,String billName,String billAddr1,String billAddr2,String billCity,String billState,String billZip,String billPhone,String shipName,String shipAddr1,String shipAddr2,String shipCity,String shipState,String shipZip,String shipPhone,String creditCard,String ccNum,String ccExpireMonth,String ccExpireYear,String cardHolder,int shippingMethod,Collection<ShoppingCartItem> items){
  Order order=null;
  Collection<OrderItem> orderitems=new ArrayList<OrderItem>();
  EntityManager em=entityManagerFactory.createEntityManager();
  for (  Object o : items) {
    ShoppingCartItem si=(ShoppingCartItem)o;
    Inventory inv=em.find(Inventory.class,si.getID());
    OrderItem oi=new OrderItem(inv);
    oi.setQuantity(si.getQuantity());
    orderitems.add(oi);
  }
  Customer c=em.find(Customer.class,customerID);
  order=new Order(c,billName,billAddr1,billAddr2,billCity,billState,billZip,billPhone,shipName,shipAddr1,shipAddr2,shipCity,shipState,shipZip,shipPhone,creditCard,ccNum,ccExpireMonth,ccExpireYear,cardHolder,shippingMethod,orderitems);
  em.persist(order);
  em.flush();
  for (  OrderItem o : orderitems) {
    o.setOrder(order);
    o.updatePK();
    em.persist(o);
  }
  em.flush();
  OrderInfo orderInfo=new OrderInfo(order);
  return orderInfo;
}

Fixed version (ground truth):
/** 
 * Create an order with contents of a shopping cart.
 * @param customerID customer's ID
 * @param billName billing name
 * @param billAddr1 billing address line 1
 * @param billAddr2 billing address line 2
 * @param billCity billing address city
 * @param billState billing address state
 * @param billZip billing address zip code
 * @param billPhone billing phone
 * @param shipName shippng name
 * @param shipAddr1 shippng address line 1
 * @param shipAddr2 shippng address line 2
 * @param shipCity shippng address city
 * @param shipState shippng address state
 * @param shipZip shippng address zip code
 * @param shipPhone shippng phone
 * @param creditCard credit card
 * @param ccNum credit card number
 * @param ccExpireMonth credit card expiration month
 * @param ccExpireYear credit card expiration year
 * @param cardHolder credit card holder name
 * @param shippingMethod int of shipping method used
 * @param items vector of StoreItems ordered
 * @return OrderInfo
 */
public OrderInfo createOrder(String customerID,String billName,String billAddr1,String billAddr2,String billCity,String billState,String billZip,String billPhone,String shipName,String shipAddr1,String shipAddr2,String shipCity,String shipState,String shipZip,String shipPhone,String creditCard,String ccNum,String ccExpireMonth,String ccExpireYear,String cardHolder,int shippingMethod,Collection<ShoppingCartItem> items){
  Order order=null;
  Collection<OrderItem> orderitems=new ArrayList<OrderItem>();
  EntityManager em=entityManagerFactory.createEntityManager();
  for (  Object o : items) {
    ShoppingCartItem si=(ShoppingCartItem)o;
    Inventory inv=em.find(Inventory.class,si.getID());
    OrderItem oi=new OrderItem(inv);
    oi.setQuantity(si.getQuantity());
    orderitems.add(oi);
  }
  Customer c=em.find(Customer.class,customerID);
  order=new Order(c,billName,billAddr1,billAddr2,billCity,billState,billZip,billPhone,shipName,shipAddr1,shipAddr2,shipCity,shipState,shipZip,shipPhone,creditCard,ccNum,ccExpireMonth,ccExpireYear,cardHolder,shippingMethod,orderitems);
  em.getTransaction().begin();
  em.persist(order);
  em.flush();
  for (  OrderItem o : orderitems) {
    o.setOrder(order);
    o.updatePK(o.getInventory().getInventoryId());
    em.persist(o);
  }
  em.flush();
  em.getTransaction().commit();
  OrderInfo orderInfo=new OrderInfo(order);
  return orderInfo;
}