PersistenceManager pm = pmf.getPersistenceManager();
Customer customer = StoreQueries.getCustomer(pm, firstName, lastName);
Iterator it = rentals.iterator();
while (it.hasNext()) {
RentalValueObject rvo = (RentalValueObject)it.next();
RentalItem ri = StoreQueries.getRentalItem
(pm, rvo.serialNumber);
Rental rental = new Rental(customer, new Date(), ri);
customer.addTransaction(rental);
customer.addRental(rental);
}
it = purchases.iterator();
while (it.hasNext()) {
PurchaseValueObject pvo = (PurchaseValueObject)it.next();
MediaItem mediaItem = StoreQueries.getMediaItem(
pm, pvo.title, pvo.format);
Purchase purchase = new Purchase(customer, new Date(), mediaItem);
customer.addTransaction(purchase);
}
pm.close();