@Bean JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); adapter.setShowSql(true); adapter.setGenerateDdl(true); return adapter; }
@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 public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setGenerateDdl(true); hibernateJpaVendorAdapter.setDatabase(Database.MYSQL); hibernateJpaVendorAdapter.setShowSql(showsql); return hibernateJpaVendorAdapter; }
@Bean public HibernateJpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter(); jpaVendorAdapter.setShowSql(true); jpaVendorAdapter.setGenerateDdl(true); jpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.H2Dialect"); return jpaVendorAdapter; }
@Bean public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); adapter.setDatabase(Database.MYSQL); adapter.setGenerateDdl(true); return adapter; }
@Bean public HibernateJpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setDatabase(Database.MYSQL); vendorAdapter.setShowSql(true); return vendorAdapter; }
private HibernateJpaVendorAdapter hibernateJpaVendorAdapter() { HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setDatabase(Database.POSTGRESQL); hibernateJpaVendorAdapter.setShowSql(true); hibernateJpaVendorAdapter.setGenerateDdl(true); hibernateJpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.PostgreSQL9Dialect"); return hibernateJpaVendorAdapter; }
@Bean public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); adapter.setDatabase(Database.valueOf(env.getProperty("spring.database.vendor"))); // adapter.setDatabase(Database.H2); // adapter.setShowSql(true); // adapter.setGenerateDdl(false); // adapter.setDatabasePlatform("org.hibernate.dialect.H2Dialect"); return adapter; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setDatabase(Database.MYSQL); vendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan(getClass().getPackage().getName()); factory.setDataSource(dataSource()); return factory; }
@Bean LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setDatabase(Database.MYSQL); vendorAdapter.setGenerateDdl(true); vendorAdapter.setShowSql(false); factoryBean.setPackagesToScan("com.magic.app.**.entities"); factoryBean.setJpaVendorAdapter(vendorAdapter); factoryBean.setDataSource(dataSource()); return factoryBean; }
@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 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; }
@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 LocalContainerEntityManagerFactoryBean entityManagerFactory(Environment env) throws Exception { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(Boolean.TRUE); vendorAdapter.setShowSql(Boolean.TRUE); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.dawidkotarba.playground.model.entities"); factory.setDataSource(dataSource(env)); factory.setJpaProperties(jpaProperties()); factory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); return factory; }
@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(); }
/** * @return * @throws DataServiceException * @throws EncryptionException */ @Bean(name = "rgbycchEmf") public LocalContainerEntityManagerFactoryBean configureEntityManagerFactory() { LOG.debug("creating instance of LocalContainerEntityManagerFactoryBean (emf)"); LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource()); entityManagerFactoryBean.setPackagesToScan("com.gffny.rgbycch.model"); LOG.debug("creating instance of HibernateJpaVendorAdapter with dialect {}", dialect); HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setDatabasePlatform(dialect); entityManagerFactoryBean.setJpaVendorAdapter(hibernateJpaVendorAdapter); entityManagerFactoryBean.setPersistenceUnitName("rgbycchPU"); Map<String, Object> jpaProperties = entityManagerFactoryBean.getJpaPropertyMap(); jpaProperties.put(org.hibernate.cfg.Environment.DIALECT, dialect); jpaProperties.put(org.hibernate.cfg.Environment.HBM2DDL_AUTO, hbm2ddlAuto); jpaProperties.put(org.hibernate.cfg.Environment.SHOW_SQL, showSql); jpaProperties.put(org.hibernate.cfg.Environment.FORMAT_SQL, formatSql); jpaProperties.put(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, true); // enable ordered and batches inserts and updates to improve performance // see // http://vladmihalcea.com/2015/03/18/how-to-batch-insert-and-update-statements-with-hibernate/ jpaProperties.put(org.hibernate.cfg.Environment.ORDER_INSERTS, true); jpaProperties.put(org.hibernate.cfg.Environment.ORDER_UPDATES, true); jpaProperties.put( org.hibernate.cfg.Environment.STATEMENT_BATCH_SIZE, Dialect.DEFAULT_BATCH_SIZE); jpaProperties.put(org.hibernate.cfg.Environment.BATCH_VERSIONED_DATA, true); // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic // value. The need for it is intended to be alleviated with future // development, thus it is not defined as an Environment constant... // // it is used to control whether we should consult the JDBC metadata to // determine certain Settings default values; it is useful to *not* do // this when // the database may not be available (mainly in tools usage). jpaProperties.put("hibernate.temp.use_jdbc_metadata_defaults", "false"); LOG.debug("returning instance of entity manager factory bean"); return entityManagerFactoryBean; }
@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; }
/** * Configures the hibernate JPA Vendor adapter. * * <p>The database type is set to <code>Database.POSTGRESQL</code>. * * @return HibernateJpaVendorAdapter * @see HibernateJpaVendorAdapter * @see Database */ @Bean public HibernateJpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter jva = new HibernateJpaVendorAdapter(); jva.setDatabase(Database.POSTGRESQL); return jva; }