From 407ea16f9f8f6d3bd5135783d98b63c0e4704609 Mon Sep 17 00:00:00 2001 From: James Moger Date: Thu, 8 Dec 2011 14:27:23 -0500 Subject: [PATCH] Added alternative method signatures to avoid subtle varargs bugs --- docs/05_releases.mkd | 10 ++++++++-- src/com/iciql/Constants.java | 4 ++-- src/com/iciql/Db.java | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/docs/05_releases.mkd b/docs/05_releases.mkd index abc8791..9a7d13e 100644 --- a/docs/05_releases.mkd +++ b/docs/05_releases.mkd @@ -6,14 +6,20 @@ **%VERSION%** ([zip](http://code.google.com/p/iciql/downloads/detail?name=%ZIP%)|[jar](http://code.google.com/p/iciql/downloads/detail?name=%JAR%))   *released %BUILDDATE%* +- Added list alternatives to the varargs methods because it was too easy to forget list.toArray() for the varargs methods +List Db.executeQuery(Class modelClass, String sql, List args) +ResultSet executeQuery(String sql, List args) + +### Older Releases + +**0.7.3**   *released 2011-12-06* + - api change release (API v8) - Fixed JOIN ON primitives - Fixed GROUP BY primitives - Fixed primitive references when selecting into a custom type with primitives - Improved fluent/type-safety of joins -### Older Releases - **0.7.2**   *released 2011-11-30* - generated models are now serializable with a default serial version id of 1 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) classMap.get(clazz); } + + /** + * Run a SQL query directly against the database. + * + * Be sure to close the ResultSet with + * + *
+	 * JdbcUtils.closeSilently(rs, true);
+	 * 
+ * + * @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. * @@ -480,6 +500,20 @@ public class Db { } } + /** + * 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 List executeQuery(Class 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. -- 2.39.5