Class PersistenceExceptionTranslationPostProcessor
- All Implemented Interfaces:
- Serializable, AopInfrastructureBean, Aware, BeanClassLoaderAware, BeanFactoryAware, BeanPostProcessor, InstantiationAwareBeanPostProcessor, SmartInstantiationAwareBeanPostProcessor, Ordered
Repository
annotation, adding a corresponding PersistenceExceptionTranslationAdvisor to
the exposed proxy (either an existing AOP proxy or a newly generated proxy that
implements all of the target's interfaces).
Translates native resource exceptions to Spring's
DataAccessException hierarchy.
Autodetects beans that implement the
PersistenceExceptionTranslator interface, which are subsequently asked to translate
candidate exceptions.
All of Spring's applicable resource factories (for example,
LocalContainerEntityManagerFactoryBean)
implement the PersistenceExceptionTranslator interface out of the box.
As a consequence, all that is usually needed to enable automatic exception
translation is marking all affected beans (such as Repositories or DAOs)
with the @Repository annotation, along with defining this post-processor
as a bean in the application context.
PersistenceExceptionTranslator beans are sorted according to Spring's
dependency ordering rules: see Ordered and
Order. Note that such beans will
get retrieved from any scope, not just singleton scope.
- Since:
- 2.0
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
- 
Field SummaryFields inherited from class AbstractBeanFactoryAwareAdvisingPostProcessorbeanFactoryFields inherited from class AbstractAdvisingBeanPostProcessoradvisor, beforeExistingAdvisorsFields inherited from interface OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidsetBeanFactory(BeanFactory beanFactory) Callback that supplies the owning factory to a bean instance.voidsetRepositoryAnnotationType(Class<? extends Annotation> repositoryAnnotationType) Set the 'repository' annotation type.Methods inherited from class AbstractBeanFactoryAwareAdvisingPostProcessorisEligible, prepareProxyFactoryMethods inherited from class AbstractAdvisingBeanPostProcessorcustomizeProxyFactory, determineBeanType, isEligible, postProcessAfterInitialization, setBeforeExistingAdvisorsMethods inherited from class ProxyProcessorSupportevaluateProxyInterfaces, getOrder, getProxyClassLoader, isConfigurationCallbackInterface, isInternalLanguageInterface, setBeanClassLoader, setOrder, setProxyClassLoaderMethods inherited from class ProxyConfigcopyDefault, copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toStringMethods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface BeanPostProcessorpostProcessBeforeInitializationMethods inherited from interface InstantiationAwareBeanPostProcessorpostProcessAfterInstantiation, postProcessBeforeInstantiation, postProcessPropertiesMethods inherited from interface SmartInstantiationAwareBeanPostProcessordetermineCandidateConstructors, getEarlyBeanReference, predictBeanType
- 
Constructor Details- 
PersistenceExceptionTranslationPostProcessorpublic PersistenceExceptionTranslationPostProcessor()
 
- 
- 
Method Details- 
setRepositoryAnnotationTypeSet the 'repository' annotation type. The default repository annotation type is theRepositoryannotation.This setter property exists so that developers can provide their own (non-Spring-specific) annotation type to indicate that a class has a repository role. - Parameters:
- repositoryAnnotationType- the desired annotation type
 
- 
setBeanFactoryDescription copied from interface:BeanFactoryAwareCallback that supplies the owning factory to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean.afterPropertiesSet()or a custom init-method.- Specified by:
- setBeanFactoryin interface- BeanFactoryAware
- Overrides:
- setBeanFactoryin class- AbstractBeanFactoryAwareAdvisingPostProcessor
- Parameters:
- beanFactory- owning BeanFactory (never- null). The bean can immediately call methods on the factory.
- See Also:
 
 
-