>> I would like to suggest changing the Torque Object.vm template to
>> use a variation of the JavaName parameter to create the object field
>> names instead of using the DB column name.  My reason for wanting to
>> do this is so that bean introspection of the field name would find
the
>> appropriate setters and getters.

> I'm confused. I thought we were already doing this.

I did a cvs update on the jakarta-turbine-torque project so I should
have the latest code.  When I run Torque standalone with the latest
templates it names the fields as a variation of the name parameter from
the schema xml file.  

Here is a patch file for what we did to get it to use the javaName 
parameter instead.  Like I said, we don't have much experience with 
Velocity templates so there is probably a better, more elegant way 
to do what we did.

-- Steve

###################### Begin Patch ################################
Index: Object.vm
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-torque/src/templates/om/Object.vm,v
retrieving revision 1.6
diff -u -r1.6 Object.vm
--- Object.vm   2001/09/10 21:14:02     1.6
+++ Object.vm   2001/10/17 20:35:25
@@ -47,7 +47,9 @@
     #if (!$table.isAlias())
       #foreach ($col in $table.Columns)
         #set ( $cjtype = $col.JavaNative )
-        #set ( $clo=$col.Name.toLowerCase() )
+       #set ( $cjn1=$col.JavaName.toLowerCase().substring(0, 1) )
+        #set ( $cjnr=$col.JavaName.substring(1) )
+        #set ( $clo= $strings.concat([$cjn1, $cjnr]) )
         #set ($defVal = "")
         #if ($col.DefaultValue &&
!$col.DefaultValue.equalsIgnoreCase("NULL") )
           #set ( $quote = '' )
@@ -73,7 +75,9 @@
 
       #foreach ($col in $table.Columns)
         #set ( $cfc=$col.JavaName )
-        #set ( $clo=$col.Name.toLowerCase() )
+       #set ( $cjn1=$col.JavaName.toLowerCase().substring(0, 1) )
+        #set ( $cjnr=$col.JavaName.substring(1) )
+        #set ( $clo= $strings.concat([$cjn1, $cjnr]) )
         #set ( $cjtype = $col.JavaNative )
     
         /**
@@ -239,7 +243,9 @@
    #foreach ($columnName in $fk.LocalColumns)
     #set ( $column = $table.getColumn($columnName) )
     #set ( $cjtype = $column.JavaNative )
-    #set ( $clo=$column.Name.toLowerCase() )
+    #set ( $cjn1=$column.JavaName.toLowerCase().substring(0, 1) )
+    #set ( $cjnr=$column.JavaName.substring(1) )
+    #set ( $clo= $strings.concat([$cjn1, $cjnr]) )
     #if ($cjtype == "int")
         #set ( $conditional = $strings.concat([$conditional, $and,
"this.", $clo, ">0"]) )
     #elseif ($cjtype == "long")
@@ -948,7 +954,9 @@
         #end
     #end
 
-    #set ( $clo=$col.Name.toLowerCase() )
+    #set ( $cjn1=$col.JavaName.toLowerCase().substring(0, 1) )
+    #set ( $cjnr=$col.JavaName.substring(1) )
+    #set ( $clo= $strings.concat([$cjn1, $cjnr]) )
     #set ( $cjtype = $col.JavaNative )
     #set ($argList = "${argList}$comma $cjtype $clo")
     #set ($argList2 = "${argList2}$comma String $clo")
@@ -959,7 +967,9 @@
 #if ($table.PrimaryKeys.size() == 1)
 
     #set ($col = $table.PrimaryKeys.get(0) )
-    #set ( $clo=$col.Name.toLowerCase() )
+    #set ( $cjn1=$col.JavaName.toLowerCase().substring(0, 1) )
+    #set ( $cjnr=$col.JavaName.substring(1) )
+    #set ( $clo= $strings.concat([$cjn1, $cjnr]) )
     #set ( $cjtype= $col.JavaNative )
     /** 
      * Set the PrimaryKey using ObjectKey.
@@ -1000,7 +1010,9 @@
      * Set the PrimaryKey using SimpleKeys.
      *
 #foreach ($col in $table.PrimaryKeys)
-    #set ( $clo=$col.Name.toLowerCase() )
+    #set ( $cjn1=$col.JavaName.toLowerCase().substring(0, 1) )
+    #set ( $cjnr=$col.JavaName.substring(1) )
+    #set ( $clo= $strings.concat([$cjn1, $cjnr]) )
     #set ( $cjtype= $col.JavaNative )
      * @param $cjtype $clo
 #end
@@ -1008,7 +1020,10 @@
     public void setPrimaryKey($argList) 
         $throwsClause {
 #foreach ($col in $table.PrimaryKeys)
-         set${col.JavaName}($col.Name.toLowerCase());
+         #set ( $cjn1=$col.JavaName.toLowerCase().substring(0, 1) )
+         #set ( $cjnr=$col.JavaName.substring(1) )
+         #set ( $clo= $strings.concat([$cjn1, $cjnr]) )
+         set${col.JavaName}($clo);
 #end
     }
 
@@ -1016,14 +1031,19 @@
      * Set the PrimaryKey with Strings.
      *
 #foreach ($col in $table.PrimaryKeys)
-    #set ( $clo=$col.Name.toLowerCase() )
+    #set ( $cjn1=$col.JavaName.toLowerCase().substring(0, 1) )
+    #set ( $cjnr=$col.JavaName.substring(1) )
+    #set ( $clo= $strings.concat([$cjn1, $cjnr]) )
      * @param String $clo
 #end
      */
     public void setPrimaryKey($argList2) 
         $throwsClause {
 #foreach ($col in $table.PrimaryKeys)
-         set${col.JavaName}(new
${col.JavaNative}($col.Name.toLowerCase()));
+         #set ( $cjn1=$col.JavaName.toLowerCase().substring(0, 1) )
+         #set ( $cjnr=$col.JavaName.substring(1) )
+         #set ( $clo= $strings.concat([$cjn1, $cjnr]) )
+         set${col.JavaName}(new ${col.JavaNative}($clo));
 #end
     }
 
@@ -1112,7 +1132,10 @@
         $table.JavaName copyObj = new ${table.JavaName}();
 #end
 #foreach ($col in $table.Columns)
-        copyObj.set${col.JavaName}($col.Name.toLowerCase());
+       #set ( $cjn1=$col.JavaName.toLowerCase().substring(0, 1) )
+        #set ( $cjnr=$col.JavaName.substring(1) )
+        #set ( $clo= $strings.concat([$cjn1, $cjnr]) )
+        copyObj.set${col.JavaName}($clo);
 #end 
 
 #if ($complexObjectModel)
###################### End Patch ################################


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

Reply via email to