Class SQLStateResolver
java.lang.Object
org.axonframework.eventsourcing.eventstore.jpa.SQLStateResolver
- All Implemented Interfaces:
PersistenceExceptionResolver
SQLStateResolver is an implementation of PersistenceExceptionResolver used to resolve sql state values to see if it
violates a unique key constraint.
SQL state codes are standardized - the leading two characters identifying the category. Integrity constraint
violations are in category 23. Some database systems further specify these state codes, e.g. postgres uses 23505 for
a unique key violation.
- Author:
- Jochen Munz
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor that uses the standard SQL state category for the check.SQLStateResolver(String checkState) Constructor that can be used to supply a specific SQL state code for the check. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisDuplicateKeyViolation(Exception exception) Indicates whether the givenexceptionrepresents a duplicate key violation.
-
Constructor Details
-
SQLStateResolver
public SQLStateResolver()Constructor that uses the standard SQL state category for the check. -
SQLStateResolver
Constructor that can be used to supply a specific SQL state code for the check. The check is done using startsWith(), supplying a substring of the state code is ok.- Parameters:
checkState- The state string that is used in the check.
-
-
Method Details
-
isDuplicateKeyViolation
Description copied from interface:PersistenceExceptionResolverIndicates whether the givenexceptionrepresents 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.- Specified by:
isDuplicateKeyViolationin interfacePersistenceExceptionResolver- Parameters:
exception- The exception to evaluate- Returns:
trueif the given exception represents a Duplicate Key Violation,falseotherwise.
-