Interface CustomParameterBinder


public interface CustomParameterBinder
Enables PreparedStatement parameter binding customization via PreparedStatementBinder.
Since:
3.0.0
Author:
Mark Allen
  • 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 a PreparedStatement value given a value and its index when appliesTo(TargetType) is true.

      This function is only invoked when parameter is non-null.

      Parameters:
      statementContext - current SQL context
      preparedStatement - the prepared statement to bind to
      parameterIndex - 1-based parameter index at which to perform the binding
      parameter - the parameter to bind at the specified index
      Returns:
      CustomParameterBinder.BindingResult.handled() if the custom binding was performed, or CustomParameterBinder.BindingResult.fallback() to fall back to default PreparedStatementBinder behavior
      Throws:
      SQLException - if an error occurs during binding
    • appliesTo

      @Nonnull Boolean appliesTo(@Nonnull TargetType targetType)
      Specifies which types this custom binder should handle.

      For example, if this binder should apply when binding MyCustomType, this method could return targetType.matchesClass(MyCustomType.class).

      For parameterized types like List<UUID>, this method could return targetType.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.