You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2024/01/22 14:02:09 UTC
(cayenne) 05/06: CAY-2794 Fix Incorrect JavaType for Vertical-Inheritance Attributes
This is an automated email from the ASF dual-hosted git repository.
ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 177bb615488678b0af9faf86fd2dbe2107a5889b
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Wed Feb 15 15:17:12 2023 +0400
CAY-2794 Fix Incorrect JavaType for Vertical-Inheritance Attributes
---
.../translator/select/DescriptorColumnExtractor.java | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/select/DescriptorColumnExtractor.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/select/DescriptorColumnExtractor.java
index 0ecd53fe4..1cb72ff1a 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/select/DescriptorColumnExtractor.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/translator/select/DescriptorColumnExtractor.java
@@ -118,15 +118,22 @@ class DescriptorColumnExtractor extends BaseColumnExtractor implements PropertyV
int count = result.getDbAttributes().size();
for(int i=0; i<count; i++) {
ResultNodeDescriptor resultNodeDescriptor = processTranslationResult(result, i);
+ DbAttribute dbAttribute = result.getDbAttributes().get(i);
if(resultNodeDescriptor != null) {
- resultNodeDescriptor.setJavaType(oa.getType());
- if (result.getDbAttributes().size() >= 2) {
- DbAttribute dbAttribute = result.getDbAttributes().get(i);
+ // 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 {
- addEntityResultField(result.getDbAttributes().get(i));
+ // simple attribute
+ addEntityResultField(dbAttribute);
}
}
}