diff --git a/jOOQ/src/main/java/org/jooq/impl/Factory.java b/jOOQ/src/main/java/org/jooq/impl/Factory.java index f52ed1b57b..0f9780b25f 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Factory.java +++ b/jOOQ/src/main/java/org/jooq/impl/Factory.java @@ -1031,8 +1031,7 @@ public class Factory implements Configuration { } /** - * Execute a new query holding plain SQL. There must be as many binding - * variables contained in the SQL, as passed in the bindings parameter + * Execute a new query holding plain SQL. *

* Example (Postgres): *

@@ -1081,6 +1080,58 @@ public class Factory implements Configuration { return new SQLResultQuery(this, sql, bindings).fetch(); } + /** + * Execute a new query holding plain SQL. + *

+ * Example (Postgres): + *

+ *

+     * String sql = "FETCH ALL IN \"\"";
+ * Example (SQLite): + *

+ *

+     * String sql = "pragma table_info('my_table')";
+ *

+ * NOTE: When inserting plain SQL into jOOQ objects, you must + * guarantee syntax integrity. You may also create the possibility of + * malicious SQL injection. Be sure to properly use bind variables and/or + * escape literals when concatenated into SQL clauses! + * + * @param sql The SQL + * @return The results from the executed query + * @throws SQLException if more than one record was found + */ + public final Record fetchOne(String sql) throws SQLException { + return fetchOne(sql, new Object[0]); + } + + /** + * Execute a new query holding plain SQL. There must be as many binding + * variables contained in the SQL, as passed in the bindings parameter + *

+ * Example (Postgres): + *

+ *

+     * String sql = "FETCH ALL IN \"\"";
+ * Example (SQLite): + *

+ *

+     * String sql = "pragma table_info('my_table')";
+ *

+ * NOTE: When inserting plain SQL into jOOQ objects, you must + * guarantee syntax integrity. You may also create the possibility of + * malicious SQL injection. Be sure to properly use bind variables and/or + * escape literals when concatenated into SQL clauses! + * + * @param sql The SQL + * @param bindings The bindings + * @return A query wrapping the plain SQL + * @throws SQLException if more than one record was found + */ + public final Record fetchOne(String sql, Object... bindings) throws SQLException { + return new SQLResultQuery(this, sql, bindings).fetchOne(); + } + // ------------------------------------------------------------------------- // Global Condition factory // -------------------------------------------------------------------------