empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1373810 - in /empire-db/trunk: empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/ empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/ empire-db/src/main/jav...
Date Thu, 16 Aug 2012 12:43:57 GMT
Author: doebele
Date: Thu Aug 16 12:43:56 2012
New Revision: 1373810

URL: http://svn.apache.org/viewvc?rev=1373810&view=rev
Log:
EMPIREDB-158
deprecation for executeSQL(String,Connection) and new overloads

Modified:
    empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
    empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java

Modified: empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java?rev=1373810&r1=1373809&r2=1373810&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
Thu Aug 16 12:43:56 2012
@@ -317,11 +317,11 @@ public class SampleAdvApp 
     {
         DBCommand cmd = db.createCommand();
         // Delete all Employee Department History records
-        db.executeSQL(cmd.getDelete(T_EDH), conn);
+        db.executeDelete(T_EDH, cmd, conn);
         // Delete all Employees (no constraints)
-        db.executeSQL(cmd.getDelete(T_EMP), conn);
+        db.executeDelete(T_EMP, cmd, conn);
         // Delete all Departments (no constraints)
-        db.executeSQL(cmd.getDelete(T_DEP), conn);
+        db.executeDelete(T_DEP, cmd, conn);
     }
 
     /**

Modified: empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java?rev=1373810&r1=1373809&r2=1373810&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
Thu Aug 16 12:43:56 2012
@@ -268,9 +268,9 @@ public class SampleApp 
     {
 		DBCommand cmd = db.createCommand();
 		// Delete all Employees (no constraints)
-		db.executeSQL(cmd.getDelete(db.EMPLOYEES), conn);
+		db.executeDelete(db.EMPLOYEES, cmd, conn);
 		// Delete all Departments (no constraints)
-		db.executeSQL(cmd.getDelete(db.DEPARTMENTS), conn);
+		db.executeDelete(db.DEPARTMENTS, cmd, conn);
 	}
 
 	/**

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java?rev=1373810&r1=1373809&r2=1373810&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java Thu Aug 16
12:43:56 2012
@@ -1284,7 +1284,7 @@ public abstract class DBDatabase extends
             if (log.isInfoEnabled())
 	            log.info("executeSQL affected {} Records in {} ms ", affected, execTime);
             else if (execTime>=longRunndingStmtThreshold)
-                log.warn("Long running query took {} seconds for statement {}.", execTime
/ 1000, sqlCmd);
+                log.warn("Long running statement took {} seconds for statement {}.", execTime
/ 1000, sqlCmd);
             // Return number of affected records
             return affected;
             
@@ -1300,20 +1300,63 @@ public abstract class DBDatabase extends
     }
     
     /**
-     * Executes an update, insert or delete SQL-Statement.<BR>
-     * We recommend to use a DBCommand object in order to build the sqlCmd.<BR>
-     * <P>
-     * @param sqlCmd the SQL-Command
-     * @param conn a valid connection to the database.
-     * @return the row count for insert, update or delete or 0 for SQL statements that return
nothing
+     * @deprecated This method has be deprecated in order to avoid missing command parameters
for prepared statements  
+     * <pre>
+     * Instead of using this method signature please use any of the following:
+     *      executeInsert(...)
+     *      executeUpdate(...)
+     *      executeDelete(...)
+     * or use  
+     *      executeSQL(String sqlCmd, Object[] sqlParams, Connection conn)
+     * </pre>
      */
+    @Deprecated
     public final int executeSQL(String sqlCmd, Connection conn)
     {
+        // Params missing?
+        if (isPreparedStatementsEnabled() && sqlCmd.indexOf("?")>0)
+        {   // Params may not be provided
+            log.warn("Command params may be missing for prepared statement. Please supply
params by calling executeSQL with cmd.getParamValues()!");
+        }
         return executeSQL(sqlCmd, null, conn); 
     }
+
+    /**
+     * Executes an Insert statement from a command object
+     * @param cmd the command object containing the insert command
+     * @param conn a valid connection to the database.
+     * @return the number of records that have been inserted with the supplied statement
+     */
+    public final int executeInsert(DBCommand cmd, Connection conn)
+    {
+        return executeSQL(cmd.getInsert(), cmd.getParamValues(), conn); 
+    }
+
+    /**
+     * Executes an Update statement from a command object
+     * @param cmd the command object containing the update command
+     * @param conn a valid connection to the database.
+     * @return the number of records that have been updated with the supplied statement
+     */
+    public final int executeUpdate(DBCommand cmd, Connection conn)
+    {
+        return executeSQL(cmd.getUpdate(), cmd.getParamValues(), conn); 
+    }
+
+    /**
+     * Executes a Delete statement from a command object
+     * @param from the database table from which to delete records
+     * @param cmd the command object containing the delete constraints
+     * @param conn a valid connection to the database.
+     * @return the number of records that have been deleted with the supplied statement
+     */
+    public final int executeDelete(DBTable from, DBCommand cmd, Connection conn)
+    {
+        return executeSQL(cmd.getDelete(from), cmd.getParamValues(), conn); 
+    }
     
     /**
-     * Executes a select SQL-Statement and returns a resultset containing the query results.<BR>
+     * Executes a select SQL-Statement and returns a ResultSet containing the query results.<BR>
      * This function returns a JDBC ResultSet.<BR>
      * Instead of using this function directly you should use a DBReader object instead.<BR>
      * <P>

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java?rev=1373810&r1=1373809&r2=1373810&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java Thu Aug 16
12:43:56 2012
@@ -804,7 +804,7 @@ public abstract class DBRowSet extends D
                 break;
 
             default:
-                log.warn("updateRecord: " + name + " record has not been modified! ");
+                log.info("updateRecord: " + name + " record has not been modified! ");
                 return;
         }
         if (setCount == 0)



Mime
View raw message