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


Java HibernateJpaVendorAdapter类代码示例

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


HibernateJpaVendorAdapter类属于org.springframework.orm.jpa.vendor包,在下文中一共展示了HibernateJpaVendorAdapter类的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: entityManagerFactoryBean

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入依赖的package包/类
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
    factoryBean.setDataSource(dataSource());
    factoryBean.setPackagesToScan("com.chinedu.truststack.persist");

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(true);
    vendorAdapter.setDatabasePlatform(hibernateDialect);
    factoryBean.setJpaVendorAdapter(vendorAdapter);

    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.show_sql",hibernateShowSql);
    jpaProperties.put("hibernate.hbm2ddl.auto",hibernateUpate);
    factoryBean.setJpaProperties(jpaProperties);
    return factoryBean;
}
 
开发者ID:csokafor,项目名称:spring-security-angularjs,代码行数:18,代码来源:JPAConfig.java

示例3: entityManagerFactory

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

	JpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();

	DriverManagerDataSource dataSource = new DriverManagerDataSource();
	dataSource.setUsername("root");
	dataSource.setPassword("");
	dataSource.setUrl("jdbc:mysql://localhost:3306/ensaiospring");
	dataSource.setDriverClassName("com.mysql.jdbc.Driver");

	Properties props = new Properties();
	props.setProperty("hibernate.dialect",
			"org.hibernate.dialect.MySQL5Dialect");
	props.setProperty("hibernate.show_sql", "true");
	props.setProperty("hibernate.hbm2ddl.auto", "update");

	factory.setJpaVendorAdapter(jpaVendorAdapter);
	factory.setDataSource(dataSource);
	factory.setJpaProperties(props);
	factory.setPackagesToScan("br.com.ciaware.springmvc.ensaio.models");

	return factory;
}
 
开发者ID:flaviociaware,项目名称:cwEnsaiosWeb,代码行数:26,代码来源:JPAConfiguration.java

示例4: 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

示例5: 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

示例6: entityManagerFactory

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

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan(PROPERTY_PACKAGES_TO_SCAN);

    Properties jpaProperties = new Properties();
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_DIALECT, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, true);//env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));

    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:20,代码来源:PersistenceContext.java

示例7: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入依赖的package包/类
@Bean
public FactoryBean<EntityManagerFactory> entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
	emf.setDataSource(dataSource());
	emf.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
	emf.setPackagesToScan(TestJpaDomain.class.getPackage().getName());
	emf.setPersistenceUnitName("test");
	return emf;
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:10,代码来源:TestBase.java

示例8: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入依赖的package包/类
/**
 * Big Note: For spring based applications, the difference between different types of the entity manager factory bean is not so much. Spring will
 * always play the role, as container if you configure {@link LocalContainerEntityManagerFactoryBean}  and as application if you configure
 * {@link org.springframework.orm.jpa.LocalEntityManagerFactoryBean}
 *
 * @param dataSource  Factory for connections to the physical data source
 * @param environment Interface representing the environment in which the current application is running.
 * @return suitable entity manager factor bean bean for
 */
@Bean
LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, Environment environment) {
    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
    jpaProperties.put("hibernate.hbm2ddl.auto", environment.getRequiredProperty("hibernate.hbm2ddl.auto"));
    jpaProperties.put("hibernate.ejb.naming_strategy", environment.getRequiredProperty("hibernate.ejb.naming_strategy"));
    jpaProperties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
    jpaProperties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan("com.logicify.d2g.models");
    entityManagerFactoryBean.setJpaProperties(jpaProperties);
    return entityManagerFactoryBean;
}
 
开发者ID:Logicify,项目名称:d2g-api,代码行数:25,代码来源:RepositoryConfiguration.java

示例9: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory() throws SQLException {
	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	// vendorAdapter.setGenerateDdl(true); // Crea la tabella e le colonne quando non esistono
	vendorAdapter.setShowSql(config.getShowSql());
	vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");
	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	List<String> packages = config.getDbEntityPackages();
	packages.add("net.yadaframework.persistence.entity");
	packages.add("net.yadaframework.security.persistence.entity");
	packages.add("net.yadaframework.cms.persistence.entity");
	packages.add("net.yadaframework.commerce.persistence.entity");
	log.info("Scanning packages for entities: {}", StringUtils.join(packages, ","));
	factory.setPackagesToScan(packages.toArray(new String[]{}));
	factory.setDataSource(dataSource());
	factory.afterPropertiesSet();
	return factory.getObject();
}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:20,代码来源:YadaJpaConfig.java

示例10: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan("com.tickets.business.entities");

    final Properties hibernateProperties = new Properties();
    hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "update");
    hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    em.setJpaProperties(hibernateProperties);
    
    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);

    return em;
}
 
开发者ID:sysuOTS,项目名称:TicketServer,代码行数:17,代码来源:SpringBusinessConfig.java

示例11: 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

示例12: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入依赖的package包/类
@Bean(name = "coreEntityManager")
public LocalContainerEntityManagerFactoryBean entityManagerFactory()
{
    if (driver == null){
        throw new IllegalStateException("cannot find db.type property with valid value ( mysql,ms-sql)");
    }
    driver.create();
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(driver.create());
    em.setPackagesToScan(new String[]{"com"});
    JpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(false);
    vendorAdapter.setGenerateDdl(false);

    em.setJpaVendorAdapter(vendorAdapter);
    em.setJpaProperties(additionalProperties());
    return em;
}
 
开发者ID:aranga-nana,项目名称:angular-spring-boot-micro-services-docker,代码行数:20,代码来源:JPAConfig.java

示例13: entityManagerFactoryBean

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
	Map<String, Object> properties = new Hashtable<>();
	properties.put("javax.persistence.schema-generation.database.action", "none");
	properties.put("hibernate.connection.characterEncoding", "utf8");
	properties.put("hibernate.connection.useUnicode", "true");
	properties.put("hibernate.connection.charSet", "utf8");
	properties.put("hibernate.search.default.directory_provider", "filesystem");
	properties.put("hibernate.search.default.indexBase", context.getInitParameter("indexDir"));

	HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
	adapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(adapter);
	factory.setDataSource(this.bookManagerDataSource());
	factory.setPackagesToScan("net.viperfish.bookManager");
	factory.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
	factory.setValidationMode(ValidationMode.NONE);
	factory.setJpaPropertyMap(properties);
	return factory;
}
 
开发者ID:shilongdai,项目名称:bookManager,代码行数:23,代码来源:RootApplicationContextConfig.java

示例14: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    myLogger.info("entityManagerFactory");
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPackagesToScan("com.github.swrirobotics");
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

    Properties jpaProperties = new Properties();
    // Disable HBM2DDL; we use Liquibase to create our database
    jpaProperties.put(Environment.HBM2DDL_AUTO, "");
    // Set a large batch size for better performance over slow network links
    jpaProperties.put(Environment.STATEMENT_BATCH_SIZE, "100");
    jpaProperties.put(Environment.ORDER_INSERTS, "true");
    jpaProperties.put(Environment.ORDER_UPDATES, "true");
    jpaProperties.put(Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
}
 
开发者ID:swri-robotics,项目名称:bag-database,代码行数:21,代码来源:JpaConfig.java

示例15: 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


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