Class StoredProcedureQuery<T>
java.lang.Object
com.github.collinalpert.java2db.queries.StoredProcedureQuery<T>
- All Implemented Interfaces:
Queryable<T>,SingleQueryable<T>
- Direct Known Subclasses:
AsyncStoredProcedureQuery
public class StoredProcedureQuery<T> extends Object implements Queryable<T>
- Author:
- Collin Alpert
-
Constructor Summary
Constructors Constructor Description StoredProcedureQuery(Class<T> underlyingClass, DBConnection connection, String procedureName, Object[] arguments) -
Method Summary
Modifier and Type Method Description Optional<T>first()Gets the first value from the database result.StringgetQuery()Responsible for building and returning the individual DQL statement.T[]toArray()Executes a new query and returns the result as an array.List<T>toList()Executes the query and returns the result as aList.<K, V> Map<K,V>toMap(Function<T,K> keyMapping, Function<T,V> valueMapping)Executes a new query and returns the result as aMap.Stream<T>toStream()Executes the query and returns the result as aStream.
-
Constructor Details
-
StoredProcedureQuery
public StoredProcedureQuery(Class<T> underlyingClass, DBConnection connection, String procedureName, Object[] arguments)
-
-
Method Details
-
toList
Executes the query and returns the result as aList. -
toStream
Executes the query and returns the result as aStream. -
toArray
Executes a new query and returns the result as an array. -
toMap
Executes a new query and returns the result as aMap.- Specified by:
toMapin interfaceQueryable<T>- Type Parameters:
K- The type of the field representing the keys.V- The type of the field representing the values.- Parameters:
keyMapping- The field representing the keys of the map.valueMapping- The field representing the values of the map.- Returns:
- A map containing the result of the query.
-
first
Gets the first value from the database result. This method should be used when only one result is expected.- Specified by:
firstin interfaceSingleQueryable<T>- Returns:
- The first row as an entity wrapped in an
Optionalif there is at least one row. OtherwiseOptional.empty()is returned. If the value from the database isnull, an emptyOptionalis also returned.
-
getQuery
Responsible for building and returning the individual DQL statement.- Specified by:
getQueryin interfaceSingleQueryable<T>- Returns:
- The DQL statement which fetches data from the database.
-