- java.lang.Object
-
- org.jooq.impl.AbstractBinding<T,U>
-
- All Implemented Interfaces:
Serializable
,Binding<T,U>
public abstract class AbstractBinding<T,U> extends Object implements Binding<T,U>
A convenient base implementation for custom bindings, simplifies the implementation.The simplification is provided by offering empty implementations for rarely used methods, such as those for stored procedure OUT parameter support:
register(BindingRegisterContext)
to register the OUT parameter.get(BindingGetStatementContext)
to read the OUT parameter.
or
SQLData
serialisation support (e.g. for Oracle user defined types):set(BindingSetSQLOutputContext)
to serialise a user defined type.get(BindingGetSQLInputContext)
to read a user defined type.
- Author:
- Lukas Eder
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractBinding()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
sql(BindingSQLContext<U> ctx)
A convenient base implementation that handles theParamType
setting and delegates tosqlInline(BindingSQLContext)
orsqlBind(BindingSQLContext)
respectively.protected void
sqlBind(BindingSQLContext<U> ctx)
Generate the SQL string for a bind variable placeholder.protected void
sqlInline(BindingSQLContext<U> ctx)
Generate the SQL string for inline values.
-
-
-
Method Detail
-
sql
public void sql(BindingSQLContext<U> ctx) throws SQLException
A convenient base implementation that handles theParamType
setting and delegates tosqlInline(BindingSQLContext)
orsqlBind(BindingSQLContext)
respectively.- 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.
-
sqlInline
protected void sqlInline(BindingSQLContext<U> ctx) throws SQLException
Generate the SQL string for inline values.The default implementation generates a string literal representation of the user defined value. Custom implementations may want to override this.
- Throws:
SQLException
-
sqlBind
protected void sqlBind(BindingSQLContext<U> ctx) throws SQLException
Generate the SQL string for a bind variable placeholder.In almost all cases, this can just be a "?" string. In some cases, the placeholder needs to be cast to a vendor specific data type, such as in PostgreSQL, "?::tsvector".
- Throws:
SQLException
-
register
public void register(BindingRegisterContext<U> ctx) throws SQLException
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.
-
get
public void get(BindingGetStatementContext<U> ctx) throws SQLException
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.
-
set
public void set(BindingSetSQLOutputContext<U> ctx) throws SQLException
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
public void get(BindingGetSQLInputContext<U> ctx) throws SQLException
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.
-
-