use of org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor in project spring-boot by spring-projects.
the class PersistenceExceptionTranslationAutoConfiguration method persistenceExceptionTranslationPostProcessor.
@Bean
@ConditionalOnMissingBean(PersistenceExceptionTranslationPostProcessor.class)
@ConditionalOnProperty(prefix = "spring.dao.exceptiontranslation", name = "enabled", matchIfMissing = true)
public static PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor() {
PersistenceExceptionTranslationPostProcessor postProcessor = new PersistenceExceptionTranslationPostProcessor();
postProcessor.setProxyTargetClass(true);
return postProcessor;
}
use of org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor in project spring-boot by spring-projects.
the class PersistenceExceptionTranslationAutoConfiguration method persistenceExceptionTranslationPostProcessor.
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "spring.dao.exceptiontranslation", name = "enabled", matchIfMissing = true)
public static PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor(Environment environment) {
PersistenceExceptionTranslationPostProcessor postProcessor = new PersistenceExceptionTranslationPostProcessor();
boolean proxyTargetClass = environment.getProperty("spring.aop.proxy-target-class", Boolean.class, Boolean.TRUE);
postProcessor.setProxyTargetClass(proxyTargetClass);
return postProcessor;
}
use of org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor in project spring-boot by spring-projects.
the class PersistenceExceptionTranslationAutoConfigurationTests method exceptionTranslationPostProcessorCanBeConfiguredToUseJdkProxy.
@Test
void exceptionTranslationPostProcessorCanBeConfiguredToUseJdkProxy() {
this.context = new AnnotationConfigApplicationContext();
TestPropertyValues.of("spring.aop.proxy-target-class=false").applyTo(this.context);
this.context.register(PersistenceExceptionTranslationAutoConfiguration.class);
this.context.refresh();
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context.getBeansOfType(PersistenceExceptionTranslationPostProcessor.class);
assertThat(beans).hasSize(1);
assertThat(beans.values().iterator().next().isProxyTargetClass()).isFalse();
}
use of org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor in project spring-boot by spring-projects.
the class PersistenceExceptionTranslationAutoConfigurationTests method exceptionTranslationPostProcessorBeanIsCreated.
@Test
public void exceptionTranslationPostProcessorBeanIsCreated() {
this.context = new AnnotationConfigApplicationContext(PersistenceExceptionTranslationAutoConfiguration.class);
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context.getBeansOfType(PersistenceExceptionTranslationPostProcessor.class);
assertThat(beans).hasSize(1);
assertThat(beans.values().iterator().next().isProxyTargetClass()).isTrue();
}
use of org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor in project spring-boot by spring-projects.
the class PersistenceExceptionTranslationAutoConfigurationTests method exceptionTranslationPostProcessorBeanIsDisabled.
@Test
public void exceptionTranslationPostProcessorBeanIsDisabled() {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "spring.dao.exceptiontranslation.enabled=false");
this.context.register(PersistenceExceptionTranslationAutoConfiguration.class);
this.context.refresh();
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context.getBeansOfType(PersistenceExceptionTranslationPostProcessor.class);
assertThat(beans.entrySet()).isEmpty();
}
Aggregations