Class Query

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isDelete()
      Checks if this builder represents a DELETE statement
      boolean isExpression()
      Checks if this builder represents a function expression
      boolean isInsert()
      Checks if this builder represents an INSERT statement
      boolean isSelect()
      Checks if this builder represents a SELECT statement
      boolean isStatementType​(java.lang.Class<?> clazz)
      Checks if this builder represents the passed statement type
      boolean isUpdate()
      Checks if this builder represents an UPDATE statement
      java.sql.PreparedStatement prepare​(java.sql.Connection connection)
      Prepares the statement using the passed database connection
      java.sql.PreparedStatement prepare​(java.sql.Connection connection, QueryOptions options)
      Prepares the statement using the passed database connection
      java.sql.CallableStatement prepareCall​(java.sql.Connection connection, QueryOptions options)
      Prepares the call using the passed database connection
      Query query()
      Returns the Query representation of this builder instance
      java.lang.Class<?> statementType()
      Returns the statement type.
      java.lang.String string​(QueryOptions options)
      Transforms this statement into an SQL string
      java.lang.String string​(QueryOptions options, java.sql.Connection connection)
      Transforms this statement into an SQL string
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.github.eikecochu.sqlbuilder.QueryPart

        string
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • string

        public java.lang.String string​(QueryOptions options)
        Description copied from interface: QueryPart
        Transforms this statement into an SQL string
        Specified by:
        string in interface QueryPart
        Parameters:
        options - The QueryOptions to apply for transformation
        Returns:
        The created SQL string
      • string

        public java.lang.String string​(QueryOptions options,
                                       java.sql.Connection connection)
        Transforms this statement into an SQL string
        Parameters:
        options - The QueryOptions to apply for transformation
        connection - Optional database connection
        Returns:
        The created SQL string
      • prepare

        public java.sql.PreparedStatement prepare​(java.sql.Connection connection)
                                           throws java.sql.SQLException
        Prepares the statement using the passed database connection
        Parameters:
        connection - The database connection
        Returns:
        The PreparedStatement
        Throws:
        java.sql.SQLException - if preparing fails
      • prepare

        public java.sql.PreparedStatement prepare​(java.sql.Connection connection,
                                                  QueryOptions options)
                                           throws java.sql.SQLException
        Prepares the statement using the passed database connection
        Parameters:
        connection - The database connection
        options - The QueryOptions to use
        Returns:
        The PreparedStatement
        Throws:
        java.sql.SQLException - if preparing fails
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.sql.Connection connection,
                                                      QueryOptions options)
                                               throws java.sql.SQLException
        Prepares the call using the passed database connection
        Parameters:
        connection - The database connection
        options - The QueryOptions to use
        Returns:
        The CallableStatement
        Throws:
        java.sql.SQLException - if preparing fails
      • statementType

        public java.lang.Class<?> statementType()
        Returns the statement type. The type is determined by the first expression of the builder, that is not a WITH expression.
        Returns:
        The statement type as Class
      • isStatementType

        public boolean isStatementType​(java.lang.Class<?> clazz)
        Checks if this builder represents the passed statement type
        Parameters:
        clazz - The statement type to check
        Returns:
        True if types match
      • isSelect

        public boolean isSelect()
        Checks if this builder represents a SELECT statement
        Returns:
        True if SELECT
      • isInsert

        public boolean isInsert()
        Checks if this builder represents an INSERT statement
        Returns:
        True if INSERT
      • isUpdate

        public boolean isUpdate()
        Checks if this builder represents an UPDATE statement
        Returns:
        True if UPDATE
      • isDelete

        public boolean isDelete()
        Checks if this builder represents a DELETE statement
        Returns:
        True if DELETE
      • isExpression

        public boolean isExpression()
        Checks if this builder represents a function expression
        Returns:
        True if expression
      • query

        public Query query()
        Description copied from interface: QueryBuilder
        Returns the Query representation of this builder instance
        Specified by:
        query in interface QueryBuilder<Query>
        Returns:
        The Query representation