Skip to content

Introduce EntityManagerFactoryBuilder types [SPR-8128] #12779

Closed

Description

@spring-projects-issues

Chris Beams opened SPR-8128 and commented


This issue is a sub-task of #12076

Issue Links:

Activity

  1. spring-projects-issues commented on Jun 1, 2011

    @spring-projects-issues
    CollaboratorAuthor

    Chris Beams commented

    Deferring this issue indefinitely. After quite a bit of work on this front, it is simply not straightforward to map the current EntityManagerFactoryBeans onto the same kind of builder style approach that (Annotation)SessionFactoryBuilder follows in the Hibernate world.

    The implementation I've worked up is fully functional, but suffers from the need to inject the bean ClassLoader, LoadTimeWeaver and ResourceLoader into the Builder before it can be properly used. There's really no way around this, and it's just not a great usage story.

    Fortunately, in the JPA world, it's not common to actually directly inject the EntityManagerFactory due to the way that @PersistenceContext works.

    For this reason, it's actually reasonable for users to configure and return a Local(Container)EntityManagerFactoryBean from a @Bean method - it has no real downside, because that @Bean method will probably never be referenced for injection purposes.

    This is a minor concession - it would be nice to tell users that it's never necessary to return a FactoryBean from a @Bean method, but considering the alternative, this is probably an acceptable exception. As mentioned above, #12965 will round this support out with the introduction of @EnableLoadTimeWeaving, for JPA implementations (EclipseLink) that depend on it.

    For future reference, I've committed the fully functioning branch of work to https://github.com/cbeams/spring-framework/tree/SPR-8128.

  2. added
    status: declined
    in: core
    type: task
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: corestatus: declinedtype: task

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions