private static void saveOrUpdateInvoice(Invoice invoice) { updateOrStoreObject(invoice); Customer customer = invoice.getCustomer(); for (Address address : customer.getAddresses()) { updateOrStoreObject(address); } updateOrStoreObject(customer); ProductGroup group = invoice.getProductGroup(); group.setInvoice(invoice); updateOrStoreObject(group); for (ProductLine line : group.getProductLines()) { line.setProductPrice(line.getProduct().getPrice()); line.setProductGroup(invoice.getProductGroup()); updateOrStoreObject(line); } }