Top Description Inners Fields Constructors Methods
org.jooq.impl

public Class DefaultRecordMapper<R extends org.jooq.Record, E>

extends Object
implements RecordMapper<R extends Record, E>
Class Inheritance
All Implemented Interfaces
org.jooq.RecordMapper, java.util.function.Function
Annotations
@SuppressWarnings:unchecked
Static Imports
java.lang.Boolean.FALSE, .Boolean.TRUE, java.util.Collections.emptyList, org.jooq.impl.DSL.field, .DSL.name, .Tools.EMPTY_FIELD, .Tools.configuration, .Tools.getAnnotatedGetter, .Tools.getAnnotatedMembers, .Tools.getAnnotatedSetters, .Tools.getMatchingGetter, .Tools.getMatchingMembers, .Tools.getMatchingSetters, .Tools.getPropertyName, .Tools.hasColumnAnnotations, .Tools.map, .Tools.newRecord, .Tools.recordType, .Tools.row0, org.jooq.tools.reflect.Reflect.accessible

This is the default implementation for RecordMapper types, which applies to Record#into(Class), Result#into(Class), and similar calls.

The mapping algorithm is this:

If <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.

If the supplied type is an interface or an abstract class

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).

If <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.

If <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):

If such a Converter is found, that one is used to map to E.

If a default constructor is available and any JPA Column annotations are found on the provided <E>, only those are used:

Additional rules:

If a default constructor is available and if there are no JPA 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):

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):

If no default constructor is available, but at least one constructor annotated with ConstructorProperties is available, that one is used

If Kotlin is available and the argument class has Kotlin reflection meta data available, and Settings#isMapConstructorParameterNamesInKotlin() is turned on, parameter names are reflected and used.

If no default constructor is available, but at least one "matching" constructor is available, that one is used

If no default constructor is available, no "matching" constructor is available, but Settings#isMapConstructorParameterNames() is turned on, and parameter names are available through reflection on Executable#getParameters(), the first constructor is used

Other restrictions

This mapper is returned by the DefaultRecordMapperProvider. You can override this behaviour by specifying your own custom RecordMapperProvider in Configuration#recordMapperProvider()

Author
Lukas Eder
See Also
RecordMapper, DefaultRecordMapperProvider, Configuration

Nested and Inner Type Summary

Modifier and TypeClass 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

Field Summary

Modifier and TypeField and Description
private final Configuration
configuration

The configuration in whose context this RecordMapper operates.

private RecordMapper<R, E>
delegate

A delegate mapper created from type information in type.

private final Field<?>[]
fields

The record type.

private final String
private transient Map<String, Integer>
prefixes

A set of field name prefixes that may defined the behaviour of nested record mappers.

private final RecordType<R>
private final Class<? extends E>
type

The target type.

Constructor Summary

AccessConstructor and Description
public
DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type)

Create a new DefaultRecordMapper.

public
DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type, Configuration configuration)

Create a new DefaultRecordMapper.

pack-priv
DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type, E instance, Configuration configuration)

Method Summary

Modifier and TypeMethod and Description
private static <E> E
attach(E attachable, Record record)

private List<String>
private static final String
debug(Boolean debug)

private final void
init(E instance)

public final E
map(R
The record to be mapped. This is never null.
record
)

Implements org.jooq.RecordMapper.map.

Map a record into a POJO.
private final Map<String, Integer>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

configurationback to summary
private final Configuration configuration

The configuration in whose context this RecordMapper operates.

This configuration can be used for caching reflection information.

delegateback to summary
private RecordMapper<R, E> delegate

A delegate mapper created from type information in type.

fieldsback to summary
private final Field<?>[] fields

Deprecated

as a consequence of Field being deprecated. See corresponding docs for further information.

The record type.

namePathSeparatorback to summary
private final String namePathSeparator
prefixesback to summary
private transient Map<String, Integer> prefixes

A set of field name prefixes that may defined the behaviour of nested record mappers.

rowTypeback to summary
private final RecordType<R> rowType
typeback to summary
private final Class<? extends E> type

The target type.

Constructor Detail

DefaultRecordMapperback to summary
public DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type)

Create a new DefaultRecordMapper.

This constructor uses a new DefaultConfiguration internally to cache various reflection methods. For better performance, use DefaultRecordMapper(RecordType, Class, Configuration) instead.

DefaultRecordMapperback to summary
public DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type, Configuration configuration)

Create a new DefaultRecordMapper.

DefaultRecordMapperback to summary
pack-priv DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type, E instance, Configuration configuration)

Method Detail

attachback to summary
private static <E> E attach(E attachable, Record record)
collectParameterNamesback to summary
private List<String> collectParameterNames(Parameter[] parameters)
debugback to summary
private static final String debug(Boolean debug)
initback to summary
private final void init(E instance)
mapback to summary
public final E map(R record)

Implements org.jooq.RecordMapper.map.

Doc from org.jooq.RecordMapper.map.

Map a record into a POJO.

Parameters
record:R

The record to be mapped. This is never null.

Returns:E

The mapped value, which may be null in some implementations.

Annotations
@Override
prefixesback to summary
private final Map<String, Integer> prefixes()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.jooq.impl back to summary

private abstract Class DefaultRecordMapper.AbstractDelegateMapper<R0 extends org.jooq.Record, E0>

extends Object
implements RecordMapper<R0 extends Record, E0>
Class Inheritance
All Implemented Interfaces
org.jooq.RecordMapper, java.util.function.Function
Known Direct Subclasses
org.jooq.impl.DefaultRecordMapper.ArrayMapper, org.jooq.impl.DefaultRecordMapper.ValueTypeMapper, org.jooq.impl.DefaultRecordMapper.ProxyMapper, org.jooq.impl.DefaultRecordMapper.RecordToRecordMapper, org.jooq.impl.DefaultRecordMapper.MutablePOJOMapper, org.jooq.impl.DefaultRecordMapper.ImmutablePOJOMapper

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Constructor Detail

AbstractDelegateMapperback to summary
private AbstractDelegateMapper()

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.jooq.impl back to summary

private Class DefaultRecordMapper.ArrayMapper

extends DefaultRecordMapper<R extends Record, E>.AbstractDelegateMapper<R extends Record, E>
Class Inheritance

Convert a record into an array of a given type.

The supplied type is usually Object[], but in some cases, it may make sense to supply String[], Integer[] etc.

Field Summary

Modifier and TypeField and Description
private final E

Constructor Summary

AccessConstructor and Description
pack-priv
ArrayMapper(E instance)

Method Summary

Modifier and TypeMethod and Description
public final E
map(R
The record to be mapped. This is never null.
record
)

Implements org.jooq.RecordMapper.map.

Map a record into a POJO.
Inherited from org.jooq.impl.DefaultRecordMapper.AbstractDelegateMapper:
toString

Field Detail

instanceback to summary
private final E instance

Constructor Detail

ArrayMapperback to summary
pack-priv ArrayMapper(E instance)

Method Detail

mapback to summary
public final E map(R record)

Implements org.jooq.RecordMapper.map.

Doc from org.jooq.RecordMapper.map.

Map a record into a POJO.

Parameters
record:R

The record to be mapped. This is never null.

Returns:E

The mapped value, which may be null in some implementations.

Annotations
@Override
org.jooq.impl back to summary

private final Record DefaultRecordMapper.ConstructorCall<E>

extends Record
implements Callable<E>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Callable
Record Components
constructor:Constructor<? extends E> 

Field Summary

Modifier and TypeField and Description
private final Constructor<? extends E>
constructor

Record Component accessed by constructor().

Constructor Summary

AccessConstructor and Description
private
ConstructorCall(Constructor<? extends E> constructor)

Method Summary

Modifier and TypeMethod and Description
public E
call()

Implements java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.
public Constructor<? extends E>
constructor()

Record Component getter of constructor.

public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.
public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.
public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

constructorback to summary
private final Constructor<? extends E> constructor

Record Component accessed by constructor().

Constructor Detail

ConstructorCallback to summary
private ConstructorCall(Constructor<? extends E> constructor)

Method Detail

callback to summary
public E call() throws Exception

Implements java.util.concurrent.Callable.call.

Doc from java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

Returns:E

computed result

Annotations
@Override
Exceptions
Exception:
if unable to compute a result
constructorback to summary
public Constructor<? extends E> constructor()

Record Component getter of constructor.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

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.

Returns:String

a string representation of the object.

org.jooq.impl back to summary

private Class DefaultRecordMapper.ImmutablePOJOMapper

extends DefaultRecordMapper<R extends Record, E>.AbstractDelegateMapper<R extends Record, E>
Class Inheritance

Convert a record into an "immutable" POJO (final fields, "matching" constructor).

Field Summary

Modifier and TypeField and Description
pack-priv final Constructor<E>
private final List<Field>[]
private final Method[]
private final boolean
private final DefaultRecordMapper.NestedMappingInfo[]
pack-priv final Class<?>[]
private final Integer[]
private final List<String>
private final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
ImmutablePOJOMapper(Constructor<E> constructor, Class<?>[] parameterTypes, List<String> propertyNames, boolean supportsNesting)

Method Summary

Modifier and TypeMethod and Description
public final E
map(R
The record to be mapped. This is never null.
record
)

Implements org.jooq.RecordMapper.map.

Map a record into a POJO.
private final Object[]
mapNested(final R record)

private final Object[]
mapNonnested(R record)

pack-priv final void
set(Record from, int fromIndex, Object[] to, Integer toIndex)

public String
toString()

Overrides org.jooq.impl.DefaultRecordMapper.AbstractDelegateMapper.toString.

Returns a string representation of the object.

Field Detail

constructorback to summary
pack-priv final Constructor<E> constructor
membersback to summary
private final List<Field>[] members
methodsback to summary
private final Method[] methods
nestedback to summary
private final boolean nested
nestedMappingInfoback to summary
private final DefaultRecordMapper.NestedMappingInfo[] nestedMappingInfo
parameterTypesback to summary
pack-priv final Class<?>[] parameterTypes
propertyIndexesback to summary
private final Integer[] propertyIndexes
propertyNamesback to summary
private final List<String> propertyNames
useAnnotationsback to summary
private final boolean useAnnotations

Constructor Detail

ImmutablePOJOMapperback to summary
pack-priv ImmutablePOJOMapper(Constructor<E> constructor, Class<?>[] parameterTypes, List<String> propertyNames, boolean supportsNesting)

Method Detail

mapback to summary
public final E map(R record)

Implements org.jooq.RecordMapper.map.

Doc from org.jooq.RecordMapper.map.

Map a record into a POJO.

Parameters
record:R

The record to be mapped. This is never null.

Returns:E

The mapped value, which may be null in some implementations.

Annotations
@Override
mapNestedback to summary
private final Object[] mapNested(final R record)
mapNonnestedback to summary
private final Object[] mapNonnested(R record)
setback to summary
pack-priv final void set(Record from, int fromIndex, Object[] to, Integer toIndex)
toStringback to summary
public String toString()

Overrides org.jooq.impl.DefaultRecordMapper.AbstractDelegateMapper.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.jooq.impl back to summary

private Class DefaultRecordMapper.MutablePOJOMapper

extends DefaultRecordMapper<R extends Record, E>.AbstractDelegateMapper<R extends Record, E>
Class Inheritance

Convert a record into a mutable POJO type

jOOQ's understanding of a mutable POJO is a Java type that has a default constructor

Field Summary

Modifier and TypeField and Description
private final Callable<E>
private final E
private final List<Field>[]
private final List<Method>[]
private final Map<String, DefaultRecordMapper.NestedMappingInfo>
private final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
MutablePOJOMapper(Callable<E> constructor, E instance)

Method Summary

Modifier and TypeMethod and Description
pack-priv final boolean
public final E
map(R
The record to be mapped. This is never null.
record
)

Implements org.jooq.RecordMapper.map.

Map a record into a POJO.
private final void
map(Record record, Object result, Field member, int index)

private final void
map(Object value, Object result, Field member)

private final List<?>
tryConvertToList(Object value, Class<?> mType, Type genericType)

Inherited from org.jooq.impl.DefaultRecordMapper.AbstractDelegateMapper:
toString

Field Detail

constructorback to summary
private final Callable<E> constructor
instanceback to summary
private final E instance
membersback to summary
private final List<Field>[] members
methodsback to summary
private final List<Method>[] methods
nestedMappingInfosback to summary
private final Map<String, DefaultRecordMapper.NestedMappingInfo> nestedMappingInfos
useAnnotationsback to summary
private final boolean useAnnotations

Constructor Detail

MutablePOJOMapperback to summary
pack-priv MutablePOJOMapper(Callable<E> constructor, E instance)

Method Detail

isMutableback to summary
pack-priv final boolean isMutable()
mapback to summary
public final E map(R record)

Implements org.jooq.RecordMapper.map.

Doc from org.jooq.RecordMapper.map.

Map a record into a POJO.

Parameters
record:R

The record to be mapped. This is never null.

Returns:E

The mapped value, which may be null in some implementations.

Annotations
@Override
mapback to summary
private final void map(Record record, Object result, Field member, int index) throws IllegalAccessException
mapback to summary
private final void map(Object value, Object result, Field member) throws IllegalAccessException
tryConvertToListback to summary
private final List<?> tryConvertToList(Object value, Class<?> mType, Type genericType)
org.jooq.impl back to summary

pack-priv Class DefaultRecordMapper.NestedMappingInfo

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final List<Integer>
pack-priv final List<RecordMapper<AbstractRecord, Object>>
pack-priv RecordDelegate<? extends AbstractRecord>
pack-priv AbstractRow<R extends Record>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

indexLookupback to summary
pack-priv final List<Integer> indexLookup
mappersback to summary
pack-priv final List<RecordMapper<AbstractRecord, Object>> mappers
recordDelegateback to summary
pack-priv RecordDelegate<? extends AbstractRecord> recordDelegate
rowback to summary
pack-priv AbstractRow<R extends Record> row

Constructor Detail

NestedMappingInfoback to summary
pack-priv NestedMappingInfo()

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.jooq.impl back to summary

private Class DefaultRecordMapper.ProxyMapper

extends DefaultRecordMapper<R extends Record, E>.AbstractDelegateMapper<R extends Record, E>
Class Inheritance

Convert a record into an hash map proxy of a given type.

This is done for types that are not instanciable

Field Summary

Modifier and TypeField and Description
private final DefaultRecordMapper<R, E>.MutablePOJOMapper

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final E
map(R
The record to be mapped. This is never null.
record
)

Implements org.jooq.RecordMapper.map.

Map a record into a POJO.
Inherited from org.jooq.impl.DefaultRecordMapper.AbstractDelegateMapper:
toString

Field Detail

pojomapperback to summary
private final DefaultRecordMapper<R, E>.MutablePOJOMapper pojomapper

Constructor Detail

ProxyMapperback to summary
pack-priv ProxyMapper()

Method Detail

mapback to summary
public final E map(R record)

Implements org.jooq.RecordMapper.map.

Doc from org.jooq.RecordMapper.map.

Map a record into a POJO.

Parameters
record:R

The record to be mapped. This is never null.

Returns:E

The mapped value, which may be null in some implementations.

Annotations
@Override
org.jooq.impl back to summary

private Class DefaultRecordMapper.RecordToRecordMapper<E extends org.jooq.impl.AbstractRecord>

extends DefaultRecordMapper<R extends Record, E>.AbstractDelegateMapper<R extends Record, AbstractRecord>
Class Inheritance

Convert a record into another record type.

Field Summary

Modifier and TypeField and Description
private final E

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final AbstractRecord
map(R
The record to be mapped. This is never null.
record
)

Implements org.jooq.RecordMapper.map.

Map a record into a POJO.
Inherited from org.jooq.impl.DefaultRecordMapper.AbstractDelegateMapper:
toString

Field Detail

instanceback to summary
private final E instance

Constructor Detail

RecordToRecordMapperback to summary
pack-priv RecordToRecordMapper(E instance)

Method Detail

mapback to summary
public final AbstractRecord map(R record)

Implements org.jooq.RecordMapper.map.

Doc from org.jooq.RecordMapper.map.

Map a record into a POJO.

Parameters
record:R

The record to be mapped. This is never null.

Returns:AbstractRecord

The mapped value, which may be null in some implementations.

Annotations
@Override
org.jooq.impl back to summary

private Class DefaultRecordMapper.ValueTypeMapper

extends DefaultRecordMapper<R extends Record, E>.AbstractDelegateMapper<R extends Record, E>
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public final E
map(R
The record to be mapped. This is never null.
record
)

Implements org.jooq.RecordMapper.map.

Map a record into a POJO.
Inherited from org.jooq.impl.DefaultRecordMapper.AbstractDelegateMapper:
toString

Constructor Detail

ValueTypeMapperback to summary
private ValueTypeMapper()

Method Detail

mapback to summary
public final E map(R record)

Implements org.jooq.RecordMapper.map.

Doc from org.jooq.RecordMapper.map.

Map a record into a POJO.

Parameters
record:R

The record to be mapped. This is never null.

Returns:E

The mapped value, which may be null in some implementations.

Annotations
@Override