/** Inserts a new row in the carrito_compras table. */
  public CarritoComprasPk insert(CarritoCompras dto) throws CarritoComprasDaoException {
    long t1 = System.currentTimeMillis();
    // declare variables
    final boolean isConnSupplied = (userConn != null);
    Connection conn = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;

    try {
      // get the user-specified connection or get a connection from the ResourceManager
      conn = isConnSupplied ? userConn : ResourceManager.getConnection();

      stmt = conn.prepareStatement(SQL_INSERT);
      int index = 1;
      stmt.setString(index++, dto.getIdCarrito());
      stmt.setDouble(index++, dto.getTotal());
      stmt.setDouble(index++, dto.getSubtotal());
      stmt.setDouble(index++, dto.getImpuestos());
      System.out.println("Executing " + SQL_INSERT + " with DTO: " + dto);
      int rows = stmt.executeUpdate();
      long t2 = System.currentTimeMillis();
      System.out.println(rows + " rows affected (" + (t2 - t1) + " ms)");
      reset(dto);
      return dto.createPk();
    } catch (Exception _e) {
      _e.printStackTrace();
      throw new CarritoComprasDaoException("Exception: " + _e.getMessage(), _e);
    } finally {
      ResourceManager.close(stmt);
      if (!isConnSupplied) {
        ResourceManager.close(conn);
      }
    }
  }
 /** Populates a DTO with data from a ResultSet */
 protected void populateDto(CarritoCompras dto, ResultSet rs) throws SQLException {
   dto.setIdCarrito(rs.getString(COLUMN_ID_CARRITO));
   dto.setTotal(rs.getDouble(COLUMN_TOTAL));
   dto.setSubtotal(rs.getDouble(COLUMN_SUBTOTAL));
   dto.setImpuestos(rs.getDouble(COLUMN_IMPUESTOS));
 }