cleanup work

This commit is contained in:
eugenp 2015-01-31 20:57:57 +02:00
parent 54c49c7f81
commit 7b531f0ce6
2 changed files with 16 additions and 10 deletions

View File

@ -29,8 +29,10 @@ public class ProductConfig {
super();
}
@Bean(name = "productEntityManager")
public LocalContainerEntityManagerFactoryBean productEntityManagerFactory() {
//
@Bean
public LocalContainerEntityManagerFactoryBean productEntityManager() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(productDataSource());
em.setPackagesToScan(new String[] { "org.baeldung.persistence.multiple.model.product" });
@ -56,10 +58,10 @@ public class ProductConfig {
return dataSource;
}
@Bean(name = "productTransactionManager")
public PlatformTransactionManager transactionManager() {
@Bean
public PlatformTransactionManager productTransactionManager() {
final JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(productEntityManagerFactory().getObject());
transactionManager.setEntityManagerFactory(productEntityManager().getObject());
return transactionManager;
}

View File

@ -30,8 +30,11 @@ public class UserConfig {
super();
}
@Bean(name = "userEntityManager")
public LocalContainerEntityManagerFactoryBean userEntityManagerFactory() {
//
@Primary
@Bean
public LocalContainerEntityManagerFactoryBean userEntityManager() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(userDataSource());
em.setPackagesToScan(new String[] { "org.baeldung.persistence.multiple.model.user" });
@ -46,6 +49,7 @@ public class UserConfig {
return em;
}
@Primary
@Bean
public DataSource userDataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
@ -58,10 +62,10 @@ public class UserConfig {
}
@Primary
@Bean(name = "userTransactionManager")
public PlatformTransactionManager transactionManager() {
@Bean
public PlatformTransactionManager userTransactionManager() {
final JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(userEntityManagerFactory().getObject());
transactionManager.setEntityManagerFactory(userEntityManager().getObject());
return transactionManager;
}