/** * The JPA SFSB interceptor will track the stack of SFSB invocations. The underlying EM will be obtained from * the current SFSB being invoked (via our JPA SFSB interceptor). * * Every entity manager call (to AbstractEntityManager) will call this method to get the underlying entity manager * (e.g. the Hibernate persistence provider). * * See org.jboss.ejb3.stateful.EJB3XPCResolver.getExtendedPersistenceContext() to see the as6 implementation of this. * * @return EntityManager */ @Override protected EntityManager getEntityManager() { internalAssociateWithJtaTx(); return underlyingEntityManager; }
/** * The JPA SFSB interceptor will track the stack of SFSB invocations. The underlying EM will be obtained from * the current SFSB being invoked (via our JPA SFSB interceptor). * * Every entity manager call (to AbstractEntityManager) will call this method to get the underlying entity manager * (e.g. the Hibernate persistence provider). * * See org.jboss.ejb3.stateful.EJB3XPCResolver.getExtendedPersistenceContext() to see the as6 implementation of this. * * @return EntityManager */ @Override protected EntityManager getEntityManager() { internalAssociateWithJtaTx(); return underlyingEntityManager; }
@Override public void userTransactionStarted() throws SystemException { Map<String, ExtendedEntityManager> currentActiveEntityManagers = SFSBCallStack.currentSFSBCallStackInvocation(); if (currentActiveEntityManagers != null && currentActiveEntityManagers.size() > 0) { for (ExtendedEntityManager extendedEntityManager: currentActiveEntityManagers.values()) { extendedEntityManager.internalAssociateWithJtaTx(); } } } }
@Override public void userTransactionStarted() throws SystemException { Map<String, ExtendedEntityManager> currentActiveEntityManagers = SFSBCallStack.currentSFSBCallStackInvocation(); if (currentActiveEntityManagers != null && currentActiveEntityManagers.size() > 0) { for (ExtendedEntityManager extendedEntityManager: currentActiveEntityManagers.values()) { extendedEntityManager.internalAssociateWithJtaTx(); } } } }
/** * Push the passed SFSB context handle onto the invocation call stack * * @param entityManagers the entity manager map */ public static void pushCall(Map<String, ExtendedEntityManager> entityManagers) { currentSFSBCallStack().add(entityManagers); if (entityManagers != null) { /** * JPA 2.0 spec section 7.9.1 Container Responsibilities: * "When a business method of the stateful session bean is invoked, * if the stateful session bean uses container managed transaction demarcation, * and the entity manager is not already associated with the current JTA transaction, * the container associates the entity manager with the current JTA transaction and * calls EntityManager.joinTransaction. * " */ for(ExtendedEntityManager extendedEntityManager: entityManagers.values()) { extendedEntityManager.internalAssociateWithJtaTx(); } } }
/** * Push the passed SFSB context handle onto the invocation call stack * * @param entityManagers the entity manager map */ public static void pushCall(Map<String, ExtendedEntityManager> entityManagers) { currentSFSBCallStack().add(entityManagers); if (entityManagers != null) { /** * JPA 2.0 spec section 7.9.1 Container Responsibilities: * "When a business method of the stateful session bean is invoked, * if the stateful session bean uses container managed transaction demarcation, * and the entity manager is not already associated with the current JTA transaction, * the container associates the entity manager with the current JTA transaction and * calls EntityManager.joinTransaction. * " */ for(ExtendedEntityManager extendedEntityManager: entityManagers.values()) { extendedEntityManager.internalAssociateWithJtaTx(); } } }