Module org.jooq
Package org.jooq

Interface Param<T>

  • All Superinterfaces:
    Field<T>, FieldOrConstraint, FieldOrRow, GroupField, Named, OrderField<T>, QueryPart, SelectField<T>, SelectFieldOrAsterisk, Serializable, Typed<T>

    public interface Param<T>
    extends Field<T>
    A named parameter and/or bind value.

    A lot of jOOQ API accepts user input values, such as for example when creating a Condition using Field.eq(Object), where a column expression is being compared with a value.

    Behind the scenes, jOOQ wraps the value in a bind value expression using DSL.val(Object). The generated SQL of such an expression depends on things like Settings.getStatementType() or ParamType being passed to configurations or Query.getSQL(ParamType) calls, etc. By default, a parameter marker ? is generated.

    Users can create parameters explicitly using DSL API, which is useful in a few cases where the value cannot be passed to jOOQ directly, e.g.

    • When the value is at the left hand side of an operator
    • When Field references and Param values are mixed

    Example:

     // Assuming import static org.jooq.impl.DSL.*;
    
     // The bind value is the first operand of an expression, in case of which it
     // needs to be wrapped in a Param explicitly
     using(configuration)
        .select()
        .from(RENTALS)
        .where(val(LocalDateTime.now()).between(RENTALS.RENTAL_DATE).and(RENTALS.DUE_DATE))
        .fetch();
    
     // The bind value is mixed with other types of Field expressions in a statement
     using(configuration)
        .insertInto(ACTOR)
        .columns(ACTOR.FIRST_NAME, ACTOR.LAST_NAME, ACTOR.LAST_UPDATE)
        .values(val("John"), val("Doe"), currentTimestamp())
        .execute();
     

    Instances can be created using DSL.param(String, Object), DSL.val(Object), DSL.inline(Object) and respective overloads.

    Author:
    Lukas Eder
    See Also:
    DSL.param(String, Object)
    • Method Detail

      • getName

        String getName()
        The name of the field.

        The name is any of these:

        • The formal name of the field, if it is a physical table/view field
        • The alias of an aliased field
        • A generated / unspecified value for any other expression
        • The name of a parameter if it is a named Param

        The Param's value for getName() coincides with getParamName()
        Specified by:
        getName in interface Field<T>
        Specified by:
        getName in interface Named
      • getParamName

        String getParamName()
        The parameter name. This name is useful for two things:
      • getValue

        T getValue()
        Get the parameter's underlying value. This returns null if no value has been set yet.
      • setValue

        @Deprecated
        void setValue​(T value)
        Deprecated.
        - 3.8.0 - [#4991] In jOOQ 4.0, Param will be made immutable. Modifying Param values is strongly discouraged.
        Set the parameter's underlying value. This is the same as setConverted(Object), but ensures generic type-safety.
        See Also:
        setConverted(Object)
      • setInline

        @Deprecated
        void setInline​(boolean inline)
        Deprecated.
        - 3.8.0 - [#4991] In jOOQ 4.0, Param will be made immutable. Modifying Param values is strongly discouraged.
        A flag on the bind value to force it to be inlined in rendered SQL
      • isInline

        boolean isInline()
        A flag on the bind value to force it to be inlined in rendered SQL
      • getParamType

        ParamType getParamType()
        The parameter type.
      • getParamMode

        ParamMode getParamMode()
        The parameter mode.