Package javax.persistence.spi

Examples of javax.persistence.spi.PersistenceProvider


    if (jpaVendorAdapter != null && this.persistenceUnitInfo instanceof SmartPersistenceUnitInfo) {
      ((SmartPersistenceUnitInfo) this.persistenceUnitInfo).setPersistenceProviderPackageName(
          jpaVendorAdapter.getPersistenceProviderRootPackage());
    }

    PersistenceProvider provider = getPersistenceProvider();
    if (provider == null) {
      String providerClassName = this.persistenceUnitInfo.getPersistenceProviderClassName();
      if (providerClassName == null) {
        throw new IllegalArgumentException(
            "No PersistenceProvider specified in EntityManagerFactory configuration, " +
            "and chosen PersistenceUnitInfo does not specify a provider class name either");
      }
      Class<?> providerClass = ClassUtils.resolveClassName(providerClassName, getBeanClassLoader());
      provider = (PersistenceProvider) BeanUtils.instantiateClass(providerClass);
    }
    if (provider == null) {
      throw new IllegalStateException("Unable to determine persistence provider. " +
          "Please check configuration of " + getClass().getName() + "; " +
          "ideally specify the appropriate JpaVendorAdapter class for this provider.");
    }

    if (logger.isInfoEnabled()) {
      logger.info("Building JPA container EntityManagerFactory for persistence unit '" +
          this.persistenceUnitInfo.getPersistenceUnitName() + "'");
    }
    this.nativeEntityManagerFactory =
        provider.createContainerEntityManagerFactory(this.persistenceUnitInfo, getJpaPropertyMap());
    postProcessEntityManagerFactory(this.nativeEntityManagerFactory, this.persistenceUnitInfo);

    return this.nativeEntityManagerFactory;
  }
View Full Code Here


      managerToUse = this.internalPersistenceUnitManager;
    }

    this.persistenceUnitInfo = determinePersistenceUnitInfo(managerToUse);

    PersistenceProvider provider = getPersistenceProvider();
    if (provider == null) {
      String providerClassName = this.persistenceUnitInfo.getPersistenceProviderClassName();
      if (providerClassName == null) {
        throw new IllegalArgumentException(
            "No PersistenceProvider specified in EntityManagerFactory configuration, " +
            "and chosen PersistenceUnitInfo does not specify a provider class name either");
      }
      Class providerClass = ClassUtils.resolveClassName(providerClassName, this.beanClassLoader);
      provider = (PersistenceProvider) BeanUtils.instantiateClass(providerClass);
    }
    if (provider == null) {
      throw new IllegalStateException("Unable to determine persistence provider. " +
          "Please check configuration of " + getClass().getName() + "; " +
          "ideally specify the appropriate JpaVendorAdapter class for this provider.");
    }

    if (logger.isInfoEnabled()) {
      logger.info("Building JPA container EntityManagerFactory for persistence unit '" +
          this.persistenceUnitInfo.getPersistenceUnitName() + "'");
    }
    this.nativeEntityManagerFactory =
        provider.createContainerEntityManagerFactory(this.persistenceUnitInfo, getJpaPropertyMap());
    postProcessEntityManagerFactory(this.nativeEntityManagerFactory, this.persistenceUnitInfo);

    return this.nativeEntityManagerFactory;
  }
View Full Code Here

      managerToUse = this.internalPersistenceUnitManager;
    }

    this.persistenceUnitInfo = determinePersistenceUnitInfo(managerToUse);

    PersistenceProvider provider = getPersistenceProvider();
    if (provider == null) {
      String providerClassName = this.persistenceUnitInfo.getPersistenceProviderClassName();
      if (providerClassName == null) {
        throw new IllegalArgumentException(
            "No PersistenceProvider specified in EntityManagerFactory configuration, " +
            "and chosen PersistenceUnitInfo does not specify a provider class name either");
      }
      Class providerClass = ClassUtils.resolveClassName(providerClassName, this.beanClassLoader);
      provider = (PersistenceProvider) BeanUtils.instantiateClass(providerClass);
    }
    if (provider == null) {
      throw new IllegalStateException("Unable to determine persistence provider. " +
          "Please check configuration of " + getClass().getName() + "; " +
          "ideally specify the appropriate JpaVendorAdapter class for this provider.");
    }

    if (logger.isInfoEnabled()) {
      logger.info("Building JPA container EntityManagerFactory for persistence unit '" +
          this.persistenceUnitInfo.getPersistenceUnitName() + "'");
    }
    this.nativeEntityManagerFactory =
        provider.createContainerEntityManagerFactory(this.persistenceUnitInfo, getJpaPropertyMap());
    postProcessEntityManagerFactory(this.nativeEntityManagerFactory, this.persistenceUnitInfo);

    return this.nativeEntityManagerFactory;
  }
View Full Code Here

    if (jpaVendorAdapter != null && this.persistenceUnitInfo instanceof MutablePersistenceUnitInfo) {
      ((MutablePersistenceUnitInfo) this.persistenceUnitInfo).setPersistenceProviderPackageName(
          jpaVendorAdapter.getPersistenceProviderRootPackage());
    }

    PersistenceProvider provider = getPersistenceProvider();
    if (provider == null) {
      String providerClassName = this.persistenceUnitInfo.getPersistenceProviderClassName();
      if (providerClassName == null) {
        throw new IllegalArgumentException(
            "No PersistenceProvider specified in EntityManagerFactory configuration, " +
            "and chosen PersistenceUnitInfo does not specify a provider class name either");
      }
      Class providerClass = ClassUtils.resolveClassName(providerClassName, getBeanClassLoader());
      provider = (PersistenceProvider) BeanUtils.instantiateClass(providerClass);
    }
    if (provider == null) {
      throw new IllegalStateException("Unable to determine persistence provider. " +
          "Please check configuration of " + getClass().getName() + "; " +
          "ideally specify the appropriate JpaVendorAdapter class for this provider.");
    }

    if (logger.isInfoEnabled()) {
      logger.info("Building JPA container EntityManagerFactory for persistence unit '" +
          this.persistenceUnitInfo.getPersistenceUnitName() + "'");
    }
    this.nativeEntityManagerFactory =
        provider.createContainerEntityManagerFactory(this.persistenceUnitInfo, getJpaPropertyMap());
    postProcessEntityManagerFactory(this.nativeEntityManagerFactory, this.persistenceUnitInfo);

    return this.nativeEntityManagerFactory;
  }
View Full Code Here

                excludeUnlistedClassesValue,
                properties,
                classLoader);
        try {
            Class clazz = classLoader.loadClass(persistenceProviderClassName);
            PersistenceProvider persistenceProvider = (PersistenceProvider) clazz.newInstance();
            entityManagerFactory = persistenceProvider.createContainerEntityManagerFactory(persistenceUnitInfo, properties);
        } catch (ClassNotFoundException e) {
            persistenceUnitInfo.destroy();
            throw new PersistenceException("Could not locate PersistenceProvider class: " + persistenceProviderClassName + " in classloader " + classLoader, e);
        } catch (InstantiationException e) {
            persistenceUnitInfo.destroy();
View Full Code Here

    /* (non-Javadoc)
     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
     */
    public void start(BundleContext ctx) throws Exception {
        this.ctx = ctx;
        PersistenceProvider provider = new PersistenceProviderImpl();
        Hashtable<String, String> props = new Hashtable<String, String>();
        // Aries queries for service providers by property "javax.persistence.provider"
        props.put(PERSISTENCE_PROVIDER_ARIES, OSGI_PERSISTENCE_PROVIDER);
        // The persistence service tracker in the geronimo spec api bundle examines
        // the property named "javax.persistence.PersistenceProvider" rather than
View Full Code Here

        assertEquals(LoadState.UNKNOWN, pu.isLoadedWithoutReference(ent,
            "transField"));       
    }
   
    private ProviderUtil getProviderUtil() {
        PersistenceProvider pp = new PersistenceProviderImpl();
        ProviderUtil pu = pp.getProviderUtil();
        return pu;
    }
View Full Code Here

    hash1.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
    ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
        pp, hash1 );
    ServiceReference ppRef = reg.getReference();
   
    PersistenceProvider pp2 = Skeleton.newMock(PersistenceProvider.class);
    Hashtable<String,Object> hash2 = new Hashtable<String, Object>();
    hash2.put("javax.persistence.provider", "do.not.use.this.Provider");
    hash2.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
    ServiceRegistration reg2 = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
        pp2, hash2 );
View Full Code Here

    hash1.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
    ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
        pp, hash1 );
    ServiceReference ppRef = reg.getReference();
   
    PersistenceProvider pp2 = Skeleton.newMock(PersistenceProvider.class);
    Hashtable<String,Object> hash2 = new Hashtable<String, Object>();
    hash2.put("javax.persistence.provider", "do.not.use.this.Provider");
    hash2.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
    ServiceRegistration reg2 = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
        pp2, hash2 );
View Full Code Here

    hash1.put("javax.persistence.provider", "no.such.Provider");
    ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
        pp, hash1 );
    ServiceReference ref = reg.getReference();

    PersistenceProvider pp2 = Skeleton.newMock(PersistenceProvider.class);
    Hashtable<String,Object> hash2 = new Hashtable<String, Object>();
    hash2.put("javax.persistence.provider", "do.not.use.this.Provider");
    hash2.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
    ServiceRegistration reg2 = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
        pp2, hash2 );
View Full Code Here

TOP

Related Classes of javax.persistence.spi.PersistenceProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.