@Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean()
      throws ClassNotFoundException {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPackagesToScan(
        environment.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);

    Properties jpaProterties = new Properties();
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_DIALECT,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_FORMAT_SQL,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_SHOW_SQL,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));

    entityManagerFactoryBean.setJpaProperties(jpaProterties);

    return entityManagerFactoryBean;
  }
 @Bean
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
   em.setDataSource(dataSource());
   em.setLoadTimeWeaver(instrumentationLoadTimeWeaver());
   em.setPersistenceProviderClass(HibernatePersistenceProvider.class);
   return em;
 }
 @Bean(name = "entityManagerFactory")
 @DependsOn({"liquibase", "dataSource"})
 FactoryBean<EntityManagerFactory> emf(JpaVendorAdapter jpaVendorAdapter) {
   SimpleHiloIdentifierGenerator.setDataSource(dataSource());
   LocalContainerEntityManagerFactoryBean fb = new LocalContainerEntityManagerFactoryBean();
   fb.setJpaProperties(hibernateProperties());
   fb.setDataSource(dataSource());
   fb.setPersistenceProviderClass(HibernatePersistence.class);
   fb.setPackagesToScan("io.cloudslang");
   fb.setJpaVendorAdapter(jpaVendorAdapter);
   return fb;
 }
Exemple #4
0
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
    entityManagerFactoryBean.setPackagesToScan(
        env.getRequiredProperty(PROP_ENTITYMANAGER_PACKAGES_TO_SCAN));

    entityManagerFactoryBean.setJpaProperties(getHibernateProperties());

    return entityManagerFactoryBean;
  }
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws URISyntaxException {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);
    entityManagerFactoryBean.setJpaProperties(hibProperties());
    entityManagerFactoryBean.setPackagesToScan(
        env.getRequiredProperty(PROPERTY_HIBERNATE_PACKAGES_TO_SCAN));
    entityManagerFactoryBean.setPersistenceUnitName("javapress");

    return entityManagerFactoryBean;
  }
 @Bean
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
   factory.setDataSource(dataSource());
   factory.setPackagesToScan(MyVaadinUI.class.getPackage().getName());
   factory.setPackagesToScan(PrisonStayDAO.class.getPackage().getName());
   factory.setPackagesToScan(Prisoner.class.getPackage().getName());
   factory.setPersistenceProviderClass(org.hibernate.jpa.HibernatePersistenceProvider.class);
   HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
   adapter.setShowSql(true);
   factory.setJpaVendorAdapter(adapter);
   factory.getJpaPropertyMap().put("hibernate.format_sql", true);
   factory.getJpaPropertyMap().put("hibernate.use_sql_comments", true);
   return factory;
 }