当前位置: 首页>>代码示例>>Java>>正文


Java HibernateJpaVendorAdapter.setDatabase方法代码示例

本文整理汇总了Java中org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.setDatabase方法的典型用法代码示例。如果您正苦于以下问题:Java HibernateJpaVendorAdapter.setDatabase方法的具体用法?Java HibernateJpaVendorAdapter.setDatabase怎么用?Java HibernateJpaVendorAdapter.setDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter的用法示例。


在下文中一共展示了HibernateJpaVendorAdapter.setDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newEntityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
public static EntityManagerFactory newEntityManagerFactory(DataSource dataSource, Class<?> ... entityPackages){
	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	vendorAdapter.setGenerateDdl(true);

	BasicDataSource basicDataSource = (BasicDataSource)dataSource;
	Database jpaDatabase = DatabaseType.findTypeByJdbcUrl(basicDataSource.getUrl()).getJpaDatabase();
	vendorAdapter.setDatabase(jpaDatabase);

	HashMap<String, Object> properties = new HashMap<String, Object>();
	//properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	//import @Entity classes
	factory.setPackagesToScan(Arrays.stream(entityPackages).map(thing -> thing.getPackage().getName()).toArray(String[]::new));
	//factory.setPersistenceUnitName("jproject");
	factory.setDataSource(dataSource);
	factory.setJpaPropertyMap(properties);
	factory.afterPropertiesSet();

	return factory.getObject();
}
 
开发者ID:profullstack,项目名称:spring-seed,代码行数:23,代码来源:JpaBuilderUtil.java

示例2: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setDatabase(Database.H2);
    vendorAdapter.setGenerateDdl(jpaGenerateDdl);
    vendorAdapter.setShowSql(jpaShowSql);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("org.bricket.b4.*.entity");
    factory.setDataSource(dataSource());
    factory.setJpaDialect(jpaDialect());

    Map<String, String> jpaProperties = new HashMap<String, String>();
    jpaProperties.put("hibernate.dialect", H2Dialect.class.getName());
    jpaProperties.put("hibernate.cache.region.factory_class", EhCacheRegionFactory.class.getName());
    jpaProperties.put("hibernate.cache.use_second_level_cache", "true");
    jpaProperties.put("hibernate.cache.use_query_cache", "true");
    jpaProperties.put("hibernate.cache.use_minimal_puts", "true");
    factory.setJpaPropertyMap(jpaProperties);

    factory.afterPropertiesSet();

    return factory.getObject();
}
 
开发者ID:bricket,项目名称:b4,代码行数:26,代码来源:B4CoreRootConfig.java

示例3: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    // JPA settings
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    // vendorAdapter.setGenerateDdl(true);
    // vendorAdapter.setShowSql(true);
    vendorAdapter.setDatabase(Database.MYSQL);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("org.amv.access.model");
    factory.setDataSource(dataSource);
    factory.setJpaProperties(jpaProperties());
    factory.afterPropertiesSet();
    return factory;
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:17,代码来源:JpaConfig.java

示例4: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false);
    vendorAdapter.setDatabase(Database.H2);
    vendorAdapter.setShowSql(false);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("jdblender.sdata.model");
    factory.setDataSource(dataSourceH2());
    Map<String, Object> props = factory.getJpaPropertyMap();
    props.put("hibernate.cache.use_query_cache", "false");
    props.put("hibernate.cache.use_second_level_cache", "false");
    props.put("hibernate.hbm2ddl.auto", "validate");
    //props.put("hibernate.jdbc.batch_size", "100");
    //props.put("hibernate.cache.use_second_level_cache", "false");
    //props.put("hibernate.order_inserts", "1");
    //props.put("hibernate.order_updates", "1");
    
    factory.setJpaPropertyMap(props);

    return factory;
}
 
开发者ID:rumatoest,项目名称:jdblender,代码行数:26,代码来源:Config.java

示例5: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	vendorAdapter.setDatabase(Database.HSQL);
	vendorAdapter.setGenerateDdl(true);

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	factory.setPackagesToScan(packagesToScan());
	factory.setPersistenceUnitName("spring-data-rest-webmvc");
	factory.setDataSource(dataSource());
	factory.afterPropertiesSet();

	return factory;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:17,代码来源:JpaInfrastructureConfig.java

示例6: getHibernateJpaVendorAdapter

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
/**
 * Gets the Hibernate JPA vendor adapter needed by the entity manager.
 *
 * @return the Hibernate JPA vendor adapter.
 */
private JpaVendorAdapter getHibernateJpaVendorAdapter()
{
    HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
    // Set the database type.
    String databaseType = configurationHelper.getProperty(ConfigurationValue.DATABASE_TYPE);
    if (StringUtils.isBlank(databaseType))
    {
        throw new IllegalStateException(
            String.format("No database type found. Ensure the \"%s\" configuration entry is configured.", ConfigurationValue.DATABASE_TYPE.getKey()));
    }
    Database database = Database.valueOf(databaseType);
    LOGGER.info("jpaTargetDatabase={}", database);
    hibernateJpaVendorAdapter.setDatabase(database);
    hibernateJpaVendorAdapter.setGenerateDdl(false);
    return hibernateJpaVendorAdapter;
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:22,代码来源:DaoSpringModuleConfig.java

示例7: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
@Autowired
public EntityManagerFactory entityManagerFactory(DataSource dataSource)  
{
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(generateDDL.booleanValue());
    vendorAdapter.setShowSql(showSQL.booleanValue());
    vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");
    vendorAdapter.setDatabase(Database.MYSQL);

    Properties properties = new Properties();
    properties.setProperty("hibernate.cache.use_second_level_cache", "true");
    properties.setProperty("hibernate.cache.region.factory_class", "org.hibernate.cache.ehcache.EhCacheRegionFactory");
    properties.setProperty("hibernate.cache.use_query_cache", "true");
    properties.setProperty("hibernate.generate_statistics", showStatistics.toString());
    
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("io.springagora.core.domain");
    factory.setDataSource(dataSource);
    factory.setJpaProperties(properties);
    factory.afterPropertiesSet();
  
    return factory.getObject();
}
 
开发者ID:ThiagoUriel,项目名称:spring-agora-web,代码行数:26,代码来源:ApplicationConfig.java

示例8: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean(name="entityManagerFactory")
public EntityManagerFactory entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setDatabase(Database.H2);
    vendorAdapter.setGenerateDdl(false);
    vendorAdapter.setShowSql(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("net.eusashead.bjugquerydsl.data");
    factory.setDataSource(dataSource());

    factory.afterPropertiesSet();

    return factory.getObject();
}
 
开发者ID:patrickvankann,项目名称:bjug-querydsl,代码行数:17,代码来源:JpaConfig.java

示例9: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
@DependsOn({"cacheManager",
            "springLiquibase"})
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();

    jpaVendorAdapter.setDatabase(jpaVendorDatabase);

    final Map<String, Object> jpaProperties = new LinkedHashMap<>();

    jpaProperties.put("hibernate.cache.region.factory_class", hibernateEhcacheRegionFactoryClass);
    jpaProperties.put("hibernate.cache.use_query_cache", hibernateUseQueryCache);
    jpaProperties.put("hibernate.cache.use_second_level_cache", hibernateUseSecondLevelCache);
    jpaProperties.put("hibernate.hbm2ddl.auto", hibernateHbm2ddl);

    final LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setJpaDialect(new HibernateJpaDialect());
    entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter);
    entityManagerFactoryBean.setPackagesToScan("org.unidle.domain");
    entityManagerFactoryBean.setJpaPropertyMap(jpaProperties);
    entityManagerFactoryBean.setMappingResources("jpa/orm.xml");

    return entityManagerFactoryBean;
}
 
开发者ID:martinlau,项目名称:unidle-old,代码行数:27,代码来源:DataConfiguration.java

示例10: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

	HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
	adapter.setDatabase(Database.HSQL);
	adapter.setGenerateDdl(true);

	LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
	factoryBean.setDataSource(dataSource());
	factoryBean.setJpaVendorAdapter(adapter);
	factoryBean.setPackagesToScan(JpaEventPublicationConfiguration.class.getPackage().getName());

	return factoryBean;
}
 
开发者ID:olivergierke,项目名称:spring-domain-events,代码行数:15,代码来源:InfrastructureConfiguration.java

示例11: jpaVendorAdapter

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
	HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
	hibernateJpaVendorAdapter.setShowSql(true);
	hibernateJpaVendorAdapter.setGenerateDdl(true);
	hibernateJpaVendorAdapter.setDatabase(Database.H2);
	return hibernateJpaVendorAdapter;
}
 
开发者ID:adessoAG,项目名称:JenkinsHue,代码行数:9,代码来源:H2DBConfig.java

示例12: jpaVendorAdapter

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
	HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
	hibernateJpaVendorAdapter.setShowSql(sql);
	hibernateJpaVendorAdapter.setGenerateDdl(sql);
	hibernateJpaVendorAdapter.setDatabase(Database.POSTGRESQL);
	return hibernateJpaVendorAdapter;
}
 
开发者ID:adessoAG,项目名称:JenkinsHue,代码行数:9,代码来源:PostgreSQLDBConfig.java

示例13: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setDatabase(Database.H2);
    vendorAdapter.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("your.microservice.core.security.idp.model.base");
    factory.setDataSource(dataSource());

    return factory;
}
 
开发者ID:jaschenk,项目名称:Your-Microservice,代码行数:14,代码来源:YourMicroserviceEnvironmentConfiguration.java

示例14: jpaVendorAdapter

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
/**
 * JPA vendor adapter provides specifics about particular JPA implementation to use
 * @return JPA vendor adapter
 */
@Bean
public JpaVendorAdapter jpaVendorAdapter(Environment env){
    HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    adapter.setDatabase(Database.POSTGRESQL);
    adapter.setShowSql(Boolean.parseBoolean(env.getProperty(PROPERTY_JPA_SHOW_SQL)));
    adapter.setDatabasePlatform(env.getProperty(PROPERTY_JPA_DATABASE_PLATFORM));
    adapter.setGenerateDdl(Boolean.parseBoolean(env.getProperty(PROPERTY_JPA_GENERATE_DDL)));
    return adapter;
}
 
开发者ID:Vapsel,项目名称:social-media-analytic-system,代码行数:14,代码来源:DataSourceConfig.java

示例15: jpaVendorAdapter

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入方法依赖的package包/类
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
	HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
	hibernateJpaVendorAdapter.setShowSql(false);
	hibernateJpaVendorAdapter.setGenerateDdl(false);
	hibernateJpaVendorAdapter.setDatabase(Database.H2);
	return hibernateJpaVendorAdapter;
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:9,代码来源:DomainAndPersitenceConfigManuelle.java


注:本文中的org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.setDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。