use of org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter in project main by JohnPeng739.
the class DalHibernateConfig method entityManagerFactoryBean.
/**
* 创建实体管理器工厂Bean
*
* @return 实体管理器工厂Bean
*/
@Bean
@DependsOn({ "dataSource" })
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
String database = env.getProperty("jpa.database", String.class, "H2");
String databasePlatform = env.getProperty("jpa.databasePlatform", String.class, "org.hibernate.dialect.H2Dialect");
boolean generateDDL = env.getProperty("jpa.generateDDL", Boolean.class, true);
boolean showSQL = env.getProperty("jpa.showSQL", Boolean.class, true);
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
adapter.setDatabase(Database.valueOf(database));
adapter.setDatabasePlatform(databasePlatform);
adapter.setGenerateDdl(generateDDL);
adapter.setShowSql(showSQL);
adapter.setPrepareConnection(true);
String[] jpaDefines = context.getBeanNamesForType(JpaEntityPackagesDefine.class);
Set<String> jpaEntityPackages = new HashSet<>();
for (String jpaDefine : jpaDefines) {
JpaEntityPackagesDefine define = context.getBean(jpaDefine, JpaEntityPackagesDefine.class);
jpaEntityPackages.addAll(define.getPackages());
}
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(context.getBean("dataSource", DataSource.class));
emf.setPackagesToScan(jpaEntityPackages.toArray(new String[0]));
emf.setJpaVendorAdapter(adapter);
return emf;
}
use of org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter in project cloudbreak by hortonworks.
the class DatabaseConfig method jpaVendorAdapter.
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
hibernateJpaVendorAdapter.setShowSql(true);
hibernateJpaVendorAdapter.setDatabase(Database.POSTGRESQL);
return hibernateJpaVendorAdapter;
}
use of org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter in project spring-security by spring-projects.
the class ApplicationConfig method entityManagerFactory.
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setDatabase(Database.HSQL);
vendorAdapter.setGenerateDdl(true);
vendorAdapter.setShowSql(true);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan(User.class.getPackage().getName());
factory.setDataSource(dataSource());
return factory;
}
use of org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter in project Asqatasun by Asqatasun.
the class PersistenceCommonConfig method entityManagerFactory.
/**
* @param dataSource
* @param url
* @param packagesToScan
* @return
*/
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, String url, String... packagesToScan) {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource);
emf.setPackagesToScan(packagesToScan);
HibernateJpaVendorAdapter hibernateAdapter = new HibernateJpaVendorAdapter();
hibernateAdapter.setShowSql(hibernateShowSql);
final Properties jpaProperties = new Properties();
jpaProperties.put(HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE, hibernateUse2ndLevelQueryCache);
jpaProperties.put(HIBERNATE_CACHE_USE_QUERY_CACHE, hibernateUseQueryCache);
jpaProperties.put(HIBERNATE_CACHE_REGION_FACTORY_CLASS, hibernateRegionFactory);
jpaProperties.put(HIBERNATE_GENERATE_STATISTICS, false);
jpaProperties.put(HIBERNATE_JDBC_BATCH_SIZE, hibernateJdbcBatchSize);
jpaProperties.put(HIBERNATE_MAX_FETCH_DEPTH, hibernateMaxFetchDepth);
jpaProperties.put(HIBERNATE_USE_OUTER_JOIN, hibernateUseOuterJoin);
jpaProperties.put(HIBERNATE_DEFAULT_BATCH_FETCH_SIZE, hibernateDefaultBatchFetchSize);
jpaProperties.put(HIBERNATE_DIALECT, getHibernateDialedFromUrl(url));
if (PersistenceCommonConfig.isHsqlDb(url)) {
jpaProperties.put("javax.persistence.schema-generation.database.action", "drop-and-create");
}
emf.setJpaProperties(jpaProperties);
emf.setJpaVendorAdapter(hibernateAdapter);
return emf;
}
use of org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter in project cas by apereo.
the class CasHibernateJpaBeanFactory method newJpaVendorAdapter.
@Override
public JpaVendorAdapter newJpaVendorAdapter(final DatabaseProperties databaseProperties) {
val bean = new HibernateJpaVendorAdapter();
bean.setGenerateDdl(databaseProperties.isGenDdl());
bean.setShowSql(databaseProperties.isShowSql());
return bean;
}
Aggregations