public final class StatementBuilder extends Object implements QueryBuilderInterface<Value>
StatementBuilder allows for statements to be constructed in parts.
Typical usage is:
StatementBuilder statementBuilder = new StatementBuilder()
.where("lastModifiedDateTime > :yesterday AND type = :type")
.orderBy("name DESC")
.limit(200)
.offset(20)
.withBindVariableValue("yesterday",
DateTimes.fromDate(new org.joda.time.DateTime().minusDays(1).toDate()))
.withBindVariableValue("type", "Type")
Statement statement = statementBuilder.toStatement();
//...
statementBuilder.increaseOffsetBy(20);
statement = statementBuilder.toStatement();
| Modifier and Type | Field and Description |
|---|---|
static int |
SUGGESTED_PAGE_LIMIT |
| Constructor and Description |
|---|
StatementBuilder()
Constructs a statement builder.
|
| Modifier and Type | Method and Description |
|---|---|
String |
buildQuery() |
StatementBuilder |
from(String table) |
Map<String,Value> |
getBindVariableMap() |
Integer |
getOffset() |
StatementBuilder |
increaseOffsetBy(Integer amount) |
StatementBuilder |
limit(Integer count) |
StatementBuilder |
offset(Integer count) |
StatementBuilder |
orderBy(String orderBy) |
StatementBuilder |
removeLimitAndOffset() |
StatementBuilder |
select(String columns) |
Statement |
toStatement()
Gets the
Statement representing the state of this statement
builder. |
StatementBuilder |
where(String conditions) |
StatementBuilder |
withBindVariableValue(String key,
Object value)
Adds a bind variable value to the statement.
|
StatementBuilder |
withBindVariableValue(String key,
Value value)
Adds a bind variable value to the statement.
|
public static final int SUGGESTED_PAGE_LIMIT
public StatementBuilder withBindVariableValue(String key, Object value)
Pql.createValue(Object). If the value is of type
Value, no conversion will be done.key - the value keyvalue - the bind variable valuepublic StatementBuilder withBindVariableValue(String key, Value value)
withBindVariableValue in interface QueryBuilderInterface<Value>key - the value keyvalue - the bind variable valuepublic Statement toStatement()
Statement representing the state of this statement
builder.Statementpublic StatementBuilder select(String columns)
select in interface QueryBuilderInterface<Value>public StatementBuilder from(String table)
from in interface QueryBuilderInterface<Value>public StatementBuilder where(String conditions)
where in interface QueryBuilderInterface<Value>public StatementBuilder limit(Integer count)
limit in interface QueryBuilderInterface<Value>public StatementBuilder offset(Integer count)
offset in interface QueryBuilderInterface<Value>public StatementBuilder increaseOffsetBy(Integer amount)
increaseOffsetBy in interface QueryBuilderInterface<Value>public Integer getOffset()
getOffset in interface QueryBuilderInterface<Value>public StatementBuilder removeLimitAndOffset()
removeLimitAndOffset in interface QueryBuilderInterface<Value>public StatementBuilder orderBy(String orderBy)
orderBy in interface QueryBuilderInterface<Value>public Map<String,Value> getBindVariableMap()
getBindVariableMap in interface QueryBuilderInterface<Value>public String buildQuery()
buildQuery in interface QueryBuilderInterface<Value>Copyright © 2013. All Rights Reserved.