Class SelectStatement

java.lang.Object
io.github.torand.fastersql.statement.SelectStatement
All Implemented Interfaces:
Sql, PreparableStatement

public class SelectStatement extends Object implements PreparableStatement
Implements a SELECT statement.
  • Method Details

    • join

      public SelectStatement join(Join... joins)
      Adds one or more JOIN clauses.
      Parameters:
      joins - the JOIN clauses.
      Returns:
      the modified statement.
    • leftOuterJoin

      public SelectStatement leftOuterJoin(Join join)
      Adds a LEFT OUTER JOIN clause.
      Parameters:
      join - the JOIN clause.
      Returns:
      the modified statement.
    • rightOuterJoin

      public SelectStatement rightOuterJoin(Join join)
      Adds a RIGHT OUTER JOIN clause.
      Parameters:
      join - the JOIN clause.
      Returns:
      the modified statement.
    • joinIf

      @SafeVarargs public final SelectStatement joinIf(boolean condition, Supplier<Join>... joinSuppliers)
      Adds one or more JOIN clauses, if the condition is true.
      Parameters:
      condition - the condition.
      joinSuppliers - the suppliers of JOIN clauses.
      Returns:
      the modified statement.
    • where

      public SelectStatement where(Predicate... predicates)
      Adds one or more predicates to the WHERE clause.
      Parameters:
      predicates - the predicates.
      Returns:
      the modified statement.
    • where

      @SafeVarargs public final SelectStatement where(OptionalPredicate... maybePredicates)
      Adds optional predicates to the WHERE clause if the wrapped predicates are present.
      Parameters:
      maybePredicates - the optional predicates.
      Returns:
      the modified statement.
    • whereIf

      @SafeVarargs public final SelectStatement whereIf(boolean condition, Supplier<Predicate>... predicateSuppliers)
      Adds supplied predicates to the WHERE clause, if the condition is true.
      Parameters:
      condition - the condition.
      predicateSuppliers - the suppliers providing predicates
      Returns:
      the modified statement.
    • groupBy

      public SelectStatement groupBy(Column... groups)
      Adds one or columns as groups to the GROUP BY clause.
      Parameters:
      groups - the groups
      Returns:
      the modified statement.
    • having

      public SelectStatement having(Predicate... predicates)
      Adds one or more predicates to the HAVING clause.
      Parameters:
      predicates - the predicates.
      Returns:
      the modified statement.
    • having

      @SafeVarargs public final SelectStatement having(OptionalPredicate... maybePredicates)
      Adds optional predicates to the HAVING clause if the wrapped predicates are present.
      Parameters:
      maybePredicates - the optional predicates.
      Returns:
      the modified statement.
    • havingIf

      @SafeVarargs public final SelectStatement havingIf(boolean condition, Supplier<Predicate>... predicateSuppliers)
      Adds one or more predicates to the HAVING clause, if the condition is true.
      Parameters:
      condition - the condition.
      predicateSuppliers - the suppliers providing predicates.
      Returns:
      the modified statement.
    • orderBy

      public SelectStatement orderBy(Order... orders)
      Adds one or more ORDER clauses.
      Parameters:
      orders - the ORDER clauses.
      Returns:
      the modified statement.
    • limit

      public SelectStatement limit(long limit)
      Adds a LIMIT clause.
      Parameters:
      limit - the limit.
      Returns:
      the modified statement.
    • offset

      public SelectStatement offset(long offset)
      Adds a OFFSET clause.
      Parameters:
      offset - the offset.
      Returns:
      the modified statement.
    • forUpdate

      public SelectStatement forUpdate()
      Adds a FOR UPDATE clause.
      Returns:
      the modified statement.
    • sql

      public String sql(Context context)
      Description copied from interface: Sql
      Formats object as an SQL fragment.
      Specified by:
      sql in interface Sql
      Parameters:
      context - the context (incl. dialect).
      Returns:
      the formatted SQL fragment.
    • params

      public Stream<Object> params(Context context)
      Description copied from interface: Sql
      Gets the statement parameters introduced by this fragment.
      Specified by:
      params in interface Sql
      Parameters:
      context - the context (incl. dialect).
      Returns:
      the statement parameters.
    • toString

      public String toString()
      Overrides:
      toString in class Object