RecordMapper types, which
applies to Record#into(Class), Result#into(Class), and
similar calls.
The mapping algorithm is this:
<E> is an array type:
The resulting array is of the nature described in Record#intoArray().
Arrays more specific than Object[] can be specified as well,
e.g. String[]. If conversion to the element type of more
specific arrays fails, a MappingException is thrown, wrapping
conversion exceptions.
Abstract types are instantiated using Java reflection Proxy
mechanisms. The returned proxy will wrap a HashMap containing
properties mapped by getters and setters of the supplied type. Methods (even
JPA-annotated ones) other than standard POJO getters and setters are not
supported. Details can be seen in Reflect#as(Class).
<E> is a TableRecord type (e.g. from a
generated record), then its meta data are used:
Generated TableRecord types reference their corresponding generated
Table types, which provide TableField meta data through
Table#fields(). All target Record#fields() are looked up in
the source table via Table#indexOf(Field) and their values are
mapped. Excess source values and missing target values are ignored.
<E> is a field "value type" and
<R extends Record1<T1>>, i.e. it has exactly one
column:
The configured ConverterProvider is used to look up a
Converter between T1 and E. By default, the
DefaultConverterProvider is used, which can (among other things):
Record types and custom types by delegating to the
Record's attached RecordMapperProviderJSON or JSONB and custom types by delegating
to Jackson or Gson (if found on the classpath)XML and custom types by delegating to JAXB (if found
on the classpath)Converter is found, that one is used to map to
E.
Column
annotations are found on the provided <E>, only those are
used:
<E> contains single-argument instance methods of
any visibility annotated with Column, those methods are
invoked<E> contains no-argument instance methods of any
visibility starting with getXXX or isXXX, annotated
with Column, then matching setXXX() instance
methods of any visibility are invoked<E> contains instance member fields of any
visibility annotated with Column, those members are setColumn#name() must match Field#getName(). All other
annotation attributes are ignored
Column annotations, or jOOQ can't find the
jakarta.persistence API on the classpath, jOOQ will map
Record values by naming convention:
If Field#getName() is MY_field (case-sensitive!), then
this field's value will be set on all of these (regardless of visibility):
MY_field(…)myField(…)setMY_field(…)setMyField(…)MY_fieldmyField
If Field#getName() is MY_field.MY_nested_field
(case-sensitive!), then this field's value will be considered a nested value
MY_nested_field, which is set on a nested POJO that is passed to
all of these (regardless of visibility):
MY_field(…)myField(…)setMY_field(…)setMyField(…)MY_fieldmyField
ConstructorProperties is available, that one is
used
ConstructorProperties annotation is used
to match constructor arguments against POJO members or getters.Record
values onto constructor arguments.Record values onto constructor arguments.
Settings#isMapConstructorParameterNamesInKotlin()
is turned on, parameter names are reflected and used.
Class#getDeclaredConstructors()). This choice is
non-deterministic as neither the JVM nor the JDK guarantee any order of
methods or constructors.Settings#isMapConstructorParameterNames() is turned on, and
parameter names are available through reflection on
Executable#getParameters(), then values are mapped by name, otherwise
by index. (see #4627)
Settings#isMapConstructorParameterNames() is turned
on, and parameter names are available through reflection on
Executable#getParameters(), the first constructor is used
Class#getDeclaredConstructors()). This choice is non-deterministic as
neither the JVM nor the JDK guarantee any order of methods or
constructors.
<E> must provide a default or a "matching"
constructor. Non-public default constructors are made accessible using
Constructor#setAccessible(boolean)null, this will
result in setting the primitive type's default value (zero for numbers, or
false for booleans). Hence, there is no way of distinguishing
null and 0 in that case.
This mapper is returned by the DefaultRecordMapperProvider. You can
override this behaviour by specifying your own custom
RecordMapperProvider in Configuration#recordMapperProvider()
RecordMapper, DefaultRecordMapperProvider, Configuration
| Modifier and Type | Class and Description |
|---|---|
| private abstract class | |
| private class | DefaultRecordMapper.ArrayMapper
Convert a record into an array of a given type. |
| private static record | |
| private class | DefaultRecordMapper.ImmutablePOJOMapper
Convert a record into an "immutable" POJO (final fields, "matching" constructor). |
| private class | DefaultRecordMapper.MutablePOJOMapper
Convert a record into a mutable POJO type jOOQ's understanding of a mutable POJO is a Java type that has a default constructor |
| pack-priv static class | |
| private class | DefaultRecordMapper.ProxyMapper
Convert a record into an hash map proxy of a given type. |
| private class | DefaultRecordMapper.RecordToRecordMapper<E extends AbstractRecord>
Convert a record into another record type. |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final Configuration | configuration
The configuration in whose context this |
| private RecordMapper | delegate
A delegate mapper created from type information in |
| private final Field | fields
The record type. |
| private final String | |
| private transient Map | prefixes
A set of field name prefixes that may defined the behaviour of nested record mappers. |
| private final RecordType | |
| private final Class | type
The target type. |
| Access | Constructor and Description |
|---|---|
| public | DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type)
Create a new |
| public | DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type, Configuration configuration)
Create a new |
| pack-priv | DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type, E instance, Configuration configuration)
|
| Modifier and Type | Method and Description |
|---|---|
| private static <E> E | |
| private List | |
| private static final String | |
| private final void | |
| public final E | map(R
The record to be mapped. This is never null. record)Implements org. |
| private final Map | |
| public String |
| configuration | back to summary |
|---|---|
| private final Configuration configuration The configuration in whose context this This configuration can be used for caching reflection information. | |
| delegate | back to summary |
|---|---|
| private RecordMapper<R, E> delegate A delegate mapper created from type information in | |
| fields | back to summary |
|---|---|
| private final Field<?>[] fields
Deprecated as a consequence of The record type. | |
| namePathSeparator | back to summary |
|---|---|
| private final String namePathSeparator | |
| prefixes | back to summary |
|---|---|
| private transient Map<String, Integer> prefixes A set of field name prefixes that may defined the behaviour of nested record mappers. | |
| rowType | back to summary |
|---|---|
| private final RecordType<R> rowType | |
| type | back to summary |
|---|---|
| private final Class<? extends E> type The target type. | |
| DefaultRecordMapper | back to summary |
|---|---|
| public DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type) Create a new
This constructor uses a new | |
| DefaultRecordMapper | back to summary |
|---|---|
| public DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type, Configuration configuration) Create a new | |
| DefaultRecordMapper | back to summary |
|---|---|
| pack-priv DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type, E instance, Configuration configuration) | |
| attach | back to summary |
|---|---|
| private static <E> E attach(E attachable, Record record) | |
| collectParameterNames | back to summary |
|---|---|
| private List | |
| debug | back to summary |
|---|---|
| private static final String debug(Boolean debug) | |
| init | back to summary |
|---|---|
| private final void init(E instance) | |
| map | back to summary |
|---|---|
| public final E map(R record) Implements org. Doc from org. Map a record into a POJO.
| |
| prefixes | back to summary |
|---|---|
| private final Map | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String |
| AbstractDelegateMapper | back to summary |
|---|---|
| private AbstractDelegateMapper() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
The supplied type is usually Object[], but in some cases, it
may make sense to supply String[], Integer[]
etc.
| Modifier and Type | Field and Description |
|---|---|
| private final E |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final E | map(R
The record to be mapped. This is never null. record)Implements org. |
| instance | back to summary |
|---|---|
| private final E instance | |
| ArrayMapper | back to summary |
|---|---|
| pack-priv ArrayMapper(E instance) | |
| map | back to summary |
|---|---|
| public final E map(R record) Implements org. Doc from org. Map a record into a POJO.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final Constructor | constructor
Record Component accessed by constructor(). |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public E | call()
Implements java. |
| public Constructor | |
| public final boolean | equals(Object
the reference object with which to compare. o)Implements abstract java. |
| public final int | |
| public final String | toString()
Implements abstract java. |
| constructor | back to summary |
|---|---|
| private final Constructor<? extends E> constructor Record Component accessed by constructor(). | |
| ConstructorCall | back to summary |
|---|---|
| private ConstructorCall(Constructor<? extends E> constructor) | |
| call | back to summary |
|---|---|
| public E call() throws Exception Implements java. Doc from java. Computes a result, or throws an exception if unable to do so. | |
| constructor | back to summary |
|---|---|
| public Constructor Record Component getter of constructor. | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of
| |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Constructor | |
| private final List | |
| private final Method[] | |
| private final boolean | |
| private final DefaultRecordMapper. | |
| pack-priv final Class | |
| private final Integer[] | |
| private final List | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv | ImmutablePOJOMapper(Constructor<E> constructor, Class<?>[] parameterTypes, List<String> propertyNames, boolean supportsNesting)
|
| Modifier and Type | Method and Description |
|---|---|
| public final E | map(R
The record to be mapped. This is never null. record)Implements org. |
| private final Object[] | |
| private final Object[] | |
| pack-priv final void | |
| public String | toString()
Overrides org. |
| constructor | back to summary |
|---|---|
| pack-priv final Constructor<E> constructor | |
| members | back to summary |
|---|---|
| private final List<Field>[] members | |
| methods | back to summary |
|---|---|
| private final Method[] methods | |
| nested | back to summary |
|---|---|
| private final boolean nested | |
| nestedMappingInfo | back to summary |
|---|---|
| private final DefaultRecordMapper. | |
| parameterTypes | back to summary |
|---|---|
| pack-priv final Class<?>[] parameterTypes | |
| propertyIndexes | back to summary |
|---|---|
| private final Integer[] propertyIndexes | |
| propertyNames | back to summary |
|---|---|
| private final List<String> propertyNames | |
| useAnnotations | back to summary |
|---|---|
| private final boolean useAnnotations | |
| ImmutablePOJOMapper | back to summary |
|---|---|
| pack-priv ImmutablePOJOMapper(Constructor<E> constructor, Class<?>[] parameterTypes, List<String> propertyNames, boolean supportsNesting) | |
| map | back to summary |
|---|---|
| public final E map(R record) Implements org. Doc from org. Map a record into a POJO.
| |
| mapNested | back to summary |
|---|---|
| private final Object[] mapNested(final R record) | |
| mapNonnested | back to summary |
|---|---|
| private final Object[] mapNonnested(R record) | |
| set | back to summary |
|---|---|
| pack-priv final void set(Record from, int fromIndex, Object[] to, Integer toIndex) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Doc from java. Returns a string representation of the object. | |
jOOQ's understanding of a mutable POJO is a Java type that has a default constructor
| Modifier and Type | Field and Description |
|---|---|
| private final Callable | |
| private final E | |
| private final List | |
| private final List | |
| private final Map | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv final boolean | |
| public final E | map(R
The record to be mapped. This is never null. record)Implements org. |
| private final void | |
| private final void | |
| private final List |
| constructor | back to summary |
|---|---|
| private final Callable<E> constructor | |
| instance | back to summary |
|---|---|
| private final E instance | |
| members | back to summary |
|---|---|
| private final List<Field>[] members | |
| methods | back to summary |
|---|---|
| private final List<Method>[] methods | |
| nestedMappingInfos | back to summary |
|---|---|
| private final Map<String, DefaultRecordMapper. | |
| useAnnotations | back to summary |
|---|---|
| private final boolean useAnnotations | |
| MutablePOJOMapper | back to summary |
|---|---|
| pack-priv MutablePOJOMapper(Callable<E> constructor, E instance) | |
| isMutable | back to summary |
|---|---|
| pack-priv final boolean isMutable() | |
| map | back to summary |
|---|---|
| public final E map(R record) Implements org. Doc from org. Map a record into a POJO.
| |
| map | back to summary |
|---|---|
| private final void map(Record record, Object result, Field member, int index) throws IllegalAccessException | |
| map | back to summary |
|---|---|
| private final void map(Object value, Object result, Field member) throws IllegalAccessException | |
| tryConvertToList | back to summary |
|---|---|
| private final List | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final List | |
| pack-priv final List | |
| pack-priv RecordDelegate | |
| pack-priv AbstractRow |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public String |
| indexLookup | back to summary |
|---|---|
| pack-priv final List<Integer> indexLookup | |
| mappers | back to summary |
|---|---|
| pack-priv final List<RecordMapper<AbstractRecord, Object>> mappers | |
| recordDelegate | back to summary |
|---|---|
| pack-priv RecordDelegate<? extends AbstractRecord> recordDelegate | |
| row | back to summary |
|---|---|
| pack-priv AbstractRow<R extends Record> row | |
| NestedMappingInfo | back to summary |
|---|---|
| pack-priv NestedMappingInfo() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
This is done for types that are not instanciable
| Modifier and Type | Field and Description |
|---|---|
| private final DefaultRecordMapper |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final E | map(R
The record to be mapped. This is never null. record)Implements org. |
| pojomapper | back to summary |
|---|---|
| private final DefaultRecordMapper<R, E>. | |
| ProxyMapper | back to summary |
|---|---|
| pack-priv ProxyMapper() | |
| map | back to summary |
|---|---|
| public final E map(R record) Implements org. Doc from org. Map a record into a POJO.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final E |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final AbstractRecord | map(R
The record to be mapped. This is never null. record)Implements org. |
| instance | back to summary |
|---|---|
| private final E instance | |
| RecordToRecordMapper | back to summary |
|---|---|
| pack-priv RecordToRecordMapper(E instance) | |
| map | back to summary |
|---|---|
| public final AbstractRecord map(R record) Implements org. Doc from org. Map a record into a POJO.
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public final E | map(R
The record to be mapped. This is never null. record)Implements org. |
| ValueTypeMapper | back to summary |
|---|---|
| private ValueTypeMapper() | |
| map | back to summary |
|---|---|
| public final E map(R record) Implements org. Doc from org. Map a record into a POJO.
| |