From 52ceaf63fabb74731f751e8547ebda9794a5e9d2 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Thu, 27 Oct 2011 21:03:57 +0000 Subject: [PATCH] [#887] Add List Cursor.fetchInto(Class) --- jOOQ/src/main/java/org/jooq/Cursor.java | 14 ++++++++++++++ jOOQ/src/main/java/org/jooq/impl/CursorImpl.java | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/jOOQ/src/main/java/org/jooq/Cursor.java b/jOOQ/src/main/java/org/jooq/Cursor.java index 9f93e5b75f..a8863ceb63 100644 --- a/jOOQ/src/main/java/org/jooq/Cursor.java +++ b/jOOQ/src/main/java/org/jooq/Cursor.java @@ -39,6 +39,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Iterator; +import java.util.List; /** * Cursors allow for lazy, sequential access to an underlying JDBC @@ -129,6 +130,19 @@ public interface Cursor extends FieldProvider, Iterable { */ RecordHandler fetchInto(RecordHandler handler) throws SQLException; + /** + * Map resulting records onto a custom type. + *

+ * This is the same as calling fetch().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) + */ + List fetchInto(Class type) throws SQLException; + /** * Explicitly close the underlying {@link PreparedStatement} and * {@link ResultSet} diff --git a/jOOQ/src/main/java/org/jooq/impl/CursorImpl.java b/jOOQ/src/main/java/org/jooq/impl/CursorImpl.java index 5db3c6f58e..e82707926b 100644 --- a/jOOQ/src/main/java/org/jooq/impl/CursorImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/CursorImpl.java @@ -121,7 +121,6 @@ class CursorImpl implements Cursor { } @Override - @Deprecated public final Result fetch() throws SQLException { return fetch(Integer.MAX_VALUE); } @@ -173,6 +172,11 @@ class CursorImpl implements Cursor { return handler; } + @Override + public final List fetchInto(Class clazz) throws SQLException { + return fetch().into(clazz); + } + @Override public final void close() throws SQLException { JooqUtil.safeClose(rs, stmt);