Class QueryStatement

    • Constructor Detail

      • QueryStatement

        public QueryStatement()
    • Method Detail

      • except

        public QueryStatement except​(@NonNull
                                     @NonNull QueryStatement query2)
        Combines this query with the given second query using an EXCEPT operator
        Parameters:
        query2 - the second query.
        Returns:
        the combined SQLQueryStatement
      • exists

        public boolean exists​(@NonNull
                              @NonNull SQLContext context)
                       throws SQLException
        Runs the query returning true if there is at least on result.
        Parameters:
        context - the context to perform the query over
        Returns:
        True if there is at least one result
        Throws:
        SQLException - something happened trying to query
      • intersect

        public QueryStatement intersect​(@NonNull
                                        @NonNull QueryStatement query2)
        Combines this query with the given second query using an INTERSECT operator
        Parameters:
        query2 - the second query.
        Returns:
        the combined SQLQueryStatement
      • query

        public <T> Stream<T> query​(@NonNull
                                   @NonNull SQLContext context,
                                   @NonNull
                                   @NonNull ResultSetMapper<? extends T> resultSetMapper)
                            throws SQLException
        Performs the query specified in this statement using the given SQLContext returning the results as a ResultSetIterator using the given ResultSetMapper to map ResultSet to objects
        Type Parameters:
        T - the Iterator type parameter
        Parameters:
        context - the context to perform the query over
        resultSetMapper - the mapper from ResultSet to Object
        Returns:
        the ResultSetIterator over the results of the given QueryStatement
        Throws:
        SQLException - something happened trying to query
      • query

        public <T> Stream<T> query​(@NonNull
                                   @NonNull SQLContext context,
                                   @NonNull
                                   @NonNull List<?> values,
                                   @NonNull
                                   @NonNull ResultSetMapper<? extends T> resultSetMapper)
                            throws SQLException
        Performs the query specified in this statement using the given SQLContext filling in indexed value placeholders using the given List of values and returning the results as a ResultSetIterator* using the given ResultSetMapper to map ResultSet to objects
        Type Parameters:
        T - the Iterator type parameter
        Parameters:
        context - the context to perform the query over
        values - the values to use to fill the query statement (by Index)
        resultSetMapper - the mapper from ResultSet to Object
        Returns:
        the ResultSetIterator over the results of the given QueryStatement
        Throws:
        SQLException - something happened trying to query
      • query

        public <T> Stream<T> query​(@NonNull
                                   @NonNull SQLContext context,
                                   @NonNull
                                   @NonNull Map<String,​?> values,
                                   @NonNull
                                   @NonNull ResultSetMapper<? extends T> resultSetMapper)
                            throws SQLException
        Performs the query specified in this statement 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
        Type Parameters:
        T - the Iterator type parameter
        Parameters:
        context - the context to perform the query over
        values - the values to use to fill the query statement (by Name)
        resultSetMapper - the mapper from ResultSet to Object
        Returns:
        the ResultSetIterator over the results of the given QueryStatement
        Throws:
        SQLException - something happened trying to query
      • query

        public final ResultSet query​(@NonNull
                                     @NonNull SQLContext context)
                              throws SQLException
        Runs the query on the given context returning a ResultSet
        Parameters:
        context - the context to perform the query over
        Returns:
        the ResultSet
        Throws:
        SQLException - Something went wrong querying
      • queryScalar

        public <T> T queryScalar​(@NonNull
                                 @NonNull SQLContext context,
                                 @NonNull
                                 @NonNull Class<T> tClass)
                          throws SQLException
        Performs this query on the given SQLContext which expects a single value for a single column to return. The resultant value is converted into the given class type for return. If there is no value or the value cannot be converted a null value is returned.
        Type Parameters:
        T - the type parameter
        Parameters:
        context - the context to perform the query over
        tClass - the class type desired for the scalar object
        Returns:
        the scalar result
        Throws:
        SQLException - something happened trying to query
      • queryScalarDouble

        public Double queryScalarDouble​(@NonNull
                                        @NonNull SQLContext context)
                                 throws SQLException
        Performs this query on the given SQLContext which expects a single value for a single column to return. The resultant value is converted into a Double return. If there is no value or the value cannot be converted a null value is returned.

        Parameters:
        context - the context to perform the query over
        Returns:
        the scalar result
        Throws:
        SQLException - something happened trying to query
      • queryScalarLong

        public Long queryScalarLong​(@NonNull
                                    @NonNull SQLContext context)
                             throws SQLException
        Performs this query on the given SQLContext which expects a single value for a single column to return. The resultant value is converted into a Long return. If there is no value or the value cannot be converted a null value is returned.
        Parameters:
        context - the context to perform the query over
        Returns:
        the scalar result
        Throws:
        SQLException - something happened trying to query
      • queryScalarString

        public String queryScalarString​(@NonNull
                                        @NonNull SQLContext context)
                                 throws SQLException
        Performs this query on the given SQLContext which expects a single value for a single column to return. The resultant value is converted into a String return. If there is no value or the value cannot be converted a null value is returned.
        Parameters:
        context - the context to perform the query over
        Returns:
        the scalar result
        Throws:
        SQLException - something happened trying to query
      • union

        public QueryStatement union​(@NonNull
                                    @NonNull QueryStatement query2)
        Combines this query with the given second query using an UNION operator
        Parameters:
        query2 - the second query.
        Returns:
        the combined SQLQueryStatement
      • unionAll

        public QueryStatement unionAll​(@NonNull
                                       @NonNull QueryStatement query2)
        Combines this query with the given second query using an UNION ALL operator
        Parameters:
        query2 - the second query.
        Returns:
        the combined SQLQueryStatement