Class SingleEntityProjectionQuery<E extends BaseEntity,R>
- java.lang.Object
-
- com.github.collinalpert.java2db.queries.SingleEntityProjectionQuery<E,R>
-
- All Implemented Interfaces:
SingleQueryable<R>
- Direct Known Subclasses:
AsyncSingleEntityProjectionQuery,EntityProjectionQuery
public class SingleEntityProjectionQuery<E extends BaseEntity,R> extends java.lang.Object implements SingleQueryable<R>
- Author:
- Collin Alpert
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Class<R>returnType
-
Constructor Summary
Constructors Constructor Description SingleEntityProjectionQuery(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,R> projection, SingleEntityQuery<E> originalQuery)
-
-
-
Field Detail
-
returnType
protected final java.lang.Class<R> returnType
-
-
Constructor Detail
-
SingleEntityProjectionQuery
public SingleEntityProjectionQuery(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,R> projection, SingleEntityQuery<E> originalQuery)
-
-
Method Detail
-
first
public java.util.Optional<R> first()
Description copied from interface:SingleQueryableGets the first value from the database result. This method should be used when only one result is expected.- Specified by:
firstin interfaceSingleQueryable<E extends BaseEntity>- 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
public java.lang.String getQuery()
Description copied from interface:SingleQueryableResponsible for building and returning the individual DQL statement.- Specified by:
getQueryin interfaceSingleQueryable<E extends BaseEntity>- Returns:
- The DQL statement which fetches data from the database.
-
-