Class Select

    • Method Detail

      • from

        public static Select from​(@NonNull
                                  @NonNull SQLElement table)
        Creates a new Select statement with the given table for the from clause
        Parameters:
        table - the table to select from
        Returns:
        this Select object
      • from

        public static Select from​(@NonNull
                                  @NonNull String table)
        Creates a new Select statement with the given table for the from clause
        Parameters:
        table - the table to select from
        Returns:
        this Select object
      • columns

        public Select columns​(@NonNull
                              @NonNull SQLElement... columns)
        Sets the columns being selected. Note that this clears any previously specified columns.
        Parameters:
        columns - the columns being selected
        Returns:
        this Select object
      • columns

        public Select columns​(@NonNull
                              @NonNull Collection<? extends SQLElement> columns)
        Sets the columns being selected. Note that this clears any previously specified columns.
        Parameters:
        columns - the columns being selected
        Returns:
        this Select object
      • distinct

        public Select distinct()
        Performs a select distinct
        Returns:
        this Select object
      • distinct

        public Select distinct​(boolean distinct)
        Sets whether or not the selct will be distinct
        Parameters:
        distinct - true - select distinct, false - normal select
        Returns:
        this Select object
      • groupBy

        public Select groupBy​(@NonNull
                              @NonNull String... groupBy)
        Sets the group by clause to the given strings. Note that this clears any previously specified groupBy.
        Parameters:
        groupBy - the group by statements
        Returns:
        this Select object
      • groupBy

        public Select groupBy​(@NonNull
                              @NonNull SQLElement... groupBy)
        Sets the group by clause to the given strings. Note that this clears any previously specified groupBy.
        Parameters:
        groupBy - the group by statements
        Returns:
        this Select object
      • groupBy

        public Select groupBy​(@NonNull
                              @NonNull Collection<? extends SQLElement> groupBy)
        Sets the group by clause to the given strings. Note that this clears any previously specified groupBy.
        Parameters:
        groupBy - the group by statements
        Returns:
        this Select object
      • having

        public Select having​(SQLElement havingClause)
        Sets the criteria for group bys (i.e. HAVING) for the selection.
        Parameters:
        havingClause - the having clause
        Returns:
        this Select object
      • having

        public Select having​(String havingClause)
        Sets the criteria for group bys (i.e. HAVING) for the selection.
        Parameters:
        havingClause - the having clause
        Returns:
        this Select object
      • innerJoin

        public Select innerJoin​(@NonNull
                                @NonNull SQLElement table,
                                @NonNull
                                @NonNull SQLElement criteria)
        Adds an inner join with the given table on the given criteria to the from clause
        Parameters:
        table - the table or expression to join with
        criteria - the criteria for joining
        Returns:
        this Select object
      • join

        public Select join​(@NonNull
                           @NonNull JoinType type,
                           @NonNull
                           @NonNull SQLElement table,
                           @NonNull
                           @NonNull SQLElement criteria)
        Adds a join with the given table on the given criteria to the from clause
        Parameters:
        type - the join type
        table - the table or expression to join with
        criteria - the criteria for joining
        Returns:
        this Select object
      • leftOuterJoin

        public Select leftOuterJoin​(@NonNull
                                    @NonNull SQLElement table,
                                    @NonNull
                                    @NonNull SQLElement criteria)
        Adds a left outer join with the given table on the given criteria to the from clause
        Parameters:
        table - the table or expression to join with
        criteria - the criteria for joining
        Returns:
        this Select object
      • limit

        public Select limit​(SQLElement limitClause)
        Sets the limit clause for selection
        Parameters:
        limitClause - the limit clause
        Returns:
        this Select object
      • orderBy

        public Select orderBy​(@NonNull
                              @NonNull String... orderBy)
        Sets the order by clause to the given strings. Note that this clears any previously specified orderBy.
        Parameters:
        orderBy - the order by statements
        Returns:
        this Select object
      • orderBy

        public Select orderBy​(@NonNull
                              @NonNull SQLElement... orderBy)
        Sets the order by clause to the given strings. Note that this clears any previously specified orderBy.
        Parameters:
        orderBy - the order by statements
        Returns:
        this Select object
      • orderBy

        public Select orderBy​(@NonNull
                              @NonNull Collection<? extends SQLElement> orderBy)
        Sets the order by clause to the given strings. Note that this clears any previously specified orderBy.
        Parameters:
        orderBy - the order by statements
        Returns:
        this Select object
      • queryParallel

        public final <T> Stream<T> queryParallel​(@NonNull
                                                 @NonNull SQLContext context,
                                                 @NonNull
                                                 @NonNull ResultSetMapper<? extends T> mapper,
                                                 @NonNull
                                                 @NonNull String partitionColumn)
                                          throws SQLException
        Performs this Select query using the given SQLContext using the given ResultSetMapper to map ResultSet to objects. This query method returns a parallel stream using 2 * the number processors as the partition count.
        Type Parameters:
        T - the Iterator type parameter
        Parameters:
        context - the context to perform the select over
        mapper - the mapper from ResultSet to Object
        partitionColumn - the column to use for portioning (should be numeric)
        Returns:
        the ResultSetIterator over the results of the given QueryStatement
        Throws:
        SQLException - something happened trying to query
      • queryParallel

        public final <T> Stream<T> queryParallel​(@NonNull
                                                 @NonNull SQLContext context,
                                                 @NonNull
                                                 @NonNull Map<String,​?> values,
                                                 @NonNull
                                                 @NonNull ResultSetMapper<? extends T> mapper,
                                                 @NonNull
                                                 @NonNull String partitionColumn)
                                          throws SQLException
        Performs this Select query using the given SQLContext filling in named value placeholders using the given Map of values and returning the results as a ResultSetIterator using the given ResultSetMapper* to map ResultSet to objects. This query method returns a parallel stream using 2 * the number processors as the partition count.
        Type Parameters:
        T - the Iterator type parameter
        Parameters:
        context - the context to perform the select over
        values - the values to use to fill the query statement (by Name)
        mapper - the mapper from ResultSet to Object
        partitionColumn - the column to use for portioning (should be numeric)
        Returns:
        the ResultSetIterator over the results of the given QueryStatement
        Throws:
        SQLException - something happened trying to query
      • queryParallel

        public final <T> Stream<T> queryParallel​(@NonNull
                                                 @NonNull SQLContext context,
                                                 @NonNull
                                                 @NonNull ResultSetMapper<? extends T> mapper,
                                                 @NonNull
                                                 @NonNull String partitionColumn,
                                                 int numPartitions)
                                          throws SQLException
        Performs this Select query using the given SQLContext using the given ResultSetMapper to map ResultSet to objects. This query method returns a parallel stream.
        Type Parameters:
        T - the Iterator type parameter
        Parameters:
        context - the context to perform the select over
        mapper - the mapper from ResultSet to Object
        partitionColumn - the column to use for portioning (should be numeric)
        numPartitions - the number of partitions (controls the parallelization
        Returns:
        the ResultSetIterator over the results of the given QueryStatement
        Throws:
        SQLException - something happened trying to query
      • queryParallel

        public final <T> Stream<T> queryParallel​(@NonNull
                                                 @NonNull SQLContext context,
                                                 @NonNull
                                                 @NonNull List<Object> values,
                                                 @NonNull
                                                 @NonNull ResultSetMapper<? extends T> mapper,
                                                 @NonNull
                                                 @NonNull String partitionColumn)
                                          throws SQLException
        Performs this Select query using the given SQLContext filling in indexed value placeholders using the given Map of values and returning the results as a ResultSetIterator using the given ResultSetMapper to map ResultSet to objects. This query method returns a parallel stream using 2 times the number processors as the partition count.
        Type Parameters:
        T - the Iterator type parameter
        Parameters:
        context - the context to perform the select over
        values - the values to use to fill the query statement (by Name)
        mapper - the mapper from ResultSet to Object
        partitionColumn - the column to use for portioning (should be numeric)
        Returns:
        the ResultSetIterator over the results of the given QueryStatement
        Throws:
        SQLException - something happened trying to query
      • queryParallel

        public <T> Stream<T> queryParallel​(@NonNull
                                           @NonNull SQLContext context,
                                           @NonNull
                                           @NonNull Map<String,​?> values,
                                           @NonNull
                                           @NonNull ResultSetMapper<? extends T> mapper,
                                           @NonNull
                                           @NonNull String partitionColumn,
                                           int numPartitions)
                                    throws SQLException
        Performs this Select query using the given SQLContext filling in named value placeholders using the given Map of values and returning the results as a ResultSetIterator using the given ResultSetMapper to map ResultSet to objects. This query method returns a parallel stream.
        Type Parameters:
        T - the Iterator type parameter
        Parameters:
        context - the context to perform the select over
        values - the values to use to fill the query statement (by Name)
        mapper - the mapper from ResultSet to Object
        partitionColumn - the column to use for portioning (should be numeric)
        numPartitions - the number of partitions (controls the parallelization
        Returns:
        the ResultSetIterator over the results of the given QueryStatement
        Throws:
        SQLException - something happened trying to query
      • queryParallel

        public final <T> Stream<T> queryParallel​(@NonNull
                                                 @NonNull SQLContext context,
                                                 @NonNull
                                                 @NonNull List<?> values,
                                                 @NonNull
                                                 @NonNull ResultSetMapper<? extends T> mapper,
                                                 @NonNull
                                                 @NonNull String partitionColumn,
                                                 int numPartitions)
                                          throws SQLException
        Performs this Select query using the given SQLContext filling in indexed value placeholders using the given Map of values and returning the results as a ResultSetIterator using the given ResultSetMapper* to map ResultSet to objects. This query method returns a parallel stream.
        Type Parameters:
        T - the Iterator type parameter
        Parameters:
        context - the context to perform the select over
        values - the values to use to fill the query statement (by Name)
        mapper - the mapper from ResultSet to Object
        partitionColumn - the column to use for portioning (should be numeric)
        numPartitions - the number of partitions (controls the parallelization
        Returns:
        the ResultSetIterator over the results of the given QueryStatement
        Throws:
        SQLException - something happened trying to query
      • rightOuterJoin

        public Select rightOuterJoin​(@NonNull
                                     @NonNull SQLElement table,
                                     @NonNull
                                     @NonNull SQLElement criteria)
        Adds a right outer join with the given table on the given criteria to the from clause
        Parameters:
        table - the table or expression to join with
        criteria - the criteria for joining
        Returns:
        this Select object
      • where

        public Select where​(SQLElement whereClause)
        Sets the criteria (i.e. WHERE) for the selection.
        Parameters:
        whereClause - the where clause
        Returns:
        this Select object
      • where

        public Select where​(String whereClause)
        Sets the criteria (i.e. WHERE) for the selection.
        Parameters:
        whereClause - the where clause
        Returns:
        this Select object
      • window

        public Select window​(SQLElement window)
        Sets the Window function for the selection.
        Parameters:
        window - the window clause
        Returns:
        this Select object
      • window

        public Select window​(String window)
        Sets the Window function for the selection.
        Parameters:
        window - the window clause
        Returns:
        this Select object