package basearch;

import java.util.HashMap;
import java.util.Map;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableTransactionManagement
public class ApplicationPersistence {

	@Autowired
	private DataSource dataSource;

	@Configuration
	@Profile("default")
	public static class DevelopmentJpaProperties {
		@Bean
		public Map<String,?> jpaProperties() {
			Map<String,String> properties = new HashMap<>();
			properties.put("eclipselink.weaving", "static");
			properties.put("eclipselink.logging.level", "FINE");
			properties.put("eclipselink.cache.shared.default", "false");
			return properties;
		}
	}
	
	@Configuration
	@Profile("production")
	public static class ProductionJpaProperties {
		@Bean
		public Map<String,?> jpaProperties() {
			Map<String,String> properties = new HashMap<>();
			properties.put("eclipselink.weaving", "static");
			properties.put("eclipselink.logging.level", "OFF");
			return properties;
		}
	}

	@Bean
	public LocalContainerEntityManagerFactoryBean entityManagerFactory(Map<String,?> jpaProperties) {
		LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
		factory.setDataSource(dataSource);
		factory.setJpaVendorAdapter(new EclipseLinkJpaVendorAdapter());

		// jpa settings
		factory.setJpaPropertyMap(jpaProperties);

		return factory;
	}

	@Bean
	public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
		JpaTransactionManager manager = new JpaTransactionManager();
		manager.setEntityManagerFactory(entityManagerFactory);
		return manager;
	}

	@Bean
	public PersistenceExceptionTranslationPostProcessor exceptionTranslator() {
		return new PersistenceExceptionTranslationPostProcessor();
	}

}
@@ -871,28 +871,19 @@
 rce;%0A%0A%09@
-Configuratio
+Bea
 n%0A%09@Prof
@@ -909,100 +909,304 @@
 lic 
-static class DevelopmentJpaProperties %7B%0A%09%09@Bean%0A%09%09public Map%3CString,?%3E jpaProperties() %7B
+LocalContainerEntityManagerFactoryBean developmentEntityManagerFactory() %7B%0A%09%09LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();%0A%09%09factory.setDataSource(dataSource);%0A%09%09factory.setJpaVendorAdapter(new EclipseLinkJpaVendorAdapter());%0A%0A%09%09// jpa settings
 %0A%09%09
-%09
 Map%3C
@@ -1242,33 +1242,32 @@
 ew HashMap%3C%3E();%0A
-%09
 %09%09properties.put
@@ -1293,33 +1293,32 @@
 ng%22, %22static%22);%0A
-%09
 %09%09properties.put
@@ -1354,25 +1354,24 @@
  %22FINE%22);%0A%09%09
-%09
 properties.p
@@ -1425,368 +1425,100 @@
 ;%0A%09%09
-%09
-return properties;%0A%09%09%7D%0A%09%7D%0A%09%0A%09@Configuration%0A%09@Profile(%22production%22)%0A%09public static class ProductionJpaProperties %7B%0A%09%09@Bean%0A%09%09public Map%3CString,?%3E jpaProperties() %7B%0A%09%09%09Map%3CString,String%3E properties = new HashMap%3C%3E();%0A%09%09%09properties.put(%22eclipselink.weaving%22, %22static%22);%0A%09%09%09properties.put(%22eclipselink.logging.level%22, %22OFF%22);%0A%09%09%09return properties;%0A%09%09%7D%0A%09%7D%0A%0A%09@Bean
+factory.setJpaPropertyMap(properties);%0A%0A%09%09return factory;%0A%09%7D%0A%0A%09@Bean%0A%09@Profile(%22production%22)
 %0A%09pu
@@ -1561,17 +1561,27 @@
 oryBean 
-e
+productionE
 ntityMan
@@ -1596,35 +1596,8 @@
 ory(
-Map%3CString,?%3E jpaProperties
 ) %7B%0A
@@ -1815,16 +1815,172 @@
 ettings%0A
+%09%09Map%3CString,String%3E properties = new HashMap%3C%3E();%0A%09%09properties.put(%22eclipselink.weaving%22, %22static%22);%0A%09%09properties.put(%22eclipselink.logging.level%22, %22OFF%22);%0A
 %09%09factor
@@ -2003,12 +2003,9 @@
 Map(
-jpaP
+p
 rope

Change entity manager factory definition to something that works