T
- The database type - i.e. any type available from
SQLDataType
U
- The user typepublic interface Binding<T,U>
extends java.io.Serializable
This SPI is used by jOOQ users to implement support for custom data types
that would otherwise not be supported by jOOQ and/or JDBC. All of jOOQ's
internal support for bind variable types is implemented in
DefaultBinding
.
Modifier and Type | Method and Description |
---|---|
Converter<T,U> |
converter()
A converter that can convert between the database type and the custom
type.
|
void |
get(BindingGetResultSetContext<U> ctx)
Get a
ResultSet 's OUT value. |
void |
get(BindingGetSQLInputContext<U> ctx)
Get a
SQLInput 's OUT value. |
void |
get(BindingGetStatementContext<U> ctx)
Get a
CallableStatement 's OUT value. |
static <T,U> Binding<T,U> |
of(Converter<T,U> converter,
java.util.function.Consumer<? super BindingSQLContext<U>> sqlContext,
java.util.function.Consumer<? super BindingGetResultSetContext<U>> getResultSetContext,
java.util.function.Consumer<? super BindingSetStatementContext<U>> setStatementContext)
Construct a binding from functions.
|
static <T,U> Binding<T,U> |
of(Converter<T,U> converter,
java.util.function.Consumer<? super BindingSQLContext<U>> sqlContext,
java.util.function.Consumer<? super BindingGetResultSetContext<U>> getResultSetContext,
java.util.function.Consumer<? super BindingSetStatementContext<U>> setStatementContext,
java.util.function.Consumer<? super BindingRegisterContext<U>> registerContext,
java.util.function.Consumer<? super BindingGetStatementContext<U>> getStatementContext)
Construct a binding from functions.
|
static <T,U> Binding<T,U> |
of(Converter<T,U> converter,
java.util.function.Consumer<? super BindingSQLContext<U>> sqlContext,
java.util.function.Consumer<? super BindingGetResultSetContext<U>> getResultSetContext,
java.util.function.Consumer<? super BindingSetStatementContext<U>> setStatementContext,
java.util.function.Consumer<? super BindingRegisterContext<U>> registerContext,
java.util.function.Consumer<? super BindingGetStatementContext<U>> getStatementContext,
java.util.function.Consumer<? super BindingGetSQLInputContext<U>> getSqlInputContext,
java.util.function.Consumer<? super BindingSetSQLOutputContext<U>> setSqlOutputContext)
Construct a binding from functions.
|
void |
register(BindingRegisterContext<U> ctx)
Register a
CallableStatement 's OUT parameter. |
void |
set(BindingSetSQLOutputContext<U> ctx)
Set a
SQLOutput 's IN parameter. |
void |
set(BindingSetStatementContext<U> ctx)
Set a
PreparedStatement 's IN parameter. |
void |
sql(BindingSQLContext<U> ctx)
Generate SQL code for the bind variable.
|
Converter<T,U> converter()
void sql(BindingSQLContext<U> ctx) throws java.sql.SQLException
Implementations should generate SQL code onto
BindingSQLContext.render()
, given the context's bind variable
located at BindingSQLContext.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.RenderContext.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 both
DATE
and TIMESTAMP
SQL types to
Timestamp
.RenderContext.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
sql(BindingSQLContext)
and
set(BindingSetStatementContext)
, i.e. when bind variables are
inlined, then they must not be bound to the PreparedStatement
in
set(BindingSetStatementContext)
ctx
- The context object containing all argument objects.java.sql.SQLException
- Implementations are allowed to pass on all
SQLException
s to the caller to be wrapped in
DataAccessException
s.void register(BindingRegisterContext<U> ctx) throws java.sql.SQLException
CallableStatement
's OUT
parameter.ctx
- The context object containing all argument objects.java.sql.SQLException
- Implementations are allowed to pass on all
SQLException
s to the caller to be wrapped in
DataAccessException
s.void set(BindingSetStatementContext<U> ctx) throws java.sql.SQLException
PreparedStatement
's IN
parameter.ctx
- The context object containing all argument objects.java.sql.SQLException
- Implementations are allowed to pass on all
SQLException
s to the caller to be wrapped in
DataAccessException
s.void set(BindingSetSQLOutputContext<U> ctx) throws java.sql.SQLException
SQLOutput
's IN
parameter.ctx
- The context object containing all argument objects.java.sql.SQLException
- Implementations are allowed to pass on all
SQLException
s to the caller to be wrapped in
DataAccessException
s.void get(BindingGetResultSetContext<U> ctx) throws java.sql.SQLException
ResultSet
's OUT
value.
Implementations are expected to produce a value by calling
BindingGetResultSetContext.value(Object)
, passing the resulting
value to the method.
ctx
- The context object containing all argument objects.java.sql.SQLException
- Implementations are allowed to pass on all
SQLException
s to the caller to be wrapped in
DataAccessException
s.void get(BindingGetStatementContext<U> ctx) throws java.sql.SQLException
CallableStatement
's OUT
value.
Implementations are expected to produce a value by calling
BindingGetStatementContext.value(Object)
, passing the resulting
value to the method.
ctx
- The context object containing all argument objects.java.sql.SQLException
- Implementations are allowed to pass on all
SQLException
s to the caller to be wrapped in
DataAccessException
s.void get(BindingGetSQLInputContext<U> ctx) throws java.sql.SQLException
SQLInput
's OUT
value.
Implementations are expected to produce a value by calling
BindingGetSQLInputContext.value(Object)
, passing the resulting
value to the method.
ctx
- The context object containing all argument objects.java.sql.SQLException
- Implementations are allowed to pass on all
SQLException
s to the caller to be wrapped in
DataAccessException
s.static <T,U> Binding<T,U> of(Converter<T,U> converter, java.util.function.Consumer<? super BindingSQLContext<U>> sqlContext, java.util.function.Consumer<? super BindingGetResultSetContext<U>> getResultSetContext, java.util.function.Consumer<? super BindingSetStatementContext<U>> setStatementContext)
static <T,U> Binding<T,U> of(Converter<T,U> converter, java.util.function.Consumer<? super BindingSQLContext<U>> sqlContext, java.util.function.Consumer<? super BindingGetResultSetContext<U>> getResultSetContext, java.util.function.Consumer<? super BindingSetStatementContext<U>> setStatementContext, java.util.function.Consumer<? super BindingRegisterContext<U>> registerContext, java.util.function.Consumer<? super BindingGetStatementContext<U>> getStatementContext)
static <T,U> Binding<T,U> of(Converter<T,U> converter, java.util.function.Consumer<? super BindingSQLContext<U>> sqlContext, java.util.function.Consumer<? super BindingGetResultSetContext<U>> getResultSetContext, java.util.function.Consumer<? super BindingSetStatementContext<U>> setStatementContext, java.util.function.Consumer<? super BindingRegisterContext<U>> registerContext, java.util.function.Consumer<? super BindingGetStatementContext<U>> getStatementContext, java.util.function.Consumer<? super BindingGetSQLInputContext<U>> getSqlInputContext, java.util.function.Consumer<? super BindingSetSQLOutputContext<U>> setSqlOutputContext)
Copyright © 2018. All Rights Reserved.