@Bean LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,Environment env){
  LocalContainerEntityManagerFactoryBean entityManagerFactoryBean=new LocalContainerEntityManagerFactoryBean();
  entityManagerFactoryBean.setDataSource(dataSource);
  entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
  entityManagerFactoryBean.setPackagesToScan(ENTITY_PACKAGES);
  Properties jpaProperties=new Properties();
  jpaProperties.put(PROPERTY_NAME_HIBERNATE_DIALECT,env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
  jpaProperties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO,env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO));
  jpaProperties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY,env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
  jpaProperties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL,env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
  jpaProperties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL,env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
  entityManagerFactoryBean.setJpaProperties(jpaProperties);
  return entityManagerFactoryBean;
}

@ Bean LocalContainerEntityManagerFactoryBean entityManagerFactory ( DataSource dataSource , Environment env ) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean ( ) ; entityManagerFactoryBean . setDataSource ( dataSource ) ; entityManagerFactoryBean . setJpaVendorAdapter ( new HibernateJpaVendorAdapter ( ) ) ; entityManagerFactoryBean . setPackagesToScan ( ENTITY_PACKAGES ) ; Properties jpaProperties = new Properties ( ) ; jpaProperties . put ( PROPERTY_NAME_HIBERNATE_DIALECT , env . getRequiredProperty ( PROPERTY_NAME_HIBERNATE_DIALECT ) ) ; jpaProperties . put ( PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO , env . getRequiredProperty ( PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO ) ) ; jpaProperties . put ( PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY , env . getRequiredProperty ( PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY ) ) ; jpaProperties . put ( PROPERTY_NAME_HIBERNATE_SHOW_SQL , env . getRequiredProperty ( PROPERTY_NAME_HIBERNATE_SHOW_SQL ) ) ; jpaProperties . put ( PROPERTY_NAME_HIBERNATE_FORMAT_SQL , env . getRequiredProperty ( PROPERTY_NAME_HIBERNATE_FORMAT_SQL ) ) ; entityManagerFactoryBean . setJpaProperties ( jpaProperties ) ; return entityManagerFactoryBean ; }
creates the bean that creates the jpa entity manager factory .
