}
entityManager.flush();
// Creates the product order and the products associated.
for (int i = 0; i < strDescriptionValues.length; i++) {
ProductOrder productOrder = new ProductOrder();
productOrder.setId(i);
productOrder.setDescription(strDescriptionValues[i]);
// Creates the same number of products that the order id.
// Are created 0 + 1 + 2 + ...+7 = 28 products in total.
// The products id are: 10, 20, 21,30,31,32, 40, 41, 42, 43...
List<Product> lstProducts = createProducts(i, i * INTERVAL_BETWEEN_ID);
productOrder.setProducts(lstProducts);
entityManager.persist(productOrder);
// inserts in the products the reference for the order.
insertOrderReference(lstProducts, productOrder);
}
entityManager.flush();