diff options
author | James Moger <james.moger@gmail.com> | 2011-12-08 14:27:23 -0500 |
---|---|---|
committer | James Moger <james.moger@gmail.com> | 2011-12-08 14:27:23 -0500 |
commit | 407ea16f9f8f6d3bd5135783d98b63c0e4704609 (patch) | |
tree | e8a579aed18b8bf48dc12323ae06b97c286efd6f /src | |
parent | fe7a924f168f5738fead18a4b0dad8b0451a5973 (diff) | |
download | iciql-407ea16f9f8f6d3bd5135783d98b63c0e4704609.tar.gz iciql-407ea16f9f8f6d3bd5135783d98b63c0e4704609.zip |
Added alternative method signatures to avoid subtle varargs bugs
Diffstat (limited to 'src')
-rw-r--r-- | src/com/iciql/Constants.java | 4 | ||||
-rw-r--r-- | src/com/iciql/Db.java | 34 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/com/iciql/Constants.java b/src/com/iciql/Constants.java index 5c1bfc0..37f0c2b 100644 --- a/src/com/iciql/Constants.java +++ b/src/com/iciql/Constants.java @@ -25,11 +25,11 @@ public class Constants { // The build script extracts this exact line so be careful editing it
// and only use A-Z a-z 0-9 .-_ in the string.
- public static final String VERSION = "0.7.3";
+ public static final String VERSION = "0.7.4-SNAPSHOT";
// The build script extracts this exact line so be careful editing it
// and only use A-Z a-z 0-9 .-_ in the string.
- public static final String VERSION_DATE = "2011-12-06";
+ public static final String VERSION_DATE = "PENDING";
// The build script extracts this exact line so be careful editing it
// and only use A-Z a-z 0-9 .-_ in the string.
diff --git a/src/com/iciql/Db.java b/src/com/iciql/Db.java index 05d7f46..e05ec56 100644 --- a/src/com/iciql/Db.java +++ b/src/com/iciql/Db.java @@ -448,6 +448,26 @@ public class Db { return (TableDefinition<T>) classMap.get(clazz);
}
+
+ /**
+ * Run a SQL query directly against the database.
+ *
+ * Be sure to close the ResultSet with
+ *
+ * <pre>
+ * JdbcUtils.closeSilently(rs, true);
+ * </pre>
+ *
+ * @param sql
+ * the SQL statement
+ * @param args
+ * optional object arguments for x=? tokens in query
+ * @return the result set
+ */
+ public ResultSet executeQuery(String sql, List<?> args) {
+ return executeQuery(sql, args.toArray());
+ }
+
/**
* Run a SQL query directly against the database.
*
@@ -490,6 +510,20 @@ public class Db { * the SQL statement
* @return the result set
*/
+ public <T> List<T> executeQuery(Class<? extends T> modelClass, String sql, List<?> args) {
+ return executeQuery(modelClass, sql, args.toArray());
+ }
+
+ /**
+ * Run a SQL query directly against the database and map the results to the
+ * model class.
+ *
+ * @param modelClass
+ * the model class to bind the query ResultSet rows into.
+ * @param sql
+ * the SQL statement
+ * @return the result set
+ */
public <T> List<T> executeQuery(Class<? extends T> modelClass, String sql, Object... args) {
ResultSet rs = null;
try {
|