HHH-16399 Recognize ConstraintViolationException form errorCode in MSSQL
This is for Hibernate Reactive. Hibernate ORM recognizes the error because, when it comes from the JDBC driver, it's an instance of `java.sql.SQLIntegrityConstraintViolationException`.
This commit is contained in:
parent
715a12ba7e
commit
6cdef8beab
|
@ -46,6 +46,7 @@ import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
||||||
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
||||||
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
import org.hibernate.exception.ConstraintViolationException;
|
||||||
import org.hibernate.exception.LockTimeoutException;
|
import org.hibernate.exception.LockTimeoutException;
|
||||||
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
||||||
import org.hibernate.internal.util.JdbcExceptionHelper;
|
import org.hibernate.internal.util.JdbcExceptionHelper;
|
||||||
|
@ -720,6 +721,9 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
|
||||||
if ( 1222 == errorCode ) {
|
if ( 1222 == errorCode ) {
|
||||||
throw new LockTimeoutException( message, sqlException, sql );
|
throw new LockTimeoutException( message, sqlException, sql );
|
||||||
}
|
}
|
||||||
|
if ( 2627 == errorCode || 2601 == errorCode ) {
|
||||||
|
throw new ConstraintViolationException( message, sqlException, sql );
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue