org.springframework.jdbc.JdbcUpdateAffectedIncorrectNumberOfRowsException Java Examples

The following examples show how to use org.springframework.jdbc.JdbcUpdateAffectedIncorrectNumberOfRowsException. 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 File: SqlUpdateTests.java    From spring-analysis-note with 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 File: SqlUpdateTests.java    From spring-analysis-note with 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 File: SqlUpdateTests.java    From java-technology-stack with 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 File: SqlUpdateTests.java    From java-technology-stack with 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 File: SqlUpdateTests.java    From spring4-understanding with 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 File: SqlUpdateTests.java    From spring4-understanding with 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 File: SqlUpdateTests.java    From effectivejava with 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 File: SqlUpdateTests.java    From effectivejava with 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 File: SqlMapClientTemplate.java    From gocd with 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 File: CobarSqlMapClientTemplate.java    From cobarclient with 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 File: CobarSqlMapClientTemplate.java    From cobarclient with 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 File: SqlUpdate.java    From spring-analysis-note with 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 File: SqlUpdate.java    From java-technology-stack with 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 File: SqlUpdate.java    From lams with 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 File: SqlUpdate.java    From spring4-understanding with 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 File: SqlUpdate.java    From effectivejava with 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);
	}
}