@Override public int delete(String statement, Object[] args, FieldType[] argfieldTypes) throws SQLException { if (proxy == null) { return 0; } else { return proxy.delete(statement, args, argfieldTypes); } }
@Override public int delete(String statement, Object[] args, FieldType[] argfieldTypes) throws SQLException { if (proxy == null) { return 0; } else { return proxy.delete(statement, args, argfieldTypes); } }
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); } }
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); } }
@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); }
/** * 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); } } }
/** * 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); } } }
/** * 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); } }
/** * 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); } }