Package org.jooq.impl

Class DefaultBinding<T,​U>

  • All Implemented Interfaces:
    java.io.Serializable, Binding<T,​U>

    public class DefaultBinding<T,​U>
    extends java.lang.Object
    implements Binding<T,​U>
    Author:
    Lukas Eder
    See Also:
    Serialized Form
    • Constructor Detail

      • DefaultBinding

        @Deprecated
        public DefaultBinding​(Converter<T,​U> converter)
        Deprecated.
        - 3.11 - [#6631] - Use binding(Converter) instead.
    • Method Detail

      • binding

        public static final <T,​U> Binding<T,​U> binding​(Converter<T,​U> converter)
      • converter

        public Converter<T,​U> converter()
        Description copied from interface: Binding
        A converter that can convert between the database type and the custom type.
        Specified by:
        converter in interface Binding<T,​U>
      • sql

        public void sql​(BindingSQLContext<U> ctx)
                 throws java.sql.SQLException
        Description copied from interface: Binding
        Generate SQL code for the bind variable.

        Implementations should generate SQL code onto BindingSQLContext.render(), given the context's bind variable located at BindingSQLContext.value(). Examples of such SQL code are:

        • "?": Default implementations can simply generate a question mark.

        • "123": Implementations may choose to inline bind variables to influence execution plan generation.

          RenderContext.paramType() contains information whether inlined bind variables are expected in the current context.

        • "CAST(? AS DATE)": Cast a database to a more specific type. This can be useful in databases like Oracle, which map both DATE and TIMESTAMP SQL types to Timestamp.

          RenderContext.castMode() may contain some hints about whether casting is suggested in the current context.

        • "?::json": Vendor-specific bind variables can be supported, e.g. SQLDialect.POSTGRES's JSON data type.

        Implementations must provide consistent behaviour between Binding.sql(BindingSQLContext) and Binding.set(BindingSetStatementContext), i.e. when bind variables are inlined, then they must not be bound to the PreparedStatement in Binding.set(BindingSetStatementContext)

        Specified by:
        sql in interface Binding<T,​U>
        Parameters:
        ctx - The context object containing all argument objects.
        Throws:
        java.sql.SQLException - Implementations are allowed to pass on all SQLExceptions to the caller to be wrapped in DataAccessExceptions.
      • register

        public void register​(BindingRegisterContext<U> ctx)
                      throws java.sql.SQLException
        Description copied from interface: Binding
        Register a CallableStatement's OUT parameter.
        Specified by:
        register in interface Binding<T,​U>
        Parameters:
        ctx - The context object containing all argument objects.
        Throws:
        java.sql.SQLException - Implementations are allowed to pass on all SQLExceptions to the caller to be wrapped in DataAccessExceptions.
      • set

        public void set​(BindingSetStatementContext<U> ctx)
                 throws java.sql.SQLException
        Description copied from interface: Binding
        Set a PreparedStatement's IN parameter.
        Specified by:
        set in interface Binding<T,​U>
        Parameters:
        ctx - The context object containing all argument objects.
        Throws:
        java.sql.SQLException - Implementations are allowed to pass on all SQLExceptions to the caller to be wrapped in DataAccessExceptions.
      • set

        public void set​(BindingSetSQLOutputContext<U> ctx)
                 throws java.sql.SQLException
        Description copied from interface: Binding
        Set a SQLOutput's IN parameter.
        Specified by:
        set in interface Binding<T,​U>
        Parameters:
        ctx - The context object containing all argument objects.
        Throws:
        java.sql.SQLException - Implementations are allowed to pass on all SQLExceptions to the caller to be wrapped in DataAccessExceptions.
      • get

        public void get​(BindingGetResultSetContext<U> ctx)
                 throws java.sql.SQLException
        Description copied from interface: Binding
        Get a ResultSet's OUT value.

        Implementations are expected to produce a value by calling BindingGetResultSetContext.value(Object), passing the resulting value to the method.

        Specified by:
        get in interface Binding<T,​U>
        Parameters:
        ctx - The context object containing all argument objects.
        Throws:
        java.sql.SQLException - Implementations are allowed to pass on all SQLExceptions to the caller to be wrapped in DataAccessExceptions.
      • get

        public void get​(BindingGetStatementContext<U> ctx)
                 throws java.sql.SQLException
        Description copied from interface: Binding
        Get a CallableStatement's OUT value.

        Implementations are expected to produce a value by calling BindingGetStatementContext.value(Object), passing the resulting value to the method.

        Specified by:
        get in interface Binding<T,​U>
        Parameters:
        ctx - The context object containing all argument objects.
        Throws:
        java.sql.SQLException - Implementations are allowed to pass on all SQLExceptions to the caller to be wrapped in DataAccessExceptions.
      • get

        public void get​(BindingGetSQLInputContext<U> ctx)
                 throws java.sql.SQLException
        Description copied from interface: Binding
        Get a SQLInput's OUT value.

        Implementations are expected to produce a value by calling BindingGetSQLInputContext.value(Object), passing the resulting value to the method.

        Specified by:
        get in interface Binding<T,​U>
        Parameters:
        ctx - The context object containing all argument objects.
        Throws:
        java.sql.SQLException - Implementations are allowed to pass on all SQLExceptions to the caller to be wrapped in DataAccessExceptions.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object