public class DefaultRecordMapper<R extends Record,E> extends Object implements RecordMapper<R,E>
RecordMapper
types.
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.
Column
annotations are found on the provided <E>
, only those are
used:
<E>
contains public single-argument instance methods
annotated with Column
, those methods are invoked<E>
contains public no-argument instance methods
starting with getXXX
or isXXX
, annotated with
Column
, then matching public setXXX()
instance
methods are invoked<E>
contains public instance member fields 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
javax.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:
MY_field(...)
myField(...)
setMY_field(...)
setMyField(...)
MY_field
myField
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.Class.getDeclaredConstructors()
Class.getDeclaredConstructors()
Abstract types are instanciated 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>
must provide a default or a "matching" constructor.
Non-public default constructors are made accessible using
AccessibleObject.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
Constructor and Description |
---|
DefaultRecordMapper(RecordType<R> rowType,
Class<? extends E> type) |
Modifier and Type | Method and Description |
---|---|
E |
map(R record)
A callback method indicating that the next record has been fetched.
|
public DefaultRecordMapper(RecordType<R> rowType, Class<? extends E> type)
public final E map(R record)
RecordMapper
map
in interface RecordMapper<R extends Record,E>
Copyright © 2014. All Rights Reserved.