db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r327847 - in /db/torque: runtime/trunk/xdocs/ templates/trunk/src/templates/om/ templates/trunk/src/templates/om/bean/ test/trunk/test-project/src/schema/
Date Sun, 23 Oct 2005 19:51:47 GMT
Author: tfischer
Date: Sun Oct 23 12:51:13 2005
New Revision: 327847

URL: http://svn.apache.org/viewcvs?rev=327847&view=rev
Log:
Added additional imports for foreign keys which are defined in a different package.
Changed the runtimetest to test the correct behaviour.
Fixes TRQS325.
Thanks to Robert Dietrick for the patch.

Modified:
    db/torque/runtime/trunk/xdocs/changes.xml
    db/torque/templates/trunk/src/templates/om/Object.vm
    db/torque/templates/trunk/src/templates/om/ObjectWithManager.vm
    db/torque/templates/trunk/src/templates/om/bean/Bean.vm
    db/torque/templates/trunk/src/templates/om/bean/ObjectBeanImports.vm
    db/torque/templates/trunk/src/templates/om/bean/ObjectBeanMethods.vm
    db/torque/test/trunk/test-project/src/schema/ext-schema.xml

Modified: db/torque/runtime/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/xdocs/changes.xml?rev=327847&r1=327846&r2=327847&view=diff
==============================================================================
--- db/torque/runtime/trunk/xdocs/changes.xml (original)
+++ db/torque/runtime/trunk/xdocs/changes.xml Sun Oct 23 12:51:13 2005
@@ -26,6 +26,11 @@
   <body>
 
   <release version="3.2-rc3-dev" date="in SVN">
+    <action type="fix" dev="tfischer" issue="TRQS325">
+      Fixed importing references for foreign keys if the
+      object for the foreign key is in another package.<br />
+      Thanks to Robert Dietrick for the patch.
+    </action>
     <action type="update" dev="tfischer">
       The default values of the generator options 
       torque.subpackage.base.bean,

Modified: db/torque/templates/trunk/src/templates/om/Object.vm
URL: http://svn.apache.org/viewcvs/db/torque/templates/trunk/src/templates/om/Object.vm?rev=327847&r1=327846&r2=327847&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/om/Object.vm (original)
+++ db/torque/templates/trunk/src/templates/om/Object.vm Sun Oct 23 12:51:13 2005
@@ -55,6 +55,17 @@
 import ${packagePeer}.*;
 #end
 
+#set ($currentPackage = $table.Database.Package)
+#foreach ($col in $table.Columns)
+  #if ($col.isForeignKey())
+    #set ($fkPackage = $table.Database.getTable($col.RelatedTableName).getPackage())
+      #if  (!$fkPackage.equals($currentPackage) )
+import ${fkPackage}.${table.Database.getTable($col.RelatedTableName).JavaName};
+import ${fkPackage}.${table.Database.getTable($col.RelatedTableName).JavaName}Peer;
+      #end
+  #end
+#end
+
 #if ($generateBeans)
   $generator.parse("om/bean/ObjectBeanImports.vm",$path,"child",$child)
 #end

Modified: db/torque/templates/trunk/src/templates/om/ObjectWithManager.vm
URL: http://svn.apache.org/viewcvs/db/torque/templates/trunk/src/templates/om/ObjectWithManager.vm?rev=327847&r1=327846&r2=327847&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/om/ObjectWithManager.vm (original)
+++ db/torque/templates/trunk/src/templates/om/ObjectWithManager.vm Sun Oct 23 12:51:13 2005
@@ -55,6 +55,22 @@
 import ${packagePeer}.*;
 #end
 
+#set ($currentPackage = $table.Database.Package)
+#foreach ($col in $table.Columns)
+  #if ($col.isForeignKey())
+    #set ($fkPackage = $table.Database.getTable($col.RelatedTableName).getPackage())
+      #if  (!$fkPackage.equals($currentPackage) )
+import ${fkPackage}.${table.Database.getTable($col.RelatedTableName).JavaName};
+import ${fkPackage}.${table.Database.getTable($col.RelatedTableName).JavaName}Peer;
+        #if ($subpackageManager)
+import ${fkPackage}.${subpackageManager}.${table.Database.getTable($col.RelatedTableName).JavaName}Manager;
+        #else
+import ${fkPackage}.${table.Database.getTable($col.RelatedTableName).JavaName}Manager;
+        #end
+      #end
+  #end
+#end
+
 #if ($packageBaseObject != $packageManager)
 import ${packageManager}.*;
 #end

Modified: db/torque/templates/trunk/src/templates/om/bean/Bean.vm
URL: http://svn.apache.org/viewcvs/db/torque/templates/trunk/src/templates/om/bean/Bean.vm?rev=327847&r1=327846&r2=327847&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/om/bean/Bean.vm (original)
+++ db/torque/templates/trunk/src/templates/om/bean/Bean.vm Sun Oct 23 12:51:13 2005
@@ -29,6 +29,20 @@
   import ${packageBean}.*;
 #end
 
+#set ($currentPackage = $table.Database.Package)
+#foreach ($col in $table.Columns)
+  #if ($col.isForeignKey())
+    #set ($fkPackage = $table.Database.getTable($col.RelatedTableName).getPackage())
+      #if  (!$fkPackage.equals($currentPackage) )
+        #if ($subpackageBean)
+import ${fkPackage}.${subpackageBean}.${table.Database.getTable($col.RelatedTableName).JavaName}${beanSuffix};
+        #else
+import ${fkPackage}.${table.Database.getTable($col.RelatedTableName).JavaName}${beanSuffix};
+        #end
+      #end
+  #end
+#end
+
 /**
 #if ($addTimeStamp)
  * This class was autogenerated by Torque on:

Modified: db/torque/templates/trunk/src/templates/om/bean/ObjectBeanImports.vm
URL: http://svn.apache.org/viewcvs/db/torque/templates/trunk/src/templates/om/bean/ObjectBeanImports.vm?rev=327847&r1=327846&r2=327847&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/om/bean/ObjectBeanImports.vm (original)
+++ db/torque/templates/trunk/src/templates/om/bean/ObjectBeanImports.vm Sun Oct 23 12:51:13
2005
@@ -19,7 +19,11 @@
   #foreach ($fk in $table.ForeignKeys)
     #set ( $tblFK = $table.Database.getTable($fk.ForeignTableName) )
     #set ( $className = "${tblFK.JavaName}" )
-import ${packageBean}.${className}${beanSuffix};
+      #if ($subpackageBean)
+import ${tblFK.getPackage()}.${subpackageBean}.${className}${beanSuffix};
+      #else
+import ${tblFK.getPackage()}.${className}${beanSuffix};
+      #end
   #end
 
   #if ($objectIsCaching)

Modified: db/torque/templates/trunk/src/templates/om/bean/ObjectBeanMethods.vm
URL: http://svn.apache.org/viewcvs/db/torque/templates/trunk/src/templates/om/bean/ObjectBeanMethods.vm?rev=327847&r1=327846&r2=327847&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/om/bean/ObjectBeanMethods.vm (original)
+++ db/torque/templates/trunk/src/templates/om/bean/ObjectBeanMethods.vm Sun Oct 23 12:51:13
2005
@@ -35,7 +35,7 @@
      *        to already created beans
      * @return a $beanClassName with the contents of this object
      */
-    protected $beanClassName getBean(IdentityMap createdBeans)
+    public $beanClassName getBean(IdentityMap createdBeans)
     {
         ${beanClassName} result = ($beanClassName) createdBeans.get(this);
         if (result != null ) {
@@ -142,7 +142,9 @@
      * Creates an instance of ${table.JavaName} with the contents
      * of a $beanClassName.
      * This behaviour could have also been achieved using a constructor,
-     * however as this class is abstract no constructors are allowed
+     * however as this class is abstract no constructors are allowed.
+     *
+     * This method is intended for internal use only.
      * @param bean the $beanClassName which contents are used to create
      *        the resulting class
      * @param createdObjects a IdentityMap which maps beans
@@ -150,7 +152,7 @@
      * @return an instance of ${table.JavaName} with the contents of bean
      */
 
-    protected static ${table.JavaName} create${table.JavaName}(${beanClassName} bean, IdentityMap
createdObjects)
+    public static ${table.JavaName} create${table.JavaName}(${beanClassName} bean, IdentityMap
createdObjects)
         throws TorqueException
     {
         ${table.JavaName} result = (${table.JavaName}) createdObjects.get(bean);

Modified: db/torque/test/trunk/test-project/src/schema/ext-schema.xml
URL: http://svn.apache.org/viewcvs/db/torque/test/trunk/test-project/src/schema/ext-schema.xml?rev=327847&r1=327846&r2=327847&view=diff
==============================================================================
--- db/torque/test/trunk/test-project/src/schema/ext-schema.xml (original)
+++ db/torque/test/trunk/test-project/src/schema/ext-schema.xml Sun Oct 23 12:51:13 2005
@@ -18,7 +18,8 @@
 
 <database
   name="@DATABASE_DEFAULT@"
-  defaultIdMethod="@DATABASE_ID_METHOD@">
+  defaultIdMethod="@DATABASE_ID_METHOD@"
+  package="org.apache.torque.test.ext">
 
   <external-schema filename="extext-schema.xml" />
 



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message