Package com.github.eikecochu.sqlbuilder
Class Query
- java.lang.Object
-
- com.github.eikecochu.sqlbuilder.QueryPartImpl<Query>
-
- com.github.eikecochu.sqlbuilder.Query
-
- All Implemented Interfaces:
QueryBuilder<Query>,QueryPart,QueryPartLinked<Query>,QueryPartSQL<Query>
public class Query extends QueryPartImpl<Query> implements QueryBuilder<Query>
The Query class is the final class of the building process and describes a complete query.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisDelete()Checks if this builder represents a DELETE statementbooleanisExpression()Checks if this builder represents a function expressionbooleanisInsert()Checks if this builder represents an INSERT statementbooleanisSelect()Checks if this builder represents a SELECT statementbooleanisStatementType(java.lang.Class<?> clazz)Checks if this builder represents the passed statement typebooleanisUpdate()Checks if this builder represents an UPDATE statementjava.sql.PreparedStatementprepare(java.sql.Connection connection)Prepares the statement using the passed database connectionjava.sql.PreparedStatementprepare(java.sql.Connection connection, QueryOptions options)Prepares the statement using the passed database connectionjava.sql.CallableStatementprepareCall(java.sql.Connection connection, QueryOptions options)Prepares the call using the passed database connectionQueryquery()Returns the Query representation of this builder instancejava.lang.Class<?>statementType()Returns the statement type.java.lang.Stringstring(QueryOptions options)Transforms this statement into an SQL stringjava.lang.Stringstring(QueryOptions options, java.sql.Connection connection)Transforms this statement into an SQL stringjava.lang.StringtoString()-
Methods inherited from class com.github.eikecochu.sqlbuilder.QueryPartImpl
parent, sql
-
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.QueryBuilder
query
-
Methods inherited from interface com.github.eikecochu.sqlbuilder.QueryPartLinked
ext, parent, parent
-
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
string
public java.lang.String string(QueryOptions options)
Description copied from interface:QueryPartTransforms this statement into an 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 transformationconnection- Optional database connection- Returns:
- The created SQL string
-
prepare
public java.sql.PreparedStatement prepare(java.sql.Connection connection) throws java.sql.SQLExceptionPrepares 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.SQLExceptionPrepares the statement using the passed database connection- Parameters:
connection- The database connectionoptions- 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.SQLExceptionPrepares the call using the passed database connection- Parameters:
connection- The database connectionoptions- 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:QueryBuilderReturns the Query representation of this builder instance- Specified by:
queryin interfaceQueryBuilder<Query>- Returns:
- The Query representation
-
-