Example usage for org.springframework.dao.support ChainedPersistenceExceptionTranslator addDelegate

List of usage examples for org.springframework.dao.support ChainedPersistenceExceptionTranslator addDelegate

Introduction

In this page you can find the example usage for org.springframework.dao.support ChainedPersistenceExceptionTranslator addDelegate.

Prototype

public final void addDelegate(PersistenceExceptionTranslator pet) 

Source Link

Document

Add a PersistenceExceptionTranslator to the chained delegate list.

Usage

From source file:org.kuali.rice.krad.data.jpa.JpaPersistenceProvider.java

/**
 * Gets any {@link PersistenceExceptionTranslator}s from the {@link BeanFactory}.
 *
 * @param beanFactory The {@link BeanFactory} to use.
 *
 * @return A {@link PersistenceExceptionTranslator} from the {@link BeanFactory}.
 *///from   ww w.  j  a v a 2s.c o  m
protected PersistenceExceptionTranslator detectPersistenceExceptionTranslators(
        ListableBeanFactory beanFactory) {
    // Find all translators, being careful not to activate FactoryBeans.
    Map<String, PersistenceExceptionTranslator> pets = BeanFactoryUtils
            .beansOfTypeIncludingAncestors(beanFactory, PersistenceExceptionTranslator.class, false, false);
    ChainedPersistenceExceptionTranslator cpet = new ChainedPersistenceExceptionTranslator();
    for (PersistenceExceptionTranslator pet : pets.values()) {
        cpet.addDelegate(pet);
    }
    // always add one last persistence exception translator as a catch all
    cpet.addDelegate(new DefaultPersistenceExceptionTranslator());
    return cpet;
}