All versions: 3.11 | 3.10 | 3.9 | 3.8 | 3.7 | Development versions: 3.12 | Unsupported versions: 3.6 | 3.5 | 3.4 | 3.3 | 3.2 | 2.6

When using a custom type in jOOQ, you need to let jOOQ know about its associated org.jooq.Converter. Ad-hoc usages of such converters has been discussed in the chapter about data type conversion. A more common use-case, however, is to let jOOQ know about custom types at code generation time. Use the following configuration elements to specify, that you'd like to use GregorianCalendar for all database fields that start with DATE_OF_

<database>
  <!-- First, register your custom types here -->
  <customTypes>
    <customType>
      <!-- Specify the fully-qualified class name of your custom type -->
      <name>java.util.GregorianCalendar</name>

      <!-- Associate that custom type with your converter. Note, a
           custom type can only have one converter in jOOQ -->
      <converter>com.example.CalendarConverter</converter>
    </customType>
  </customTypes>

  <!-- Then, associate custom types with database columns -->
  <forcedTypes>
    <forcedType>
      <!-- Specify again he fully-qualified class name of your custom type -->
      <name>java.util.GregorianCalendar</name>

      <!-- Add a Java regular expression matching fully-qualified columns.
           Use the pipe to separate several expressions.
           If provided, both "expressions" and "types" must match. -->
      <expressions>.*\.DATE_OF_.*</expressions>
      
      <!-- Add a Java regular expression matching data types to be forced to
           have this type. If provided, both "expressions" and "types" must match. -->
      <types>.*</types>
    </forcedType>
  </forcedTypes>
</database>

The above configuration will lead to AUTHOR.DATE_OF_BIRTH being generated like this:

public class TAuthor extends TableImpl<TAuthorRecord> {

    // [...]
    public final TableField<TAuthorRecord, GregorianCalendar> DATE_OF_BIRTH =    // [...]
    // [...]

}

This means that the bound type of <T> will be GregorianCalendar, wherever you reference DATE_OF_BIRTH. jOOQ will use your custom converter when binding variables and when fetching data from java.util.ResultSet:

// Get all date of births of authors born after 1980
List<GregorianCalendar> result =
create.selectFrom(AUTHOR)
      .where(AUTHOR.DATE_OF_BIRTH.gt(new GregorianCalendar(1980, 0, 1)))
      .fetch(AUTHOR.DATE_OF_BIRTH);
The jOOQ Logo