HHH-16399 Minor refactoring

This commit is contained in:
Davide D'Alto 2023-03-30 10:35:21 +02:00 committed by Davide D'Alto
parent d3629eb6fa
commit b0b6152d14
1 changed files with 10 additions and 7 deletions

View File

@ -714,17 +714,20 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
return (sqlException, message, sql) -> {
final String sqlState = JdbcExceptionHelper.extractSqlState( sqlException );
final int errorCode = JdbcExceptionHelper.extractErrorCode( sqlException );
if ( "HY008".equals( sqlState ) ) {
throw new QueryTimeoutException( message, sqlException, sql );
}
if ( 1222 == errorCode ) {
throw new LockTimeoutException( message, sqlException, sql );
final int errorCode = JdbcExceptionHelper.extractErrorCode( sqlException );
switch ( errorCode ) {
case 1222:
throw new LockTimeoutException( message, sqlException, sql );
case 2627:
case 2601:
throw new ConstraintViolationException( message, sqlException, sql );
default:
return null;
}
if ( 2627 == errorCode || 2601 == errorCode ) {
throw new ConstraintViolationException( message, sqlException, sql );
}
return null;
};
}