Interface CustomParameterBinder
public interface CustomParameterBinder
Enables
PreparedStatement
parameter binding customization via PreparedStatementBinder
.- Since:
- 3.0.0
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Result of a custom parameter binding attempt. -
Method Summary
Modifier and TypeMethodDescriptionappliesTo
(TargetType targetType) Specifies which types this custom binder should handle.bind
(StatementContext<?> statementContext, PreparedStatement preparedStatement, Integer parameterIndex, Object parameter) Performs custom binding of aPreparedStatement
value given avalue
and itsindex
whenappliesTo(TargetType)
istrue
.
-
Method Details
-
bind
@Nonnull CustomParameterBinder.BindingResult bind(@Nonnull StatementContext<?> statementContext, @Nonnull PreparedStatement preparedStatement, @Nonnull Integer parameterIndex, @Nonnull Object parameter) throws SQLException Performs custom binding of aPreparedStatement
value given avalue
and itsindex
whenappliesTo(TargetType)
istrue
.This function is only invoked when
parameter
is non-null.- Parameters:
statementContext
- current SQL contextpreparedStatement
- the prepared statement to bind toparameterIndex
- 1-based parameter index at which to perform the bindingparameter
- the parameter to bind at the specified index- Returns:
CustomParameterBinder.BindingResult.handled()
if the custom binding was performed, orCustomParameterBinder.BindingResult.fallback()
to fall back to defaultPreparedStatementBinder
behavior- Throws:
SQLException
- if an error occurs during binding
-
appliesTo
Specifies which types this custom binder should handle.For example, if this binder should apply when binding
MyCustomType
, this method could returntargetType.matchesClass(MyCustomType.class)
.For parameterized types like
List<UUID>
, this method could returntargetType.matchesParameterizedType(List.class, UUID.class)
.- Parameters:
targetType
- the target type to evaluate - should this custom binder handle it or not?- Returns:
true
if this binder should handle the type,false
otherwise.
-