[#7431] Document the fact that fetchOne() needs to fetch the second record

This commit is contained in:
lukaseder 2018-04-23 09:35:09 +02:00
parent 3b53630cbb
commit 1075887293
2 changed files with 27 additions and 6 deletions

View File

@ -69,15 +69,25 @@ import org.jooq.impl.DefaultRecordMapper;
* A query that can return results. Mostly, this is a {@link Select} query used
* for a <code>SELECT</code> statement.
* <p>
* <h3>Lifecycle guarantees</h3> Most methods in this type are based on
* {@link #fetch()}, which completes the whole {@link ConnectionProvider} and
* {@link ExecuteListener} lifecycles, eagerly fetching all results into memory.
* Underlying JDBC {@link ResultSet}s are always closed. Underlying JDBC
* {@link PreparedStatement}s are closed, unless {@link #keepStatement(boolean)}
* is set.
* <h3>Lifecycle guarantees</h3>
* <p>
* Most methods in this type are based on {@link #fetch()}, which completes the
* whole {@link ConnectionProvider} and {@link ExecuteListener} lifecycles,
* eagerly fetching all results into memory. Underlying JDBC {@link ResultSet}s
* are always closed. Underlying JDBC {@link PreparedStatement}s are closed,
* unless {@link #keepStatement(boolean)} is set.
* <p>
* In order to keep open {@link ResultSet}s and fetch records lazily, use
* {@link #fetchLazy()} instead and then operate on {@link Cursor}.
* <p>
* <h3>Performance</h3>
* <p>
* Methods throwing {@link TooManyRowsException} need to retrieve at most two
* records from the underlying JDBC {@link ResultSet}, which, depending on the
* {@link java.sql.Statement#getFetchSize()} /
* {@link ResultQuery#fetchSize(int)}, might incur additional database
* roundtrips. If this causes problems, {@link ResultQuery#fetchAny()} may be
* preferred.
*
* @author Lukas Eder
*/

View File

@ -37,6 +37,8 @@
*/
package org.jooq.exception;
import java.sql.ResultSet;
import org.jooq.InsertResultStep;
import org.jooq.ResultQuery;
@ -51,6 +53,15 @@ import org.jooq.ResultQuery;
* {@link InsertResultStep#fetchOne()} on an <code>INSERT</code> statement, the
* database change will still be executed: the rows will still be locked or
* inserted.
* <p>
* <strong>Performance</strong>
* <p>
* Methods throwing {@link TooManyRowsException} need to retrieve at most two
* records from the underlying JDBC {@link ResultSet}, which, depending on the
* {@link java.sql.Statement#getFetchSize()} /
* {@link ResultQuery#fetchSize(int)}, might incur additional database
* roundtrips. If this causes problems, {@link ResultQuery#fetchAny()} may be
* preferred.
*
* @author Lukas Eder
*/