dlr         01/10/22 16:05:59

  Modified:    src/templates/om Object.vm
  Log:
  Patch by Byron Foster <[EMAIL PROTECTED]> to fix defect #3496 (reported
  by Dave Hewitt <[EMAIL PROTECTED]>):
  
  Here is a patch that fixes bug #3496:
      http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3496
  
  In general ObjectKeys are no longer stored within a Torque OM object
  with a value property of null, but are rather converted to null so
  that the associated get call always return null for when an object is
  not associated or defined.  I think this is intuitive behavior as
  described in the bug.   This is consistent with what the current get
  property method expects for how ObjectKey fields will be handled.
  
  I removed code that previously did just the inverse so that when a
  null value was passed to the set method a new ObjectKey was created
  and set given a value of null. I did not find where this is necessary
  or desirable, certainly since it breaks the associated get method.
  
  This will change behavior slightly but I dont think it will affect
  current code that calls Torque OM objects. Before the new changes if a
  foreign key field is not required, then selecting an object out of the
  database that does not have an associated object for the given foreign
  key would create an ObjectKey with a null value property.  With this
  patch this same case simply returns null.  But like the bug states
  people should be testing this case currently with:
  
  if (getXXX() != null || getXXX().getValue() != null)
  
  Revision  Changes    Path
  1.7       +16 -13    jakarta-turbine-torque/src/templates/om/Object.vm
  
  Index: Object.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/Object.vm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- Object.vm 2001/09/10 21:14:02     1.6
  +++ Object.vm 2001/10/22 23:05:59     1.7
  @@ -102,6 +102,22 @@
            */
           public void set${cfc}($cjtype v ) $throwsClause
           {
  +          #if ( ($cjtype == "NumberKey") 
  +               || ($cjtype == "StringKey")
  +               || ($cjtype == "DateKey") )
  +
  +            if (v != null && v.getValue() == null)
  +            {
  +                // If this is an Objectkey than this set method is
  +                // probably storing the id of this object or some
  +                // associated object.  If the objectKey value is null
  +                // then we convert the parameter to null so that this
  +                // property is consistently null to indicate that no
  +                // object is associated or defined.
  +                v = null;
  +            }
  +          #end 
  +
           #if ($complexObjectModel)
             #if ($col.isForeignKey())
               #set ( $tmp = $col.RelatedTableName )
  @@ -152,20 +168,7 @@
           if ( !ObjectUtils.equals(this.$clo, v) )
           {
    #end
  -          #if ( ($cjtype == "NumberKey") 
  -               || ($cjtype == "StringKey")
  -               || ($cjtype == "DateKey") )
  -            if (this.$clo == null)
  -            {
  -                this.$clo = new $cjtype(v);
  -            }
  -            else
  -            {
  -                this.${clo}.setValue(v);
  -            }
  -          #else  
               this.$clo = v;
  -          #end
               setModified(true);
           }
   #else
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to