diff --git a/src/main/java/com/avaje/ebean/QueryIterator.java b/src/main/java/com/avaje/ebean/QueryIterator.java index 96787bd3f..4f714e7bd 100644 --- a/src/main/java/com/avaje/ebean/QueryIterator.java +++ b/src/main/java/com/avaje/ebean/QueryIterator.java @@ -17,8 +17,10 @@ import java.util.Iterator; *
** Remember that with {@link QueryIterator} you must call {@link QueryIterator#close()} - * when you have finished iterating the results (typically in a finally block). + * when you have finished iterating the results. Use "try with resources" or ensure it + * is closed in a finally block. *
+ *{@code
*
* Query query = server.find(Customer.class)
@@ -38,6 +40,19 @@ import java.util.Iterator;
* }
*
* }
+ * + *
{@code
+ *
+ * // try with resources
+ * try (QueryIterator it = query.findIterate()) {
+ * while (it.hasNext()) {
+ * Customer customer = it.next();
+ * // do something with customer ...
+ * }
+ * }
+ *
+ * }
*
* @param