Java 类org.springframework.orm.jpa.EntityManagerFactoryInfo 实例源码

项目:lams    文件:SharedEntityManagerBean.java   
@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);
}
项目:spring4-understanding    文件:SharedEntityManagerBean.java   
@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);
}
项目:class-guard    文件:PersistenceAnnotationBeanPostProcessor.java   
private EntityManager resolveEntityManager(String requestingBeanName) {
    // Obtain EntityManager reference from JNDI?
    EntityManager em = getPersistenceContext(this.unitName, false);
    if (em == null) {
        // No pre-built EntityManager found -> build one based on factory.
        // Obtain EntityManagerFactory from JNDI?
        EntityManagerFactory emf = getPersistenceUnit(this.unitName);
        if (emf == null) {
            // Need to search for EntityManagerFactory beans.
            emf = findEntityManagerFactory(this.unitName, requestingBeanName);
        }
        // Inject a shared transactional EntityManager proxy.
        if (emf instanceof EntityManagerFactoryInfo &&
                ((EntityManagerFactoryInfo) emf).getEntityManagerInterface() != null) {
            // Create EntityManager based on the info's vendor-specific type
            // (which might be more specific than the field's type).
            em = SharedEntityManagerCreator.createSharedEntityManager(emf, this.properties);
        }
        else {
            // Create EntityManager based on the field's type.
            em = SharedEntityManagerCreator.createSharedEntityManager(emf, this.properties, getResourceType());
        }
    }
    return em;
}
项目:lams    文件:PersistenceAnnotationBeanPostProcessor.java   
private EntityManager resolveEntityManager(String requestingBeanName) {
    // Obtain EntityManager reference from JNDI?
    EntityManager em = getPersistenceContext(this.unitName, false);
    if (em == null) {
        // No pre-built EntityManager found -> build one based on factory.
        // Obtain EntityManagerFactory from JNDI?
        EntityManagerFactory emf = getPersistenceUnit(this.unitName);
        if (emf == null) {
            // Need to search for EntityManagerFactory beans.
            emf = findEntityManagerFactory(this.unitName, requestingBeanName);
        }
        // Inject a shared transactional EntityManager proxy.
        if (emf instanceof EntityManagerFactoryInfo &&
                ((EntityManagerFactoryInfo) emf).getEntityManagerInterface() != null) {
            // Create EntityManager based on the info's vendor-specific type
            // (which might be more specific than the field's type).
            em = SharedEntityManagerCreator.createSharedEntityManager(
                    emf, this.properties, this.synchronizedWithTransaction);
        }
        else {
            // Create EntityManager based on the field's type.
            em = SharedEntityManagerCreator.createSharedEntityManager(
                    emf, this.properties, this.synchronizedWithTransaction, getResourceType());
        }
    }
    return em;
}
项目:spring4-understanding    文件:PersistenceAnnotationBeanPostProcessor.java   
private EntityManager resolveEntityManager(String requestingBeanName) {
    // Obtain EntityManager reference from JNDI?
    EntityManager em = getPersistenceContext(this.unitName, false);
    if (em == null) {
        // No pre-built EntityManager found -> build one based on factory.
        // Obtain EntityManagerFactory from JNDI?
        EntityManagerFactory emf = getPersistenceUnit(this.unitName);
        if (emf == null) {
            // Need to search for EntityManagerFactory beans.
            emf = findEntityManagerFactory(this.unitName, requestingBeanName);
        }
        // Inject a shared transactional EntityManager proxy.
        if (emf instanceof EntityManagerFactoryInfo &&
                ((EntityManagerFactoryInfo) emf).getEntityManagerInterface() != null) {
            // Create EntityManager based on the info's vendor-specific type
            // (which might be more specific than the field's type).
            em = SharedEntityManagerCreator.createSharedEntityManager(
                    emf, this.properties, this.synchronizedWithTransaction);
        }
        else {
            // Create EntityManager based on the field's type.
            em = SharedEntityManagerCreator.createSharedEntityManager(
                    emf, this.properties, this.synchronizedWithTransaction, getResourceType());
        }
    }
    return em;
}
项目:class-guard    文件:SharedEntityManagerBean.java   
public final void afterPropertiesSet() {
    EntityManagerFactory emf = getEntityManagerFactory();
    if (emf == null) {
        throw new IllegalArgumentException("'entityManagerFactory' or 'persistenceUnitName' is required");
    }
    Class[] ifcs = null;
    if (emf instanceof EntityManagerFactoryInfo) {
        EntityManagerFactoryInfo emfInfo = (EntityManagerFactoryInfo) emf;
        if (this.entityManagerInterface == null) {
            this.entityManagerInterface = emfInfo.getEntityManagerInterface();
            if (this.entityManagerInterface == null) {
                this.entityManagerInterface = EntityManager.class;
            }
        }
        JpaDialect jpaDialect = emfInfo.getJpaDialect();
        if (jpaDialect != null && jpaDialect.supportsEntityManagerPlusOperations()) {
            ifcs = new Class[] {this.entityManagerInterface, EntityManagerPlus.class};
        }
        else {
            ifcs = new Class[] {this.entityManagerInterface};
        }
    }
    else {
        if (this.entityManagerInterface == null) {
            this.entityManagerInterface = EntityManager.class;
        }
        ifcs = new Class[] {this.entityManagerInterface};
    }
    this.shared = SharedEntityManagerCreator.createSharedEntityManager(emf, getJpaPropertyMap(), ifcs);
}
项目:spring4-understanding    文件:EclipseLinkEntityManagerFactoryIntegrationTests.java   
public void testCanCastNativeEntityManagerFactoryToEclipseLinkEntityManagerFactoryImpl() {
    EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
    assertTrue(emfi.getNativeEntityManagerFactory().getClass().getName().endsWith("EntityManagerFactoryImpl"));
}
项目:spring4-understanding    文件:HibernateEntityManagerFactoryIntegrationTests.java   
public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() {
    EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
    assertTrue(emfi.getNativeEntityManagerFactory() instanceof HibernateEntityManagerFactory);
}
项目:spring4-understanding    文件:OpenJpaEntityManagerFactoryIntegrationTests.java   
public void testCanCastNativeEntityManagerFactoryToOpenJpaEntityManagerFactoryImpl() {
    EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
    assertTrue("native EMF expected", emfi.getNativeEntityManagerFactory() instanceof OpenJPAEntityManagerFactory);
}
项目:class-guard    文件:EclipseLinkEntityManagerFactoryIntegrationTests.java   
public void testCanCastNativeEntityManagerFactoryToTopLinkEntityManagerFactoryImpl() {
    EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
    assertTrue(emfi.getNativeEntityManagerFactory().getClass().getName().endsWith("EntityManagerFactoryImpl"));
}
项目:class-guard    文件:HibernateEntityManagerFactoryIntegrationTests.java   
public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() {
    EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
    assertTrue(emfi.getNativeEntityManagerFactory() instanceof HibernateEntityManagerFactory);
}
项目:class-guard    文件:TopLinkEntityManagerFactoryIntegrationTests.java   
public void testCanCastNativeEntityManagerFactoryToTopLinkEntityManagerFactoryImpl() {
    EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
    assertTrue(emfi.getNativeEntityManagerFactory().getClass().getName().endsWith("EntityManagerFactoryImpl"));
}
项目:class-guard    文件:OpenJpaEntityManagerFactoryIntegrationTests.java   
public void testCanCastNativeEntityManagerFactoryToOpenJpaEntityManagerFactoryImpl() {
    EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
    assertTrue("native EMF expected", emfi.getNativeEntityManagerFactory() instanceof OpenJPAEntityManagerFactory);
}
项目:statefulj    文件:JPAPerister.java   
public JPAPerister(List<State<T>> states, State<T> startState, Class<T> clazz, EntityManagerFactoryInfo entityManagerFactory, PlatformTransactionManager transactionManager) {
    this(states, null, startState, clazz, entityManagerFactory.getNativeEntityManagerFactory().createEntityManager(), transactionManager);
}