parent
9925c0bac8
commit
8cf2bb4702
@ -86,6 +86,8 @@ public class Settings
|
||||
protected Boolean returnRecordToPojo = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean mapJPAAnnotations = true;
|
||||
@XmlElement(defaultValue = "false")
|
||||
protected Boolean mapConstructorParameterNames = false;
|
||||
@XmlElement(defaultValue = "0")
|
||||
protected Integer queryTimeout = 0;
|
||||
@XmlElement(defaultValue = "0")
|
||||
@ -693,6 +695,30 @@ public class Settings
|
||||
this.mapJPAAnnotations = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether constructor parameter names obtained via reflection in Java 8+ should be considered by the DefaultRecordMapper. This flag has no effect in Java 6 or 7.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isMapConstructorParameterNames() {
|
||||
return mapConstructorParameterNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the mapConstructorParameterNames property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setMapConstructorParameterNames(Boolean value) {
|
||||
this.mapConstructorParameterNames = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default JDBC queryTimeout property that should be applied to all
|
||||
* jOOQ queries, for which no specific queryTimeout was specified.
|
||||
@ -1003,6 +1029,11 @@ public class Settings
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withMapConstructorParameterNames(Boolean value) {
|
||||
setMapConstructorParameterNames(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withQueryTimeout(Integer value) {
|
||||
setQueryTimeout(value);
|
||||
return this;
|
||||
|
||||
@ -349,15 +349,19 @@ public class DefaultRecordMapper<R extends Record, E> implements RecordMapper<R,
|
||||
|
||||
|
||||
// [#4627] use parameter names from byte code if available
|
||||
Parameter[] parameters = constructor.getParameters();
|
||||
if (parameters != null && parameters.length > 0)
|
||||
delegate = new ImmutablePOJOMapperWithParameterNames(
|
||||
constructor,
|
||||
Arrays.stream(parameters).map(Parameter::getName).collect(Collectors.toList())
|
||||
);
|
||||
else
|
||||
if (Boolean.TRUE.equals(configuration.settings().isMapConstructorParameterNames())) {
|
||||
Parameter[] parameters = constructor.getParameters();
|
||||
|
||||
delegate = new ImmutablePOJOMapper(constructor, parameterTypes);
|
||||
if (parameters != null && parameters.length > 0)
|
||||
delegate = new ImmutablePOJOMapperWithParameterNames(
|
||||
constructor,
|
||||
Arrays.stream(parameters).map(Parameter::getName).collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (delegate == null)
|
||||
delegate = new ImmutablePOJOMapper(constructor, parameterTypes);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -140,6 +140,10 @@ IDENTITY values, and if <returnAllOnUpdatableRecord/> is active, also other valu
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether JPA annotations should be considered by the DefaultRecordMapper.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="mapConstructorParameterNames" type="boolean" minOccurs="0" maxOccurs="1" default="false">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether constructor parameter names obtained via reflection in Java 8+ should be considered by the DefaultRecordMapper. This flag has no effect in Java 6 or 7.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="queryTimeout" type="int" minOccurs="0" maxOccurs="1" default="0">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The default JDBC queryTimeout property that should be applied to all
|
||||
jOOQ queries, for which no specific queryTimeout was specified.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user