Repository: tomee Updated Branches: refs/heads/tomee-1.7.x 5d57a556c -> d7b4a7bba
openejb.jpa.query.wrap-no-tx flag to control wrapping or not of not jta queries from jta entity manager Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/d7b4a7bb Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/d7b4a7bb Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/d7b4a7bb Branch: refs/heads/tomee-1.7.x Commit: d7b4a7bba2df6d5b8d513f5a38c259c78f2e0656 Parents: 5d57a55 Author: Romain Manni-Bucau <[email protected]> Authored: Thu Mar 26 14:00:32 2015 +0100 Committer: Romain Manni-Bucau <[email protected]> Committed: Thu Mar 26 14:00:32 2015 +0100 ---------------------------------------------------------------------- .../org/apache/openejb/persistence/JtaEntityManager.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/d7b4a7bb/container/openejb-core/src/main/java/org/apache/openejb/persistence/JtaEntityManager.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/persistence/JtaEntityManager.java b/container/openejb-core/src/main/java/org/apache/openejb/persistence/JtaEntityManager.java index 5151885..1dfb8b8 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/persistence/JtaEntityManager.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/persistence/JtaEntityManager.java @@ -18,6 +18,7 @@ package org.apache.openejb.persistence; import org.apache.openejb.OpenEJBRuntimeException; +import org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory; import org.apache.openejb.core.ivm.IntraVmArtifact; import org.apache.openejb.util.LogCategory; import org.apache.openejb.util.Logger; @@ -72,6 +73,7 @@ public class JtaEntityManager implements EntityManager, Serializable { private final boolean extended; private final String unitName; private final Logger logger; + private final boolean wrapNoTxQueries; public JtaEntityManager(final JtaEntityManagerRegistry registry, final EntityManagerFactory entityManagerFactory, final Map properties, final String unitName) { this(unitName, registry, entityManagerFactory, properties, false); @@ -90,6 +92,9 @@ public class JtaEntityManager implements EntityManager, Serializable { this.properties = properties; this.extended = extended; logger = unitName == null ? baseLogger : baseLogger.getChildLogger(unitName); + final String wrapConfig = ReloadableEntityManagerFactory.class.isInstance(entityManagerFactory) ? + ReloadableEntityManagerFactory.class.cast(entityManagerFactory).getUnitProperties().getProperty("openejb.jpa.query.wrap-no-tx", "true") : "true"; + this.wrapNoTxQueries = wrapConfig == null || "true".equalsIgnoreCase(wrapConfig); } EntityManager getEntityManager() { @@ -320,14 +325,14 @@ public class JtaEntityManager implements EntityManager, Serializable { } private Query proxyIfNoTx(final Method method, final Object... args) { - if (!extended && !isTransactionActive()) { + if (wrapNoTxQueries && !extended && !isTransactionActive()) { return new JtaQuery(getEntityManager(), this, method, args); } return createQuery(Query.class, getEntityManager(), method, args); } private <T> TypedQuery<T> typedProxyIfNoTx(final Method method, final Object... args) { - if (!extended && !isTransactionActive()) { + if (wrapNoTxQueries && !extended && !isTransactionActive()) { return new JtaTypedQuery<T>(getEntityManager(), this, method, args); } return createQuery(TypedQuery.class, getEntityManager(), method, args);
