Class ReactiveCassandraAccessor

java.lang.Object
org.springframework.data.cassandra.core.cql.ReactiveCassandraAccessor
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
ReactiveCqlTemplate

public abstract class ReactiveCassandraAccessor extends Object implements org.springframework.beans.factory.InitializingBean
Base class for ReactiveCqlTemplate and other CQL-accessing DAO helpers, defining common properties such as ReactiveSessionFactory and exception translator.

Not intended to be used directly.

Since:
2.0
Author:
Mark Paluch
See Also:
  • Field Details

    • logger

      protected final org.apache.commons.logging.Log logger
      Logger available to subclasses
  • Constructor Details

    • ReactiveCassandraAccessor

      public ReactiveCassandraAccessor()
  • Method Details

    • setSessionFactory

      public void setSessionFactory(ReactiveSessionFactory sessionFactory)
      Sets the ReactiveSessionFactory to use.
      Parameters:
      sessionFactory - must not be null.
    • getSessionFactory

      @Nullable public ReactiveSessionFactory getSessionFactory()
      Returns the configured ReactiveSessionFactory.
      Returns:
      the configured ReactiveSessionFactory.
    • setExceptionTranslator

      public void setExceptionTranslator(CqlExceptionTranslator exceptionTranslator)
      Sets the exception translator used by this template to translate Cassandra specific exceptions into Spring DAO's Exception Hierarchy.
      Parameters:
      exceptionTranslator - exception translator to set; must not be null.
      See Also:
    • getExceptionTranslator

      public CqlExceptionTranslator getExceptionTranslator()
      Returns the exception translator for this instance.
      Returns:
      the Cassandra exception translator.
      See Also:
    • afterPropertiesSet

      public void afterPropertiesSet()
      Ensures the Cassandra ReactiveSessionFactory and exception translator has been properly set.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • translateExceptionIfPossible

      @Nullable protected org.springframework.dao.DataAccessException translateExceptionIfPossible(RuntimeException ex)
      Translate the given DriverException 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:
      ex - the offending DriverException
      Returns:
      the DataAccessException, wrapping the DriverException
      See Also:
    • translate

      protected org.springframework.dao.DataAccessException translate(String task, @Nullable String cql, RuntimeException ex)
      Translate the given DriverException 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 DriverException
      See Also:
    • toCql

      @Nullable protected static String toCql(@Nullable Object cqlProvider)
      Determine CQL from potential provider object.
      Parameters:
      cqlProvider - object that's potentially a CqlProvider
      Returns:
      the CQL string, or null
      Since:
      3.2.7
      See Also: