From 5972144ff44f248c3563cd8e28d22095b9083bfb Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 16 Apr 2021 16:22:26 +0200 Subject: [PATCH] [jOOQ/jOOQ#11778] DefaultRecordMapper should reflect on Class.getRecordComponents() --- .../src/main/java/org/jooq/conf/Settings.java | 42 +++++++++++++++++++ .../org/jooq/impl/DefaultRecordMapper.java | 20 +++++++++ .../resources/xsd/jooq-runtime-3.15.0.xsd | 4 ++ pom.xml | 1 - 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java index 67ca2453ed..33aa2475fe 100644 --- a/jOOQ/src/main/java/org/jooq/conf/Settings.java +++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java @@ -199,6 +199,8 @@ public class Settings @XmlElement(defaultValue = "true") protected Boolean mapJPAAnnotations = true; @XmlElement(defaultValue = "true") + protected Boolean mapRecordComponentParameterNames = true; + @XmlElement(defaultValue = "true") protected Boolean mapConstructorPropertiesParameterNames = true; @XmlElement(defaultValue = "false") protected Boolean mapConstructorParameterNames = false; @@ -1832,6 +1834,30 @@ public class Settings this.mapJPAAnnotations = value; } + /** + * Whether constructor parameter names obtained from the {@link java.lang.Record} component names should be considered by the DefaultRecordMapper. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isMapRecordComponentParameterNames() { + return mapRecordComponentParameterNames; + } + + /** + * Sets the value of the mapRecordComponentParameterNames property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setMapRecordComponentParameterNames(Boolean value) { + this.mapRecordComponentParameterNames = value; + } + /** * Whether constructor parameter names obtained from the {@link java.beans.ConstructorProperties} annotation should be considered by the DefaultRecordMapper. * @@ -3229,6 +3255,11 @@ public class Settings return this; } + public Settings withMapRecordComponentParameterNames(Boolean value) { + setMapRecordComponentParameterNames(value); + return this; + } + public Settings withMapConstructorPropertiesParameterNames(Boolean value) { setMapConstructorPropertiesParameterNames(value); return this; @@ -3679,6 +3710,7 @@ public class Settings builder.append("returnAllOnUpdatableRecord", returnAllOnUpdatableRecord); builder.append("returnRecordToPojo", returnRecordToPojo); builder.append("mapJPAAnnotations", mapJPAAnnotations); + builder.append("mapRecordComponentParameterNames", mapRecordComponentParameterNames); builder.append("mapConstructorPropertiesParameterNames", mapConstructorPropertiesParameterNames); builder.append("mapConstructorParameterNames", mapConstructorParameterNames); builder.append("mapConstructorParameterNamesInKotlin", mapConstructorParameterNamesInKotlin); @@ -4348,6 +4380,15 @@ public class Settings return false; } } + if (mapRecordComponentParameterNames == null) { + if (other.mapRecordComponentParameterNames!= null) { + return false; + } + } else { + if (!mapRecordComponentParameterNames.equals(other.mapRecordComponentParameterNames)) { + return false; + } + } if (mapConstructorPropertiesParameterNames == null) { if (other.mapConstructorPropertiesParameterNames!= null) { return false; @@ -4827,6 +4868,7 @@ public class Settings result = ((prime*result)+((returnAllOnUpdatableRecord == null)? 0 :returnAllOnUpdatableRecord.hashCode())); result = ((prime*result)+((returnRecordToPojo == null)? 0 :returnRecordToPojo.hashCode())); result = ((prime*result)+((mapJPAAnnotations == null)? 0 :mapJPAAnnotations.hashCode())); + result = ((prime*result)+((mapRecordComponentParameterNames == null)? 0 :mapRecordComponentParameterNames.hashCode())); result = ((prime*result)+((mapConstructorPropertiesParameterNames == null)? 0 :mapConstructorPropertiesParameterNames.hashCode())); result = ((prime*result)+((mapConstructorParameterNames == null)? 0 :mapConstructorParameterNames.hashCode())); result = ((prime*result)+((mapConstructorParameterNamesInKotlin == null)? 0 :mapConstructorParameterNamesInKotlin.hashCode())); diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultRecordMapper.java b/jOOQ/src/main/java/org/jooq/impl/DefaultRecordMapper.java index a8e4f1036a..296385174a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultRecordMapper.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultRecordMapper.java @@ -67,6 +67,7 @@ import java.lang.reflect.Modifier; import java.lang.reflect.Parameter; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Proxy; +// ... import java.lang.reflect.Type; import java.sql.Timestamp; import java.util.ArrayList; @@ -420,6 +421,25 @@ public class DefaultRecordMapper implements RecordMapper is active, also other valu + + + + diff --git a/pom.xml b/pom.xml index 4f29b9b33a..0d475f2657 100644 --- a/pom.xml +++ b/pom.xml @@ -650,7 +650,6 @@ UTF-8 - com.google.inject