This patch allows the user to disable primary/foreign key setter
overloading in the Object/ObjectWithManager classes using the
"overloadKeySetters" property in Torque's build.properties file. 

When set to true (the default), Torque behaves as it did previously.
When set to false the setter methods accepting a String parameter will
not be generated. 

I ran the test suite, and as far as I could tell everything worked
properly. 

-james 

On Mon, 2002-04-29 at 20:44, John McNally wrote: 
> The correct rule is to lookup the getter and use that to determine the
> setter.  This is implemented correctly in some of the bean introspection
> classes, in some versions of the jdk.  Since the bugs occur in different
> classes/methods in different versions of the jdk, it makes it hard to
> work around.
> 
> If the introspection was not so buggy, torque overloading of the setter
> would not be a problem.  But having run into so many problems with this
> myself I would welcome a patch to conditionally remove the additional
> setter.  It should not be difficult.  properties defined in
> build.properties are available automatically within the templates, so it
> should not involve any java code.
> 
> john mcnally
> 
-- 
[]  James A. Hillyerd <[EMAIL PROTECTED]> - Java Software Engineer
[]  PGP 1024D/D31BC40D F87B 7906 C0DA 32E8 B8F6 DE23 FBF6 4712 D31B C40D
Index: conf/build.properties
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/src/conf/build.properties,v
retrieving revision 1.12
diff -u -r1.12 build.properties
--- conf/build.properties	10 Apr 2002 21:21:25 -0000	1.12
+++ conf/build.properties	1 May 2002 07:24:02 -0000
@@ -67,6 +67,10 @@
 #
 # useManagers=Generate Manager classes that use JCS for caching.  Still
 # considered experimental.
+#
+# overloadKeySetters=false prevents overloading of the setter method for
+# primary/foreign keys.  This is useful when working with broken
+# JavaBean implementations.
 # -------------------------------------------------------------------
 
 targetPackage=org.apache.torque
@@ -77,6 +81,7 @@
 addTimeStamp=true
 addIntakeRetrievable=false
 useManagers=false
+overloadKeySetters=true
 
 # -------------------------------------------------------------------
 #
Index: templates/om/Object.vm
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/src/templates/om/Object.vm,v
retrieving revision 1.28
diff -u -r1.28 Object.vm
--- templates/om/Object.vm	30 Apr 2002 23:49:48 -0000	1.28
+++ templates/om/Object.vm	1 May 2002 07:24:05 -0000
@@ -194,14 +194,16 @@
      }
 
 ##if ($complexObjectModel)
-  #if ($col.isPrimaryKey() || $col.isForeignKey())
-   /**
-    * Set the value of $cfc as a string.
-    */
-    public void set${cfc}(String v ) $throwsClause
-    {
-         set${cfc}(new ${cjtype}(v));
-    }
+  #if ($overloadKeySetters)
+    #if ($col.isPrimaryKey() || $col.isForeignKey())
+     /**
+      * Set the value of $cfc as a string.
+      */
+      public void set${cfc}(String v ) $throwsClause
+      {
+           set${cfc}(new ${cjtype}(v));
+      }
+    #end
   #end
 ##end
 
Index: templates/om/ObjectWithManager.vm
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/src/templates/om/ObjectWithManager.vm,v
retrieving revision 1.7
diff -u -r1.7 ObjectWithManager.vm
--- templates/om/ObjectWithManager.vm	30 Apr 2002 23:49:48 -0000	1.7
+++ templates/om/ObjectWithManager.vm	1 May 2002 07:24:07 -0000
@@ -198,14 +198,16 @@
      }
 
 ##if ($complexObjectModel)
-  #if ($col.isPrimaryKey() || $col.isForeignKey())
-   /**
-    * Set the value of $cfc as a string.
-    */
-    public void set${cfc}(String v ) $throwsClause
-    {
-         set${cfc}(new ${cjtype}(v));
-    }
+  #if ($overloadKeySetters)
+    #if ($col.isPrimaryKey() || $col.isForeignKey())
+     /**
+      * Set the value of $cfc as a string.
+      */
+      public void set${cfc}(String v ) $throwsClause
+      {
+           set${cfc}(new ${cjtype}(v));
+      }
+    #end
   #end
 ##end
 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to