diff --git a/jOOQ/src/main/java/org/jooq/DSLContext.java b/jOOQ/src/main/java/org/jooq/DSLContext.java index 1508ad0f6a..20d7f326e1 100644 --- a/jOOQ/src/main/java/org/jooq/DSLContext.java +++ b/jOOQ/src/main/java/org/jooq/DSLContext.java @@ -10680,6 +10680,16 @@ public interface DSLContext extends Scope , AutoCloseable { Optional fetchOptional(ResultQuery query) throws DataAccessException, TooManyRowsException; + /** + * Fetch a single value from a single column table. + * + * @param table The table from which to fetch a value + * @return The value or null, if no record was found. + * @throws DataAccessException if something went wrong executing the query + * @throws TooManyRowsException if the query returned more than one record + */ + T fetchValue(Table> table) throws DataAccessException, TooManyRowsException; + /** * Execute a {@link ResultQuery} in the context of this * DSLContext and return a single value. @@ -10740,6 +10750,15 @@ public interface DSLContext extends Scope , AutoCloseable { Optional fetchOptionalValue(TableField field) throws DataAccessException, TooManyRowsException, InvalidResultException; + /** + * Fetch all values from a single column table. + * + * @param table The table from which to fetch values + * @return The values. This will never be null. + * @throws DataAccessException if something went wrong executing the query + */ + List fetchValues(Table> table) throws DataAccessException; + /** * Execute a {@link ResultQuery} in the context of this * DSLContext and return all values for the only column. diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java index 24bb28a72b..c144b9c64d 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java @@ -4159,6 +4159,11 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri } + @Override + public T fetchValue(Table> table) { + return fetchValue(selectFrom(table)); + } + @Override public > T fetchValue(ResultQuery query) { final Configuration previous = Tools.getConfiguration(query); @@ -4194,6 +4199,11 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri } + @Override + public List fetchValues(Table> table) throws DataAccessException { + return fetchValues(selectFrom(table)); + } + @Override public > List fetchValues(ResultQuery query) { return (List) fetch(query).getValues(0);