Skip to content

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

Closed
@spring-projects-issues

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:

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