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(@NonNull TargetType targetType) Specifies which types this custom binder should handle.bind(@NonNull StatementContext<?> statementContext, @NonNull PreparedStatement preparedStatement, @NonNull Integer parameterIndex, @NonNull Object parameter) Performs custom binding of aPreparedStatementvalue given avalueand itsindexwhenappliesTo(TargetType)istrue.bindNull(@NonNull StatementContext<?> statementContext, @NonNull PreparedStatement preparedStatement, @NonNull Integer parameterIndex, @NonNull TargetType targetType, @NonNull Integer sqlType) Performs custom binding of a null value given itsindexandtargetType.
-
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
-
bindNull
default @NonNull CustomParameterBinder.BindingResult bindNull(@NonNull StatementContext<?> statementContext, @NonNull PreparedStatement preparedStatement, @NonNull Integer parameterIndex, @NonNull TargetType targetType, @NonNull Integer sqlType) throws SQLException Performs custom binding of a null value given itsindexandtargetType.This function is only invoked for
TypedParametervalues that arenull.- Parameters:
statementContext- current SQL contextpreparedStatement- the prepared statement to bind toparameterIndex- 1-based parameter index at which to perform the bindingtargetType- explicit target type fromTypedParametersqlType- JDBC SQL type hint (may beTypes.NULL)- Returns:
CustomParameterBinder.BindingResult.handled()if the custom binding was performed, orCustomParameterBinder.BindingResult.fallback()to fall back to default 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:
trueif this binder should handle the type,falseotherwise.
-