Available in versions: Dev (3.22) | Latest (3.21) | 3.20 | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

Bind value casting

Supported by ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

Most databases can infer the data type of a bind value from the context in which it is used. Some databases, however, cannot delay the type inference until the statement is executed, and either reject a bind value of unknown type, or assume a possibly inappropriate type. In those cases, jOOQ wraps the bind value in an explicit CAST(? AS datatype) expression to help the database's SQL parser. The paramCastMode setting governs this behaviour. The possible values of org.jooq.conf.ParamCastMode are:

  • DEFAULT (the default): Bind values are cast to their data types only when jOOQ thinks it is needed. The exact behaviour of this mode depends on the dialect, and is subject to change.
  • ALWAYS: Bind values are always cast to their data types.
  • NEVER: Bind values are never cast to their data types. You may still add explicit casts yourself using the CAST() function.

The setting applies both to bind variable placeholders and to inline values.

Example configuration

Settings settings = new Settings()
    .withParamCastMode(ParamCastMode.NEVER); // Defaults to DEFAULT

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo