-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: duplicateA duplicate of another issueA duplicate of another issuetype: enhancementA general enhancementA general enhancement
Description
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:
- Provide alternatives to using FactoryBean types within @Bean methods [SPR-7418] #12076 Provide alternatives to using FactoryBean types within
@Bean
methods ("is superseded by")
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: duplicateA duplicate of another issueA duplicate of another issuetype: enhancementA general enhancementA general enhancement