db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r567400 - /db/torque/templates/trunk/src/templates/om/MapBuilder.vm
Date Sun, 19 Aug 2007 13:27:13 GMT
Author: tv
Date: Sun Aug 19 06:27:12 2007
New Revision: 567400

URL: http://svn.apache.org/viewvc?view=rev&rev=567400
Log:
Move setting of the primaryKeyMethodInfo from generation time to runtime which should allow
changing the database adapter at runtime without re-creating the OM classes. Would please
someone with access to a DB which uses sequences (Postgres, Oracle etc) check if this works
for him, too. Fixes TORQUE-95

Modified:
    db/torque/templates/trunk/src/templates/om/MapBuilder.vm

Modified: db/torque/templates/trunk/src/templates/om/MapBuilder.vm
URL: http://svn.apache.org/viewvc/db/torque/templates/trunk/src/templates/om/MapBuilder.vm?view=diff&rev=567400&r1=567399&r2=567400
==============================================================================
--- db/torque/templates/trunk/src/templates/om/MapBuilder.vm (original)
+++ db/torque/templates/trunk/src/templates/om/MapBuilder.vm Sun Aug 19 06:27:12 2007
@@ -21,6 +21,9 @@
 
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
+#if ($table.IdMethod == "native")
+import org.apache.torque.adapter.DB;
+#end
 import org.apache.torque.map.MapBuilder;
 import org.apache.torque.map.DatabaseMap;
 import org.apache.torque.map.TableMap;
@@ -107,10 +110,16 @@
         tMap.setPrimaryKeyMethodInfo("$imp.Value");
 #elseif ($table.IdMethod == "idbroker")
         tMap.setPrimaryKeyMethodInfo(tMap.getName());
-#elseif ($table.IdMethod == "native" && $table.Database.Platform.NativeIdMethod ==
"sequence")
-        tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
-#elseif ($table.IdMethod == "native" && $table.Database.Platform.NativeIdMethod ==
"identity")
-        tMap.setPrimaryKeyMethodInfo("$table.Name");
+#elseif ($table.IdMethod == "native")
+        DB dbAdapter = Torque.getDB("$table.Database.Name");
+        if (dbAdapter.getIDMethodType().equals(DB.SEQUENCE))
+        {
+            tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
+        }
+        else if (dbAdapter.getIDMethodType().equals(DB.AUTO_INCREMENT))
+        {
+            tMap.setPrimaryKeyMethodInfo("$table.Name");
+        }
 #end
 #if ($useManagers && $table.PrimaryKey.size() > 0)
   #set ($interfaceName = $table.JavaName)



---------------------------------------------------------------------
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