@Test(expected = SQLException.class) public void testDeleteNoId() throws Exception { StatementExecutor<NoId, Void> se = new StatementExecutor<NoId, Void>(databaseType, new TableInfo<NoId, Void>(connectionSource, null, NoId.class), null); NoId noId = new NoId(); noId.stuff = "1"; ConnectionSource connectionSource = createMock(ConnectionSource.class); expect(connectionSource.getReadOnlyConnection(NOID_TABLE_NAME)).andReturn(null); replay(connectionSource); se.delete(connectionSource.getReadOnlyConnection(NOID_TABLE_NAME), noId, null); }
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) { 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); } }
MappedDelete extends BaseMappedStatement<T, ID> { 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) { 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); } } }
MappedDelete extends BaseMappedStatement<T, ID> { 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) { 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); } } private  MappedDelete(TableInfo<T, ID> tableInfo, String statement, FieldType[] argFieldTypes); }
MappedDelete extends BaseMappedStatement<T, ID> { 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) { 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); } } private  MappedDelete(TableInfo<T, ID> tableInfo, String statement, FieldType[] argFieldTypes); static MappedDelete<T, ID> build(DatabaseType databaseType, TableInfo<T, ID> tableInfo); int delete(DatabaseConnection databaseConnection, T data, ObjectCache objectCache); int deleteById(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache); }
MappedDelete extends BaseMappedStatement<T, ID> { 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) { 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); } } private  MappedDelete(TableInfo<T, ID> tableInfo, String statement, FieldType[] argFieldTypes); static MappedDelete<T, ID> build(DatabaseType databaseType, TableInfo<T, ID> tableInfo); int delete(DatabaseConnection databaseConnection, T data, ObjectCache objectCache); int deleteById(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache);  }