jpa/subsystem/src/main/java/org/jboss/as/jpa/container/AbstractEntityManager.java
protected <T> TypedQuery<T> detachTypedQueryNonTxInvocation(EntityManager underlyingEntityManager, TypedQuery<T> underLyingQuery) {
        if (!this.isExtendedPersistenceContext() && !this.isInTx()) {
            return new TypedQueryNonTxInvocationDetacher<>(underlyingEntityManager, underLyingQuery);
        }
        return underLyingQuery;
    }
protected <T> TypedQuery<T> detachTypedQueryNonTxInvocation(EntityManager underlyingEntityManager, TypedQuery<T> underLyingQuery) {
        if (!this.isExtendedPersistenceContext() && !this.isInTx()) {
            return new TypedQueryNonTxInvocationDetacher<>(underlyingEntityManager, underLyingQuery);
        }
        return underLyingQuery;
    }
used by TransactionScopedEntityManager to detach entities loaded by a query in a non-jta invocation.