Search in sources :

Example 1 with PersistenceProvider

use of jakarta.persistence.spi.PersistenceProvider in project spring-framework by spring-projects.

the class LocalContainerEntityManagerFactoryBean method createNativeEntityManagerFactory.

@Override
protected EntityManagerFactory createNativeEntityManagerFactory() throws PersistenceException {
    Assert.state(this.persistenceUnitInfo != null, "PersistenceUnitInfo not initialized");
    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 (logger.isDebugEnabled()) {
        logger.debug("Building JPA container EntityManagerFactory for persistence unit '" + this.persistenceUnitInfo.getPersistenceUnitName() + "'");
    }
    EntityManagerFactory emf = provider.createContainerEntityManagerFactory(this.persistenceUnitInfo, getJpaPropertyMap());
    postProcessEntityManagerFactory(emf, this.persistenceUnitInfo);
    return emf;
}
Also used : PersistenceProvider(jakarta.persistence.spi.PersistenceProvider) EntityManagerFactory(jakarta.persistence.EntityManagerFactory)

Aggregations

EntityManagerFactory (jakarta.persistence.EntityManagerFactory)1 PersistenceProvider (jakarta.persistence.spi.PersistenceProvider)1