Top Description Fields Constructors Methods
org.springframework.dao.support

public Class ChainedPersistenceExceptionTranslator

extends Object
implements PersistenceExceptionTranslator
Class Inheritance
All Implemented Interfaces
org.springframework.dao.support.PersistenceExceptionTranslator
Imports
java.util.ArrayList, .List, org.springframework.dao.DataAccessException, org.springframework.lang.Nullable, org.springframework.util.Assert

Implementation of PersistenceExceptionTranslator that supports chaining, allowing the addition of PersistenceExceptionTranslator instances in order. Returns non-null on the first (if any) match.
Authors
Rod Johnson, Juergen Hoeller
Since
2.0

Field Summary

Modifier and TypeField and Description
private final List<PersistenceExceptionTranslator>
delegates

List of PersistenceExceptionTranslators.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final void
addDelegate(PersistenceExceptionTranslator pet)

Add a PersistenceExceptionTranslator to the chained delegate list.

public final PersistenceExceptionTranslator[]
getDelegates()

Return all registered PersistenceExceptionTranslator delegates (as array).

public DataAccessException
translateExceptionIfPossible(RuntimeException
a RuntimeException to translate
ex
)

Implements org.springframework.dao.support.PersistenceExceptionTranslator.translateExceptionIfPossible.

Translate the given runtime exception thrown by a persistence framework to a corresponding exception from Spring's generic org.springframework.dao.DataAccessException hierarchy, if possible.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegatesback to summary
private final List<PersistenceExceptionTranslator> delegates

List of PersistenceExceptionTranslators.

Constructor Detail

ChainedPersistenceExceptionTranslatorback to summary
public ChainedPersistenceExceptionTranslator()

Method Detail

addDelegateback to summary
public final void addDelegate(PersistenceExceptionTranslator pet)

Add a PersistenceExceptionTranslator to the chained delegate list.

getDelegatesback to summary
public final PersistenceExceptionTranslator[] getDelegates()

Return all registered PersistenceExceptionTranslator delegates (as array).

translateExceptionIfPossibleback to summary
public DataAccessException translateExceptionIfPossible(RuntimeException ex)

Implements org.springframework.dao.support.PersistenceExceptionTranslator.translateExceptionIfPossible.

Doc from org.springframework.dao.support.PersistenceExceptionTranslator.translateExceptionIfPossible.

Translate the given runtime exception thrown by a persistence framework to a corresponding exception from Spring's generic org.springframework.dao.DataAccessException hierarchy, if possible.

Do not translate exceptions that are not understood by this translator: for example, if coming from another persistence framework, or resulting from user code or otherwise unrelated to persistence.

Of particular importance is the correct translation to DataIntegrityViolationException, for example on constraint violation. Implementations may use Spring JDBC's sophisticated exception translation to provide further information in the event of SQLException as a root cause.

Parameters
ex:RuntimeException

a RuntimeException to translate

Returns:DataAccessException

the corresponding DataAccessException (or null if the exception could not be translated, as in this case it may result from user code rather than from an actual persistence problem)

Annotations
@Override
@Nullable