Module org.jooq
Package org.jooq.impl

Class JPAConverter<T,U>

All Implemented Interfaces:
Serializable, ContextConverter<T,U>, Converter<T,U>

public final class JPAConverter<T,U> extends AbstractContextConverter<T,U>
A converter that delegates data type conversions to a JPA AttributeConverter.

This is particularly useful when generating code from a JPADatabase, which reverse engineers JPA annotated entities, in case of which, by default, the AttributeConverter annotations are discovered automatically and the user-defined type is applied also in the jOOQ meta model.

Author:
Lukas Eder
See Also:
  • Constructor Details

    • JPAConverter

      public JPAConverter(Class<? extends jakarta.persistence.AttributeConverter<U,T>> klass)
  • Method Details

    • from

      public final U from(T t, ConverterContext scope)
      Description copied from interface: ContextConverter
      Read and convert a database object to a user object.

      Implementations that don't support this conversion are expected to override Converter.fromSupported() to indicate lack of support.

      Parameters:
      t - The database object.
      scope - The context of this conversion.
      Returns:
      The user object.
    • to

      public final T to(U u, ConverterContext scope)
      Description copied from interface: ContextConverter
      Convert and write a user object to a database object.

      Implementations that don't support this conversion are expected to override Converter.toSupported() to indicate lack of support.

      Parameters:
      u - The user object.
      scope - The context of this conversion.
      Returns:
      The database object.