Class DefaultJdbcOptimisticLockingExceptionMapper

  • All Implemented Interfaces:
    JdbcOptimisticLockingExceptionMapper

    public class DefaultJdbcOptimisticLockingExceptionMapper
    extends Object
    implements JdbcOptimisticLockingExceptionMapper
    A default JdbcOptimisticLockingExceptionMapper which checks the caused exception (and its nested) whether any of them is a constraint violation exception.

    The following check is done:

    • If the caused exception is an SQLException
    • then the SQLState is checked if starts with 23.
    • If the caused exception is a DataIntegrityViolationException
    • If the caused exception class name has ConstraintViolation
    • in its name.
    • optional checking for FQN class name matches if any class names has been configured
    In addition you can add FQN classnames using the addClassName(String) or setClassNames(java.util.Set) methods. These class names is also matched. This allows to add vendor specific exception classes.
    • Constructor Detail

      • DefaultJdbcOptimisticLockingExceptionMapper

        public DefaultJdbcOptimisticLockingExceptionMapper()
    • Method Detail

      • isOptimisticLocking

        public boolean isOptimisticLocking​(Exception cause)
        Description copied from interface: JdbcOptimisticLockingExceptionMapper
        Checks the caused exception whether its to be considered as an OptimisticLockingAggregationRepository.OptimisticLockingException.
        Specified by:
        isOptimisticLocking in interface JdbcOptimisticLockingExceptionMapper
        Parameters:
        cause - the caused exception
        Returns:
        true if the caused should be rethrown as an OptimisticLockingAggregationRepository.OptimisticLockingException.
      • isConstraintViolation

        public static boolean isConstraintViolation​(SQLException e)
      • addClassName

        public void addClassName​(String name)
      • setClassNames

        public void setClassNames​(Set<String> names)