Module org.jooq
Package org.jooq

Interface Param<T>

All Superinterfaces:
Field<T>, FieldOrConstraint, FieldOrRow, GroupField, Named, OrderField<T>, ParamOrVariable<T>, QueryPart, SelectField<T>, SelectFieldOrAsterisk, Serializable, Typed<T>
All Known Subinterfaces:
QOM.Inline<T>, QOM.Val<T>

public non-sealed interface Param<T> extends ParamOrVariable<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 AttachableQueryPart.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:
  • Method Details

    • getParamName

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

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

      @Deprecated(forRemoval=true, since="3.8") void setValue(T value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      - 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

      @Deprecated(forRemoval=true, since="3.8") void setConverted(Object value) throws DataTypeException
      Deprecated, for removal: This API element is subject to removal in a future version.
      - 3.8.0 - [#4991] In jOOQ 4.0, Param will be made immutable. Modifying Param values is strongly discouraged.
      Sets a converted value, using this Param's underlying DataType, obtained from Typed.getDataType()
      Throws:
      DataTypeException - If value cannot be converted into this parameter's data type.
    • setInline

      @Deprecated(forRemoval=true, since="3.8") void setInline(boolean inline)
      Deprecated, for removal: This API element is subject to removal in a future version.
      - 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

      @NotNull @NotNull ParamType getParamType()
      The parameter type.
    • getParamMode

      @NotNull @NotNull ParamMode getParamMode()
      The parameter mode.
    • $value

      @Experimental T $value()
      Experimental query object model accessor method, see also QOM. Subject to change in future jOOQ versions, use at your own risk.
    • $value

      @Experimental @NotNull @NotNull Param<T> $value(T value)
      Experimental query object model accessor method, see also QOM. Subject to change in future jOOQ versions, use at your own risk.