Search in sources :

Example 1 with EntityManagerFactoryInfo

use of org.springframework.orm.jpa.EntityManagerFactoryInfo in project spring-framework by spring-projects.

the class EclipseLinkEntityManagerFactoryIntegrationTests method testCanCastNativeEntityManagerFactoryToEclipseLinkEntityManagerFactoryImpl.

@Test
public void testCanCastNativeEntityManagerFactoryToEclipseLinkEntityManagerFactoryImpl() {
    EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
    assertTrue(emfi.getNativeEntityManagerFactory().getClass().getName().endsWith("EntityManagerFactoryImpl"));
}
Also used : EntityManagerFactoryInfo(org.springframework.orm.jpa.EntityManagerFactoryInfo) Test(org.junit.Test)

Example 2 with EntityManagerFactoryInfo

use of org.springframework.orm.jpa.EntityManagerFactoryInfo in project spring-framework by spring-projects.

the class HibernateEntityManagerFactoryIntegrationTests method testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl.

@Test
public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() {
    EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
    assertTrue(emfi.getNativeEntityManagerFactory() instanceof org.hibernate.jpa.HibernateEntityManagerFactory);
    // as of Hibernate 5.2
    assertTrue(emfi.getNativeEntityManagerFactory() instanceof SessionFactory);
}
Also used : SessionFactory(org.hibernate.SessionFactory) EntityManagerFactoryInfo(org.springframework.orm.jpa.EntityManagerFactoryInfo) Test(org.junit.Test)

Example 3 with EntityManagerFactoryInfo

use of org.springframework.orm.jpa.EntityManagerFactoryInfo in project spring-framework by spring-projects.

the class SharedEntityManagerBean method afterPropertiesSet.

@Override
public final void afterPropertiesSet() {
    EntityManagerFactory emf = getEntityManagerFactory();
    if (emf == null) {
        throw new IllegalArgumentException("'entityManagerFactory' or 'persistenceUnitName' is required");
    }
    if (emf instanceof EntityManagerFactoryInfo) {
        EntityManagerFactoryInfo emfInfo = (EntityManagerFactoryInfo) emf;
        if (this.entityManagerInterface == null) {
            this.entityManagerInterface = emfInfo.getEntityManagerInterface();
            if (this.entityManagerInterface == null) {
                this.entityManagerInterface = EntityManager.class;
            }
        }
    } else {
        if (this.entityManagerInterface == null) {
            this.entityManagerInterface = EntityManager.class;
        }
    }
    this.shared = SharedEntityManagerCreator.createSharedEntityManager(emf, getJpaPropertyMap(), this.synchronizedWithTransaction, this.entityManagerInterface);
}
Also used : EntityManagerFactoryInfo(org.springframework.orm.jpa.EntityManagerFactoryInfo) EntityManagerFactory(javax.persistence.EntityManagerFactory)

Aggregations

EntityManagerFactoryInfo (org.springframework.orm.jpa.EntityManagerFactoryInfo)3 Test (org.junit.Test)2 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 SessionFactory (org.hibernate.SessionFactory)1