db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1365848 - in /db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base: retrieveByPK.vm retrieveByPKs.vm
Date Thu, 26 Jul 2012 00:03:40 GMT
Author: tfischer
Date: Thu Jul 26 00:03:39 2012
New Revision: 1365848

URL: http://svn.apache.org/viewvc?rev=1365848&view=rev
Log:
do not use Torque.getConnection() and Torque.closeConnection() - this kills pluggable transaction
handling

Modified:
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPKs.vm

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm?rev=1365848&r1=1365847&r2=1365848&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm
Thu Jul 26 00:03:39 2012
@@ -86,23 +86,27 @@
     #end
         throws TorqueException
     {
-        Connection db = null;
-        $dbObjectClassName retVal = null;
+        Connection connection = null;
         try
         {
-           db = Torque.getConnection(${peerClassName}.DATABASE_NAME);
-           retVal = retrieveByPK(
+            connection = Transaction.begin(${peerClassName}.DATABASE_NAME);
+            $dbObjectClassName result = retrieveByPK(
     #foreach ($columnElement in $primaryKeyColumnElements)
       #set ( $columnField = $columnElement.getAttribute("field") )
                ${columnField},
     #end
-               db);
+               connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
         }
         finally
         {
-            Torque.closeConnection(db);
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
         }
-        return retVal;
     }
 
     /**
@@ -154,18 +158,22 @@
     public $dbObjectClassName retrieveByPK(ObjectKey pk)
         throws TorqueException, NoRowsException, TooManyRowsException
     {
-        Connection db = null;
-        $dbObjectClassName retVal;
+        Connection connection = null;
         try
         {
-            db = Torque.getConnection(${peerClassName}.DATABASE_NAME);
-            retVal = retrieveByPK(pk, db);
+            connection = Transaction.begin(${peerClassName}.DATABASE_NAME);
+            $dbObjectClassName result = retrieveByPK(pk, connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
         }
         finally
         {
-            Torque.closeConnection(db);
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
         }
-        return retVal;
     }
 
     /**

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPKs.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPKs.vm?rev=1365848&r1=1365847&r2=1365848&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPKs.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPKs.vm
Thu Jul 26 00:03:39 2012
@@ -39,18 +39,22 @@
     public List<${dbObjectClassName}> retrieveByPKs(Collection<ObjectKey> pks)
         throws TorqueException
     {
-        Connection db = null;
-        List<${dbObjectClassName}> retVal = null;
+        Connection connection = null;
         try
         {
-           db = Torque.getConnection(${peerClassName}.DATABASE_NAME);
-           retVal = retrieveByPKs(pks, db);
+            connection = Transaction.begin(${peerClassName}.DATABASE_NAME);
+            List<${dbObjectClassName}> result = retrieveByPKs(pks, connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
         }
         finally
         {
-            Torque.closeConnection(db);
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
         }
-        return retVal;
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message