content: package com.us.example.config;
  
  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.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  import org.springframework.orm.jpa.JpaTransactionManager;
  import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
  import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
  import org.springframework.transaction.PlatformTransactionManager;
  import org.springframework.transaction.annotation.EnableTransactionManagement;
  
  @Configuration
  @EnableJpaRepositories("com.us.example.dao")
  @EnableTransactionManagement
  @ComponentScan
  public class JpaConfig {
  
      @Autowired
      private DataSource dataSource;
  
      @Bean
      public EntityManagerFactory entityManagerFactory() {
          HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
          //vendorAdapter.setShowSql(true);
          //vendorAdapter.setGenerateDdl(true);
  
          LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
          factory.setJpaVendorAdapter(vendorAdapter);
          factory.setPackagesToScan("com.us.example.bean");
          factory.setDataSource(dataSource);
  
  
          Map<String, Object> jpaProperties = new HashMap<String, Object>();
          jpaProperties.put("hibernate.ejb.naming_strategy","org.hibernate.cfg.ImprovedNamingStrategy");
          jpaProperties.put("hibernate.jdbc.batch_size",50);
          //jpaProperties.put("hibernate.show_sql",true);
  
          factory.setJpaPropertyMap(jpaProperties);
          factory.afterPropertiesSet();
          return factory.getObject();
      }
  
      @Bean
      public PlatformTransactionManager transactionManager() {
  
          JpaTransactionManager txManager = new JpaTransactionManager();
          txManager.setEntityManagerFactory(entityManagerFactory());
          return txManager;
      }
  }