int nCustomer = 20;
int nOrder = 10;
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
for (int j = 0; j < nCustomer; j++) {
Customer customer = new Customer();
customer.setName("Customer-" + j);
for (int k = 0; k < nOrder; k++) {
Order order = new Order();
order.setAmount(100);
customer.addOrder(order);
em.persist(order);
}
em.persist(customer);
}
em.getTransaction().commit();