- All Superinterfaces:
Scope
- All Known Subinterfaces:
BindContext
,RenderContext
- Author:
- Lukas Eder
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@NotNull BindContext
Bind a value using a specific type.@NotNull RenderContext.CastMode
castMode()
The currently applied cast mode for bind values.Set the new cast mode forcastMode()
.castMode
(RenderContext.CastMode mode, Consumer<? super C> consumer) Set the new cast mode forcastMode()
for the scope of aConsumer
.castModeIf
(RenderContext.CastMode mode, boolean condition) Set the new cast mode forcastMode()
, if a condition is true.Set a data value for a key for the scope of aConsumer
.boolean
Whether the current context is rendering a SQL alias declarations indeclareTables()
ordeclareFields()
sections.declareAliases
(boolean declareTables) Whether the current context is rendering a SQL alias declarations indeclareTables()
ordeclareFields()
sections.declareAliases
(boolean declareTables, Consumer<? super C> consumer) Whether the current context is rendering a SQL alias declarations indeclareTables()
ordeclareFields()
sections for the scope of aConsumer
.boolean
Whether the current context is rendering a common table expression (e.g.declareCTE
(boolean declareCTE) Set the new context value fordeclareCTE()
.declareCTE
(boolean declareCTE, Consumer<? super C> consumer) Set the new context value fordeclareCTE()
for the scope of aConsumer
.boolean
Whether the current context is rendering a SQL field declaration (e.g.declareFields
(boolean declareFields) Set the new context value fordeclareFields()
.declareFields
(boolean declareFields, Consumer<? super C> consumer) Set the new context value fordeclareFields()
for the scope of aConsumer
.boolean
Whether the current context is rendering a procedure or function parameter declaration.declareParameters
(boolean declareParameters) Set the new context value fordeclareParameters()
.declareParameters
(boolean declareParameters, Consumer<? super C> consumer) Set the new context value fordeclareParameters()
for the scope of aConsumer
.boolean
Whether the current context is rendering a SQL table declaration (e.g.declareTables
(boolean declareTables) Set the new context value fordeclareTables()
.declareTables
(boolean declareTables, Consumer<? super C> consumer) Set the new context value fordeclareTables()
for the scope of aConsumer
.boolean
Whether the current context is rendering a SQL window declaration (e.g.declareWindows
(boolean declareWindows) Set the new context value fordeclareWindows()
.declareWindows
(boolean declareWindows, Consumer<? super C> consumer) Set the new context value fordeclareWindows()
for the scope of aConsumer
.A formatter to produce scientific notation forDouble
types.A formatter to produce scientific notation forFloat
types.boolean
format()
The value ofSettings.isRenderFormatted()
.format
(boolean format) Override the value ofSettings.isRenderFormatted()
.Stop indenting subsequent SQL by one level (two characters), ifSettings.isRenderFormatted()
is set totrue
.formatIndentEnd
(int indent) Stop indenting subsequent SQL by a number of characters, ifSettings.isRenderFormatted()
is set totrue
.Deprecated, for removal: This API element is subject to removal in a future version.- [#10317] - 3.14.0 - Do not reuse this method.Deprecated, for removal: This API element is subject to removal in a future version.- [#10317] - 3.14.0 - Do not reuse this method.Start indenting subsequent SQL by one level (two characters), ifSettings.isRenderFormatted()
is set totrue
.formatIndentStart
(int indent) Start indenting subsequent SQL by a number of characters, ifSettings.isRenderFormatted()
is set totrue
.Render a new line character (only ifSettings.isRenderFormatted()
is set totrue
).Render a new line character (only ifSettings.isRenderFormatted()
is set totrue
, and theformatPrintMargin(int)
has been exceeded).formatPrintMargin
(int margin) Set a print margin that will be applied to formatted SQL, ifSettings.isRenderFormatted()
is set totrue
.Render a new line character (only ifSettings.isRenderFormatted()
is set totrue
), or a whitespace separator character otherwise.Deprecated, for removal: This API element is subject to removal in a future version.- 3.10.0 - [#4990] - UseDSL.keyword(String)
instead.@NotNull LanguageContext
The current language context.languageContext
(LanguageContext languageContext) Set the new language context forlanguageContext()
languageContext
(LanguageContext languageContext, Consumer<? super C> consumer) Set the new language context forlanguageContext()
for the scope of aConsumer
.languageContextIf
(LanguageContext languageContext, boolean condition) Set the new language context forlanguageContext()
, if a condition is true.Deprecated, for removal: This API element is subject to removal in a future version.- 3.10.0 - [#4990] - Use any ofDSL.name(String)
,DSL.quotedName(String)
orDSL.unquotedName(String)
instead.@NotNull String
Return a new alias that is unique for the scope of one query.int
Get the next bind index.@NotNull ParamType
Specify, how bind values should be rendered.Set the new context value forparamType()
.Set the new context value forparamType()
for the scope of aConsumer
.paramTypeIf
(ParamType paramType, boolean condition) Set the new context value forparamType()
, if a condition is true.paramTypeIf
(ParamType paramType, boolean condition, Consumer<? super C> runnable) Set the new context value forparamType()
for the scope of aConsumer
, if a condition is true.@NotNull String
Peek the next alias that will be generated bynextAlias()
.int
Peek the next bind index.boolean
qualify()
Whether query parts should render qualified names or not.qualify
(boolean qualify) Set the new context value forqualify()
.boolean
Whether query parts should render qualified names or not.qualifyCatalog
(boolean qualifyCatalog) Set the new context value forqualifyCatalog()
.qualifyCatalog
(boolean qualifyCatalog, Consumer<? super C> consumer) Set the new context value forqualifyCatalog()
for the scope of aConsumer
.boolean
Whether query parts should render qualified names or not.qualifySchema
(boolean qualifySchema) Set the new context value forqualifySchema()
.qualifySchema
(boolean qualifySchema, Consumer<? super C> consumer) Set the new context value forqualifySchema()
for the scope of aConsumer
.boolean
quote()
WhetherName
parts (andliteral(String)
) should be quoted.quote
(boolean quote) Set the new context value forquote()
.@NotNull String
render()
Render the context's underlying SQL statement.@NotNull String
Render a query part in a new context derived from this one.scopeEnd()
End a previous SELECT scope.int
Which level of scopes we're currently in, starting with 0 for the top scope.@Nullable QueryPart
scopeMapping
(QueryPart part) Retrieve the registered mapping for a query part in the current scope, ornull
if no such mapping exists.scopeMarkEnd
(QueryPart part) Mark the end of a scoped query part.scopeMarkStart
(QueryPart part) Mark the beginning of a scoped query part.scopeRegister
(QueryPart part) Register a "special" query part in the scope, reusing the object from a higher scope, if available.scopeRegister
(QueryPart part, boolean forceNew) Register a "special" query part in the scope, allowing to force registering the object in the new scope, if a higher scope already has the object.scopeRegister
(QueryPart part, boolean forceNew, QueryPart mapped) Register a "special" query part in the scope, allowing to force registering the object in the new scope, if a higher scope already has the object, as well as providing a mapped part to map the original part to.scopeRegisterAndMark
(QueryPart part, boolean forceNew) Start a new scope.boolean
Whether some sort of separator is required before rendering the nextQueryPart
.separatorRequired
(boolean separatorRequired) Specify that a separator will be required before the nextvisit(QueryPart)
call, but leave the decision whether to generate aformatSeparator()
or just a whitespace to that nextQueryPart
.Skip an additional update count produced by this query.int
The number of update counts to be skipped by this query.skipUpdateCounts
(int skip) Skip a number of additional update counts produced by this query.sql
(char sql) Append some SQL to the context's containedStringBuilder
.sql
(double sql) Append some SQL to the context's containedStringBuilder
.sql
(float sql) Append some SQL to the context's containedStringBuilder
.sql
(int sql) Append some SQL to the context's containedStringBuilder
.sql
(long sql) Append some SQL to the context's containedStringBuilder
.Append some SQL to the context's containedStringBuilder
.Append some SQL to the context's containedStringBuilder
.Append some SQL to the context's containedStringBuilder
preceded by the usual calls toformatIndentEnd()
andformatNewLine()
.sqlIndentEnd
(char sql) Append some SQL to the context's containedStringBuilder
preceded by the usual calls toformatIndentEnd()
andformatNewLine()
.sqlIndentEnd
(String sql) Append some SQL to the context's containedStringBuilder
preceded by the usual calls toformatIndentEnd()
andformatNewLine()
.Append some SQL to the context's containedStringBuilder
, followed by the usual calls toformatIndentStart()
andformatNewLine()
.sqlIndentStart
(char sql) Append some SQL to the context's containedStringBuilder
, followed by the usual calls toformatIndentStart()
andformatNewLine()
.sqlIndentStart
(String sql) Append some SQL to the context's containedStringBuilder
, followed by the usual calls toformatIndentStart()
andformatNewLine()
.TODO [#2667] Properties of these methods: - A clause is always started / ended, even if it isn't rendered or if it's empty!@Nullable PreparedStatement
Retrieve the context's underlyingPreparedStatement
if available, ornull
if this traversal does not operate on aPreparedStatement
.boolean
whether the current context is rendering a string literal.stringLiteral
(boolean stringLiteral) Set the new context value forstringLiteral()
.boolean
subquery()
Whether the current context is rendering a sub-query (nested query).subquery
(boolean subquery) Set the new context value forsubquery()
.int
Which level of subqueries we're currently in, starting with 0 for the top level query.Visit aQueryPart
in the currentContext
.Visit a query part with a given value forparamType()
.visitSubquery
(QueryPart part) Visit aQueryPart
as a subquery in the currentContext
.
-
Method Details
-
visit
Visit aQueryPart
in the currentContext
.This method is called by certain
QueryPart
implementations to recursively visit componentQueryPart
s.- Parameters:
part
- The componentQueryPart
- Throws:
DataAccessException
- If something went wrong while visiting the componentQueryPart
, e.g. when binding a variable
-
visitSubquery
Visit aQueryPart
as a subquery in the currentContext
.This method is called by certain
QueryPart
implementations to recursively visit componentQueryPart
s.- Parameters:
part
- The componentQueryPart
- Throws:
DataAccessException
- If something went wrong while visiting the componentQueryPart
, e.g. when binding a variable
-
start
TODO [#2667] Properties of these methods: - A clause is always started / ended, even if it isn't rendered or if it's empty! -
end
-
data
Set a data value for a key for the scope of aConsumer
. -
declareFields
boolean declareFields()Whether the current context is rendering a SQL field declaration (e.g. aField
in theSELECT
clause of the query). -
declareFields
Set the new context value fordeclareFields()
. -
declareFields
Set the new context value fordeclareFields()
for the scope of aConsumer
. -
declareTables
boolean declareTables()Whether the current context is rendering a SQL table declaration (e.g. aTable
in theFROM
orJOIN
clause of the query). -
declareTables
Set the new context value fordeclareTables()
. -
declareTables
Set the new context value fordeclareTables()
for the scope of aConsumer
. -
declareAliases
boolean declareAliases()Whether the current context is rendering a SQL alias declarations indeclareTables()
ordeclareFields()
sections. -
declareAliases
Whether the current context is rendering a SQL alias declarations indeclareTables()
ordeclareFields()
sections. -
declareAliases
Whether the current context is rendering a SQL alias declarations indeclareTables()
ordeclareFields()
sections for the scope of aConsumer
. -
declareWindows
boolean declareWindows()Whether the current context is rendering a SQL window declaration (e.g. aWindowDefinition
in theWINDOW
clause of the query). -
declareWindows
Set the new context value fordeclareWindows()
. -
declareWindows
Set the new context value fordeclareWindows()
for the scope of aConsumer
. -
declareParameters
Whether the current context is rendering a procedure or function parameter declaration. -
declareParameters
Set the new context value fordeclareParameters()
. -
declareParameters
Set the new context value fordeclareParameters()
for the scope of aConsumer
. -
declareCTE
boolean declareCTE()Whether the current context is rendering a common table expression (e.g. aCommonTableExpression
in theWITH
clause of the query). -
declareCTE
Set the new context value fordeclareCTE()
. -
declareCTE
Set the new context value fordeclareCTE()
for the scope of aConsumer
. -
subquery
boolean subquery()Whether the current context is rendering a sub-query (nested query). -
subquery
Set the new context value forsubquery()
. -
subqueryLevel
int subqueryLevel()Which level of subqueries we're currently in, starting with 0 for the top level query. -
scopeLevel
int scopeLevel()Which level of scopes we're currently in, starting with 0 for the top scope. -
scopeStart
Start a new scope. -
scopeMarkStart
Mark the beginning of a scoped query part. -
scopeRegister
Register a "special" query part in the scope, reusing the object from a higher scope, if available. -
scopeRegisterAndMark
-
scopeRegister
Register a "special" query part in the scope, allowing to force registering the object in the new scope, if a higher scope already has the object.[#10992] This is necessary to allow for hiding identifiers from nested scopes.
-
scopeRegister
Register a "special" query part in the scope, allowing to force registering the object in the new scope, if a higher scope already has the object, as well as providing a mapped part to map the original part to.[#10716] When wrapping parts of a query in a derived table, additional table mappings may be needed.
-
scopeMapping
Retrieve the registered mapping for a query part in the current scope, ornull
if no such mapping exists. -
scopeMarkEnd
Mark the end of a scoped query part. -
scopeEnd
End a previous SELECT scope. -
stringLiteral
boolean stringLiteral()whether the current context is rendering a string literal. -
stringLiteral
Set the new context value forstringLiteral()
. -
nextIndex
int nextIndex()Get the next bind index. This increments an internal counter. This is relevant for two use-cases:- When binding variables to a
PreparedStatement
. Client code must assure that callingnextIndex()
is followed by setting a bind value tostatement()
- When rendering unnamed bind variables with
paramType()
being toNAMED
- When binding variables to a
-
peekIndex
int peekIndex()Peek the next bind index. This won't increment the internal counter, unlikenextIndex()
. -
skipUpdateCount
Skip an additional update count produced by this query. -
skipUpdateCounts
Skip a number of additional update counts produced by this query. -
skipUpdateCounts
int skipUpdateCounts()The number of update counts to be skipped by this query. -
statement
Retrieve the context's underlyingPreparedStatement
if available, ornull
if this traversal does not operate on aPreparedStatement
. -
bindValue
Bind a value using a specific type. This will also increment the internal counter.- Throws:
DataAccessException
- If something went wrong while binding a variable
-
peekAlias
Peek the next alias that will be generated bynextAlias()
. -
nextAlias
Return a new alias that is unique for the scope of one query. These aliases are sometimes needed when unaliased projections are defined in subqueries, which can lead to syntax errors. -
render
Render the context's underlying SQL statement. -
render
Render a query part in a new context derived from this one. The rendered SQL will not be appended to this context. -
keyword
Deprecated, for removal: This API element is subject to removal in a future version.- 3.10.0 - [#4990] - UseDSL.keyword(String)
instead.Append a SQL keyword to the context's containedStringBuilder
.Use this to have your SQL keyword rendered in
RenderKeywordCase
. -
sql
Append some SQL to the context's containedStringBuilder
. -
sql
Append some SQL to the context's containedStringBuilder
.Set
literal = true
to indicate that theRenderContext
shall not format the argument SQL. -
sqlIndentStart
Append some SQL to the context's containedStringBuilder
, followed by the usual calls toformatIndentStart()
andformatNewLine()
. -
sqlIndentEnd
Append some SQL to the context's containedStringBuilder
preceded by the usual calls toformatIndentEnd()
andformatNewLine()
. -
sqlIndentStart
Append some SQL to the context's containedStringBuilder
, followed by the usual calls toformatIndentStart()
andformatNewLine()
. -
sqlIndentEnd
Append some SQL to the context's containedStringBuilder
preceded by the usual calls toformatIndentEnd()
andformatNewLine()
. -
sql
Append some SQL to the context's containedStringBuilder
. -
sqlIndentStart
Append some SQL to the context's containedStringBuilder
, followed by the usual calls toformatIndentStart()
andformatNewLine()
. -
sqlIndentEnd
Append some SQL to the context's containedStringBuilder
preceded by the usual calls toformatIndentEnd()
andformatNewLine()
. -
sql
Append some SQL to the context's containedStringBuilder
. -
sql
Append some SQL to the context's containedStringBuilder
. -
floatFormat
DecimalFormat floatFormat()A formatter to produce scientific notation forFloat
types. -
sql
Append some SQL to the context's containedStringBuilder
. -
doubleFormat
DecimalFormat doubleFormat()A formatter to produce scientific notation forDouble
types. -
sql
Append some SQL to the context's containedStringBuilder
. -
format
Override the value ofSettings.isRenderFormatted()
. -
format
boolean format()The value ofSettings.isRenderFormatted()
. -
formatNewLine
Render a new line character (only ifSettings.isRenderFormatted()
is set totrue
). -
formatNewLineAfterPrintMargin
Render a new line character (only ifSettings.isRenderFormatted()
is set totrue
, and theformatPrintMargin(int)
has been exceeded). -
formatSeparator
Render a new line character (only ifSettings.isRenderFormatted()
is set totrue
), or a whitespace separator character otherwise. -
separatorRequired
Specify that a separator will be required before the nextvisit(QueryPart)
call, but leave the decision whether to generate aformatSeparator()
or just a whitespace to that nextQueryPart
. -
separatorRequired
boolean separatorRequired()Whether some sort of separator is required before rendering the nextQueryPart
. -
formatIndentStart
Start indenting subsequent SQL by one level (two characters), ifSettings.isRenderFormatted()
is set totrue
.This is the same as calling
formatIndentStart(int)
with a parameter of2
-
formatIndentStart
Start indenting subsequent SQL by a number of characters, ifSettings.isRenderFormatted()
is set totrue
. -
formatIndentLockStart
Deprecated, for removal: This API element is subject to removal in a future version.- [#10317] - 3.14.0 - Do not reuse this method. It will be removed without replacement.Start indenting subsequent SQL at the same level as the current line, ifSettings.isRenderFormatted()
is set totrue
. -
formatIndentEnd
Stop indenting subsequent SQL by one level (two characters), ifSettings.isRenderFormatted()
is set totrue
.This is the same as calling
formatIndentEnd(int)
with a parameter of2
-
formatIndentEnd
Stop indenting subsequent SQL by a number of characters, ifSettings.isRenderFormatted()
is set totrue
. -
formatIndentLockEnd
Deprecated, for removal: This API element is subject to removal in a future version.- [#10317] - 3.14.0 - Do not reuse this method. It will be removed without replacement.Stop indenting subsequent SQL at the same level as the current line, ifSettings.isRenderFormatted()
is set totrue
. -
formatPrintMargin
Set a print margin that will be applied to formatted SQL, ifSettings.isRenderFormatted()
is set totrue
.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
-
literal
Deprecated, for removal: This API element is subject to removal in a future version.- 3.10.0 - [#4990] - Use any ofDSL.name(String)
,DSL.quotedName(String)
orDSL.unquotedName(String)
instead.Append some literal to the context's containedStringBuilder
. -
quote
boolean quote()WhetherName
parts (andliteral(String)
) should be quoted. -
quote
Set the new context value forquote()
. -
quote
-
qualify
boolean qualify()Whether query parts should render qualified names or not. -
qualify
Set the new context value forqualify()
.This is the same as
qualifySchema(boolean)
. -
qualify
-
qualifySchema
boolean qualifySchema()Whether query parts should render qualified names or not.This is the same as
qualifySchema()
. -
qualifySchema
Set the new context value forqualifySchema()
. -
qualifySchema
Set the new context value forqualifySchema()
for the scope of aConsumer
. -
qualifyCatalog
boolean qualifyCatalog()Whether query parts should render qualified names or not.The catalog can only be qualified when
qualifySchema()
istrue
as well. -
qualifyCatalog
Set the new context value forqualifyCatalog()
.The catalog can only be qualified when
qualifySchema()
istrue
as well. -
qualifyCatalog
Set the new context value forqualifyCatalog()
for the scope of aConsumer
.The catalog can only be qualified when
qualifySchema()
istrue
as well. -
paramType
Specify, how bind values should be rendered.- As
ParamType.INDEXED
parameters:
?, ?, ?
- As
ParamType.NAMED
parameters:
:1, :2, :custom_name
- As
ParamType.INLINED
parameters:
1, 'A', null
- As
-
paramType
Set the new context value forparamType()
. -
visit
Visit a query part with a given value forparamType()
. -
paramTypeIf
Set the new context value forparamType()
, if a condition is true. -
paramType
Set the new context value forparamType()
for the scope of aConsumer
. -
paramTypeIf
Set the new context value forparamType()
for the scope of aConsumer
, if a condition is true. -
languageContext
The current language context. -
languageContext
Set the new language context forlanguageContext()
-
languageContext
Set the new language context forlanguageContext()
for the scope of aConsumer
. -
languageContextIf
Set the new language context forlanguageContext()
, if a condition is true. -
castMode
The currently applied cast mode for bind values. -
castMode
Set the new cast mode forcastMode()
. -
castMode
Set the new cast mode forcastMode()
for the scope of aConsumer
. -
castModeIf
Set the new cast mode forcastMode()
, if a condition is true.
-