@Bean public EntityManagerFactory entityManagerFactory() { Properties jpaProterties = new Properties(); jpaProterties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect")); jpaProterties.put( "hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql")); jpaProterties.put( "hibernate.ejb.naming_strategy", environment.getRequiredProperty("hibernate.ejb.naming_strategy")); jpaProterties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql")); jpaProterties.put( "hibernate.generate_statistics", environment.getRequiredProperty("hibernate.generate_statistics")); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(false); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("br.com.uol.cubus.support.domain"); factory.setDataSource(dataSource()); factory.setJpaProperties(jpaProterties); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean(name = "entityManagerFactory") public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setDataSource(dataSource()); factoryBean.setPersistenceUnitName("a1ecommerceEntityManager"); factoryBean.setPackagesToScan(new String[] {"com.a1electronics.ecommerce.dbo"}); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); factoryBean.setJpaVendorAdapter(vendorAdapter); Properties jpaProperties = new Properties(); // Configures the used database dialect. This allows Hibernate to create // SQL // that is optimized for the used database. jpaProperties.put("hibernate.dialect", env.getRequiredProperty("hibernate.dialect")); // If the value of this property is true, Hibernate writes all SQL // statements to the console. jpaProperties.put("hibernate.show_sql", env.getRequiredProperty("hibernate.show_sql")); // If the value of this property is true, Hibernate will format the SQL // that is written to the console. jpaProperties.put("hibernate.format_sql", env.getRequiredProperty("hibernate.format_sql")); // jpaProperties.put("hibernate.hbm2ddl.auto",env.getRequiredProperty("hibernate.hbm2ddl.auto")); // To fix the followinf issue // HHH000424: Disabling contextual LOB creation as createClob() method threw error : // java.lang.reflect.InvocationTargetException jpaProperties.put("hibernate.temp.use_jdbc_metadata_defaults", false); factoryBean.setJpaProperties(jpaProperties); factoryBean.afterPropertiesSet(); factoryBean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); // factoryBean.setPersistenceUnitName(env.getRequiredProperty("persistence.unitName")); return factoryBean; }
@Bean() public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean(); retVal.setPersistenceUnitName("HAPI_PU"); retVal.setDataSource(dataSource()); retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity"); retVal.setPersistenceProvider(new HibernatePersistenceProvider()); retVal.setJpaProperties(jpaProperties()); retVal.afterPropertiesSet(); return retVal; }
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.kjipo.event"); // TODO Is there another way to attach the data source to the EntityManagerFactory? factory.setDataSource(dataSource); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setShowSql(showSql()); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.softtech.web.model"); factory.setJpaProperties(additionalProperties()); factory.setDataSource(dataSource()); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setShowSql(true); HashMap<String, String> hibernateProperties = new HashMap<String, String>(); hibernateProperties.put("hibernate.hbm2ddl.auto", "create-drop"); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("org.chikoo.core.model.entity"); factory.setJpaPropertyMap(hibernateProperties); factory.setDataSource(dataSource()); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setGenerateDdl(true); hibernateJpaVendorAdapter.setShowSql(true); LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource); emf.setPackagesToScan("po"); emf.setJpaVendorAdapter(hibernateJpaVendorAdapter); Properties properties = new Properties(); properties.setProperty("hibernate.hbm2ddl.auto", "create-drop"); properties.setProperty("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect"); emf.setJpaProperties(properties); emf.afterPropertiesSet(); return emf.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan( new ConfigAccessor() .get() .getDataSources() .get(new ConfigAccessor().get().getDefaultDataSourceName()) .toArray(new String[0])); factory.setDataSource(dataSource); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(Boolean.TRUE); vendorAdapter.setShowSql(Boolean.TRUE); factory.setDataSource(dataSource()); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("br.edu.ifes.scel.entities"); Properties jpaProperties = new Properties(); jpaProperties.put("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); factory.setJpaProperties(jpaProperties); factory.afterPropertiesSet(); factory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); return factory; }