[#7101] Add T DSLContext.fetchValue(Field<T>)

This commit is contained in:
lukaseder 2018-01-26 10:10:39 +01:00
parent ca98250aae
commit 54b8e03d4d
2 changed files with 15 additions and 0 deletions

View File

@ -10654,6 +10654,16 @@ public interface DSLContext extends Scope , AutoCloseable {
*/
<T> T fetchValue(TableField<?, T> field) throws DataAccessException, TooManyRowsException, InvalidResultException;
/**
* Execute a {@link ResultQuery} in the context of this
* <code>DSLContext</code> and return a single value.
*
* @param field The field for which to fetch a single value.
* @return The value or <code>null</code>, if no record was found.
* @throws DataAccessException if something went wrong executing the query
*/
<T> T fetchValue(Field<T> field) throws DataAccessException;
/**
* Execute a {@link ResultQuery} in the context of this

View File

@ -4145,6 +4145,11 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return fetchValue(select(field).from(field.getTable()));
}
@Override
public <T> T fetchValue(Field<T> field) {
return fetchValue(select(field));
}
@Override
public <T, R extends Record1<T>> Optional<T> fetchOptionalValue(ResultQuery<R> query) {