Attached is a patch to the Object.vm om template that allows a foreign key to
reference the local table (representing a recursive relationship, as in the archetypal
employee/manager relationship) and "properly" (or at least consistently) names the
init, add, and get methods, e.g., addEmployeeRelatedByManagerSSN(Employee l). This
change seems consistent with the handling in the association code, i.e.,
setEmployeeRelatedByManagerSSN(Employee v).
I'm not sure why the foreign key code generation was short circuited in the template
if the foreign key table name is the same as the current table (any background?) That
said, there may be unforeseen ramifications of this change, however, it seems to
generate correct code for us and our current schema.
Scott Finnerty
Index: jakarta-turbine-torque/src/templates/om/Object.vm
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/src/templates/om/Object.vm,v
retrieving revision 1.31
diff -u -r1.31 Object.vm
--- jakarta-turbine-torque/src/templates/om/Object.vm 28 May 2002 01:00:16 -0000
1.31
+++ jakarta-turbine-torque/src/templates/om/Object.vm 30 May 2002 21:39:23 -0000
@@ -331,12 +331,11 @@
##
#foreach ($fk in $table.Referrers)
#set ( $tblFK = $fk.Table )
- #if ( !($tblFK.Name.equals($table.Name)) )
#set ( $className = $tblFK.JavaName )
#set ( $relatedByCol = "" )
#foreach ($columnName in $fk.LocalColumns)
#set ( $column = $tblFK.getColumn($columnName) )
- #if ($column.isMultipleFK())
+ #if ($column.isMultipleFK() || $tblFK.Name.equals($table.Name) )
#set ($relatedByCol= "$relatedByCol$column.JavaName")
#end
#end
@@ -563,7 +562,7 @@
return $collName;
}
- #end #end #end #end
+ #end #end #end
## ===========================================================
#*
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>