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 classResult 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 aPreparedStatementvalue given avalueand itsindexwhenappliesTo(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 aPreparedStatementvalue given avalueand itsindexwhenappliesTo(TargetType)istrue.This function is only invoked when
parameteris 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 defaultPreparedStatementBinderbehavior- 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:
trueif this binder should handle the type,falseotherwise.
-