geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r532889 - in /geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence: CMPEntityManagerTxScoped.java NoTxQueryWrapper.java
Date Thu, 26 Apr 2007 22:12:09 GMT
Author: djencks
Date: Thu Apr 26 15:12:08 2007
New Revision: 532889

URL: http://svn.apache.org/viewvc?view=rev&rev=532889
Log:
GERONIMO-3121 Wrap Querys created outside a tx so we don't need to close the entity manager
immediately

Added:
    geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/NoTxQueryWrapper.java
      - copied, changed from r532876, incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/persistence/JtaQuery.java
Modified:
    geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/CMPEntityManagerTxScoped.java

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/CMPEntityManagerTxScoped.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/CMPEntityManagerTxScoped.java?view=diff&rev=532889&r1=532888&r2=532889
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/CMPEntityManagerTxScoped.java
(original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/CMPEntityManagerTxScoped.java
Thu Apr 26 15:12:08 2007
@@ -250,11 +250,7 @@
             return entityManager.createQuery(s);
         } else {
             entityManager = createEntityManager();
-            try {
-                return entityManager.createQuery(s);
-            } finally {
-                entityManager.close();
-            }
+            return new NoTxQueryWrapper(entityManager, entityManager.createQuery(s));
         }
     }
 
@@ -264,11 +260,7 @@
             return entityManager.createNamedQuery(s);
         } else {
             entityManager = createEntityManager();
-            try {
-                return entityManager.createNamedQuery(s);
-            } finally {
-                entityManager.close();
-            }
+            return new NoTxQueryWrapper(entityManager, entityManager.createNamedQuery(s));
         }
     }
 
@@ -278,11 +270,7 @@
             return entityManager.createNativeQuery(s);
         } else {
             entityManager = createEntityManager();
-            try {
-                return entityManager.createNativeQuery(s);
-            } finally {
-                entityManager.close();
-            }
+            return new NoTxQueryWrapper(entityManager, entityManager.createNativeQuery(s));
         }
     }
 
@@ -292,11 +280,7 @@
             return entityManager.createNativeQuery(s, aClass);
         } else {
             entityManager = createEntityManager();
-            try {
-                return entityManager.createNativeQuery(s, aClass);
-            } finally {
-                entityManager.close();
-            }
+            return new NoTxQueryWrapper(entityManager, entityManager.createNativeQuery(s,
aClass));
         }
     }
 
@@ -306,11 +290,7 @@
             return entityManager.createNativeQuery(s, s1);
         } else {
             entityManager = createEntityManager();
-            try {
-                return entityManager.createNativeQuery(s, s1);
-            } finally {
-                entityManager.close();
-            }
+            return new NoTxQueryWrapper(entityManager, entityManager.createNativeQuery(s,
s1));
         }
     }
 

Copied: geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/NoTxQueryWrapper.java
(from r532876, incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/persistence/JtaQuery.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/NoTxQueryWrapper.java?view=diff&rev=532889&p1=incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/persistence/JtaQuery.java&r1=532876&p2=geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/NoTxQueryWrapper.java&r2=532889
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/persistence/JtaQuery.java
(original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/NoTxQueryWrapper.java
Thu Apr 26 15:12:08 2007
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.openejb.persistence;
+package org.apache.geronimo.persistence;
 
 import javax.persistence.EntityManager;
 import javax.persistence.FlushModeType;
@@ -29,11 +29,11 @@
  * The JtaQuery is a wrapper around a query and and entity manager that automatically closes
the entity managers
  * when the query is finished.  This implementation is only for non-transaction queryies
  */
-public class JtaQuery implements Query {
+public class NoTxQueryWrapper implements Query {
     private final EntityManager entityManager;
     private final Query query;
 
-    public JtaQuery(EntityManager entityManager, Query query) {
+    public NoTxQueryWrapper(EntityManager entityManager, Query query) {
         this.entityManager = entityManager;
         this.query = query;
     }



Mime
View raw message