- 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
SQLDataserialisation 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 voidget(BindingGetSQLInputContext<U> ctx)Get aSQLInput'sOUTvalue.voidget(BindingGetStatementContext<U> ctx)Get aCallableStatement'sOUTvalue.voidregister(BindingRegisterContext<U> ctx)Register aCallableStatement'sOUTparameter.voidset(BindingSetSQLOutputContext<U> ctx)Set aSQLOutput'sINparameter.voidsql(BindingSQLContext<U> ctx)A convenient base implementation that handles theParamTypesetting and delegates tosqlInline(BindingSQLContext)orsqlBind(BindingSQLContext)respectively.protected voidsqlBind(BindingSQLContext<U> ctx)Generate the SQL string for a bind variable placeholder.protected voidsqlInline(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 theParamTypesetting and delegates tosqlInline(BindingSQLContext)orsqlBind(BindingSQLContext)respectively.- Specified by:
sqlin interfaceBinding<T,U>- Parameters:
ctx- The context object containing all argument objects.- Throws:
SQLException- Implementations are allowed to pass on allSQLExceptions to the caller to be wrapped inDataAccessExceptions.
-
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:BindingRegister aCallableStatement'sOUTparameter.- Specified by:
registerin interfaceBinding<T,U>- Parameters:
ctx- The context object containing all argument objects.- Throws:
SQLException- Implementations are allowed to pass on allSQLExceptions to the caller to be wrapped inDataAccessExceptions.
-
get
public void get(BindingGetStatementContext<U> ctx) throws SQLException
Description copied from interface:BindingGet aCallableStatement'sOUTvalue.Implementations are expected to produce a value by calling
BindingGetStatementContext.value(Object), passing the resulting value to the method.- Specified by:
getin interfaceBinding<T,U>- Parameters:
ctx- The context object containing all argument objects.- Throws:
SQLException- Implementations are allowed to pass on allSQLExceptions to the caller to be wrapped inDataAccessExceptions.
-
set
public void set(BindingSetSQLOutputContext<U> ctx) throws SQLException
Description copied from interface:BindingSet aSQLOutput'sINparameter.- Specified by:
setin interfaceBinding<T,U>- Parameters:
ctx- The context object containing all argument objects.- Throws:
SQLException- Implementations are allowed to pass on allSQLExceptions to the caller to be wrapped inDataAccessExceptions.
-
get
public void get(BindingGetSQLInputContext<U> ctx) throws SQLException
Description copied from interface:BindingGet aSQLInput'sOUTvalue.Implementations are expected to produce a value by calling
BindingGetSQLInputContext.value(Object), passing the resulting value to the method.- Specified by:
getin interfaceBinding<T,U>- Parameters:
ctx- The context object containing all argument objects.- Throws:
SQLException- Implementations are allowed to pass on allSQLExceptions to the caller to be wrapped inDataAccessExceptions.
-
-