Requires that an active transaction exists for the current calling thread.

@return the ID of the active transaction, never {@code null}
@throws RelationalProviderException if the current thread is not associated with a transaction.
779185
protected static String requireActiveTransaction() {
        return Optional.ofNullable(ACTIVE_TX_ID.get()).orElseThrow(() -> new RelationalProviderException(
                RelationalProviderI18n.threadNotAssociatedWithTransaction,
                Thread.currentThread().getName()));
    }
835644
public final Transaction getTransaction()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "getTransaction"
                            );
        // If the log is full introduce a delay for a checkpoiunt before allowing the 
        // application to proceed.
        objectManagerState.transactionPacing();
        Transaction transaction = objectManagerState.getTransaction();

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "getTransaction"
                       , "returns transaction=" + transaction + "(Transaction)"
                            );
        return transaction;
    }
483790
public DbConn getConn()
    {
        Connection cnx = null;
        try
        {
            Thread.interrupted(); // this is VERY sad. Needed for Oracle driver which otherwise fails spectacularly.
            cnx = _ds.getConnection();
            if (cnx.getAutoCommit())
            {
                cnx.setAutoCommit(false);
                cnx.rollback(); // To ensure no open transaction created by the pool before changing TX mode
            }

            if (cnx.getTransactionIsolation() != Connection.TRANSACTION_READ_COMMITTED)
            {
                cnx.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
            }

            return new DbConn(this, cnx);
        }
        catch (SQLException e)
        {
            DbHelper.closeQuietly(cnx); // May have been left open when the pool has given us a failed connection.
            throw new DatabaseException(e);
        }
    }
688069
@Override
    public synchronized Transaction getContract() {
        checkState(multisigContract != null);
        if (stateMachine.getState() == State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER) {
            stateMachine.transition(State.READY);
        }
        return multisigContract;
    }
1197002
public String getTransactionId() throws SIMPException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getTransactionId");

    assertValidControllable();

    String id = null;
    PersistentTranId pTranId = msgItem.getTransactionId();
    if (pTranId != null)
    {
      id = pTranId.toTMString();
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getTransactionId", id);
    return id;
  }
352905
@Override
    EntityManager getEMInvocationInfo(boolean requireTx, LockModeType mode)
    {
        UOWCoordinator uowCoord = ivAbstractJPAComponent.getUOWCurrent().getUOWCoord();
        SynchronizationRegistryUOWScope uowSyncRegistry = getSynchronizationRegistryUOWScope(uowCoord);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "getEMInvocationInfo : " + requireTx + " : tid=" + txIdToString(uowCoord));

        boolean globalTx = uowCoord.isGlobal();

        // The container must throw the TransactionRequiredException if a transaction-scoped
        // persistence context is used, and the EntityManager persist, remove, merge, or refresh
        // method is invoked when no transaction is active.
        if (!globalTx && (requireTx || (mode != null && !LockModeType.NONE.equals(mode)))) //d597764
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(tc, "getEMInvocationInfo : TransactionRequiredException: " +
                            "No active transaction for " + ivPuRefId);

            // The provider is not responsible to throw this exception for
            //  persist, remove, refresh and merge methods since these methods are supported in
            //  extend-scoped persistence context. The "container" must enforced this
            //  rule per JPA spec.
            throw new TransactionRequiredException("No active transaction for " + ivPuRefId);
        }

        // (JPA 5.6.3.1 Requirements for Persistence Context Propagation)
        // Persistence contexts are propagated by the container across component invocations as follows.
        //
        // If a component is called and there is no JTA transaction or the JTA transaction is not
        // propagated, the persistence context is not propagated.
        // * If an entity manager is then invoked from within the component:
        // * Invocation of an entity manager defined with PersistenceContext-Type.TRANSACTION will
        //      result in use of a new persistence context (as described in section 5.6.1).
        // * Invocation of an entity manager defined with PersistenceContext-Type.EXTENDED will
        //      result in the use of the existing extended persistence context bound to that component.
        // * If the entity manager is invoked within a JTA transaction, the persistence context will
        //      be bound to the JTA transaction.
        //
        // If a component is called and the JTA transaction is propagated into that component:
        // * If the component is a stateful session bean to which an extended persistence context
        //      has been bound and there is a different persistence context bound to the JTA transaction,
        //      an EJBException is thrown by the container.
        // * Otherwise, if there is a persistence context bound to the JTA transaction, that
        //      persistence context is propagated and used.

        JPAExEmInvocation invocationEm = getInvocation(uowSyncRegistry, ivTxKeyPuId); // d683375, d689596
        if (invocationEm == null)
        {
            EntityManager em = ivEntityManagerPool.getEntityManager(globalTx, ivUnsynchronized); // d510184
            if (globalTx)
            {
                // 5.9.1 Container Responsibilities
                //  For the management of a transaction-scoped persistence context, if there is no
                //  EntityManager already associated with the JTA transaction:
                //  * The container creates a new entity manager by calling EntityManagerFactory.createEntityManager
                //      when the first invocation of an entity manager with PersistenceContextType.TRANSACTION
                //      occurs within the scope of a business method executing in the JTA transaction.
                //
                //  When the container creates an entity manager, it may pass a map of properties to the
                //      persistence provider by using the EntityManagerFactory.createEntityManager(Map map)
                //      method. If properties have been specified in the PersistenceContext annotation or
                //      the persistence-context-ref deployment descriptor element, this method must be
                //      used and the map must include the specified properties.

                JPATxEmInvocation txEmInvocation = createJPATxEmInvocation(uowCoord, em);

                // Register invocation object to transaction manager for clean up on commit/rollback.
                registerEmInvocation(uowCoord, txEmInvocation); //d638095.2

                invocationEm = txEmInvocation;
            }
            else
            {
                // 5.6.3.1 Requirements for Persistence Context Propagation
                // Persistence contexts are propagated by the container across component invocations as follows.
                // If a component is called and there is no JTA transaction or the JTA transaction is not propagated,
                //  the persistence context is not propagated.
                //  *   If an entity manager is then invoked from within the component:
                //      *   Invocation of an entity manager defined with PersistenceContext-Type.TRANSACTION will
                //          result in use of a new persistence context (as described in section 5.6.1).
                //
                // 5.9.1 Container Responsibilities
                // [39] The container may choose to pool EntityManagers and instead of creating and
                //      closing in each case acquire one from its pool and call clear() on it.

                // For a specific UnitOfWork a new JPANoTxEmInvocation object and
                // Entity Manager instance will be created.
                // The invocation objects will be registered with the UOW and held
                // in a map keyed by the UnitOfWork id so that the same invocation
                // and entity manager are used for the entire LTC or Activity Session.
                // Both the invocation object and Entity Manager instance will be pooled
                // or closed during afterCompletion processing of the UOW.

                JPANoTxEmInvocation noTxEmInvocation = createJPANoTxEmInvocation(uowCoord, em);

                // Register invocation object to transaction manager for clean up on commit/rollback.
                // Currently registration for local transactions is not Tiered.  This may need to change
                // if conflicts arise.  //d638095.4

                LocalTransactionCoordinator ltCoord = (LocalTransactionCoordinator) uowCoord;
                ltCoord.enlistSynchronization(noTxEmInvocation); // F61571

                invocationEm = noTxEmInvocation;
            }

            setInvocation(uowSyncRegistry, ivTxKeyPuId, invocationEm); // d683375, d689596
        } else {
            // JPA 2.1: 7.6.4.1 Requirements for Persistence Context Propagation
            // If a component is called and the JTA transaction is propagated into that component:
            //   * If there is a persistence context of type SynchronizationType.UNSYNCHRONIZED associated with the 
            //     JTA transaction and the target component specifies a persistence context of type 
            //     SynchronizationType.SYNCHRONIZED, the IllegalStateException is thrown by the container.
            if (invocationEm.isTxUnsynchronized() && !isTxUnsynchronized()) {
                Tr.error(tc, "JPATXSYNC_ILLEGAL_PROPAGATION_CWWJP0046E");
                String msgTxt = "CWWJP0046E: An UNSYNCHRONIZED JPA persistence context cannot be propagated into a SYNCHRONIZED EntityManager.";
                throw new IllegalStateException(msgTxt);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "getEMInvocationInfo : " + invocationEm);
        return invocationEm;
    }
1204668
public WePayOrder queryByTransactionId(String transactionId){
        checkNotNullAndEmpty(transactionId, "transactionId");
        Map<String, String> queryParams = new TreeMap<>();
        put(queryParams, WepayField.TRANSACTION_ID, transactionId);
        return doQueryOrder(queryParams);
    }
70113
public static Transaction getTransactionAndMarkForJoin(Session session, ServiceManager serviceManager) throws ClassNotFoundException,
			NoSuchMethodException, IllegalAccessException, InvocationTargetException {
		Transaction transaction = session.getTransaction();
		doMarkforJoined( serviceManager, transaction );
		return transaction;
	}
606908
public final int getTransactionType()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(this, tc, "getTransactionType");
            SibTr.exit(this, tc, "getTransactionType", "return=TX_GLOBAL");
        }
        return TX_GLOBAL;
    }
1117754
private TransactionalType getTransactionalType(FQMethod method) {
        TransactionalType type = transactionalMethods.get(method);
        if (type == null) {
            return TransactionalType.NONE;
        }

        return type;
    }
1214215
private UUID retrievePaymentId(@Nullable final String paymentExternalKey, @Nullable final String paymentTransactionExternalKey, final InternalCallContext internalCallContext) throws PaymentApiException {
        if (paymentExternalKey != null) {
            final PaymentModelDao payment = paymentDao.getPaymentByExternalKey(paymentExternalKey, internalCallContext);
            if (payment != null) {
                return payment.getId();
            }
        }

        if (paymentTransactionExternalKey == null) {
            return null;
        }

        final List<PaymentTransactionModelDao> paymentTransactionModelDaos = paymentDao.getPaymentTransactionsByExternalKey(paymentTransactionExternalKey, internalCallContext);
        for (final PaymentTransactionModelDao paymentTransactionModelDao : paymentTransactionModelDaos) {
            if (paymentTransactionModelDao.getTransactionStatus() == TransactionStatus.SUCCESS ||
                paymentTransactionModelDao.getTransactionStatus() == TransactionStatus.PENDING ||
                paymentTransactionModelDao.getTransactionStatus() == TransactionStatus.UNKNOWN) {
                return paymentTransactionModelDao.getPaymentId();
            }
        }

        UUID paymentIdCandidate = null;
        for (final PaymentTransactionModelDao paymentTransactionModelDao : paymentTransactionModelDaos) {
            if (paymentTransactionModelDao.getTransactionStatus() == TransactionStatus.PAYMENT_FAILURE ||
                paymentTransactionModelDao.getTransactionStatus() == TransactionStatus.PLUGIN_FAILURE) {
                if (paymentIdCandidate == null) {
                    paymentIdCandidate = paymentTransactionModelDao.getPaymentId();
                } else if (!paymentIdCandidate.equals(paymentTransactionModelDao.getPaymentId())) {
                    throw new PaymentApiException(ErrorCode.PAYMENT_INTERNAL_ERROR, "Multiple failed payments sharing the same transaction external key - this should never happen");
                }
            }
        }

        return paymentIdCandidate;
    }
146034
@Nullable
    public Relationship getRelationship(@Nonnull String id) {
        if (id == null || id.trim().length() == 0) {
            throw new IllegalArgumentException("A relationship ID must be specified.");
        }

        return relationshipsById.get(id);
    }
300537
public Identity getIdentity()
    {
        if(identity == null)
        {
            identity = tx.getBroker().serviceIdentity().buildIdentity(obj);
        }
        return identity;
    }
316098
public int getIndex() {
        List<TransactionOutput> outputs = getParentTransaction().getOutputs();
        for (int i = 0; i < outputs.size(); i++) {
            if (outputs.get(i) == this)
                return i;
        }
        throw new IllegalStateException("Output linked to wrong parent transaction?");
    }
187218
public Transaction newTransaction()
    {
        if ((getCurrentDatabase() == null))
        {
            throw new DatabaseClosedException("Database is NULL, must have a DB in order to create a transaction");
        }
        TransactionImpl tx = new TransactionImpl(this);
        try
        {
            getConfigurator().configure(tx);
        }
        catch (ConfigurationException e)
        {
            throw new ODMGRuntimeException("Error in configuration of TransactionImpl instance: " + e.getMessage());
        }
        return tx;
    }
140536
public final int getTransactionIsolation() 
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) 
        {
            try {
                Tr.debug(this, tc, "The current isolation level from our tracking is: ", currentTransactionIsolation);
                Tr.debug(this, tc, "Isolation reported by the JDBC driver: ", sqlConn.getTransactionIsolation());
            } catch (Throwable x) {
                // NO FFDC needed
                // do nothing as we are taking the isolation level here for debugging reasons only
            }
        }

        return currentTransactionIsolation;
    }
1013181
public static String getCurrentId()
  {
    SystemManager system = getCurrent();

    if (system == null) {
      ClassLoader loader = Thread.currentThread().getContextClassLoader();

      throw new IllegalStateException(L.l("{0} is not available in this context.\n  {1}",
                                          SystemManager.class.getSimpleName(),
                                          loader));
    }

    return system.getId();
  }