Detect MSSQL code 2601 as duplicate key (aligned with sql-error-codes.xml)

Closes gh-29950
This commit is contained in:
Juergen Hoeller
2023-02-09 14:59:09 +01:00
parent 5819d76d98
commit ca9439657e
5 changed files with 18 additions and 8 deletions

View File

@@ -59,6 +59,7 @@ public class SQLExceptionSubclassTranslatorTests {
doTest(new SQLIntegrityConstraintViolationException("", "23505", 0), DuplicateKeyException.class);
doTest(new SQLIntegrityConstraintViolationException("", "23000", 1), DuplicateKeyException.class);
doTest(new SQLIntegrityConstraintViolationException("", "23000", 1062), DuplicateKeyException.class);
doTest(new SQLIntegrityConstraintViolationException("", "23000", 2601), DuplicateKeyException.class);
doTest(new SQLIntegrityConstraintViolationException("", "23000", 2627), DuplicateKeyException.class);
doTest(new SQLInvalidAuthorizationSpecException("", "", 0), PermissionDeniedDataAccessException.class);
doTest(new SQLNonTransientConnectionException("", "", 0), DataAccessResourceFailureException.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,7 +72,12 @@ public class SQLStateSQLExceptionTranslatorTests {
}
@Test
public void translateDuplicateKeyMSSQL() {
public void translateDuplicateKeyMSSQL1() {
doTest("23000", 2601, DuplicateKeyException.class);
}
@Test
public void translateDuplicateKeyMSSQL2() {
doTest("23000", 2627, DuplicateKeyException.class);
}