org.springframework.orm.jpa.EntityManagerFactoryInfo Java Examples
The following examples show how to use
org.springframework.orm.jpa.EntityManagerFactoryInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SharedEntityManagerBean.java From spring-analysis-note with MIT License | 6 votes |
@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); }
Example #2
Source File: SharedEntityManagerBean.java From spring4-understanding with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: SharedEntityManagerBean.java From lams with GNU General Public License v2.0 | 6 votes |
@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); }
Example #4
Source File: SharedEntityManagerBean.java From java-technology-stack with MIT License | 6 votes |
@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); }
Example #5
Source File: PersistenceAnnotationBeanPostProcessor.java From spring-analysis-note with MIT License | 5 votes |
private EntityManager resolveEntityManager(@Nullable 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; }
Example #6
Source File: PersistenceAnnotationBeanPostProcessor.java From spring4-understanding with Apache License 2.0 | 5 votes |
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; }
Example #7
Source File: PersistenceAnnotationBeanPostProcessor.java From lams with GNU General Public License v2.0 | 5 votes |
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; }
Example #8
Source File: JpaTransactionManagerHandler.java From opensharding-spi-impl with Apache License 2.0 | 5 votes |
private EntityManager createEntityManager() { EntityManagerFactory entityManagerFactory = transactionManager.getEntityManagerFactory(); if (entityManagerFactory instanceof EntityManagerFactoryInfo) { entityManagerFactory = ((EntityManagerFactoryInfo) entityManagerFactory).getNativeEntityManagerFactory(); } Map<String, Object> properties = transactionManager.getJpaPropertyMap(); return !CollectionUtils.isEmpty(properties) ? entityManagerFactory.createEntityManager(properties) : entityManagerFactory.createEntityManager(); }
Example #9
Source File: HibernateMultiEntityManagerFactoryIntegrationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() { assertTrue("Must have introduced config interface", this.entityManagerFactory instanceof EntityManagerFactoryInfo); EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) this.entityManagerFactory; assertEquals("Drivers", emfi.getPersistenceUnitName()); assertNotNull("PersistenceUnitInfo must be available", emfi.getPersistenceUnitInfo()); assertNotNull("Raw EntityManagerFactory must be available", emfi.getNativeEntityManagerFactory()); }
Example #10
Source File: PersistenceAnnotationBeanPostProcessor.java From java-technology-stack with MIT License | 5 votes |
private EntityManager resolveEntityManager(@Nullable 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; }
Example #11
Source File: HibernateMultiEntityManagerFactoryIntegrationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() { assertTrue("Must have introduced config interface", this.entityManagerFactory instanceof EntityManagerFactoryInfo); EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) this.entityManagerFactory; assertEquals("Drivers", emfi.getPersistenceUnitName()); assertNotNull("PersistenceUnitInfo must be available", emfi.getPersistenceUnitInfo()); assertNotNull("Raw EntityManagerFactory must be available", emfi.getNativeEntityManagerFactory()); }
Example #12
Source File: HibernateEntityManagerFactoryIntegrationTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() { EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory; assertTrue(emfi.getNativeEntityManagerFactory() instanceof org.hibernate.jpa.HibernateEntityManagerFactory); assertTrue(emfi.getNativeEntityManagerFactory() instanceof SessionFactory); // as of Hibernate 5.2 }
Example #13
Source File: EclipseLinkEntityManagerFactoryIntegrationTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void testCanCastNativeEntityManagerFactoryToEclipseLinkEntityManagerFactoryImpl() { EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory; assertTrue(emfi.getNativeEntityManagerFactory().getClass().getName().endsWith("EntityManagerFactoryImpl")); }
Example #14
Source File: HibernateNativeEntityManagerFactoryIntegrationTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() { assertFalse("Must not have introduced config interface", entityManagerFactory instanceof EntityManagerFactoryInfo); }
Example #15
Source File: HibernateNativeEntityManagerFactoryIntegrationTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() { assertFalse("Must not have introduced config interface", entityManagerFactory instanceof EntityManagerFactoryInfo); }
Example #16
Source File: HibernateEntityManagerFactoryIntegrationTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() { EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory; assertTrue(emfi.getNativeEntityManagerFactory() instanceof org.hibernate.jpa.HibernateEntityManagerFactory); assertTrue(emfi.getNativeEntityManagerFactory() instanceof SessionFactory); // as of Hibernate 5.2 }
Example #17
Source File: EclipseLinkEntityManagerFactoryIntegrationTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void testCanCastNativeEntityManagerFactoryToEclipseLinkEntityManagerFactoryImpl() { EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory; assertTrue(emfi.getNativeEntityManagerFactory().getClass().getName().endsWith("EntityManagerFactoryImpl")); }
Example #18
Source File: EclipseLinkEntityManagerFactoryIntegrationTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
public void testCanCastNativeEntityManagerFactoryToEclipseLinkEntityManagerFactoryImpl() { EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory; assertTrue(emfi.getNativeEntityManagerFactory().getClass().getName().endsWith("EntityManagerFactoryImpl")); }
Example #19
Source File: HibernateEntityManagerFactoryIntegrationTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() { EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory; assertTrue(emfi.getNativeEntityManagerFactory() instanceof HibernateEntityManagerFactory); }
Example #20
Source File: OpenJpaEntityManagerFactoryIntegrationTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
public void testCanCastNativeEntityManagerFactoryToOpenJpaEntityManagerFactoryImpl() { EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory; assertTrue("native EMF expected", emfi.getNativeEntityManagerFactory() instanceof OpenJPAEntityManagerFactory); }
Example #21
Source File: JPAPerister.java From statefulj with Apache License 2.0 | 4 votes |
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); }