Interface CqlExceptionTranslator

All Superinterfaces:
org.springframework.dao.support.PersistenceExceptionTranslator
All Known Implementing Classes:
CassandraExceptionTranslator
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface CqlExceptionTranslator extends org.springframework.dao.support.PersistenceExceptionTranslator
Strategy interface for translating between driver exceptions and Spring's data access strategy-agnostic DataAccessException hierarchy.
Author:
Mark Paluch
See Also:
  • DataAccessException
  • Method Summary

    Modifier and Type
    Method
    Description
    default org.springframework.dao.DataAccessException
    Translate the given RuntimeException into a generic DataAccessException.

    Methods inherited from interface org.springframework.dao.support.PersistenceExceptionTranslator

    translateExceptionIfPossible
  • Method Details

    • translate

      default org.springframework.dao.DataAccessException translate(@Nullable String task, @Nullable String cql, RuntimeException ex)
      Translate the given RuntimeException into a generic DataAccessException.

      The returned DataAccessException is supposed to contain the original DriverException as root cause. However, client code may not generally rely on this due to DataAccessExceptions possibly being caused by other resource APIs as well. That said, a getRootCause() instanceof DataAccessException check (and subsequent cast) is considered reliable when expecting Cassandra-based access to have happened.

      Parameters:
      task - readable text describing the task being attempted.
      cql - CQL query or update that caused the problem (may be null).
      ex - the offending DriverException.
      Returns:
      the DataAccessException, wrapping the RuntimeException.
      See Also:
      • NestedRuntimeException.getRootCause()