[#1718] Document usage of InvalidResultException on the

ResultQuery.fetchXXX() Javadocs
This commit is contained in:
Lukas Eder 2012-08-17 10:53:47 +02:00
parent ed947217d7
commit 818edad796
2 changed files with 40 additions and 78 deletions

View File

@ -63,6 +63,7 @@ import javax.sql.DataSource;
import org.jooq.conf.Settings;
import org.jooq.conf.StatementType;
import org.jooq.exception.DataAccessException;
import org.jooq.exception.InvalidResultException;
import org.jooq.exception.MappingException;
import org.jooq.impl.Factory;
@ -1027,6 +1028,7 @@ public interface FactoryOperations extends Configuration {
*
* @return The record or <code>null</code> if no record was returned
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
@Support
<R extends Record> R fetchOne(Table<R> table) throws DataAccessException;
@ -1041,6 +1043,7 @@ public interface FactoryOperations extends Configuration {
*
* @return The record or <code>null</code> if no record was returned
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
@Support
<R extends Record> R fetchOne(Table<R> table, Condition condition) throws DataAccessException;
@ -1489,6 +1492,7 @@ public interface FactoryOperations extends Configuration {
* <code>null</code>, even if the database returns no
* {@link ResultSet}
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
@Support
Record fetchOne(String sql) throws DataAccessException;
@ -1516,6 +1520,7 @@ public interface FactoryOperations extends Configuration {
* @return The results from the executed query. This may be
* <code>null</code> if the database returned no records
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
@Support
Record fetchOne(String sql, Object... bindings) throws DataAccessException;
@ -1547,6 +1552,7 @@ public interface FactoryOperations extends Configuration {
* @return The results from the executed query. This may be
* <code>null</code> if the database returned no records
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
@Support
Record fetchOne(String sql, QueryPart... parts) throws DataAccessException;

View File

@ -46,6 +46,7 @@ import java.util.concurrent.ExecutorService;
import org.jooq.conf.Settings;
import org.jooq.exception.DataAccessException;
import org.jooq.exception.DataTypeException;
import org.jooq.exception.InvalidResultException;
import org.jooq.exception.MappingException;
/**
@ -286,11 +287,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting value or <code>null</code> if the query returned no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one value</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
<T> T fetchOne(Field<T> field) throws DataAccessException;
@ -303,11 +301,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting value or <code>null</code> if the query returned no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one value</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
<T> T fetchOne(Field<?> field, Class<? extends T> type) throws DataAccessException;
@ -320,11 +315,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting value or <code>null</code> if the query returned no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one value</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
<T, U> U fetchOne(Field<T> field, Converter<? super T, U> converter) throws DataAccessException;
@ -337,11 +329,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting value or <code>null</code> if the query returned no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one value</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
Object fetchOne(int fieldIndex) throws DataAccessException;
@ -354,11 +343,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting value or <code>null</code> if the query returned no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one value</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
<T> T fetchOne(int fieldIndex, Class<? extends T> type) throws DataAccessException;
@ -371,11 +357,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting value or <code>null</code> if the query returned no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one value</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
<U> U fetchOne(int fieldIndex, Converter<?, U> converter) throws DataAccessException;
@ -388,11 +371,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting value or <code>null</code> if the query returned no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one value</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
Object fetchOne(String fieldName) throws DataAccessException;
@ -405,11 +385,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting value or <code>null</code> if the query returned no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one value</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
<T> T fetchOne(String fieldName, Class<? extends T> type) throws DataAccessException;
@ -422,11 +399,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting value or <code>null</code> if the query returned no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one value</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
<U> U fetchOne(String fieldName, Converter<?, U> converter) throws DataAccessException;
@ -439,11 +413,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting record or <code>null</code> if the query returns no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one record</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
R fetchOne() throws DataAccessException;
@ -465,11 +436,9 @@ public interface ResultQuery<R extends Record> extends Query {
* maps.
*
* @return The result.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li>
* <li>if several fields share the same name</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the key field returned two or more
* equal values from the result set.
*/
List<Map<String, Object>> fetchMaps() throws DataAccessException;
@ -479,12 +448,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting record or <code>null</code> if the query returns no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li>
* <li>if the query returned more than one record</li>
* <li>if several fields share the same name</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
Map<String, Object> fetchOneMap() throws DataAccessException;
@ -503,12 +468,9 @@ public interface ResultQuery<R extends Record> extends Query {
* @param key The key field. Client code must assure that this field is
* unique in the result set.
* @return A Map containing the results
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the key field returned two or more equal values from the
* result set.</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the key field returned two or more
* equal values from the result set.
*/
<K> Map<K, R> fetchMap(Field<K> key) throws DataAccessException;
@ -525,12 +487,9 @@ public interface ResultQuery<R extends Record> extends Query {
* unique in the result set.
* @param value The value field
* @return A Map containing the results
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the key field returned two or more equal values from the
* result set.</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the key field returned two or more
* equal values from the result set.
*/
<K, V> Map<K, V> fetchMap(Field<K> key, Field<V> value) throws DataAccessException;
@ -659,11 +618,8 @@ public interface ResultQuery<R extends Record> extends Query {
*
* @return The resulting record or <code>null</code> if the query returns no
* records.
* @throws DataAccessException This exception is thrown
* <ul>
* <li>if something went wrong executing the query</li> <li>if
* the query returned more than one record</li>
* </ul>
* @throws DataAccessException if something went wrong executing the query
* @throws InvalidResultException if the query returned more than one record
*/
Object[] fetchOneArray() throws DataAccessException;