public static void add(String puScopedName, EntityManager entityManager) { Map<String, EntityManager> map = nonTxStack.peek(); if (map == null && !nonTxStack.isEmpty()) { // replace null with a collection to hold the entity managers. map = new HashMap<String, EntityManager>(); nonTxStack.pop(); nonTxStack.push(map); // replace top of stack (currently null) with new collection } if (map != null) { map.put(puScopedName, entityManager); } } }
public static void add(String puScopedName, EntityManager entityManager) { Map<String, EntityManager> map = nonTxStack.peek(); if (map == null && !nonTxStack.isEmpty()) { // replace null with a collection to hold the entity managers. map = new HashMap<String, EntityManager>(); nonTxStack.pop(); nonTxStack.push(map); // replace top of stack (currently null) with new collection } if (map != null) { map.put(puScopedName, entityManager); } } }
/** * current session bean invocation is ending, close any transactional entity managers created without a JTA * transaction. */ public static void popCall() { Map<String, EntityManager> emStack = nonTxStack.pop(); if (emStack != null) { for (EntityManager entityManager : emStack.values()) { try { if (entityManager.isOpen()) { entityManager.close(); } } catch (RuntimeException safeToIgnore) { if (ROOT_LOGGER.isTraceEnabled()) { ROOT_LOGGER.trace("Could not close (non-transactional) container managed entity manager." + " This shouldn't impact application functionality (only read " + "operations occur in non-transactional mode)", safeToIgnore); } } } } }
/** * current session bean invocation is ending, close any transactional entity managers created without a JTA * transaction. */ public static void popCall() { Map<String, EntityManager> emStack = nonTxStack.pop(); if (emStack != null) { for (EntityManager entityManager : emStack.values()) { try { if (entityManager.isOpen()) { entityManager.close(); } } catch (RuntimeException safeToIgnore) { if (ROOT_LOGGER.isTraceEnabled()) { ROOT_LOGGER.trace("Could not close (non-transactional) container managed entity manager." + " This shouldn't impact application functionality (only read " + "operations occur in non-transactional mode)", safeToIgnore); } } } } }