You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by mp...@apache.org on 2003/05/27 21:58:58 UTC
cvs commit: db-torque/src/templates/om Object.vm ObjectWithManager.vm
mpoeschl 2003/05/27 12:58:58
Modified: src/templates/om Tag: TORQUE_3_0_BRANCH Object.vm
ObjectWithManager.vm
Log:
TRQS47: bug in torque generated copy() method
Revision Changes Path
No revision
No revision
1.54.2.2 +28 -33 db-torque/src/templates/om/Attic/Object.vm
Index: Object.vm
===================================================================
RCS file: /home/cvs/db-torque/src/templates/om/Attic/Object.vm,v
retrieving revision 1.54.2.1
retrieving revision 1.54.2.2
diff -u -r1.54.2.1 -r1.54.2.2
--- Object.vm 28 Jan 2003 02:10:59 -0000 1.54.2.1
+++ Object.vm 27 May 2003 19:58:58 -0000 1.54.2.2
@@ -685,11 +685,7 @@
#end
#set ( $tblFK2 = $table.Database.getTable($fk2.ForeignTableName) )
- #if ($tblFK2.isForReferenceOnly())
- #set ($doJoinGet = false)
- #else
- #set ($doJoinGet = true)
- #end
+ #set ( $doJoinGet = !$tblFK2.isForReferenceOnly())
#set ( $relatedByCol2 = "" )
#foreach ($columnName in $fk2.LocalColumns)
#set ( $column = $tblFK.getColumn($columnName) )
@@ -1173,7 +1169,7 @@
#set ( $argList = "" )
#set ( $argList2 = "" )
#set ( $comma = "" )
-#foreach ($col in $table.PrimaryKeys)
+#foreach ($col in $table.PrimaryKey)
#if ($complexObjectModel)
#if ( $col.isForeignKey() || ($col.Referrers.size() > 0) )
#set ( $throwsClause = "throws TorqueException" )
@@ -1188,9 +1184,9 @@
#set ( $comma = "," )
#end
-#if ($table.PrimaryKeys.size() == 1)
+#if ($table.PrimaryKey.size() == 1)
- #set ($col = $table.PrimaryKeys.get(0) )
+ #set ($col = $table.PrimaryKey.get(0) )
#set ( $clo=$col.Name.toLowerCase() )
#set ( $cjtype= $col.JavaNative )
/**
@@ -1278,9 +1274,9 @@
#end
}
-#elseif ($table.PrimaryKeys.size() > 1)
+#elseif ($table.PrimaryKey.size() > 1)
- private final SimpleKey[] pks = new SimpleKey[$table.PrimaryKeys.size()];
+ private final SimpleKey[] pks = new SimpleKey[$table.PrimaryKey.size()];
private final ComboKey comboPK = new ComboKey(pks);
/**
* Set the PrimaryKey with an ObjectKey
@@ -1292,7 +1288,7 @@
SimpleKey[] keys = (SimpleKey[]) key.getValue();
SimpleKey tmpKey = null;
#set ($i = 0)
- #foreach ($pk in $table.PrimaryKeys)
+ #foreach ($pk in $table.PrimaryKey)
#set ($pktype = $pk.JavaNative)
#if ($pktype == "short")
set${pk.JavaName}(((NumberKey)keys[$i]).shortValue());
@@ -1332,7 +1328,7 @@
/**
* Set the PrimaryKey using SimpleKeys.
*
-#foreach ($col in $table.PrimaryKeys)
+#foreach ($col in $table.PrimaryKey)
#set ( $clo=$col.Name.toLowerCase() )
#set ( $cjtype= $col.JavaNative )
* @param $cjtype $clo
@@ -1341,7 +1337,7 @@
public void setPrimaryKey($argList)
$throwsClause
{
-#foreach ($col in $table.PrimaryKeys)
+#foreach ($col in $table.PrimaryKey)
set${col.JavaName}($col.Name.toLowerCase());
#end
}
@@ -1362,11 +1358,11 @@
*/
public ObjectKey getPrimaryKey()
{
-#if ($table.PrimaryKeys.size() == 1)
- return SimpleKey.keyFor(get${table.PrimaryKeys.get(0).JavaName}());
-#elseif ($table.PrimaryKeys.size() > 1)
+#if ($table.PrimaryKey.size() == 1)
+ return SimpleKey.keyFor(get${table.PrimaryKey.get(0).JavaName}());
+#elseif ($table.PrimaryKey.size() > 1)
#set ($i = 0)
- #foreach ($pk in $table.PrimaryKeys)
+ #foreach ($pk in $table.PrimaryKey)
pks[$i] = SimpleKey.keyFor(get${pk.JavaName}());
#set ($i = $i +1)
#end
@@ -1430,8 +1426,22 @@
copyObj.set${col.JavaName}($col.Name.toLowerCase());
#end
+#foreach ($col in $table.Columns)
+ #if ($col.isPrimaryKey())
+ #if($col.Primitive)
+ #set ($coldefval = "0")
+ #set ($coldefval = $col.DefaultValue)
+ copyObj.set${col.JavaName}($coldefval);
+ #else
+ #set ( $pkid = "null" )
+ #set ( $cjtype = $col.JavaNative )
+ copyObj.set${col.JavaName}((${cjtype})${pkid});
+ #end
+ #end
+#end
+
+
#if ($complexObjectModel)
- copyObj.setNew(false);
#set ( $list = "List " )
#foreach ($fk in $table.Referrers)
#set ( $tblFK = $fk.Table )
@@ -1458,27 +1468,12 @@
{
$className obj = ($className) v.get(i);
copyObj.add$pCollNameNoS(obj.copy());
- ((Persistent) v.get(i)).setNew(true);
}
#set ( $list = "" )
#end
#end
- copyObj.setNew(true);
#end
-#foreach ($col in $table.Columns)
- #if ($col.isPrimaryKey())
- #if($col.Primitive)
- #set ($coldefval = "0")
- #set ($coldefval = $col.DefaultValue)
- copyObj.set${col.JavaName}($coldefval);
- #else
- #set ( $pkid = "null" )
- #set ( $cjtype = $col.JavaNative )
- copyObj.set${col.JavaName}((${cjtype})${pkid});
- #end
- #end
-#end
return copyObj;
}
#end
1.29.2.2 +29 -36 db-torque/src/templates/om/Attic/ObjectWithManager.vm
Index: ObjectWithManager.vm
===================================================================
RCS file: /home/cvs/db-torque/src/templates/om/Attic/ObjectWithManager.vm,v
retrieving revision 1.29.2.1
retrieving revision 1.29.2.2
diff -u -r1.29.2.1 -r1.29.2.2
--- ObjectWithManager.vm 28 Jan 2003 02:11:00 -0000 1.29.2.1
+++ ObjectWithManager.vm 27 May 2003 19:58:58 -0000 1.29.2.2
@@ -662,11 +662,7 @@
#end
#set ( $tblFK2 = $table.Database.getTable($fk2.ForeignTableName) )
- #if ($tblFK2.isForReferenceOnly())
- #set ($doJoinGet = false)
- #else
- #set ($doJoinGet = true)
- #end
+ #set ( $doJoinGet = !$tblFK2.isForReferenceOnly())
#set ( $relatedByCol2 = "" )
#foreach ($columnName in $fk2.LocalColumns)
#set ( $column = $tblFK.getColumn($columnName) )
@@ -1087,7 +1083,7 @@
${table.JavaName}Peer.doUpdate(($table.JavaName)this, con);
}
-#if ($table.PrimaryKeys.size() > 0)
+#if ($table.PrimaryKey.size() > 0)
#set ($interfaceName = $table.JavaName)
#if ($table.Interface)
#set ($interfaceName = $table.Interface)
@@ -1136,7 +1132,7 @@
}
#end
-#if ($table.PrimaryKeys.size() > 0)
+#if ($table.PrimaryKey.size() > 0)
/**
* Specify whether to cache the object after saving to the db.
* This method returns false
@@ -1169,9 +1165,9 @@
#set ( $comma = "," )
#end
-#if ($table.PrimaryKeys.size() == 1)
+#if ($table.PrimaryKey.size() == 1)
- #set ($col = $table.PrimaryKeys.get(0) )
+ #set ($col = $table.PrimaryKey.get(0) )
#set ( $clo=$col.Name.toLowerCase() )
#set ( $cjtype= $col.JavaNative )
/**
@@ -1256,9 +1252,9 @@
#end
}
-#elseif ($table.PrimaryKeys.size() > 1)
+#elseif ($table.PrimaryKey.size() > 1)
- private final SimpleKey[] pks = new SimpleKey[$table.PrimaryKeys.size()];
+ private final SimpleKey[] pks = new SimpleKey[$table.PrimaryKey.size()];
private final ComboKey comboPK = new ComboKey(pks);
/**
* Set the PrimaryKey with an ObjectKey
@@ -1268,7 +1264,7 @@
SimpleKey[] keys = (SimpleKey[]) key.getValue();
SimpleKey tmpKey = null;
#set ($i = 0)
- #foreach ($pk in $table.PrimaryKeys)
+ #foreach ($pk in $table.PrimaryKey)
#set ($pktype = $pk.JavaNative)
#if ($pktype == "short")
set${pk.JavaName}(((NumberKey)keys[$i]).shortValue());
@@ -1308,7 +1304,7 @@
/**
* Set the PrimaryKey using SimpleKeys.
*
-#foreach ($col in $table.PrimaryKeys)
+#foreach ($col in $table.PrimaryKey)
#set ( $clo=$col.Name.toLowerCase() )
#set ( $cjtype= $col.JavaNative )
* @param $cjtype $clo
@@ -1316,7 +1312,7 @@
*/
public void setPrimaryKey($argList)
$throwsClause {
-#foreach ($col in $table.PrimaryKeys)
+#foreach ($col in $table.PrimaryKey)
set${col.JavaName}($col.Name.toLowerCase());
#end
}
@@ -1338,11 +1334,11 @@
*/
public ObjectKey getPrimaryKey()
{
-#if ($table.PrimaryKeys.size() == 1)
- return SimpleKey.keyFor(get${table.PrimaryKeys.get(0).JavaName}());
-#elseif ($table.PrimaryKeys.size() > 1)
+#if ($table.PrimaryKey.size() == 1)
+ return SimpleKey.keyFor(get${table.PrimaryKey.get(0).JavaName}());
+#elseif ($table.PrimaryKey.size() > 1)
#set ($i = 0)
- #foreach ($pk in $table.PrimaryKeys)
+ #foreach ($pk in $table.PrimaryKey)
pks[$i] = SimpleKey.keyFor(get${pk.JavaName}());
#set ($i = $i +1)
#end
@@ -1387,8 +1383,7 @@
* Makes a copy of this object.
* It creates a new object filling in the simple attributes.
#if ($complexObjectModel)
- * It then fills all the association collections and sets the
- * related objects to isNew=true.
+ * It then fills all the association collections.
#end
*/
#if ($table.ChildrenColumn || $table.isAbstract())
@@ -1403,8 +1398,21 @@
copyObj.set${col.JavaName}($col.Name.toLowerCase());
#end
+#foreach ($col in $table.Columns)
+ #if ($col.isPrimaryKey())
+ #if($col.Primitive)
+ #set ($coldefval = "0")
+ #set ($coldefval = $col.DefaultValue)
+ copyObj.set${col.JavaName}($coldefval);
+ #else
+ #set ( $pkid = "null" )
+ #set ( $cjtype = $col.JavaNative )
+ copyObj.set${col.JavaName}((${cjtype})${pkid});
+ #end
+ #end
+#end
+
#if ($complexObjectModel)
- copyObj.setNew(false);
#set ( $list = "List " )
#foreach ($fk in $table.Referrers)
#set ( $tblFK = $fk.Table )
@@ -1431,27 +1439,12 @@
{
$className obj = ($className) v.get(i);
copyObj.add$pCollNameNoS(obj.copy());
- ((Persistent)v.get(i)).setNew(true);
}
#set ( $list = "" )
#end
#end
- copyObj.setNew(true);
#end
-#foreach ($col in $table.Columns)
- #if ($col.isPrimaryKey())
- #if($col.Primitive)
- #set ($coldefval = "0")
- #set ($coldefval = $col.DefaultValue)
- copyObj.set${col.JavaName}($coldefval);
- #else
- #set ( $pkid = "null" )
- #set ( $cjtype = $col.JavaNative )
- copyObj.set${col.JavaName}((${cjtype})${pkid});
- #end
- #end
-#end
return copyObj;
}
#end