Translate SQL Exception with State S0001 and Vendor Code 2628 to a Spring Exception in MSSQL 2019 #30681
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
Issue Description:
In the Spring JDBC framework, SQL exceptions with state
S0001
and vendor code2628
for MSSQL 2019 are not properly translated to a Spring exception. This behavior differs from the previous version, MSSQL 2017, where the same exception was translated into a Data Integrity Violation exception by Spring. The issue can be reproduced by inserting a value larger in length by the max allowed value of a column.Expected Behavior:
When encountering an SQL exception with state
S0001
and vendor code2628
messageString or binary data would be truncated in table '%.*ls', column '%.*ls'. Truncated value: '%.*ls'.
from MSSQL 2019, the Spring JDBC framework should accurately translate it into a corresponding Spring exception. Instead the exception ends uncategorised (UncategorizedSQLException).In older version of the MSSQL server (2017) the same exception is defined with:
22001
8152
then when the chain of the sql exception translators are executed the state class
22
is recognised as anDataIntegrityViolationException
within theSQLErrorCodeSQLExceptionTranslator
. But in versions above 2017th the state is changed toS0001
, so none of the translators understand the exception.Proposed solution:
Since i could not found another broken exception translation, the vendor code can be added in the sql-error-codes.xml.
The text was updated successfully, but these errors were encountered: