Example usage for org.springframework.orm.jpa JpaVendorAdapter getEntityManagerFactoryInterface

List of usage examples for org.springframework.orm.jpa JpaVendorAdapter getEntityManagerFactoryInterface

Introduction

In this page you can find the example usage for org.springframework.orm.jpa JpaVendorAdapter getEntityManagerFactoryInterface.

Prototype

default Class<? extends EntityManagerFactory> getEntityManagerFactoryInterface() 

Source Link

Document

Return the vendor-specific EntityManagerFactory interface that the EntityManagerFactory proxy is supposed to implement.

Usage

From source file:org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.java

@Override
public void afterPropertiesSet() throws PersistenceException {
    JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter();
    if (jpaVendorAdapter != null) {
        if (this.persistenceProvider == null) {
            this.persistenceProvider = jpaVendorAdapter.getPersistenceProvider();
        }//w w  w  .  j a v a2  s . c  o  m
        PersistenceUnitInfo pui = getPersistenceUnitInfo();
        Map<String, ?> vendorPropertyMap = (pui != null ? jpaVendorAdapter.getJpaPropertyMap(pui)
                : jpaVendorAdapter.getJpaPropertyMap());
        if (!CollectionUtils.isEmpty(vendorPropertyMap)) {
            vendorPropertyMap.forEach((key, value) -> {
                if (!this.jpaPropertyMap.containsKey(key)) {
                    this.jpaPropertyMap.put(key, value);
                }
            });
        }
        if (this.entityManagerFactoryInterface == null) {
            this.entityManagerFactoryInterface = jpaVendorAdapter.getEntityManagerFactoryInterface();
            if (!ClassUtils.isVisible(this.entityManagerFactoryInterface, this.beanClassLoader)) {
                this.entityManagerFactoryInterface = EntityManagerFactory.class;
            }
        }
        if (this.entityManagerInterface == null) {
            this.entityManagerInterface = jpaVendorAdapter.getEntityManagerInterface();
            if (!ClassUtils.isVisible(this.entityManagerInterface, this.beanClassLoader)) {
                this.entityManagerInterface = EntityManager.class;
            }
        }
        if (this.jpaDialect == null) {
            this.jpaDialect = jpaVendorAdapter.getJpaDialect();
        }
    }

    AsyncTaskExecutor bootstrapExecutor = getBootstrapExecutor();
    if (bootstrapExecutor != null) {
        this.nativeEntityManagerFactoryFuture = bootstrapExecutor.submit(this::buildNativeEntityManagerFactory);
    } else {
        this.nativeEntityManagerFactory = buildNativeEntityManagerFactory();
    }

    // Wrap the EntityManagerFactory in a factory implementing all its interfaces.
    // This allows interception of createEntityManager methods to return an
    // application-managed EntityManager proxy that automatically joins
    // existing transactions.
    this.entityManagerFactory = createEntityManagerFactoryProxy(this.nativeEntityManagerFactory);
}