When the Id method is autoincrement and a Torque OM object is inserted
the primary key is not known until after the insert. Once Torque
performs the insert it calls the setPrimaryKey method of the OM object,
since the primary key prior to the insert was probably null the current
ObjectKey and the one being set do not match so the modified flag is set
to true.
So the quick tour: after an insert is performed the modified flag
falsely indicates the object is modified.
Thanks,
Byron
Index: src/templates/om/Peer.vm
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/src/templates/om/Peer.vm,v
retrieving revision 1.4
diff -u -U10 -r1.4 Peer.vm
--- src/templates/om/Peer.vm 2001/10/17 23:38:44 1.4
+++ src/templates/om/Peer.vm 2001/10/20 12:36:18
@@ -639,20 +639,21 @@
/** Method to do inserts */
public static void doInsert( $table.JavaName obj ) throws Exception
{
#if ($table.IdMethod.equals("none"))
doInsert(buildCriteria(obj));
#else
obj.setPrimaryKey(doInsert(buildCriteria(obj)));
#end
obj.setNew(false);
+ obj.setModified(false);
}
/**
* @param obj the data object to update in the database.
*/
public static void doUpdate($table.JavaName obj) throws Exception
{
doUpdate(buildCriteria(obj));
}
@@ -673,20 +674,21 @@
*/
public static void doInsert( $table.JavaName obj, DBConnection dbCon)
throws Exception
{
#if ($table.IdMethod.equals("none"))
doInsert(buildCriteria(obj), dbCon);
#else
obj.setPrimaryKey(doInsert(buildCriteria(obj), dbCon));
#end
obj.setNew(false);
+ obj.setModified(false);
}
/**
* Method to do update. This method is to be used during a transaction,
* otherwise use the doUpdate($table.JavaName) method. It will take
* care of the connection details internally.
*
* @param obj the data object to update in the database.
*/
public static void doUpdate($table.JavaName obj, DBConnection dbCon)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]