org.springframework.orm.jpa.SharedEntityManagerCreator Java Examples
The following examples show how to use
org.springframework.orm.jpa.SharedEntityManagerCreator.
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 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 #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 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 #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 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 #7
Source File: JpaLockingStrategyTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
private LockingStrategy newLockTxProxy(final String appId, final String uniqueId, final int ttl) { final JpaLockingStrategy lock = new JpaLockingStrategy(); lock.entityManager = SharedEntityManagerCreator.createSharedEntityManager(factory); lock.setApplicationId(appId); lock.setUniqueId(uniqueId); lock.setLockTimeout(ttl); return (LockingStrategy) Proxy.newProxyInstance( JpaLockingStrategy.class.getClassLoader(), new Class[] {LockingStrategy.class}, new TransactionalLockInvocationHandler(lock, this.txManager)); }
Example #8
Source File: JpaLockingStrategyTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
private LockingStrategy newLockTxProxy(final String appId, final String uniqueId, final int ttl) { final JpaLockingStrategy lock = new JpaLockingStrategy(); lock.entityManager = SharedEntityManagerCreator.createSharedEntityManager(factory); lock.setApplicationId(appId); lock.setUniqueId(uniqueId); lock.setLockTimeout(ttl); return (LockingStrategy) Proxy.newProxyInstance( JpaLockingStrategy.class.getClassLoader(), new Class[] {LockingStrategy.class}, new TransactionalLockInvocationHandler(lock)); }
Example #9
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 #10
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 #11
Source File: AbstractJpaTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) { this.entityManagerFactory = entityManagerFactory; this.sharedEntityManager = SharedEntityManagerCreator.createSharedEntityManager(this.entityManagerFactory); }
Example #12
Source File: OpenJpaEntityManagerFactoryIntegrationTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
public void testCanGetSharedOpenJpaEntityManagerProxy() { OpenJPAEntityManager openJPAEntityManager = (OpenJPAEntityManager) SharedEntityManagerCreator.createSharedEntityManager( entityManagerFactory, null, OpenJPAEntityManager.class); assertNotNull(openJPAEntityManager.getDelegate()); }
Example #13
Source File: FileConversionQueueItemRepositoryImpl.java From sakai with Educational Community License v2.0 | 4 votes |
public FileConversionQueueItemRepositoryImpl(EntityManagerFactory entityManagerFactory) { this(SharedEntityManagerCreator.createSharedEntityManager(entityManagerFactory)); }
Example #14
Source File: FileConversionQueueItemRepositoryImpl.java From sakai with Educational Community License v2.0 | 4 votes |
public FileConversionQueueItemRepositoryImpl(EntityManagerFactory entityManagerFactory) { this(SharedEntityManagerCreator.createSharedEntityManager(entityManagerFactory)); }
Example #15
Source File: RepositoryHelper.java From es with Apache License 2.0 | 4 votes |
public static void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) { entityManager = SharedEntityManagerCreator.createSharedEntityManager(entityManagerFactory); }