Java Code Examples for org.springframework.jdbc.JdbcUpdateAffectedIncorrectNumberOfRowsException

The following examples show how to use org.springframework.jdbc.JdbcUpdateAffectedIncorrectNumberOfRowsException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note   Source File: SqlUpdateTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testOverMaxRows() throws SQLException {
	given(preparedStatement.executeUpdate()).willReturn(8);
	given(connection.prepareStatement(UPDATE)).willReturn(preparedStatement);

	MaxRowsUpdater pc = new MaxRowsUpdater();

	assertThatExceptionOfType(JdbcUpdateAffectedIncorrectNumberOfRowsException.class).isThrownBy(
			pc::run);
}
 
Example 2
Source Project: spring-analysis-note   Source File: SqlUpdateTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testNotRequiredRows() throws SQLException {
	given(preparedStatement.executeUpdate()).willReturn(2);
	given(connection.prepareStatement(UPDATE)).willReturn(preparedStatement);
	RequiredRowsUpdater pc = new RequiredRowsUpdater();
	assertThatExceptionOfType(JdbcUpdateAffectedIncorrectNumberOfRowsException.class).isThrownBy(
			pc::run);
}
 
Example 3
Source Project: java-technology-stack   Source File: SqlUpdateTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testOverMaxRows() throws SQLException {
	given(preparedStatement.executeUpdate()).willReturn(8);
	given(connection.prepareStatement(UPDATE)).willReturn(preparedStatement);

	MaxRowsUpdater pc = new MaxRowsUpdater();

	thrown.expect(JdbcUpdateAffectedIncorrectNumberOfRowsException.class);
	pc.run();
}
 
Example 4
Source Project: java-technology-stack   Source File: SqlUpdateTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testNotRequiredRows() throws SQLException {
	given(preparedStatement.executeUpdate()).willReturn(2);
	given(connection.prepareStatement(UPDATE)).willReturn(preparedStatement);
	thrown.expect(JdbcUpdateAffectedIncorrectNumberOfRowsException.class);
	RequiredRowsUpdater pc = new RequiredRowsUpdater();
	pc.run();
}
 
Example 5
Source Project: spring4-understanding   Source File: SqlUpdateTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testOverMaxRows() throws SQLException {
	given(preparedStatement.executeUpdate()).willReturn(8);
	given(connection.prepareStatement(UPDATE)).willReturn(preparedStatement);

	MaxRowsUpdater pc = new MaxRowsUpdater();

	thrown.expect(JdbcUpdateAffectedIncorrectNumberOfRowsException.class);
	pc.run();
}
 
Example 6
Source Project: spring4-understanding   Source File: SqlUpdateTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testNotRequiredRows() throws SQLException {
	given(preparedStatement.executeUpdate()).willReturn(2);
	given(connection.prepareStatement(UPDATE)).willReturn(preparedStatement);
	thrown.expect(JdbcUpdateAffectedIncorrectNumberOfRowsException.class);
	RequiredRowsUpdater pc = new RequiredRowsUpdater();
	pc.run();
}
 
Example 7
Source Project: effectivejava   Source File: SqlUpdateTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testOverMaxRows() throws SQLException {
	given(preparedStatement.executeUpdate()).willReturn(8);
	given(connection.prepareStatement(UPDATE)).willReturn(preparedStatement);

	MaxRowsUpdater pc = new MaxRowsUpdater();

	thrown.expect(JdbcUpdateAffectedIncorrectNumberOfRowsException.class);
	pc.run();
}
 
Example 8
Source Project: effectivejava   Source File: SqlUpdateTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testNotRequiredRows() throws SQLException {
	given(preparedStatement.executeUpdate()).willReturn(2);
	given(connection.prepareStatement(UPDATE)).willReturn(preparedStatement);
	thrown.expect(JdbcUpdateAffectedIncorrectNumberOfRowsException.class);
	RequiredRowsUpdater pc = new RequiredRowsUpdater();
	pc.run();
}
 
Example 9
Source Project: gocd   Source File: SqlMapClientTemplate.java    License: Apache License 2.0 5 votes vote down vote up
public void update(String statementName, Object parameter, int requiredRowsAffected) {
    goCache.stopServingForTransaction();
    int actualRowsAffected = delegate.update(statementName, parameter);
    if (actualRowsAffected != requiredRowsAffected) {
        throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(
                statementName, requiredRowsAffected, actualRowsAffected);
    }
}
 
Example 10
Source Project: cobarclient   Source File: CobarSqlMapClientTemplate.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void delete(final String statementName, final Object parameterObject,
                   int requiredRowsAffected) throws DataAccessException {
    Integer rowAffected = this.delete(statementName, parameterObject);
    if (rowAffected != requiredRowsAffected) {
        throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(statementName,
                requiredRowsAffected, rowAffected);
    }
}
 
Example 11
Source Project: cobarclient   Source File: CobarSqlMapClientTemplate.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void update(String statementName, Object parameterObject, int requiredRowsAffected)
        throws DataAccessException {
    int rowAffected = this.update(statementName, parameterObject);
    if (rowAffected != requiredRowsAffected) {
        throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(statementName,
                requiredRowsAffected, rowAffected);
    }
}
 
Example 12
Source Project: spring-analysis-note   Source File: SqlUpdate.java    License: MIT License 3 votes vote down vote up
/**
 * Check the given number of affected rows against the
 * specified maximum number or required number.
 * @param rowsAffected the number of affected rows
 * @throws JdbcUpdateAffectedIncorrectNumberOfRowsException
 * if the actually affected rows are out of bounds
 * @see #setMaxRowsAffected
 * @see #setRequiredRowsAffected
 */
protected void checkRowsAffected(int rowsAffected) throws JdbcUpdateAffectedIncorrectNumberOfRowsException {
	if (this.maxRowsAffected > 0 && rowsAffected > this.maxRowsAffected) {
		throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(resolveSql(), this.maxRowsAffected, rowsAffected);
	}
	if (this.requiredRowsAffected > 0 && rowsAffected != this.requiredRowsAffected) {
		throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(resolveSql(), this.requiredRowsAffected, rowsAffected);
	}
}
 
Example 13
Source Project: java-technology-stack   Source File: SqlUpdate.java    License: MIT License 3 votes vote down vote up
/**
 * Check the given number of affected rows against the
 * specified maximum number or required number.
 * @param rowsAffected the number of affected rows
 * @throws JdbcUpdateAffectedIncorrectNumberOfRowsException
 * if the actually affected rows are out of bounds
 * @see #setMaxRowsAffected
 * @see #setRequiredRowsAffected
 */
protected void checkRowsAffected(int rowsAffected) throws JdbcUpdateAffectedIncorrectNumberOfRowsException {
	if (this.maxRowsAffected > 0 && rowsAffected > this.maxRowsAffected) {
		throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(resolveSql(), this.maxRowsAffected, rowsAffected);
	}
	if (this.requiredRowsAffected > 0 && rowsAffected != this.requiredRowsAffected) {
		throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(resolveSql(), this.requiredRowsAffected, rowsAffected);
	}
}
 
Example 14
Source Project: lams   Source File: SqlUpdate.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Check the given number of affected rows against the
 * specified maximum number or required number.
 * @param rowsAffected the number of affected rows
 * @throws JdbcUpdateAffectedIncorrectNumberOfRowsException
 * if the actually affected rows are out of bounds
 * @see #setMaxRowsAffected
 * @see #setRequiredRowsAffected
 */
protected void checkRowsAffected(int rowsAffected) throws JdbcUpdateAffectedIncorrectNumberOfRowsException {
	if (this.maxRowsAffected > 0 && rowsAffected > this.maxRowsAffected) {
		throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(getSql(), this.maxRowsAffected, rowsAffected);
	}
	if (this.requiredRowsAffected > 0 && rowsAffected != this.requiredRowsAffected) {
		throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(getSql(), this.requiredRowsAffected, rowsAffected);
	}
}
 
Example 15
Source Project: spring4-understanding   Source File: SqlUpdate.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Check the given number of affected rows against the
 * specified maximum number or required number.
 * @param rowsAffected the number of affected rows
 * @throws JdbcUpdateAffectedIncorrectNumberOfRowsException
 * if the actually affected rows are out of bounds
 * @see #setMaxRowsAffected
 * @see #setRequiredRowsAffected
 */
protected void checkRowsAffected(int rowsAffected) throws JdbcUpdateAffectedIncorrectNumberOfRowsException {
	if (this.maxRowsAffected > 0 && rowsAffected > this.maxRowsAffected) {
		throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(getSql(), this.maxRowsAffected, rowsAffected);
	}
	if (this.requiredRowsAffected > 0 && rowsAffected != this.requiredRowsAffected) {
		throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(getSql(), this.requiredRowsAffected, rowsAffected);
	}
}
 
Example 16
Source Project: effectivejava   Source File: SqlUpdate.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Check the given number of affected rows against the
 * specified maximum number or required number.
 * @param rowsAffected the number of affected rows
 * @throws JdbcUpdateAffectedIncorrectNumberOfRowsException
 * if the actually affected rows are out of bounds
 * @see #setMaxRowsAffected
 * @see #setRequiredRowsAffected
 */
protected void checkRowsAffected(int rowsAffected) throws JdbcUpdateAffectedIncorrectNumberOfRowsException {
	if (this.maxRowsAffected > 0 && rowsAffected > this.maxRowsAffected) {
		throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(getSql(), this.maxRowsAffected, rowsAffected);
	}
	if (this.requiredRowsAffected > 0 && rowsAffected != this.requiredRowsAffected) {
		throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(getSql(), this.requiredRowsAffected, rowsAffected);
	}
}