From f7bf0f14f3ac1090d8d05426217ac05fa7e19e5c Mon Sep 17 00:00:00 2001 From: lukaseder Date: Fri, 10 Feb 2017 16:02:23 +0100 Subject: [PATCH] [#5361] Add ResultQuery.fetchStreamInto() --- jOOQ/src/main/java/org/jooq/ResultQuery.java | 41 ++++++++++++++++++- .../org/jooq/impl/AbstractResultQuery.java | 10 +++++ .../main/java/org/jooq/impl/SelectImpl.java | 10 +++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/jOOQ/src/main/java/org/jooq/ResultQuery.java b/jOOQ/src/main/java/org/jooq/ResultQuery.java index 51ddf395fb..8a162a77ca 100644 --- a/jOOQ/src/main/java/org/jooq/ResultQuery.java +++ b/jOOQ/src/main/java/org/jooq/ResultQuery.java @@ -153,6 +153,45 @@ public interface ResultQuery extends Query, Iterable { */ Stream fetchStream() throws DataAccessException; + /** + * Stream this query, mapping records into a custom type. + *

+ * This is the same as calling + * fetchStream().map(r -> r.into(type)). See + * {@link Record#into(Class)} for more details + * + * @param The generic entity type. + * @param type The entity type. + * @see Record#into(Class) + * @see Result#into(Class) + * @see DefaultRecordMapper + * @return The results. + * @throws DataAccessException if something went wrong executing the query + * @throws MappingException wrapping any reflection or data type conversion + * exception that might have occurred while mapping records + */ + Stream fetchStreamInto(Class type) throws DataAccessException, MappingException; + + /** + * Stream this query, mapping records into a custom record. + *

+ * This is the same as calling + * fetchStream().map(r -> r.into(table)). See + * {@link Record#into(Table)} for more details + *

+ * The result and its contained records are attached to the original + * {@link Configuration} by default. Use {@link Settings#isAttachRecords()} + * to override this behaviour. + * + * @param The generic table record type. + * @param table The table type. + * @return The results. This will never be null. + * @see Record#into(Table) + * @see Result#into(Table) + * @throws DataAccessException if something went wrong executing the query + */ + Stream fetchStreamInto(Table table) throws DataAccessException; + /** * Stream this query. *

@@ -3023,11 +3062,11 @@ public interface ResultQuery extends Query, Iterable { * @param type The entity type. * @see Record#into(Class) * @see Result#into(Class) + * @see DefaultRecordMapper * @return The results. This will never be null. * @throws DataAccessException if something went wrong executing the query * @throws MappingException wrapping any reflection or data type conversion * exception that might have occurred while mapping records - * @see DefaultRecordMapper */ List fetchInto(Class type) throws DataAccessException, MappingException; diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractResultQuery.java b/jOOQ/src/main/java/org/jooq/impl/AbstractResultQuery.java index 707dbd8cc8..a822857b63 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractResultQuery.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractResultQuery.java @@ -336,6 +336,16 @@ abstract class AbstractResultQuery extends AbstractQuery imple return fetchLazy().stream(); } + @Override + public final Stream fetchStreamInto(Class type) { + return fetchStream().map(r -> r.into(type)); + } + + @Override + public final Stream fetchStreamInto(Table table) { + return fetchStream().map(r -> r.into(table)); + } + @Override public final Stream stream() { return fetchLazy().stream(); diff --git a/jOOQ/src/main/java/org/jooq/impl/SelectImpl.java b/jOOQ/src/main/java/org/jooq/impl/SelectImpl.java index 1ebc322ca8..e105127c38 100644 --- a/jOOQ/src/main/java/org/jooq/impl/SelectImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/SelectImpl.java @@ -2718,6 +2718,16 @@ final class SelectImpl Stream fetchStreamInto(Class type) { + return getDelegate().fetchStreamInto(type); + } + + @Override + public Stream fetchStreamInto(Table table) { + return getDelegate().fetchStreamInto(table); + } + @Override public final Stream stream() { return getDelegate().stream();