You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2012/11/30 09:39:36 UTC

svn commit: r1415541 - /db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/executeStatement.vm

Author: tfischer
Date: Fri Nov 30 08:39:36 2012
New Revision: 1415541

URL: http://svn.apache.org/viewvc?rev=1415541&view=rev
Log:
TORQUE-244 use prepared statements in executeStatement, add possibility to set replacement values

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

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/executeStatement.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/executeStatement.vm?rev=1415541&r1=1415540&r2=1415541&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/executeStatement.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/executeStatement.vm Fri Nov 30 08:39:36 2012
@@ -28,51 +28,101 @@
 ## as velocity variables.  
 ##
     /**
-     * Utility method which executes a given SQL statement.  This
-     * method should be used for update, insert, and delete
-     * statements.
+     * Utility method which executes a given sql statement
+     * as prepared statement.
+     * This method should be used for update, insert, and delete statements.
+     * Use executeQuery() for selects.
+     *
+     * @param statementString A String with the sql statement to execute.
      *
-     * @param statementString A String with the SQL statement to execute.
      * @return The number of rows affected.
-     * @throws TorqueException Any exceptions caught during processing will be
-     *         rethrown wrapped into a TorqueException.
+     *
+     * @throws TorqueException if executing the statement fails
+     *         or no database connection can be established.
      */
-    public static int executeStatement(String statementString)
+    public static int executeStatement(String statementString) 
             throws TorqueException
     {
         return ${peerImplGetter}().executeStatement(statementString);
     }
 
     /**
-     * Utility method which executes a given sql statement.  This
-     * method should be used for update, insert, and delete
-     * statements.
+     * Utility method which executes a given sql statement
+     * as prepared statement.
+     * This method should be used for update, insert, and delete statements.
+     * Use executeQuery() for selects.
      *
      * @param statementString A String with the sql statement to execute.
-     * @param dbName Name of database to connect to.
+     * @param replacementValues values to use as placeholders in the query.
+     *        or null or empty if no placeholders need to be filled.
+     *
      * @return The number of rows affected.
-     * @throws TorqueException Any exceptions caught during processing will be
-     *         rethrown wrapped into a TorqueException.
+     *
+     * @throws TorqueException if executing the statement fails
+     *         or no database connection can be established.
      */
-    public static int executeStatement(String statementString, String dbName)
+    public static int executeStatement(
+                String statementString,
+                List<JdbcTypedValue> replacementValues)
             throws TorqueException
     {
-        return ${peerImplGetter}().executeStatement(statementString, dbName);
+        return ${peerImplGetter}().executeStatement(
+                statementString, 
+                replacementValues);
     }
 
     /**
-     * Utility method which executes a given sql statement.  This
-     * method should be used for update, insert, and delete
-     * statements.
+     * Utility method which executes a given sql statement
+     * as prepared statement.
+     * This method should be used for update, insert, and delete statements.
+     * Use executeQuery() for selects.
      *
      * @param statementString A String with the sql statement to execute.
-     * @param con A Connection.
+     * @param dbName The name of the database to execute the statement against,
+     *        or null for the default DB.
+     * @param replacementValues values to use as placeholders in the query.
+     *        or null or empty if no placeholders need to be filled.
+     *
      * @return The number of rows affected.
-     * @throws TorqueException Any exceptions caught during processing will be
-     *         rethrown wrapped into a TorqueException.
+     *
+     * @throws TorqueException if executing the statement fails
+     *         or no database connection can be established.
      */
-    public static int executeStatement(String statementString, Connection con)
-            throws TorqueException
+    public static int executeStatement(
+            String statementString,
+            String dbName,
+            List<JdbcTypedValue> replacementValues)
+        throws TorqueException
+    {
+        return ${peerImplGetter}().executeStatement(
+                statementString, 
+                dbName,
+                replacementValues);
+    }
+
+    /**
+     * Utility method which executes a given sql statement
+     * as prepared statement.
+     * This method should be used for update, insert, and delete statements.
+     * Use executeQuery() for selects.
+     *
+     * @param statementString A String with the sql statement to execute.
+     * @param con The database connection to use.
+     * @param replacementValues values to use as placeholders in the query.
+     *        or null or empty if no placeholders need to be filled.
+     *
+     * @return The number of rows affected.
+     *
+     * @throws TorqueException if executing the statement fails.
+     */
+    public static int executeStatement(
+            String statementString,
+            Connection con,
+            List<JdbcTypedValue> replacementValues)
+        throws TorqueException
     {
-        return ${peerImplGetter}().executeStatement(statementString, con);
+        return ${peerImplGetter}().executeStatement(
+                statementString, 
+                con,
+                replacementValues);
     }



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