empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1520265 - /empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
Date Thu, 05 Sep 2013 09:58:21 GMT
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);  
     }
     
     /**



Mime
View raw message