On Thu, Jan 18, 2001 at 10:11:00PM +0000, Sean Legassick wrote:
> How strange - I just hit this problem as well and came up with a fix.
> I'm not entirely sure that it's correct so it's below, and I'd welcome
> comments.
>
> Basically I figure if a table's idMethod is set to null then neither the
> if (!obj.IsNew()) in buildCriteria nor the setPrimaryKey call in the
> doInsert methods are needed.
Good thinking (I believe) but the patch was a little hasty - the one
below works better. I'm not sure whether to commit it because I'm not
100% clear on whether this is an appropriate usage of idMethod="none".
Index: Peer.vm
===================================================================
RCS file: /products/cvs/turbine/turbine/conf/torque/templates/om/Peer.vm,v
retrieving revision 1.14
diff -u -r1.14 Peer.vm
--- Peer.vm 2001/01/11 05:49:05 1.14
+++ Peer.vm 2001/01/19 00:15:08
@@ -469,7 +469,11 @@
/** 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);
}
@@ -497,7 +501,11 @@
*/
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);
}
@@ -531,12 +539,10 @@
#foreach ($col in $table.Columns)
#set ( $cfc=$col.JavaName )
#set ( $cup=$col.Name.toUpperCase() )
- #if($col.isPrimaryKey())
+ #if ($col.isPrimaryKey() && !$table.IdMethod.equals("none"))
if ( !obj.isNew() )
+ #end
criteria.add( $cup, obj.get${cfc}() );
- #else
- criteria.add( $cup, obj.get${cfc}() );
- #end
#end
return criteria;
}
--
Sean Legassick
[EMAIL PROTECTED]
Als Mensch kann mir nichts menschliches Fremd sein
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]