src/main/java/com/qa/IMS/persistence/dao/OrderDAO.java
@Override
	public Order update(Order order) {
		try (Connection connection = DBUtils.getInstance().getConnection();
				Statement statement = connection.createStatement();) {
			statement.executeUpdate("INSERT INTO orders_items(order_id, item_id, quantity, total) values('" + order.getOrder_id()
			+ "','" + order.getProduct_id()+ "','" + order.getQuantity() + "','" + order.getTotal() + "')");
			statement.executeUpdate("UPDATE orders SET total = (SELECT SUM(total) FROM orders_items WHERE order_id =" +order.getOrder_id()  + ") WHERE order_id=" + order.getOrder_id());
			LOGGER.info("Order Updated");
			return readItem(order.getOrder_id());
		} catch (Exception e) {
			
			LOGGER.info(e.getMessage());
		}
		return null;
	}
/**
	 * Updates a customer in the database
	 * 
	 * @param customer - takes in a customer object, the id field will be used to
	 *                 update that customer in the database
	 * @return
	 */
Updates a customer in the database

@param customer - takes in a customer object, the id field will be used to
update that customer in the database
@return
Updates a customer in the database @param customer - takes in a customer object the id field will be used to update that customer in the database @return
@Override
	public Order update(Order order) {
		try (Connection connection = DBUtils.getInstance().getConnection();
				Statement statement = connection.createStatement();) {
			statement.executeUpdate("INSERT INTO orders_items(order_id, item_id, quantity, total) values('" + order.getOrder_id()
			+ "','" + order.getProduct_id()+ "','" + order.getQuantity() + "','" + order.getTotal() + "')");
			statement.executeUpdate("UPDATE orders SET total = (SELECT SUM(total) FROM orders_items WHERE order_id =" +order.getOrder_id()  + ") WHERE order_id=" + order.getOrder_id());
			LOGGER.info("Order Updated");
			return readItem(order.getOrder_id());
		} catch (Exception e) {
			LOGGER.info(e.getMessage());
		}
		return null;
	}
@ Override public Order update ( Order order ) { try ( Connection connection = DBUtils . getInstance ( ) . getConnection ( ) ; Statement statement = connection . createStatement ( ) ; ) { statement . executeUpdate ( "INSERT INTO orders_items(order_id, item_id, quantity, total) values('" + order . getOrder_id ( ) + "','" + order . getProduct_id ( ) + "','" + order . getQuantity ( ) + "','" + order . getTotal ( ) + "')" ) ; statement . executeUpdate ( "UPDATE orders SET total = (SELECT SUM(total) FROM orders_items WHERE order_id =" + order . getOrder_id ( ) + ") WHERE order_id=" + order . getOrder_id ( ) ) ; LOGGER . info ( "Order Updated" ) ; return readItem ( order . getOrder_id ( ) ) ; } catch ( Exception e ) { LOGGER . info ( e . getMessage ( ) ) ; } return null ; }
Updates a customer in the database
Updates a customer in the database