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 SingleEntityQuery<E> originalQuery  
    protected java.lang.Class<R> returnType  
  • Constructor Summary

    Constructors 
    Constructor Description
    SingleEntityProjectionQuery​(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,​R> projection, SingleEntityQuery<E> originalQuery)  
  • Method Summary

    Modifier and Type Method Description
    java.util.Optional<R> first()
    Gets the first value from the database result.
    java.lang.String getQuery()
    Responsible for building and returning the individual DQL statement.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • first

      public java.util.Optional<R> first()
      Description copied from interface: SingleQueryable
      Gets the first value from the database result. This method should be used when only one result is expected.
      Specified by:
      first in interface SingleQueryable<E extends BaseEntity>
      Returns:
      The first row as an entity wrapped in an Optional if there is at least one row. Otherwise Optional.empty() is returned. If the value from the database is null, an empty Optional is also returned.
    • getQuery

      public java.lang.String getQuery()
      Description copied from interface: SingleQueryable
      Responsible for building and returning the individual DQL statement.
      Specified by:
      getQuery in interface SingleQueryable<E extends BaseEntity>
      Returns:
      The DQL statement which fetches data from the database.