- All Implemented Interfaces:
Serializable
,Binding<T,
U>
- Author:
- Lukas Eder
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
static class
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultBinding
(Binding<T, U> delegate) Deprecated, for removal: This API element is subject to removal in a future version.- 3.21.0 - [#19125] - This class will be removed from public API, do not reuse.DefaultBinding
(Converter<T, U> converter) Deprecated, for removal: This API element is subject to removal in a future version.- 3.11 - [#6631] - Usebinding(Converter)
instead. -
Method Summary
Modifier and TypeMethodDescriptionGet an array binding for this binding, ornull
if no such array binding is available.Binding
<?, ?> Get an array component binding for this binding, ornull
if this binding isn't for an array type.static final <T,
U> Binding <T, U> Get the internal default binding for aConverter
.static final <T> Binding
<T, T> Get the internal default binding for aDataType
.A converter that can convert between the database type and the custom type.Get an optionalFormatter
implementation, instructing jOOQ on how to embed the user type inSQLDataType.JSON
,SQLDataType.JSONB
, andSQLDataType.XML
contexts.void
get
(BindingGetResultSetContext<U> ctx) Get aResultSet
'sOUT
value.void
get
(BindingGetSQLInputContext<U> ctx) Get aSQLInput
'sOUT
value.void
get
(BindingGetStatementContext<U> ctx) Get aCallableStatement
'sOUT
value.void
register
(BindingRegisterContext<U> ctx) Register aCallableStatement
'sOUT
parameter.void
set
(BindingSetSQLOutputContext<U> ctx) Set aSQLOutput
'sIN
parameter.void
set
(BindingSetStatementContext<U> ctx) Set aPreparedStatement
'sIN
parameter.void
sql
(BindingSQLContext<U> ctx) Generate SQL code for the bind variable.toString()
-
Constructor Details
-
DefaultBinding
Deprecated, for removal: This API element is subject to removal in a future version.- 3.11 - [#6631] - Usebinding(Converter)
instead. -
DefaultBinding
Deprecated, for removal: This API element is subject to removal in a future version.- 3.21.0 - [#19125] - This class will be removed from public API, do not reuse.
-
-
Method Details
-
binding
Get the internal default binding for aConverter
. -
binding
Get the internal default binding for aDataType
. -
formatter
Description copied from interface:Binding
Get an optionalFormatter
implementation, instructing jOOQ on how to embed the user type inSQLDataType.JSON
,SQLDataType.JSONB
, andSQLDataType.XML
contexts.This may be necessary when embedding user-defined types in
DSL.multiset(TableLike)
queries, when the user-defined type serialises differently in aNestedCollectionEmulation.JSONB
emulation than standalone, for example.A
null
formatter will have no effect on generated SQL.Note: while it is possible to implement a custom formatter for array types, it is usually simpler to just delegate to the
Binding.arrayComponentBinding()
for this, and let jOOQ's internals handle the intricate mapping of generic arrays to XML or JSON. -
arrayBinding
Description copied from interface:Binding
Get an array binding for this binding, ornull
if no such array binding is available.- Specified by:
arrayBinding
in interfaceBinding<T,
U>
-
arrayComponentBinding
Description copied from interface:Binding
Get an array component binding for this binding, ornull
if this binding isn't for an array type.Implementations must ensure that the resulting type is
Binding<X, Y>
, if this Binding's type variables resolve toT = X[]
andU = Y[]
, as this cannot be enforced by the Java compiler.- Specified by:
arrayComponentBinding
in interfaceBinding<T,
U>
-
converter
Description copied from interface:Binding
A converter that can convert between the database type and the custom type.While the
Converter
property of a binding is not optional (Converter.fromType()
andConverter.toType()
are needed by jOOQ's internals), the conversion implementation (i.e.Converter.from(Object)
andConverter.to(Object)
) isn't strictly required if implementations don't rely on it. If these conversion implementations are non-functional, it is advised to hint at this fact inConverter.fromSupported()
andConverter.toSupported()
. -
sql
Description copied from interface:Binding
Generate SQL code for the bind variable.Implementations should generate SQL code onto
BindingSQLContext.render()
, given the context's bind variable located atBindingSQLContext.value()
. Examples of such SQL code are:"?"
: Default implementations can simply generate a question mark.
"123"
: Implementations may choose to inline bind variables to influence execution plan generation.
Context.paramType()
contains information whether inlined bind variables are expected in the current context.
"CAST(? AS DATE)"
: Cast a database to a more specific type. This can be useful in databases like Oracle, which map bothDATE
andTIMESTAMP
SQL types toTimestamp
.
Context.castMode()
may contain some hints about whether casting is suggested in the current context.
"?::json"
: Vendor-specific bind variables can be supported, e.g.SQLDialect.POSTGRES
's JSON data type.
Implementations must provide consistent behaviour between
Binding.sql(BindingSQLContext)
andBinding.set(BindingSetStatementContext)
, i.e. when bind variables are inlined, then they must not be bound to thePreparedStatement
inBinding.set(BindingSetStatementContext)
- Specified by:
sql
in interfaceBinding<T,
U> - Parameters:
ctx
- The context object containing all argument objects.- Throws:
SQLException
- Implementations are allowed to pass on allSQLException
s to the caller to be wrapped inDataAccessException
s.
-
register
Description copied from interface:Binding
Register aCallableStatement
'sOUT
parameter.- Specified by:
register
in interfaceBinding<T,
U> - Parameters:
ctx
- The context object containing all argument objects.- Throws:
SQLException
- Implementations are allowed to pass on allSQLException
s to the caller to be wrapped inDataAccessException
s.
-
set
Description copied from interface:Binding
Set aPreparedStatement
'sIN
parameter.- Specified by:
set
in interfaceBinding<T,
U> - Parameters:
ctx
- The context object containing all argument objects.- Throws:
SQLException
- Implementations are allowed to pass on allSQLException
s to the caller to be wrapped inDataAccessException
s.
-
set
Description copied from interface:Binding
Set aSQLOutput
'sIN
parameter.- Specified by:
set
in interfaceBinding<T,
U> - Parameters:
ctx
- The context object containing all argument objects.- Throws:
SQLException
- Implementations are allowed to pass on allSQLException
s to the caller to be wrapped inDataAccessException
s.
-
get
Description copied from interface:Binding
Get aResultSet
'sOUT
value.Implementations are expected to produce a value by calling
BindingGetResultSetContext.value(Object)
, passing the resulting value to the method.- Specified by:
get
in interfaceBinding<T,
U> - Parameters:
ctx
- The context object containing all argument objects.- Throws:
SQLException
- Implementations are allowed to pass on allSQLException
s to the caller to be wrapped inDataAccessException
s.
-
get
Description copied from interface:Binding
Get aCallableStatement
'sOUT
value.Implementations are expected to produce a value by calling
BindingGetStatementContext.value(Object)
, passing the resulting value to the method.- Specified by:
get
in interfaceBinding<T,
U> - Parameters:
ctx
- The context object containing all argument objects.- Throws:
SQLException
- Implementations are allowed to pass on allSQLException
s to the caller to be wrapped inDataAccessException
s.
-
get
Description copied from interface:Binding
Get aSQLInput
'sOUT
value.Implementations are expected to produce a value by calling
BindingGetSQLInputContext.value(Object)
, passing the resulting value to the method.- Specified by:
get
in interfaceBinding<T,
U> - Parameters:
ctx
- The context object containing all argument objects.- Throws:
SQLException
- Implementations are allowed to pass on allSQLException
s to the caller to be wrapped inDataAccessException
s.
-
toString
-