类 PersistenceExceptionTranslationPostProcessor
- java.lang.Object
- org.springframework.aop.framework.ProxyConfig
- org.springframework.aop.framework.ProxyProcessorSupport
- org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor
- org.springframework.aop.framework.autoproxy.AbstractBeanFactoryAwareAdvisingPostProcessor
- org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor
- 所有已实现的接口:
Serializable
,AopInfrastructureBean
,Aware
,BeanClassLoaderAware
,BeanFactoryAware
,BeanPostProcessor
,Ordered
public class PersistenceExceptionTranslationPostProcessor extends AbstractBeanFactoryAwareAdvisingPostProcessor
Bean post-processor that automatically applies persistence exception translation to any bean marked with Spring's @Repository
annotation, adding a correspondingPersistenceExceptionTranslationAdvisor
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 thePersistenceExceptionTranslator
interface, which are subsequently asked to translate candidate exceptions.All of Spring's applicable resource factories (e.g.
LocalContainerEntityManagerFactoryBean
) implement thePersistenceExceptionTranslator
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.- 从以下版本开始:
- 2.0
- 作者:
- Rod Johnson, Juergen Hoeller
- 另请参阅:
PersistenceExceptionTranslationAdvisor
,Repository
,DataAccessException
,PersistenceExceptionTranslator
, 序列化表格
字段概要
从类继承的字段 org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor
advisor, beforeExistingAdvisors
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 PersistenceExceptionTranslationPostProcessor()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance.void
setRepositoryAnnotationType(Class<? extends Annotation> repositoryAnnotationType)
Set the 'repository' annotation type.从类继承的方法 org.springframework.aop.framework.autoproxy.AbstractBeanFactoryAwareAdvisingPostProcessor
prepareProxyFactory
从类继承的方法 org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor
customizeProxyFactory, isEligible, isEligible, postProcessAfterInitialization, postProcessBeforeInitialization, setBeforeExistingAdvisors
从类继承的方法 org.springframework.aop.framework.ProxyProcessorSupport
evaluateProxyInterfaces, getOrder, getProxyClassLoader, isConfigurationCallbackInterface, isInternalLanguageInterface, setBeanClassLoader, setOrder, setProxyClassLoader
从类继承的方法 org.springframework.aop.framework.ProxyConfig
copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString
构造器详细资料
PersistenceExceptionTranslationPostProcessor
public PersistenceExceptionTranslationPostProcessor()
方法详细资料
setRepositoryAnnotationType
public void setRepositoryAnnotationType(Class<? extends Annotation> repositoryAnnotationType)
Set the 'repository' annotation type. The default repository annotation type is theRepository
annotation.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.
- 参数:
repositoryAnnotationType
- the desired annotation type
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
从接口复制的说明:BeanFactoryAware
Callback 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.- 指定者:
setBeanFactory
在接口中BeanFactoryAware
- 覆盖:
setBeanFactory
在类中AbstractBeanFactoryAwareAdvisingPostProcessor
- 参数:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- 另请参阅:
BeanInitializationException