List of usage examples for org.springframework.orm.jpa EntityManagerFactoryInfo getNativeEntityManagerFactory
EntityManagerFactory getNativeEntityManagerFactory();
From source file:org.springframework.orm.jpa.ExtendedEntityManagerCreator.java
/** * Create a container-managed extended EntityManager proxy. * @param emf the EntityManagerFactory to create the EntityManager with. * If this implements the EntityManagerFactoryInfo interface, the corresponding * JpaDialect and PersistenceUnitInfo will be detected accordingly. * @param properties the properties to be passed into the {@code createEntityManager} * call (may be {@code null})/*from w w w. j ava2s .c o m*/ * @param synchronizedWithTransaction whether to automatically join ongoing * transactions (according to the JPA 2.1 SynchronizationType rules) * @return a container-managed EntityManager that expects container-driven lifecycle * management but may opt out of automatic transaction synchronization * @see javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map) * @since 4.0 */ public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, @Nullable Map<?, ?> properties, boolean synchronizedWithTransaction) { Assert.notNull(emf, "EntityManagerFactory must not be null"); if (emf instanceof EntityManagerFactoryInfo) { EntityManagerFactoryInfo emfInfo = (EntityManagerFactoryInfo) emf; EntityManagerFactory nativeEmf = emfInfo.getNativeEntityManagerFactory(); EntityManager rawEntityManager = (!CollectionUtils.isEmpty(properties) ? nativeEmf.createEntityManager(properties) : nativeEmf.createEntityManager()); return createProxy(rawEntityManager, emfInfo, true, synchronizedWithTransaction); } else { EntityManager rawEntityManager = (!CollectionUtils.isEmpty(properties) ? emf.createEntityManager(properties) : emf.createEntityManager()); return createProxy(rawEntityManager, null, null, null, null, true, synchronizedWithTransaction); } }