Violation of a unique index on insert in MSSQL is translated to DataIntegrityViolationException instead of DuplicateKeyException #29950
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
type: regression
A bug that is also a regression
Milestone
Affects: 6.0.4 (spring-r2dbc)
When inserting a row in MSSQL, using
spring-r2dbc
, that results in a unique constraint violation, the thrown exception isDataIntegrityViolationException
.I would have expected a
DuplicateKeyException
, for its Javadoc documentation states:The SQL state and code returned by MSSQL are the following:
The method
ConnectionFactoryUtils.indicatesDuplicateKey()
does not seem to take into account the2601
error code.The exception thrown has the following stack trace:
Note that it also affects
spring-jdbc
when usingJdbcTemplate
, for the error translation done inSQLStateSQLExceptionTranslator.indicatesDuplicateKey()
is pretty much the same.This might also relates to the following issue: #29699
The text was updated successfully, but these errors were encountered: