if (!error.isEmpty()) {
renderView(request, response);
return;
}
Entity product = new EntityImpl();
product.put("name", name);
product.put("imageCollection", request.getParameter("imageCollection"));
product.put("description", description);
product.put("quantity", quantity);
product.put("price", price);
product.put("discount", discount);
product.put("type", type);
product.put("category", category);
try {
Connection conn = getConnection();
conn.setAutoCommit(false);
productDAO.setConnection(conn);
imageCollectionDAO.setConnection(conn);
imageDAO.setConnection(conn);
Entity imageCollection = new EntityImpl();
imageCollectionDAO.save(imageCollection);
for (Entity image : images) {
image.put("collection", imageCollection.get("id"));
imageDAO.save(image);
}
product.put("imageCollection", imageCollection.get("id"));
productDAO.save(product);
conn.commit();
conn.close();