This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch STABLE-4.2
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/STABLE-4.2 by this push:
     new ff6239b46 CAY-2794 Fix Incorrect JavaType for Vertical-Inheritance 
Attributes
ff6239b46 is described below

commit ff6239b46004b4e9e69a0002dabda95d4495906e
Author: Nikita Timofeev <[email protected]>
AuthorDate: Wed Feb 15 14:17:12 2023 +0300

    CAY-2794 Fix Incorrect JavaType for Vertical-Inheritance Attributes
---
 .../access/translator/select/DescriptorColumnExtractor.java   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git 
a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DescriptorColumnExtractor.java
 
b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DescriptorColumnExtractor.java
index 494519c75..1cb72ff1a 100644
--- 
a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DescriptorColumnExtractor.java
+++ 
b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DescriptorColumnExtractor.java
@@ -120,12 +120,19 @@ class DescriptorColumnExtractor extends 
BaseColumnExtractor implements PropertyV
             ResultNodeDescriptor resultNodeDescriptor = 
processTranslationResult(result, i);
             DbAttribute dbAttribute = result.getDbAttributes().get(i);
             if(resultNodeDescriptor != null) {
-                resultNodeDescriptor.setJavaType(oa.getType());
-                if (result.getDbAttributes().size() > 1) {
+                // set exact Java type only for the result node directly 
related to the ObjAttribute we processing
+                // for the rest DbAttributes Java type would be calculated 
based on the DB type
+                // see also CAY-2794
+                if(dbAttribute == oa.getDbAttribute()) {
+                    resultNodeDescriptor.setJavaType(oa.getType());
+                }
+                if (count > 1) {
+                    // it was a flattened attribute, so need to keep full path 
info
                     String dataRowKey = result.getAttributePaths().get(i) + 
"." + dbAttribute.getName();
                     resultNodeDescriptor.setDataRowKey(dataRowKey);
                     addEntityResultField(dataRowKey);
                 } else {
+                    // simple attribute
                     addEntityResultField(dbAttribute);
                 }
             }

Reply via email to