Interface SqlArrayType<T>

Type Parameters:
T - the array element type

public interface SqlArrayType<T>
Strategy for converting elements of array-like arguments into SQL array elements.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an equivalent value in a type supported by the JDBC vendor.
    default Class<?>
    Returns the element class that is used to create the backing array.
    Returns the vendor-specific SQL type name String for the element type T.
    static <T> SqlArrayType<T>
    of(String typeName, Function<T,?> conversion)
    Create a SqlArrayType from the given type and convert function.
  • Method Details

    • getTypeName

      String getTypeName()
      Returns the vendor-specific SQL type name String for the element type T. This value will be passed to Connection.createArrayOf(String, Object[]) to create SQL arrays.
      Returns:
      the type name
    • convertArrayElement

      Object convertArrayElement(T element)
      Returns an equivalent value in a type supported by the JDBC vendor. If element type T is already supported by the JDBC vendor, this method may return element without modification.
      Parameters:
      element - the element to convert
      Returns:
      the converted element
    • getArrayElementClass

      default Class<?> getArrayElementClass()
      Returns the element class that is used to create the backing array. By default, Object is used and the backing array is an Object[] array. Can be overridden if a more specific type is needed.
      Returns:
      A Class instance which is used with Array.newInstance(Class, int).
    • of

      static <T> SqlArrayType<T> of(String typeName, Function<T,?> conversion)
      Create a SqlArrayType from the given type and convert function.
      Parameters:
      typeName - the vendor sql type to use
      conversion - convert the array element to the jdbc representation
      Returns:
      the created array type