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


Java HibernatePersistenceProvider类代码示例

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


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

示例1: fixDeprecatedHibernateWarning

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
/**
 * fixes the warning (Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb
 * .HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.)
 *
 * must be called before getting the EntityManagerFactory
 */
private static void fixDeprecatedHibernateWarning() {
    PersistenceProviderResolverHolder.setPersistenceProviderResolver(new PersistenceProviderResolver() {
        private final List<PersistenceProvider> providers_ =
                Arrays.asList(new PersistenceProvider[]{new HibernatePersistenceProvider()});

        @Override
        public List<PersistenceProvider> getPersistenceProviders() {
            return providers_;
        }

        @Override
        public void clearCachedProviders() {

        }
    });
}
 
开发者ID:sothawo,项目名称:trakxmap,代码行数:23,代码来源:DB.java

示例2: init

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Before
public void init() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());

    Map<String, Object> configuration = new HashMap<>();

    Integrator integrator = integrator();
    if (integrator != null) {
        configuration.put("hibernate.integrator_provider", (IntegratorProvider) () -> Collections.singletonList(integrator));
    }

    emf = new HibernatePersistenceProvider().createContainerEntityManagerFactory(
        persistenceUnitInfo,
        configuration
    );
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:17,代码来源:AbstractJPAProgrammaticBootstrapTest.java

示例3: entityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory() {
    logger.debug("Configuring EntityManager");
    LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean();
    lcemfb.setPersistenceProvider(new HibernatePersistenceProvider());
    lcemfb.setPersistenceUnitName("persistenceUnit");
    lcemfb.setDataSource(dataSource());
    lcemfb.setJpaDialect(new HibernateJpaDialect());
    lcemfb.setJpaVendorAdapter(jpaVendorAdapter());
    lcemfb.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.generate_statistics", false);
    jpaProperties.put("hibernate.show_sql", Boolean.parseBoolean(databaseShowSQL));
    lcemfb.setJpaProperties(jpaProperties);
    lcemfb.setPackagesToScan("cn.org.once.cstack.model");
    lcemfb.afterPropertiesSet();
    return lcemfb.getObject();
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:19,代码来源:DatabaseConfiguration.java

示例4: entityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory() {
    logger.debug("Configuring EntityManager");
    LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean();
    lcemfb.setPersistenceProvider(new HibernatePersistenceProvider());
    lcemfb.setPersistenceUnitName("persistenceUnit");
    lcemfb.setDataSource(dataSource());
    lcemfb.setJpaDialect(new HibernateJpaDialect());
    lcemfb.setJpaVendorAdapter(jpaVendorAdapter());
    lcemfb.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.generate_statistics", true);
    jpaProperties.put("hibernate.show_sql", Boolean.parseBoolean(databaseShowSQL));
    lcemfb.setJpaProperties(jpaProperties);
    lcemfb.setPackagesToScan("cn.org.once.cstack.model");
    lcemfb.afterPropertiesSet();
    return lcemfb.getObject();
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:19,代码来源:DatabaseConfigurationTest.java

示例5: setupH2EMF

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
private EntityManagerFactory setupH2EMF(String ddlMode) throws IOException {
  Map<String, Object> configuration = new HashMap<>();

  String jdbcUri = template("jdbc:h2:file:{{datapath}}/datastore")
      .add("datapath", BiliomiContainer.getParameters().getWorkingDir().getCanonicalPath())
      .apply();

  configuration.put("hibernate.connection.url", jdbcUri);
  configuration.put("hibernate.hbm2ddl.auto", ddlMode);

  // Add entity classes
  configuration.put(AvailableSettings.LOADED_CLASSES, scanForEntityClasses());

  // Create Entity manager factory
  logger.debug("Creating entity manager factory for local H2 database...");
  HibernatePersistenceProvider provider = new HibernatePersistenceProvider();
  return provider.createEntityManagerFactory("Biliomi-H2-DS", configuration);
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:19,代码来源:EntityManagerFactoryProducer.java

示例6: entityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory(DataSource dataSource) {
    final Database database = Database.valueOf(vendor.toUpperCase());
    /*
    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(showSql);
    vendorAdapter.setGenerateDdl(showDdl);
    vendorAdapter.setDatabase(database);
    */

    final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setPersistenceUnitName("CCRI_PU");
   // factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("uk.nhs.careconnect.ri.entity");
    factory.setDataSource(dataSource);
    factory.setPersistenceProvider(new HibernatePersistenceProvider());
    factory.setJpaProperties(jpaProperties());
    factory.afterPropertiesSet();


    return factory.getObject();
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:23,代码来源:DataSourceConfig.java

示例7: createEntityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
public static LocalContainerEntityManagerFactoryBean createEntityManagerFactory(JPAConfig config, List<JPAParams> jpaParamsList) {
    LocalContainerEntityManagerFactoryBean entityManager = new LocalContainerEntityManagerFactoryBean();
    if (config.isJtaDatasource()) {
        entityManager.setJtaDataSource(config.getDataSource());
    } else {
        entityManager.setDataSource(config.getDataSource());
    }
    Properties p = new Properties();
    p.putAll(config.getJpaProperties());
    if (jpaParamsList != null) {
        for (JPAParams jpaParams : jpaParamsList) {
            p.putAll(jpaParams.getProperties());
        }
    }
    entityManager.setJpaProperties(p);
    entityManager.setPackagesToScan(config.getPackageToScan());
    entityManager.setPersistenceProvider(new HibernatePersistenceProvider());
    return entityManager;
}
 
开发者ID:Kloudtek,项目名称:ktspring,代码行数:20,代码来源:HibernateJPAConfig.java

示例8: entityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws Exception {
	
	LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
	entityManagerFactoryBean.setDataSource(dataSource());
	entityManagerFactoryBean.setPackagesToScan(environment.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
	entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);
	
	Properties jpaProterties = new Properties();
	
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_DIALECT, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL));
	
	entityManagerFactoryBean.setJpaProperties(jpaProterties);
	
	return entityManagerFactoryBean;
}
 
开发者ID:pedro-hos,项目名称:amigo-secreto,代码行数:21,代码来源:PersistenceContext.java

示例9: entityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws Exception {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
 
    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPackagesToScan(environment.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);
 
    Properties jpaProterties = new Properties();
    jpaProterties.put(PROPERTY_NAME_HIBERNATE_DIALECT, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProterties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProterties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProterties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
    jpaProterties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL));;
    
    entityManagerFactoryBean.setJpaProperties(jpaProterties);
 
    return entityManagerFactoryBean;
}
 
开发者ID:leosilvadev,项目名称:SJPAReference,代码行数:20,代码来源:PersistenceContext.java

示例10: entityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws Exception {
	LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();

	entityManagerFactoryBean.setDataSource(dataSource());
	entityManagerFactoryBean.setPackagesToScan("com.github.kmbulebu.nicknack.server.model");
	entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);


	Properties jpaProperties = new Properties();

	jpaProperties.put(PROPERTY_NAME_HIBERNATE_DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
	jpaProperties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, "true");
	jpaProperties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY, ImprovedNamingStrategy.class.getName());
	jpaProperties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, "false");
	jpaProperties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO, "update");

	entityManagerFactoryBean.setJpaProperties(jpaProperties);

	return entityManagerFactoryBean;
}
 
开发者ID:kmbulebu,项目名称:NickNack,代码行数:22,代码来源:H2DatabaseConfiguration.java

示例11: entityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws Exception {
	LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
	entityManagerFactoryBean.setDataSource(dataSource());
	entityManagerFactoryBean.setPackagesToScan(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN);
	entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);
	entityManagerFactoryBean.setJpaDialect(hibernateJpaDialect());
	
	Properties jpaProterties = new Properties();
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_DIALECT, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL));
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_ENVERS_PREFIX, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_ENVERS_PREFIX));
	jpaProterties.put(PROPERTY_NAME_HIBERNATE_ENVERS_SUFFIX, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_ENVERS_SUFFIX));
	entityManagerFactoryBean.setJpaProperties(jpaProterties);
	return entityManagerFactoryBean;
}
 
开发者ID:leosilvadev,项目名称:simplebank,代码行数:20,代码来源:PersistenceConfig.java

示例12: classesShouldExtendRapidoidThing

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Test
public void classesShouldExtendRapidoidThing() {
	for (String cls : Cls.getRapidoidClasses()) {

		if (cls.startsWith("org.rapidoid.plugin.app.")
			|| cls.startsWith("org.rapidoid.fluent.")
			|| cls.startsWith("org.rapidoid.benchmark.")) continue;

		Class<?> clazz = Cls.get(cls);

		if (!clazz.isInterface() && !clazz.isEnum() && !clazz.isAnnotation()) {
			U.must(RapidoidThing.class.isAssignableFrom(clazz)
				|| clazz == TestCommons.class
				|| Exception.class.isAssignableFrom(clazz)
				|| ClassLoader.class.isAssignableFrom(clazz)
				|| HibernatePersistenceProvider.class.isAssignableFrom(clazz)
				|| OutputStream.class.isAssignableFrom(clazz)
				|| Map.class.isAssignableFrom(clazz)
				|| JsonSerializer.class.isAssignableFrom(clazz)
				|| JsonDeserializer.class.isAssignableFrom(clazz)
				|| LogFactory.class.isAssignableFrom(clazz)
				|| Thread.class.isAssignableFrom(clazz), "" + cls);
		}
	}
}
 
开发者ID:rapidoid,项目名称:rapidoid,代码行数:26,代码来源:RapidoidThingsTest.java

示例13: buildEntityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
/**
 * Creates {@link EntityManagerFactory} by
 * <a href="http://hibernate.org">"Hibernate"</a> or by extended builder
 * {@link Ejb3ConfigurationImpl} if entity classes or persistence.xml file
 * path are provided
 *
 * @see Ejb3ConfigurationImpl#configure(String, Map) and
 *      Ejb3ConfigurationImpl#createEntityManagerFactory()
 *
 * @param unitName
 * @return {@link EntityManagerFactory}
 */
private EntityManagerFactory buildEntityManagerFactory(String unitName) throws IOException {

    EntityManagerFactory emf;

    HibernatePersistenceProvider provider;
    HibernatePersistenceProviderExt.Builder builder = new HibernatePersistenceProviderExt.Builder();
    configureProvider(builder);
    provider = builder.build();
    configureTransactionManager();
    // Adds JNDI properties
    addJndiProperties();
    if (springPersistence) {
        emf = getFromSpring(provider, unitName);
    } else {
        emf = provider.createEntityManagerFactory(unitName, properties);
    }

    return emf;
}
 
开发者ID:levants,项目名称:lightmare,代码行数:32,代码来源:JpaManager.java

示例14: entityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
    emf.setDataSource(dataSource);
    emf.setPackagesToScan(Post.class.getPackage().getName());
    emf.setPersistenceProvider(new HibernatePersistenceProvider());
    emf.setJpaProperties(jpaProperties());
    return emf;
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:10,代码来源:JpaConfig.java

示例15: entityManagerFactory

import org.hibernate.jpa.HibernatePersistenceProvider; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean();
	//retVal.setPersistenceUnitManager(persistenceUnitManager());
	retVal.setMappingResources(orm);
	retVal.setPackagesToScan("org.partners.usciitg_prep.terminology.jpa");
	retVal.setPersistenceUnitName(persistenceUnitName);
	retVal.setDataSource(dataSource());
	retVal.setPersistenceProvider(new HibernatePersistenceProvider());		
	retVal.setJpaProperties(jpaProperties());
	return retVal;
}
 
开发者ID:Discovery-Research-Network-SCCM,项目名称:FHIR-CQL-ODM-service,代码行数:13,代码来源:FhirServerTestConfigDstu3.java


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