Skip to content

Mixing PersistenceExceptionTranslator logic into FactoryBeans prevents using PersistenceExeptionTranslationPostProcessor with @Configuration classes [SPR-7387] #12045

Closed
@spring-projects-issues

Description

@spring-projects-issues

Baruch Sadogursky opened SPR-7387 and commented

This is clear Single responsibility principle violation.
The implementation logic of PersistenceExceptionTranslator resides into various FactoryBeans (LocalSessionFactoryBean, LocalEntityManagerFactoryBean, etc) and there is no way to introduce translators to ApplicationContext for PersistenceExeptionTranslationPostProcessor to find them without adding the FactoryBeans to ApplicationContext.
It works fine for xml metadata, since we add the FactoryBeans to the context anyway.
This is not the case when working with Java @Configuration classes. In them we don't expose FactoryBeans to ApplicationContext, but use them internally in @Bean methods, returning only the result of the getObject() call. This way there are no PersistenceExceptionTranslators in the ApplicationContext and PersistenceExeptionTranslationPostProcessor fails.


Affects: 3.0.3

Attachments:

Issue Links:

Referenced from: commits 3bb01ee

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: duplicateA duplicate of another issuetype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions