Tabnine Logo
DatabaseConnection.delete
Code IndexAdd Tabnine to your IDE (free)

How to use
delete
method
in
com.j256.ormlite.support.DatabaseConnection

Best Java code snippets using com.j256.ormlite.support.DatabaseConnection.delete (Showing top 9 results out of 315)

origin: j256/ormlite-core

@Override
public int delete(String statement, Object[] args, FieldType[] argfieldTypes) throws SQLException {
  if (proxy == null) {
    return 0;
  } else {
    return proxy.delete(statement, args, argfieldTypes);
  }
}
origin: com.j256.ormlite/ormlite-core

@Override
public int delete(String statement, Object[] args, FieldType[] argfieldTypes) throws SQLException {
  if (proxy == null) {
    return 0;
  } else {
    return proxy.delete(statement, args, argfieldTypes);
  }
}
origin: com.j256.ormlite/ormlite-core

private static <T, ID> int updateRows(DatabaseConnection databaseConnection, Class<T> clazz,
    MappedDeleteCollection<T, ID> deleteCollection, Object[] args, ObjectCache objectCache) throws SQLException {
  try {
    int rowC = databaseConnection.delete(deleteCollection.statement, args, deleteCollection.argFieldTypes);
    if (rowC > 0 && objectCache != null) {
      for (Object id : args) {
        objectCache.remove(clazz, id);
      }
    }
    logger.debug("delete-collection with statement '{}' and {} args, changed {} rows",
        deleteCollection.statement, args.length, rowC);
    if (args.length > 0) {
      // need to do the (Object) cast to force args to be a single object
      logger.trace("delete-collection arguments: {}", (Object) args);
    }
    return rowC;
  } catch (SQLException e) {
    throw SqlExceptionUtil.create("Unable to run delete collection stmt: " + deleteCollection.statement, e);
  }
}
origin: j256/ormlite-core

private static <T, ID> int updateRows(DatabaseConnection databaseConnection, Class<T> clazz,
    MappedDeleteCollection<T, ID> deleteCollection, Object[] args, ObjectCache objectCache)
    throws SQLException {
  try {
    int rowC = databaseConnection.delete(deleteCollection.statement, args, deleteCollection.argFieldTypes);
    if (rowC > 0 && objectCache != null) {
      for (Object id : args) {
        objectCache.remove(clazz, id);
      }
    }
    logger.debug("delete-collection with statement '{}' and {} args, changed {} rows",
        deleteCollection.statement, args.length, rowC);
    if (args.length > 0) {
      // need to do the (Object) cast to force args to be a single object
      logger.trace("delete-collection arguments: {}", (Object) args);
    }
    return rowC;
  } catch (SQLException e) {
    throw SqlExceptionUtil.create("Unable to run delete collection stmt: " + deleteCollection.statement, e);
  }
}
origin: j256/ormlite-core

@Test
public void testDelete() throws Exception {
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  String statement = "insert bar";
  int result = 13872321;
  expect(conn.delete(statement, null, null)).andReturn(result);
  conn.close();
  DatabaseConnectionProxy proxy = new DatabaseConnectionProxy(conn);
  replay(conn);
  assertEquals(result, proxy.delete(statement, null, null));
  proxy.close();
  verify(conn);
}
origin: j256/ormlite-core

  /**
   * Delete the object from the database.
   */
  public int deleteById(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache) throws SQLException {
    try {
      Object[] args = new Object[] { convertIdToFieldObject(id) };
      int rowC = databaseConnection.delete(statement, args, argFieldTypes);
      logger.debug("delete data with statement '{}' and {} args, changed {} rows", statement, args.length, rowC);
      if (args.length > 0) {
        // need to do the (Object) cast to force args to be a single object
        logger.trace("delete arguments: {}", (Object) args);
      }
      if (rowC > 0 && objectCache != null) {
        objectCache.remove(clazz, id);
      }
      return rowC;
    } catch (SQLException e) {
      throw SqlExceptionUtil.create("Unable to run deleteById stmt on id " + id + ": " + statement, e);
    }
  }
}
origin: com.j256.ormlite/ormlite-core

  /**
   * Delete the object from the database.
   */
  public int deleteById(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache) throws SQLException {
    try {
      Object[] args = new Object[] { convertIdToFieldObject(id) };
      int rowC = databaseConnection.delete(statement, args, argFieldTypes);
      logger.debug("delete data with statement '{}' and {} args, changed {} rows", statement, args.length, rowC);
      if (args.length > 0) {
        // need to do the (Object) cast to force args to be a single object
        logger.trace("delete arguments: {}", (Object) args);
      }
      if (rowC > 0 && objectCache != null) {
        objectCache.remove(clazz, id);
      }
      return rowC;
    } catch (SQLException e) {
      throw SqlExceptionUtil.create("Unable to run deleteById stmt on id " + id + ": " + statement, e);
    }
  }
}
origin: j256/ormlite-core

/**
 * Delete the object from the database.
 */
public int delete(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException {
  try {
    Object[] args = getFieldObjects(data);
    int rowC = databaseConnection.delete(statement, args, argFieldTypes);
    logger.debug("delete data with statement '{}' and {} args, changed {} rows", statement, args.length, rowC);
    if (args.length > 0) {
      // need to do the (Object) cast to force args to be a single object
      logger.trace("delete arguments: {}", (Object) args);
    }
    if (rowC > 0 && objectCache != null) {
      Object id = idField.extractJavaFieldToSqlArgValue(data);
      objectCache.remove(clazz, id);
    }
    return rowC;
  } catch (SQLException e) {
    throw SqlExceptionUtil.create("Unable to run delete stmt on object " + data + ": " + statement, e);
  }
}
origin: com.j256.ormlite/ormlite-core

/**
 * Delete the object from the database.
 */
public int delete(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException {
  try {
    Object[] args = getFieldObjects(data);
    int rowC = databaseConnection.delete(statement, args, argFieldTypes);
    logger.debug("delete data with statement '{}' and {} args, changed {} rows", statement, args.length, rowC);
    if (args.length > 0) {
      // need to do the (Object) cast to force args to be a single object
      logger.trace("delete arguments: {}", (Object) args);
    }
    if (rowC > 0 && objectCache != null) {
      Object id = idField.extractJavaFieldToSqlArgValue(data);
      objectCache.remove(clazz, id);
    }
    return rowC;
  } catch (SQLException e) {
    throw SqlExceptionUtil.create("Unable to run delete stmt on object " + data + ": " + statement, e);
  }
}
com.j256.ormlite.supportDatabaseConnectiondelete

Javadoc

Perform a SQL delete with the associated SQL statement, arguments, and types.

Popular methods of DatabaseConnection

  • executeStatement
    Execute a statement directly on the connection.
  • isAutoCommit
    Return if auto-commit is currently enabled.
  • setAutoCommit
    Set the auto-commit to be on (true) or off (false). Setting auto-commit to true may or may-not cause
  • commit
    Commit all changes since the savepoint was created. If savePoint is null then commit all outstanding
  • compileStatement
    Like compileStatement(String, StatementType, FieldType[]) except the caller can specify the result f
  • setSavePoint
    Start a save point with a certain name. It can be a noop if savepoints are not supported.
  • close
  • closeQuietly
    Close the connection to the database but swallow any exceptions.
  • insert
    Perform a SQL update while with the associated SQL statement, arguments, and types. This will possib
  • isAutoCommitSupported
    Return if auto-commit is supported.
  • queryForLong
    Perform a query whose result should be a single long-integer value.
  • rollback
    Roll back all changes since the savepoint was created. If savePoint is null then roll back all outst
  • queryForLong,
  • rollback,
  • isClosed,
  • isTableExists,
  • queryForOne,
  • update,
  • releaseSavePoint

Popular in Java

  • Creating JSON documents from java classes using gson
  • getExternalFilesDir (Context)
  • compareTo (BigDecimal)
  • runOnUiThread (Activity)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JTable (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now