/** * Returns the delegated EntityManager. If the persistence context is transaction-scoped, the EntityManager associated with the current transaction will be * used. * * @return the EntityManager */ private EntityManager getEntityManager() { // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } return emService.getEntityManager(unitName, this, trx); } catch (SystemException | Fabric3Exception e) { throw new ServiceRuntimeException(e); } }
/** * Initializes the delegated EntityManager. If the persistence context is transaction-scoped, the EntityManager associated with the current transaction will * be used. Otherwise, if the persistence context is extended, the EntityManager associated with the current conversation will be used. */ private void initEntityManager() { if (em != null) { return; } // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } em = emService.getEntityManager(unitName, this, trx); } catch (SystemException | Fabric3Exception e) { throw new ServiceRuntimeException(e); } }
/** * Returns the delegated EntityManager. If the persistence context is transaction-scoped, the EntityManager associated with the current transaction will be * used. * * @return the EntityManager */ private EntityManager getEntityManager() { // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } return emService.getEntityManager(unitName, this, trx); } catch (SystemException | Fabric3Exception e) { throw new ServiceRuntimeException(e); } }
/** * Initializes the delegated EntityManager. If the persistence context is transaction-scoped, the EntityManager associated with the current transaction will * be used. Otherwise, if the persistence context is extended, the EntityManager associated with the current conversation will be used. */ private void initEntityManager() { if (em != null) { return; } // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } em = emService.getEntityManager(unitName, this, trx); } catch (SystemException | Fabric3Exception e) { throw new ServiceRuntimeException(e); } }
/** * Returns the delegated Session. If the persistence context is transaction-scoped, the Session associated with the current transaction will be used. * * @return the Session */ private Session getSessionLocal() { // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } EntityManager em = emService.getEntityManager(unitName, this, trx); return (Session) em.getDelegate(); } catch (SystemException | Fabric3Exception e) { throw new ServiceRuntimeException(e); } }
/** * Returns the delegated Session. If the persistence context is transaction-scoped, the Session associated with the current transaction will be used. * * @return the Session */ private Session getSessionLocal() { // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } EntityManager em = emService.getEntityManager(unitName, this, trx); return (Session) em.getDelegate(); } catch (SystemException | Fabric3Exception e) { throw new ServiceRuntimeException(e); } }
/** * Initializes the delegated Session. If the persistence context is transaction-scoped, the Session associated with the current transaction will be used. */ private void initSession() { if (session != null) { return; } // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } EntityManager em = emService.getEntityManager(unitName, this, trx); session = (Session) em.getDelegate(); } catch (SystemException | Fabric3Exception e) { throw new ServiceRuntimeException(e); } }
/** * Initializes the delegated Session. If the persistence context is transaction-scoped, the Session associated with the current transaction will be used. */ private void initSession() { if (session != null) { return; } // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } EntityManager em = emService.getEntityManager(unitName, this, trx); session = (Session) em.getDelegate(); } catch (SystemException | Fabric3Exception e) { throw new ServiceRuntimeException(e); } }
/** * Returns the delegated EntityManager. If the persistence context is transaction-scoped, the EntityManager associated with the current * transaction will be used. * * @return the EntityManager */ private EntityManager getEntityManager() { // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } return emService.getEntityManager(unitName, this, trx); } catch (SystemException e) { throw new ServiceRuntimeException(e); } catch (EntityManagerCreationException e) { throw new ServiceRuntimeException(e); } }
/** * Initializes the delegated EntityManager. If the persistence context is transaction-scoped, the EntityManager associated with the current * transaction will be used. Otherwise, if the persistence context is extended, the EntityManager associated with the current conversation will be * used. */ private void initEntityManager() { if (em != null) { return; } // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } em = emService.getEntityManager(unitName, this, trx); } catch (SystemException e) { throw new ServiceRuntimeException(e); } catch (EntityManagerCreationException e) { throw new ServiceRuntimeException(e); } }
/** * Returns the delegated Session. If the persistence context is transaction-scoped, the Session associated with the current transaction will be used. * * @return the Session */ private Session getSession() { // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } EntityManager em = emService.getEntityManager(unitName, this, trx); return (Session) em.getDelegate(); } catch (SystemException e) { throw new ServiceRuntimeException(e); } catch (EntityManagerCreationException e) { throw new ServiceRuntimeException(e); } }
/** * Initializes the delegated Session. If the persistence context is transaction-scoped, the Session associated with the current transaction will be used. */ private void initSession() { if (session != null) { return; } // a transaction-scoped persistence context try { Transaction trx = tm.getTransaction(); if (trx == null) { throw new IllegalStateException("A transaction is not active - ensure the component is executing in a managed transaction"); } EntityManager em = emService.getEntityManager(unitName, this, trx); session = (Session) em.getDelegate(); } catch (SystemException e) { throw new ServiceRuntimeException(e); } catch (EntityManagerCreationException e) { throw new ServiceRuntimeException(e); } }