Skip to content

JavaConfig - provide more tooling when working with a FactoryBean implementation [SPR-6474] #11140

Closed

Description

@spring-projects-issues

Michael Isvy opened SPR-6474 and commented

Please consider that you need to declare an EntityManagerFactory using JavaConfig.

Currently, the code you need to write looks like this:

@Bean
public EntityManagerFactory entityManagerFactory() { 
        LocalContainerEntityManagerFactoryBean entityManagerFactory = new
        LocalContainerEntityManagerFactoryBean();
        //...
	entityManagerFactory.afterPropertiesSet();
	return entityManagerFactory.getObject();
}

There are 2 things that I can easily forget here: the calls to afterPropertiesSet() and to getObject(). It will be much easier if we provide a convenience class called ConfigurationUtils that we could use in that way:

@Bean
public EntityManagerFactory entityManagerFactory() { 
        LocalContainerEntityManagerFactoryBean entityManagerFactory = new
        LocalContainerEntityManagerFactoryBean();
        //...
	return ConfigurationUtils.proceedFactoryBean(entityManagerFactory);
}

Issue Links:

Activity

  1. spring-projects-issues commented on Aug 3, 2010

    @spring-projects-issues
    CollaboratorAuthor

    Chris Beams commented

    See #12076

  2. added
    type: enhancement
    in: core
    status: duplicate
    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: duplicatetype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions