Class EntityProjectionQuery<E extends BaseEntity,​R>

    • Constructor Summary

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

      Modifier and Type Method Description
      java.util.Optional<R> first()
      Gets the first value from the database result.
      R[] toArray()
      Executes a new query and returns the result as an array.
      java.util.List<R> toList()
      Executes the query and returns the result as a List
      java.util.stream.Stream<R> toStream()
      Executes the query and returns the result as a Stream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EntityProjectionQuery

        public EntityProjectionQuery​(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,​R> projection,
                                     EntityQuery<E> originalQuery)
    • Method Detail

      • 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>
        Overrides:
        first in class SingleEntityProjectionQuery<E extends BaseEntity,​R>
        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.
      • toList

        public java.util.List<R> toList()
        Description copied from interface: Queryable
        Executes the query and returns the result as a List
        Specified by:
        toList in interface Queryable<E extends BaseEntity>
        Returns:
        A list of entities representing the result rows.
      • toStream

        public java.util.stream.Stream<R> toStream()
        Description copied from interface: Queryable
        Executes the query and returns the result as a Stream
        Specified by:
        toStream in interface Queryable<E extends BaseEntity>
        Returns:
        A list of entities representing the result rows.
      • toArray

        public R[] toArray()
        Description copied from interface: Queryable
        Executes a new query and returns the result as an array.
        Specified by:
        toArray in interface Queryable<E extends BaseEntity>
        Returns:
        An array of entities representing the result rows.