You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by jg...@apache.org on 2010/02/17 18:55:37 UTC

svn commit: r911119 - in /ibatis/java/ibator/trunk/core/ibator-core: doc/ src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/

Author: jgbutler
Date: Wed Feb 17 17:55:37 2010
New Revision: 911119

URL: http://svn.apache.org/viewvc?rev=911119&view=rev
Log:
[Ibator] Fix for IBATIS-731 - rename key field to avoid name collisions

Modified:
    ibatis/java/ibator/trunk/core/ibator-core/doc/ReleaseNotes.txt
    ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DeleteByPrimaryKeyMethodGenerator.java
    ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/SelectByPrimaryKeyMethodGenerator.java

Modified: ibatis/java/ibator/trunk/core/ibator-core/doc/ReleaseNotes.txt
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/doc/ReleaseNotes.txt?rev=911119&r1=911118&r2=911119&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/doc/ReleaseNotes.txt (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/doc/ReleaseNotes.txt Wed Feb 17 17:55:37 2010
@@ -15,6 +15,7 @@
 4. Fixed IBATIS-601 - improper validation of <generatedKey>
 5. Fixed IBATIS-609 - incorrect parsing of Java generic types
 6. Fixed spelling error LONCVARCHAR->LONGVARCHAR (thanks Allard)
+7. Fixed IBATIS-731 - change name of primary key variable to avoid conflicts
 
 Enhancements:
 1. IBATIS-569 - Make it easier to override IbatorRules in plugins
@@ -42,6 +43,7 @@
 19. Added new "or" method to example classes
 20. Added new "useCompoundColumnNames" property on <table>
 
+
 -------------------------------------------------------------------------------
 Version 1.2.1:
 

Modified: ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DeleteByPrimaryKeyMethodGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DeleteByPrimaryKeyMethodGenerator.java?rev=911119&r1=911118&r2=911119&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DeleteByPrimaryKeyMethodGenerator.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DeleteByPrimaryKeyMethodGenerator.java Wed Feb 17 17:55:37 2010
@@ -54,14 +54,14 @@
 
             sb.setLength(0);
             sb.append(keyType.getShortName());
-            sb.append(" key = new "); //$NON-NLS-1$
+            sb.append(" _key = new "); //$NON-NLS-1$
             sb.append(keyType.getShortName());
             sb.append("();"); //$NON-NLS-1$
             method.addBodyLine(sb.toString());
 
             for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
                 sb.setLength(0);
-                sb.append("key."); //$NON-NLS-1$
+                sb.append("_key."); //$NON-NLS-1$
                 sb.append(JavaBeansUtil.getSetterMethodName(introspectedColumn
                         .getJavaProperty()));
                 sb.append('(');
@@ -74,7 +74,7 @@
         sb.setLength(0);
         sb.append("int rows = "); //$NON-NLS-1$
         sb.append(daoTemplate.getDeleteMethod(introspectedTable.getIbatis2SqlMapNamespace(),
-                introspectedTable.getDeleteByPrimaryKeyStatementId(), "key")); //$NON-NLS-1$
+                introspectedTable.getDeleteByPrimaryKeyStatementId(), "_key")); //$NON-NLS-1$
         method.addBodyLine(sb.toString());
         method.addBodyLine("return rows;"); //$NON-NLS-1$
 
@@ -105,7 +105,7 @@
         if (introspectedTable.getRules().generatePrimaryKeyClass()) {
             FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
             importedTypes.add(type);
-            method.addParameter(new Parameter(type, "key")); //$NON-NLS-1$
+            method.addParameter(new Parameter(type, "_key")); //$NON-NLS-1$
         } else {
             for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
                 FullyQualifiedJavaType type = introspectedColumn

Modified: ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/SelectByPrimaryKeyMethodGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/SelectByPrimaryKeyMethodGenerator.java?rev=911119&r1=911118&r2=911119&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/SelectByPrimaryKeyMethodGenerator.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/SelectByPrimaryKeyMethodGenerator.java Wed Feb 17 17:55:37 2010
@@ -55,14 +55,14 @@
 
             sb.setLength(0);
             sb.append(keyType.getShortName());
-            sb.append(" key = new "); //$NON-NLS-1$
+            sb.append(" _key = new "); //$NON-NLS-1$
             sb.append(keyType.getShortName());
             sb.append("();"); //$NON-NLS-1$
             method.addBodyLine(sb.toString());
 
             for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
                 sb.setLength(0);
-                sb.append("key."); //$NON-NLS-1$
+                sb.append("_key."); //$NON-NLS-1$
                 sb.append(JavaBeansUtil.getSetterMethodName(introspectedColumn
                         .getJavaProperty()));
                 sb.append('(');
@@ -81,7 +81,7 @@
         sb.append(") "); //$NON-NLS-1$
         sb.append(daoTemplate.getQueryForObjectMethod(introspectedTable
                 .getIbatis2SqlMapNamespace(),
-                introspectedTable.getSelectByPrimaryKeyStatementId(), "key")); //$NON-NLS-1$
+                introspectedTable.getSelectByPrimaryKeyStatementId(), "_key")); //$NON-NLS-1$
         method.addBodyLine(sb.toString());
         method.addBodyLine("return record;"); //$NON-NLS-1$
 
@@ -117,7 +117,7 @@
         if (introspectedTable.getRules().generatePrimaryKeyClass()) {
             FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
             importedTypes.add(type);
-            method.addParameter(new Parameter(type, "key")); //$NON-NLS-1$
+            method.addParameter(new Parameter(type, "_key")); //$NON-NLS-1$
         } else {
             for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
                 FullyQualifiedJavaType type = introspectedColumn.getFullyQualifiedJavaType();