jon 2002/05/31 13:08:12
Modified: src/templates/om Peer.vm
Log:
The bug #3496 is marked resolved, but I'm not sure it is. The attached
patch makes sure that when the object is populated by the peer that keys
are set to null and not to a key containing a null value. Particularly
in the case of foreign keys, it is plausible to have a null value. This
fix makes checks for null work with key fields - as occurs in the gets
for associated objects. Thus this fix seems to address the problem
described in bug #3496.
Scott Finnerty
Revision Changes Path
1.31 +17 -2 jakarta-turbine-torque/src/templates/om/Peer.vm
Index: Peer.vm
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/Peer.vm,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- Peer.vm 28 May 2002 01:00:16 -0000 1.30
+++ Peer.vm 31 May 2002 20:08:12 -0000 1.31
@@ -337,8 +337,23 @@
#end
#else
#if ($col.isPrimaryKey() || $col.isForeignKey() )
- obj.set${col.JavaName}(
- new ${col.JavaNative}(row.getValue(offset +
$n).$col.VillageMethod));
+ ## The field should always be an Object type but make sure so we
+ ## are sure we can set it to null.
+ if ( row.getValue(offset+$n).$col.VillageMethod instanceof Object )
+ {
+ ## If the database value is a null value then set the Key
+ ## value to null so comparisons with ObjectUtils.equals really work.
+ if ( null == row.getValue(offset+$n).$col.VillageMethod )
+ {
+ obj.set${col.JavaName}( (${col.JavaNative}) null );
+ }
+ else
+ ## Do what we normally do
+ {
+ obj.set${col.JavaName}(
+ new
${col.JavaNative}(row.getValue(offset+$n).$col.VillageMethod));
+ }
+ }
#else
obj.set${col.JavaName}(row.getValue(offset + $n).$col.VillageMethod);
#end
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>