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 2019/03/01 07:42:01 UTC
[cayenne] branch STABLE-4.1 updated: CAY-2544 Possible name clash
of ivar and property name in generated class
This is an automated email from the ASF dual-hosted git repository.
ntimofeev pushed a commit to branch STABLE-4.1
in repository https://gitbox.apache.org/repos/asf/cayenne.git
The following commit(s) were added to refs/heads/STABLE-4.1 by this push:
new beb27b2 CAY-2544 Possible name clash of ivar and property name in generated class
beb27b2 is described below
commit beb27b2ef3d20b81803229dce0ba6d75c0cb0e56
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Fri Mar 1 10:41:58 2019 +0300
CAY-2544 Possible name clash of ivar and property name in generated class
---
RELEASE-NOTES.txt | 1 +
cayenne-cgen/src/main/resources/templates/v4_1/singleclass.vm | 8 ++++++--
cayenne-cgen/src/main/resources/templates/v4_1/superclass.vm | 8 ++++++--
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index b37e65d..8fc447c 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -62,6 +62,7 @@ CAY-2531 Importing same schema after Import Revert clears all entities in datama
CAY-2533 Modeler: Exception on validating ObjRelationship without db path
CAY-2535 Imposible to import stored proceedure apart from db tables
CAY-2537 Generate DB Schema: Schema Generation Complete popup window is hidden
+CAY-2544 Possible name clash of ivar and property name in generated class
CAY-2547 CayenneDataObject serialization issue
----------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v4_1/singleclass.vm b/cayenne-cgen/src/main/resources/templates/v4_1/singleclass.vm
index 0f4d3e7..67fc0f7 100644
--- a/cayenne-cgen/src/main/resources/templates/v4_1/singleclass.vm
+++ b/cayenne-cgen/src/main/resources/templates/v4_1/singleclass.vm
@@ -90,8 +90,12 @@ public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName}
## Create Properties ##
#######################
#foreach( $attr in ${object.DeclaredAttributes} )
-#set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)")
- public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
+ #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
+ #set ( $propName = $stringUtils.capitalizedAsConstant($attr.Name) )
+ #if ( $propName.equals($attr.name) )
+ #set ( $propName = $propName + "_")
+ #end
+ public static final Property<$type> $propName = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
#end
#foreach( $rel in ${object.DeclaredRelationships} )
#if( $rel.ToMany )
diff --git a/cayenne-cgen/src/main/resources/templates/v4_1/superclass.vm b/cayenne-cgen/src/main/resources/templates/v4_1/superclass.vm
index e275c0f..a1bbd58 100644
--- a/cayenne-cgen/src/main/resources/templates/v4_1/superclass.vm
+++ b/cayenne-cgen/src/main/resources/templates/v4_1/superclass.vm
@@ -97,8 +97,12 @@ public abstract class ${superClassName} extends ${baseClassName} {
## Create Properties ##
#######################
#foreach( $attr in ${object.DeclaredAttributes} )
- #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)")
- public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
+ #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
+ #set ( $propName = $stringUtils.capitalizedAsConstant($attr.Name) )
+ #if ( $propName.equals($attr.name) )
+ #set ( $propName = $propName + "_")
+ #end
+ public static final Property<$type> $propName = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
#end
#foreach( $rel in ${object.DeclaredRelationships} )
#if( $rel.ToMany )