public interface Context<C extends Context<C>> extends Scope
BindContext
,
RenderContext
Modifier and Type | Method and Description |
---|---|
BindContext |
bindValue(Object value,
Field<?> field)
Bind a value using a specific type.
|
Boolean |
cast()
Deprecated.
- [#3703] - 3.5.0 - Do not use this any longer
|
RenderContext.CastMode |
castMode()
The currently applied cast mode for bind values.
|
C |
castMode(RenderContext.CastMode mode)
Set the new cast mode for
castMode() . |
C |
castModeSome(SQLDialect... dialects)
Deprecated.
- [#3703] - 3.5.0 - Do not use this any longer
|
boolean |
declareAliases()
Whether the current context is rendering a SQL alias declarations in
declareTables() or declareFields() sections. |
C |
declareAliases(boolean declareTables)
Whether the current context is rendering a SQL alias declarations in
declareTables() or declareFields() sections. |
boolean |
declareCTE()
Whether the current context is rendering a common table expression (e.g.
|
C |
declareCTE(boolean declareCTE)
Set the new context value for
declareCTE() . |
boolean |
declareFields()
Whether the current context is rendering a SQL field declaration (e.g. a
Field in the SELECT clause of the query). |
C |
declareFields(boolean declareFields)
Set the new context value for
declareFields() . |
boolean |
declareTables()
Whether the current context is rendering a SQL table declaration (e.g. a
Table in the FROM or JOIN clause of the
query). |
C |
declareTables(boolean declareTables)
Set the new context value for
declareTables() . |
boolean |
declareWindows()
Whether the current context is rendering a SQL window declaration (e.g. a
WindowDefinition in the WINDOW clause of the query). |
C |
declareWindows(boolean declareWindows)
Set the new context value for
declareWindows() . |
C |
end(Clause clause) |
boolean |
format()
The value of
Settings.isRenderFormatted() . |
C |
format(boolean format)
Override the value of
Settings.isRenderFormatted() . |
C |
formatIndentEnd()
Stop indenting subsequent SQL by one level (two characters), if
Settings.isRenderFormatted() is set to true . |
C |
formatIndentEnd(int indent)
Stop indenting subsequent SQL by a number of characters, if
Settings.isRenderFormatted() is set to true . |
C |
formatIndentLockEnd()
Stop indenting subsequent SQL at the same level as the current line, if
Settings.isRenderFormatted() is set to true . |
C |
formatIndentLockStart()
Start indenting subsequent SQL at the same level as the current line, if
Settings.isRenderFormatted() is set to true . |
C |
formatIndentStart()
Start indenting subsequent SQL by one level (two characters), if
Settings.isRenderFormatted() is set to true . |
C |
formatIndentStart(int indent)
Start indenting subsequent SQL by a number of characters, if
Settings.isRenderFormatted() is set to true . |
C |
formatNewLine()
Render a new line character (only if
Settings.isRenderFormatted()
is set to true ). |
C |
formatNewLineAfterPrintMargin()
Render a new line character (only if
Settings.isRenderFormatted()
is set to true , and the formatPrintMargin(int) has
been exceeded). |
C |
formatPrintMargin(int margin)
Set a print margin that will be applied to formatted SQL, if
Settings.isRenderFormatted() is set to true . |
C |
formatSeparator()
Render a new line character (only if
Settings.isRenderFormatted()
is set to true ), or a whitespace separator character
otherwise. |
C |
keyword(String keyword)
Deprecated.
- 3.10.0 - [#4990] - Use
DSL.keyword(String) instead. |
C |
literal(String literal)
Deprecated.
- 3.10.0 - [#4990] - Use any of
DSL.name(String) ,
DSL.quotedName(String) or
DSL.unquotedName(String) instead. |
String |
nextAlias()
Return a new alias that is unique for the scope of one query.
|
int |
nextIndex()
Get the next bind index.
|
ParamType |
paramType()
Specify, how bind values should be rendered.
|
C |
paramType(ParamType paramType)
Set the new context value for
paramType() . |
String |
peekAlias()
Peek the next alias that will be generated by
nextAlias() . |
int |
peekIndex()
Peek the next bind index.
|
boolean |
qualify()
Whether query parts should render qualified names or not.
|
C |
qualify(boolean qualify)
Set the new context value for
qualify() . |
boolean |
qualifyCatalog()
Whether query parts should render qualified names or not.
|
C |
qualifyCatalog(boolean qualifyCatalog)
Set the new context value for
qualifyCatalog() . |
boolean |
qualifySchema()
Whether query parts should render qualified names or not.
|
C |
qualifySchema(boolean qualifySchema)
Set the new context value for
qualifySchema() . |
boolean |
quote()
Whether
Name parts (and literal(String) ) should be quoted. |
C |
quote(boolean quote)
Set the new context value for
quote() . |
String |
render()
Render the context's underlying SQL statement.
|
String |
render(QueryPart part)
Render a query part in a new context derived from this one.
|
C |
scopeEnd()
End a previous SELECT scope.
|
C |
scopeMarkEnd(QueryPart part)
Mark the end of a scoped query part.
|
C |
scopeMarkStart(QueryPart part)
Mark the beginning of a scoped query part.
|
C |
scopeRegister(QueryPart part)
Register a "special" query part in the scope.
|
C |
scopeStart()
Start a new SELECT scope.
|
C |
sql(char sql)
Append some SQL to the context's contained
StringBuilder . |
C |
sql(int sql)
Append some SQL to the context's contained
StringBuilder . |
C |
sql(String sql)
Append some SQL to the context's contained
StringBuilder . |
C |
sql(String sql,
boolean literal)
Append some SQL to the context's contained
StringBuilder . |
C |
start(Clause clause)
TODO [#2667]
Properties of these methods:
- A clause is always started / ended, even if it isn't rendered or if it's empty!
|
PreparedStatement |
statement()
Retrieve the context's underlying
PreparedStatement if available,
or null if this traversal does not operate on a
PreparedStatement . |
boolean |
stringLiteral()
whether the current context is rendering a string literal.
|
C |
stringLiteral(boolean stringLiteral)
Set the new context value for
stringLiteral() . |
boolean |
subquery()
Whether the current context is rendering a sub-query (nested query).
|
C |
subquery(boolean subquery)
Set the new context value for
subquery() . |
C |
visit(QueryPart part)
Visit a
QueryPart in the current Context . |
C visit(QueryPart part) throws DataAccessException
QueryPart
in the current Context
.
This method is called by certain QueryPart
implementations
to recursively visit component QueryPart
s.
part
- The component QueryPart
DataAccessException
- If something went wrong while visiting the
component QueryPart
, e.g. when binding a
variableC start(Clause clause)
boolean declareFields()
Field
in the SELECT
clause of the query).C declareFields(boolean declareFields)
declareFields()
.boolean declareTables()
Table
in the FROM
or JOIN
clause of the
query).C declareTables(boolean declareTables)
declareTables()
.boolean declareAliases()
declareTables()
or declareFields()
sections.C declareAliases(boolean declareTables)
declareTables()
or declareFields()
sections.boolean declareWindows()
WindowDefinition
in the WINDOW
clause of the query).C declareWindows(boolean declareWindows)
declareWindows()
.boolean declareCTE()
CommonTableExpression
in the WITH
clause of the
query).C declareCTE(boolean declareCTE)
declareCTE()
.boolean subquery()
C subquery(boolean subquery)
subquery()
.C scopeStart()
C scopeEnd()
boolean stringLiteral()
C stringLiteral(boolean stringLiteral)
stringLiteral()
.int nextIndex()
PreparedStatement
. Client code
must assure that calling nextIndex()
is followed by setting a
bind value to BindContext.statement()
RenderContext.paramType()
being to NAMED
int peekIndex()
nextIndex()
.PreparedStatement statement()
PreparedStatement
if available,
or null
if this traversal does not operate on a
PreparedStatement
.BindContext bindValue(Object value, Field<?> field) throws DataAccessException
DataAccessException
- If something went wrong while binding a
variableString peekAlias()
nextAlias()
.String nextAlias()
String render()
String render(QueryPart part)
@Deprecated C keyword(String keyword)
DSL.keyword(String)
instead.StringBuilder
.
Use this to have your SQL keyword rendered in RenderKeywordStyle
.
C sql(String sql)
StringBuilder
.C sql(String sql, boolean literal)
StringBuilder
.
Set literal = true
to indicate that the
RenderContext
shall not format the argument SQL.
C sql(char sql)
StringBuilder
.C sql(int sql)
StringBuilder
.C format(boolean format)
Settings.isRenderFormatted()
.boolean format()
Settings.isRenderFormatted()
.C formatNewLine()
Settings.isRenderFormatted()
is set to true
).C formatNewLineAfterPrintMargin()
Settings.isRenderFormatted()
is set to true
, and the formatPrintMargin(int)
has
been exceeded).C formatSeparator()
Settings.isRenderFormatted()
is set to true
), or a whitespace separator character
otherwise.C formatIndentStart()
Settings.isRenderFormatted()
is set to true
.
This is the same as calling formatIndentStart(int)
with a
parameter of 2
C formatIndentStart(int indent)
Settings.isRenderFormatted()
is set to true
.C formatIndentLockStart()
Settings.isRenderFormatted()
is set to true
.C formatIndentEnd()
Settings.isRenderFormatted()
is set to true
.
This is the same as calling formatIndentEnd(int)
with a
parameter of 2
C formatIndentEnd(int indent)
Settings.isRenderFormatted()
is set to true
.C formatIndentLockEnd()
Settings.isRenderFormatted()
is set to true
.C formatPrintMargin(int margin)
Settings.isRenderFormatted()
is set to true
.
The default print margin is 80
. Setting this to zero or a
negative value means that no print margin will be applied.
The print margin is applied to any of these QueryParts
:
Field.in(Field...)
and related expressions@Deprecated C literal(String literal)
DSL.name(String)
,
DSL.quotedName(String)
or
DSL.unquotedName(String)
instead.StringBuilder
.boolean quote()
Name
parts (and literal(String)
) should be quoted.boolean qualify()
C qualify(boolean qualify)
qualify()
.
This is the same as qualifySchema(boolean)
.
boolean qualifySchema()
This is the same as qualifySchema()
.
C qualifySchema(boolean qualifySchema)
qualifySchema()
.boolean qualifyCatalog()
The catalog can only be qualified when qualifySchema()
is
true
as well.
C qualifyCatalog(boolean qualifyCatalog)
qualifyCatalog()
.
The catalog can only be qualified when qualifySchema()
is
true
as well.
ParamType paramType()
ParamType.INDEXED
parameters: ?, ?, ?
ParamType.NAMED
parameters: :1, :2, :custom_name
ParamType.INLINED
parameters: 1, 'A', null
C paramType(ParamType paramType)
paramType()
.RenderContext.CastMode castMode()
C castMode(RenderContext.CastMode mode)
castMode()
.@Deprecated Boolean cast()
CastMode | result |
---|---|
ALWAYS |
true |
NEVER |
false |
SOME |
true or false depending on the dialect |
DEFAULT |
null |
@Deprecated C castModeSome(SQLDialect... dialects)
RenderContext.CastMode.SOME
for a list of dialects.Copyright © 2019. All rights reserved.