當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。