diff --git a/jOOQ-test/src/org/jooq/test/_/testcases/FetchTests.java b/jOOQ-test/src/org/jooq/test/_/testcases/FetchTests.java index ae3f335342..8a838417b5 100644 --- a/jOOQ-test/src/org/jooq/test/_/testcases/FetchTests.java +++ b/jOOQ-test/src/org/jooq/test/_/testcases/FetchTests.java @@ -393,6 +393,18 @@ extends BaseTest
SELECT * FROM [table]
+ *
SELECT * FROM [table]
. *

* The result and its contained records are attached to this * {@link Configuration} by default. Use {@link Settings#isAttachRecords()} @@ -4514,7 +4514,7 @@ public interface DSLContext { /** * Execute and return all records for - *

SELECT * FROM [table] WHERE [condition] 
+ *
SELECT * FROM [table] WHERE [condition] 
. *

* The result and its contained records are attached to this * {@link Configuration} by default. Use {@link Settings#isAttachRecords()} @@ -4527,7 +4527,7 @@ public interface DSLContext { /** * Execute and return zero or one record for - *

SELECT * FROM [table]
+ *
SELECT * FROM [table]
. *

* The resulting record is attached to this {@link Configuration} by * default. Use {@link Settings#isAttachRecords()} to override this @@ -4542,7 +4542,7 @@ public interface DSLContext { /** * Execute and return zero or one record for - *

SELECT * FROM [table] WHERE [condition] 
+ *
SELECT * FROM [table] WHERE [condition] 
. *

* The resulting record is attached to this {@link Configuration} by * default. Use {@link Settings#isAttachRecords()} to override this @@ -4558,7 +4558,7 @@ public interface DSLContext { /** * Execute and return zero or one record for - *

SELECT * FROM [table] LIMIT 1
+ *
SELECT * FROM [table] LIMIT 1
. *

* The resulting record is attached to this {@link Configuration} by * default. Use {@link Settings#isAttachRecords()} to override this @@ -4570,9 +4570,23 @@ public interface DSLContext { @Support R fetchAny(Table table) throws DataAccessException; + /** + * Execute and return zero or one record for + *

SELECT * FROM [table] WHERE [condition] LIMIT 1
. + *

+ * The resulting record is attached to this {@link Configuration} by + * default. Use {@link Settings#isAttachRecords()} to override this + * behaviour. + * + * @return The record or null if no record was returned + * @throws DataAccessException if something went wrong executing the query + */ + @Support + R fetchAny(Table table, Condition condition) throws DataAccessException; + /** * Execute and return all records lazily for - *

SELECT * FROM [table]
+ *
SELECT * FROM [table]
. *

* The result and its contained records are attached to this * {@link Configuration} by default. Use {@link Settings#isAttachRecords()} @@ -4585,7 +4599,7 @@ public interface DSLContext { /** * Execute and return all records lazily for - *

SELECT * FROM [table] WHERE [condition] 
+ *
SELECT * FROM [table] WHERE [condition] 
. *

* The result and its contained records are attached to this * {@link Configuration} by default. Use {@link Settings#isAttachRecords()} @@ -4597,7 +4611,7 @@ public interface DSLContext { Cursor fetchLazy(Table table, Condition condition) throws DataAccessException; /** - * Insert one record + * Insert one record. *

* This executes something like the following statement: *

INSERT INTO [table] ... VALUES [record] 
@@ -4614,7 +4628,7 @@ public interface DSLContext { > int executeInsert(R record) throws DataAccessException; /** - * Update a table + * Update a table. *
UPDATE [table] SET [modified values in record] WHERE [record is supplied record] 
* * @return The number of updated records @@ -4624,7 +4638,7 @@ public interface DSLContext { > int executeUpdate(R record) throws DataAccessException; /** - * Update a table + * Update a table. *
UPDATE [table] SET [modified values in record] WHERE [condition]
* * @return The number of updated records @@ -4634,7 +4648,7 @@ public interface DSLContext { , T> int executeUpdate(R record, Condition condition) throws DataAccessException; /** - * Delete a record from a table + * Delete a record from a table. *
DELETE FROM [table] WHERE [record is supplied record]
* * @return The number of deleted records @@ -4644,7 +4658,7 @@ public interface DSLContext { > int executeDelete(R record) throws DataAccessException; /** - * Delete a record from a table + * Delete a record from a table. *
DELETE FROM [table] WHERE [condition]
* * @return The number of deleted records diff --git a/jOOQ/src/main/java/org/jooq/impl/DSLContextImpl.java b/jOOQ/src/main/java/org/jooq/impl/DSLContextImpl.java index e589605f11..cd0f566cf5 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSLContextImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSLContextImpl.java @@ -1659,6 +1659,12 @@ class DSLContextImpl implements DSLContext, Serializable { return Utils.filterOne(selectFrom(table).limit(1).fetch()); } + @Override + @Support + public final R fetchAny(Table table, Condition condition) throws DataAccessException { + return Utils.filterOne(selectFrom(table).where(condition).limit(1).fetch()); + } + @Override @Support public final Cursor fetchLazy(Table table) throws DataAccessException {