/** * 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. * @return a container-managed EntityManager that will automatically participate * in any managed transaction * @see javax.persistence.EntityManagerFactory#createEntityManager() */ public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf) { return createContainerManagedEntityManager(emf, null, true); }
/** * 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}) * @return a container-managed EntityManager that will automatically participate * in any managed transaction * @see javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map) */ public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, @Nullable Map<?, ?> properties) { return createContainerManagedEntityManager(emf, properties, true); }
/** * 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. * @return a container-managed EntityManager that will automatically participate * in any managed transaction * @see javax.persistence.EntityManagerFactory#createEntityManager() */ public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf) { return createContainerManagedEntityManager(emf, null, true); }
protected EntityManager createContainerManagedEntityManager() { return ExtendedEntityManagerCreator.createContainerManagedEntityManager(this.entityManagerFactory); }
/** * 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}) * @return a container-managed EntityManager that will automatically participate * in any managed transaction * @see javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map) */ public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, @Nullable Map<?, ?> properties) { return createContainerManagedEntityManager(emf, properties, true); }
private EntityManager resolveExtendedEntityManager(Object target, @Nullable String requestingBeanName) { // Obtain EntityManager reference from JNDI? EntityManager em = getPersistenceContext(this.unitName, true); 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 container-managed extended EntityManager. em = ExtendedEntityManagerCreator.createContainerManagedEntityManager( emf, this.properties, this.synchronizedWithTransaction); } if (em instanceof EntityManagerProxy && beanFactory != null && requestingBeanName != null && beanFactory.containsBean(requestingBeanName) && !beanFactory.isPrototype(requestingBeanName)) { extendedEntityManagersToClose.put(target, ((EntityManagerProxy) em).getTargetEntityManager()); } return em; } }
private EntityManager resolveExtendedEntityManager(Object target, @Nullable String requestingBeanName) { // Obtain EntityManager reference from JNDI? EntityManager em = getPersistenceContext(this.unitName, true); 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 container-managed extended EntityManager. em = ExtendedEntityManagerCreator.createContainerManagedEntityManager( emf, this.properties, this.synchronizedWithTransaction); } if (em instanceof EntityManagerProxy && beanFactory != null && requestingBeanName != null && beanFactory.containsBean(requestingBeanName) && !beanFactory.isPrototype(requestingBeanName)) { extendedEntityManagersToClose.put(target, ((EntityManagerProxy) em).getTargetEntityManager()); } return em; } }
/** * 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. * @return a container-managed EntityManager that will automatically participate * in any managed transaction * @see javax.persistence.EntityManagerFactory#createEntityManager() */ public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf) { return createContainerManagedEntityManager(emf, null, true); }
/** * 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}) * @return a container-managed EntityManager that will automatically participate * in any managed transaction * @see javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map) */ public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, @Nullable Map<?, ?> properties) { return createContainerManagedEntityManager(emf, properties, true); }
private EntityManager resolveExtendedEntityManager(Object target, @Nullable String requestingBeanName) { // Obtain EntityManager reference from JNDI? EntityManager em = getPersistenceContext(this.unitName, true); 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 container-managed extended EntityManager. em = ExtendedEntityManagerCreator.createContainerManagedEntityManager( emf, this.properties, this.synchronizedWithTransaction); } if (em instanceof EntityManagerProxy && beanFactory != null && requestingBeanName != null && beanFactory.containsBean(requestingBeanName) && !beanFactory.isPrototype(requestingBeanName)) { extendedEntityManagersToClose.put(target, ((EntityManagerProxy) em).getTargetEntityManager()); } return em; } }