SQLErrorCodesResolver
which moved
to jakarta.@Deprecated public class SQLErrorCodesResolver extends Object implements PersistenceExceptionResolver
This implementation will attempt to locate these error codes in the SQLException.getErrorCode()
and
SQLException.getSQLState()
, respectively.
Constructor and Description |
---|
SQLErrorCodesResolver(DataSource dataSource)
Deprecated.
Initialize a SQLErrorCodesResolver, automatically detecting the database name through the given dataSource.
|
SQLErrorCodesResolver(List<Integer> duplicateKeyCodes)
Deprecated.
Initializes the SQLErrorCodesResolver using the given list of SQL Codes representing Key Constraint Violations.
|
SQLErrorCodesResolver(Properties properties,
DataSource dataSource)
Deprecated.
Initialize the SQLErrorCodesResolver with the given
properties and use the dataSource
to automatically retrieve the database product name. |
SQLErrorCodesResolver(Properties properties,
String databaseProductName)
Deprecated.
Initialize a SQLErrorCodesResolver, automatically detecting the database name through the given dataSource.
|
SQLErrorCodesResolver(String databaseProductName)
Deprecated.
Initialize a SQLErrorCodesResolver, automatically detecting the database name through the given dataSource.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
isDuplicateKeyCode(SQLException sqlException,
List<Integer> errorCodes)
Deprecated.
|
boolean |
isDuplicateKeyViolation(Exception exception)
Deprecated.
Indicates whether the given
exception represents a duplicate key violation. |
public SQLErrorCodesResolver(List<Integer> duplicateKeyCodes)
duplicateKeyCodes
- A list of Integer containing SQL Codes representing Key Constraint Violationspublic SQLErrorCodesResolver(DataSource dataSource) throws SQLException
dataSource
- The data source providing the information about the backing database.SQLException
- when retrieving the database product name failsAxonConfigurationException
- is the dataSource returns an unknown database product name. Use SQLErrorCodesResolver(Properties, DataSource)
instead.public SQLErrorCodesResolver(String databaseProductName)
databaseProductName
- The product name of the databaseAxonConfigurationException
- is the dataSource returns an unknown database product name. Use SQLErrorCodesResolver(Properties, String)
instead.public SQLErrorCodesResolver(Properties properties, String databaseProductName)
databaseName
.duplicateKeyCodes=keyCode[,keyCode]*
databaseName
is the database product name as returned by the driver, with spaces ('
') replaced by underscore ('_'). The key codes must be a comma separated list of SQL Error code numbers (int).properties
- the properties defining SQL Error Codes for Duplicate Key violations for different
databasesdatabaseProductName
- The product name of the databasepublic SQLErrorCodesResolver(Properties properties, DataSource dataSource) throws SQLException
properties
and use the dataSource
to automatically retrieve the database product name.
The form of the properties is expected to be:databaseName
.duplicateKeyCodes=keyCode[,keyCode]*
databaseName
is the database product name as returned by the driver, with spaces ('
') replaced by underscore ('_'). The key codes must be a comma separated list of SQL Error code numbers (int).properties
- the properties defining SQL Error Codes for Duplicate Key violations for different databasesdataSource
- The data source providing the database product nameSQLException
- when retrieving the database product name failspublic boolean isDuplicateKeyViolation(Exception exception)
PersistenceExceptionResolver
exception
represents a duplicate key violation. Typically, duplicate key
violations indicates concurrent access to an entity in the application. Two users might be accessing the same
Aggregate, for example.isDuplicateKeyViolation
in interface PersistenceExceptionResolver
exception
- The exception to evaluatetrue
if the given exception represents a Duplicate Key Violation, false
otherwise.protected boolean isDuplicateKeyCode(SQLException sqlException, List<Integer> errorCodes)
sqlException
- The exception to locate the error code inerrorCodes
- The error codes indicating duplicate key violationstrue
if the error code of the sqlException
is in the given list of errorCodes
, otherwise
false
Copyright © 2010–2024. All rights reserved.