Reputation: 10139
Is there are special method of Spring Framework to throw an exception in case affected rowcount is zero while UPDATE
operation is performed?
I know the following methods:
org.springframework.dao.EmptyResultDataAccessException
is used at SELECT operation.
int rowCount = this.getJdbcTemplate().update("update");
if (rowCount == 0) {
throw new Exception(...);
}
Upvotes: 3
Views: 1010
Reputation: 582
Someday I was looking similar something, I found this:
You can define a given number of rows to update, if your SQL update overcome this number, a exception is thrown. I think you can define zero as incorrect number.
I hope this information helps you.
Good luck.
Upvotes: 1