/** * Convenience method for deleting all rows from the given table, using the * provided {@code WHERE} clause. * <p>Use with caution outside of a transaction! * <p>See the Javadoc for {@link JdbcTestUtils#deleteFromTableWhere} for details. * @param tableName the name of the table to delete rows from * @param whereClause the {@code WHERE} clause to append to the query * @param args arguments to bind to the query (leaving it to the {@code * PreparedStatement} to guess the corresponding SQL type); may also contain * {@link org.springframework.jdbc.core.SqlParameterValue SqlParameterValue} * objects which indicate not only the argument value but also the SQL type * and optionally the scale. * @return the number of rows deleted from the table * @since 4.0 * @see JdbcTestUtils#deleteFromTableWhere */ protected int deleteFromTableWhere(String tableName, String whereClause, Object... args) { return JdbcTestUtils.deleteFromTableWhere(this.jdbcTemplate, tableName, whereClause, args); }
/** * Convenience method for deleting all rows from the given table, using the * provided {@code WHERE} clause. * <p>Use with caution outside of a transaction! * <p>See the Javadoc for {@link JdbcTestUtils#deleteFromTableWhere} for details. * @param tableName the name of the table to delete rows from * @param whereClause the {@code WHERE} clause to append to the query * @param args arguments to bind to the query (leaving it to the {@code * PreparedStatement} to guess the corresponding SQL type); may also contain * {@link org.springframework.jdbc.core.SqlParameterValue SqlParameterValue} * objects which indicate not only the argument value but also the SQL type * and optionally the scale. * @return the number of rows deleted from the table * @since 4.0 * @see JdbcTestUtils#deleteFromTableWhere */ protected int deleteFromTableWhere(String tableName, String whereClause, Object... args) { return JdbcTestUtils.deleteFromTableWhere(this.jdbcTemplate, tableName, whereClause, args); }
@Test public void deleteWithoutWhereClause() throws Exception { given(jdbcTemplate.update("DELETE FROM person")).willReturn(10); int deleted = JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "person", null); assertThat(deleted, equalTo(10)); }
@Test public void deleteWithWhereClauseAndArguments() throws Exception { given(jdbcTemplate.update("DELETE FROM person WHERE name = ? and age > ?", "Bob", 25)).willReturn(10); int deleted = JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "person", "name = ? and age > ?", "Bob", 25); assertThat(deleted, equalTo(10)); }
@Test public void deleteWithWhereClause() throws Exception { given(jdbcTemplate.update("DELETE FROM person WHERE name = 'Bob' and age > 25")).willReturn(10); int deleted = JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "person", "name = 'Bob' and age > 25"); assertThat(deleted, equalTo(10)); }
/** * Convenience method for deleting all rows from the given table, using the * provided {@code WHERE} clause. * <p>Use with caution outside of a transaction! * <p>See the Javadoc for {@link JdbcTestUtils#deleteFromTableWhere} for details. * @param tableName the name of the table to delete rows from * @param whereClause the {@code WHERE} clause to append to the query * @param args arguments to bind to the query (leaving it to the {@code * PreparedStatement} to guess the corresponding SQL type); may also contain * {@link org.springframework.jdbc.core.SqlParameterValue SqlParameterValue} * objects which indicate not only the argument value but also the SQL type * and optionally the scale. * @return the number of rows deleted from the table * @since 4.0 * @see JdbcTestUtils#deleteFromTableWhere */ protected int deleteFromTableWhere(String tableName, String whereClause, Object... args) { return JdbcTestUtils.deleteFromTableWhere(this.jdbcTemplate, tableName, whereClause, args); }
/** * Convenience method for deleting all rows from the given table, using the * provided {@code WHERE} clause. * <p>Use with caution outside of a transaction! * <p>See the Javadoc for {@link JdbcTestUtils#deleteFromTableWhere} for details. * @param tableName the name of the table to delete rows from * @param whereClause the {@code WHERE} clause to append to the query * @param args arguments to bind to the query (leaving it to the {@code * PreparedStatement} to guess the corresponding SQL type); may also contain * {@link org.springframework.jdbc.core.SqlParameterValue SqlParameterValue} * objects which indicate not only the argument value but also the SQL type * and optionally the scale. * @return the number of rows deleted from the table * @since 4.0 * @see JdbcTestUtils#deleteFromTableWhere */ protected int deleteFromTableWhere(String tableName, String whereClause, Object... args) { return JdbcTestUtils.deleteFromTableWhere(this.jdbcTemplate, tableName, whereClause, args); }
/** * Convenience method for deleting all rows from the given table, using the * provided {@code WHERE} clause. * <p>Use with caution outside of a transaction! * <p>See the Javadoc for {@link JdbcTestUtils#deleteFromTableWhere} for details. * @param tableName the name of the table to delete rows from * @param whereClause the {@code WHERE} clause to append to the query * @param args arguments to bind to the query (leaving it to the {@code * PreparedStatement} to guess the corresponding SQL type); may also contain * {@link org.springframework.jdbc.core.SqlParameterValue SqlParameterValue} * objects which indicate not only the argument value but also the SQL type * and optionally the scale. * @return the number of rows deleted from the table * @since 4.0 * @see JdbcTestUtils#deleteFromTableWhere */ protected int deleteFromTableWhere(String tableName, String whereClause, Object... args) { return JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, tableName, whereClause, args); }
/** * Convenience method for deleting all rows from the given table, using the * provided {@code WHERE} clause. * <p>Use with caution outside of a transaction! * <p>See the Javadoc for {@link JdbcTestUtils#deleteFromTableWhere} for details. * @param tableName the name of the table to delete rows from * @param whereClause the {@code WHERE} clause to append to the query * @param args arguments to bind to the query (leaving it to the {@code * PreparedStatement} to guess the corresponding SQL type); may also contain * {@link org.springframework.jdbc.core.SqlParameterValue SqlParameterValue} * objects which indicate not only the argument value but also the SQL type * and optionally the scale. * @return the number of rows deleted from the table * @since 4.0 * @see JdbcTestUtils#deleteFromTableWhere */ protected int deleteFromTableWhere(String tableName, String whereClause, Object... args) { return JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, tableName, whereClause, args); }