You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2013/09/05 11:58:21 UTC

svn commit: r1520265 - /empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java

Author: doebele
Date: Thu Sep  5 09:58:20 2013
New Revision: 1520265

URL: http://svn.apache.org/r1520265
Log:
EMPIREDB-170
created a new overload DBDatabase.querySingleValue(DBCommand cmd, DataType dataType, Connection conn) that allows to specify the expected return type.

Modified:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java

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=1520265&r1=1520264&r2=1520265&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 Sep  5 09:58:20 2013
@@ -817,13 +817,31 @@ public abstract class DBDatabase extends
      * If the query does not return a result a QueryNoResultException is thrown
      * 
      * @param cmd the Command object that contains the select statement
+     * @param dataType the expected data type
+     * @param conn a valid connection to the database.
+     * 
+     * @return the value of the first column in the first row of the query 
+     */
+    public final Object querySingleValue(DBCommand cmd, DataType dataType, Connection conn)
+    {
+        Object value = querySingleValue(cmd.getSelect(), cmd.getParamValues(), dataType, conn);
+        if (value==ObjectUtils.NO_VALUE)
+        	throw new QueryNoResultException(cmd.getSelect());
+        return value;
+    }
+    
+    /**
+     * Returns the value of the first row/column of a sql-query as an object.
+     * If the query does not return a result a QueryNoResultException is thrown
+     * 
+     * @param cmd the Command object that contains the select statement
      * @param conn a valid connection to the database.
      * 
      * @return the value of the first column in the first row of the query 
      */
     public final Object querySingleValue(DBCommand cmd, Connection conn)
     {
-        return querySingleValue(cmd.getSelect(), cmd.getParamValues(), conn);  
+        return querySingleValue(cmd, DataType.UNKNOWN, conn);  
     }
     
     /**