db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: db-torque/src/generator/src/templates/om Object.vm ObjectWithManager.vm
Date Wed, 21 Jan 2004 19:57:23 GMT
mpoeschl    2004/01/21 11:57:22

  Modified:    src/generator/src/templates/om Object.vm
                        ObjectWithManager.vm
  Log:
  sync Object.vm and ObjectWithManager.vm
  
  Revision  Changes    Path
  1.10      +76 -79    db-torque/src/generator/src/templates/om/Object.vm
  
  Index: Object.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/om/Object.vm,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Object.vm	29 Oct 2003 22:57:59 -0000	1.9
  +++ Object.vm	21 Jan 2004 19:57:22 -0000	1.10
  @@ -9,8 +9,8 @@
   import java.math.BigDecimal;
   import java.sql.Connection;
   import java.util.ArrayList;
  -import java.util.Date;
   import java.util.Collections;
  +import java.util.Date;
   import java.util.List;
   
   #if ($addSaveMethod)
  @@ -215,7 +215,7 @@
               for (int i = 0; i < ${collName}.size(); i++)
               {
                   ((${tblFK.JavaName}) ${collName}.get(i))
  -                    .set${colFK.JavaName}(v);
  +                        .set${colFK.JavaName}(v);
               }
           }
           #end
  @@ -267,42 +267,42 @@
         #set ( $colFK = $tblFK.getColumn($colFKName) )
           if (v == null)
           {
  -        #if($colFK.Primitive)
  -          #set ($coldefval = "0")
  -          #set ($coldefval = $column.DefaultValue)
  +      #if($colFK.Primitive)
  +        #set ($coldefval = "0")
  +        #set ($coldefval = $column.DefaultValue)
               set${column.JavaName}($coldefval);
  -          #else
  +      #else
               set${column.JavaName}(($column.JavaNative) null);
  -          #end
  +      #end
           }
           else
           {
               set${column.JavaName}(v.get${colFK.JavaName}());
           }
  -        #end
  +    #end
           $varName = v;
       }
   
  -        #set ( $and = "" )
  -        #set ( $comma = "" )
  -        #set ( $conditional = "" )
  -        #set ( $arglist = "" )
  -        #set ( $argsize = 0 )
  -        #foreach ($columnName in $fk.LocalColumns)
  -          #set ( $column = $table.getColumn($columnName) )
  -          #set ( $cjtype = $column.JavaNative )
  -          #set ( $clo=$column.UncapitalisedJavaName )
  -          #if ($cjtype == "short" || $cjtype == "int" || $cjtype == "long" || $cjtype ==
"byte" || $cjtype == "float" || $cjtype == "double")
  -            #set ( $conditional = "$conditional${and}this.${clo} > 0" )
  -          #else
  -            #set ( $conditional = "$conditional${and}!ObjectUtils.equals(this.${clo}, null)"
)
  -          #end
  -          #set ( $arglist = "$arglist${comma}this.$clo" )
  -          #set ( $and = " && " )
  -          #set ( $comma = ", " )
  -          #set ( $argsize = $argsize + 1 )
  -        #end
  -      #set ( $pCollName = "${table.JavaName}s$relCol" )
  +    #set ( $and = "" )
  +    #set ( $comma = "" )
  +    #set ( $conditional = "" )
  +    #set ( $arglist = "" )
  +    #set ( $argsize = 0 )
  +    #foreach ($columnName in $fk.LocalColumns)
  +      #set ( $column = $table.getColumn($columnName) )
  +      #set ( $cjtype = $column.JavaNative )
  +      #set ( $clo=$column.UncapitalisedJavaName )
  +      #if ($cjtype == "short" || $cjtype == "int" || $cjtype == "long" || $cjtype == "byte"
|| $cjtype == "float" || $cjtype == "double")
  +        #set ( $conditional = "$conditional${and}this.${clo} > 0" )
  +      #else
  +        #set ( $conditional = "$conditional${and}!ObjectUtils.equals(this.${clo}, null)"
)
  +      #end
  +      #set ( $arglist = "$arglist${comma}this.$clo" )
  +      #set ( $and = " && " )
  +      #set ( $comma = ", " )
  +      #set ( $argsize = $argsize + 1 )
  +    #end
  +    #set ( $pCollName = "${table.JavaName}s$relCol" )
   
       /**
        * Get the associated $className object
  @@ -346,95 +346,95 @@
        * ObjectKey.  e.g.
        * <code>bar.setFooKey(foo.getPrimaryKey())</code>
        *
  -      #if ($fk.LocalColumns.size() > 1)
  +    #if ($fk.LocalColumns.size() > 1)
        * Note: It is important that the xml schema used to create this class
        * maintains consistency in the order of related columns between
        * $table.Name and ${tblFK.Name}.
        * If for some reason this is impossible, this method should be
        * overridden in <code>$table.JavaName</code>.
  -      #end
  +    #end
        */
       public void set${pVarName}Key(ObjectKey key) throws TorqueException
       {
  -      #if ($fk.LocalColumns.size() > 1)
  +    #if ($fk.LocalColumns.size() > 1)
           SimpleKey[] keys = (SimpleKey[]) key.getValue();
  -        #set ($i = 0)
  -        #foreach ($colName in $fk.LocalColumns)
  -          #set ($col = $table.getColumn($colName) )
  -
  -          #set ($fktype = $col.JavaNative)
  -          #if ($fktype == "short")
  +      #set ($i = 0)
  +      #foreach ($colName in $fk.LocalColumns)
  +        #set ($col = $table.getColumn($colName) )
  +        #set ($fktype = $col.JavaNative)
  +        #if ($fktype == "short")
           set${col.JavaName}(((NumberKey) keys[$i]).shortValue());
  -          #elseif($fktype == "int")
  +        #elseif($fktype == "int")
           set${col.JavaName}(((NumberKey) keys[$i]).intValue());
  -          #elseif($fktype == "long")
  +        #elseif($fktype == "long")
           set${col.JavaName}(((NumberKey) keys[$i]).longValue());
  -          #elseif($fktype == "BigDecimal")
  +        #elseif($fktype == "BigDecimal")
           set${col.JavaName}(((NumberKey) keys[$i]).getBigDecimal());
  -          #elseif($fktype == "byte") )
  +        #elseif($fktype == "byte") )
           set${col.JavaName}(((NumberKey) keys[$i]).byteValue());
  -          #elseif($fktype == "float")
  +        #elseif($fktype == "float")
           set${col.JavaName}(((NumberKey) keys[$i]).floatValue());
  -          #elseif($fktype == "double")
  +        #elseif($fktype == "double")
           set${col.JavaName}(((NumberKey) keys[$i]).doubleValue());
  -          #elseif($fktype == "Short")
  +        #elseif($fktype == "Short")
           set${col.JavaName}(new Short(((NumberKey) keys[$i]).shortValue()));
  -          #elseif($fktype == "Integer")
  +        #elseif($fktype == "Integer")
           set${col.JavaName}(new Integer(((NumberKey) keys[$i]).intValue()));
  -          #elseif($fktype == "Long")
  +        #elseif($fktype == "Long")
           set${col.JavaName}(new Long(((NumberKey) keys[$i]).longValue()));
  -          #elseif($fktype == "Byte") )
  +        #elseif($fktype == "Byte") )
           set${col.JavaName}(new Byte(((NumberKey) keys[$i]).byteValue()));
  -          #elseif($fktype == "Float")
  +        #elseif($fktype == "Float")
           set${col.JavaName}(new Float(((NumberKey) keys[$i]).floatValue()));
  -          #elseif($fktype == "Double")
  +        #elseif($fktype == "Double")
           set${col.JavaName}(new Double(((NumberKey) keys[$i]).doubleValue()));
  -          #elseif($fktype == "String")
  +        #elseif($fktype == "String")
           set${col.JavaName}(keys[$i].toString());
  -          #elseif($fktype == "Date")
  +        #elseif($fktype == "Date")
           set${col.JavaName}(((DateKey)keys[$i]).getDate());
  -          #end
  -          #set ( $i = $i + 1 )
           #end
  -      #else
  -        #set ($colName = $fk.LocalColumns.get(0))
  -        #set ($col = $table.getColumn($colName) )
   
  -        #set ($fktype = $col.JavaNative)
  -        #if ($fktype == "short")
  +        #set ( $i = $i + 1 )
  +      #end
  +    #else
  +      #set ($colName = $fk.LocalColumns.get(0))
  +      #set ($col = $table.getColumn($colName) )
  +
  +      #set ($fktype = $col.JavaNative)
  +      #if ($fktype == "short")
           set${col.JavaName}(((NumberKey) key).shortValue());
  -        #elseif($fktype == "int")
  +      #elseif($fktype == "int")
           set${col.JavaName}(((NumberKey) key).intValue());
  -        #elseif($fktype == "long")
  +      #elseif($fktype == "long")
           set${col.JavaName}(((NumberKey) key).longValue());
  -        #elseif($fktype == "BigDecimal")
  +      #elseif($fktype == "BigDecimal")
           set${col.JavaName}(((NumberKey) key).getBigDecimal());
  -        #elseif($fktype == "byte") )
  +      #elseif($fktype == "byte") )
           set${col.JavaName}(((NumberKey) key).byteValue());
  -        #elseif($fktype == "float")
  +      #elseif($fktype == "float")
           set${col.JavaName}(((NumberKey) key).floatValue());
  -        #elseif($fktype == "double")
  +      #elseif($fktype == "double")
           set${col.JavaName}(((NumberKey) key).doubleValue());
  -        #elseif($fktype == "Short")
  +      #elseif($fktype == "Short")
           set${col.JavaName}(new Short(((NumberKey) key).shortValue()));
  -        #elseif($fktype == "Integer")
  +      #elseif($fktype == "Integer")
           set${col.JavaName}(new Integer(((NumberKey) key).intValue()));
  -        #elseif($fktype == "Long")
  +      #elseif($fktype == "Long")
           set${col.JavaName}(new Long(((NumberKey) key).longValue()));
  -        #elseif($fktype == "Byte") )
  +      #elseif($fktype == "Byte") )
           set${col.JavaName}(new Byte(((NumberKey) key).byteValue()));
  -        #elseif($fktype == "Float")
  +      #elseif($fktype == "Float")
           set${col.JavaName}(new Float(((NumberKey) key).floatValue()));
  -        #elseif($fktype == "Double")
  +      #elseif($fktype == "Double")
           set${col.JavaName}(new Double(((NumberKey) key).doubleValue()));
  -        #elseif($fktype == "String")
  +      #elseif($fktype == "String")
           set${col.JavaName}(key.toString());
  -        #elseif($fktype == "Date")
  +      #elseif($fktype == "Date")
           set${col.JavaName}(((DateKey)key).getDate());
  -        #end
         #end
  +    #end
       }
  -    #end   ## end of foreach loop over foreign keys
  +  #end   ## end of foreach loop over foreign keys
   
     ##
     ## setup foreign key associations
  @@ -1185,7 +1185,6 @@
   
   ## PrimaryKey methods
   #if (!$table.isAlias())
  -
     #set ( $throwsClause = "" )
     #set ( $argList = "" )
     #set ( $argList2 = "" )
  @@ -1210,7 +1209,7 @@
       /**
        * Set the PrimaryKey using ObjectKey.
        *
  -     * @param  $clo ObjectKey
  +     * @param $clo ObjectKey
        */
       public void setPrimaryKey(ObjectKey key)
           $throwsClause
  @@ -1296,7 +1295,7 @@
   
       private final SimpleKey[] pks = new SimpleKey[$table.PrimaryKey.size()];
       private final ComboKey comboPK = new ComboKey(pks);
  -    
  +
       /**
        * Set the PrimaryKey with an ObjectKey
        *
  @@ -1389,7 +1388,6 @@
           return null;
     #end
       }
  -
   #end ##ends if(!$table.isAlias())
   
   #if ($addIntakeRetrievable)
  @@ -1492,7 +1490,6 @@
         #end
       #end
     #end
  -
           return copyObj;
       }
   #end
  
  
  
  1.6       +92 -44    db-torque/src/generator/src/templates/om/ObjectWithManager.vm
  
  Index: ObjectWithManager.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/om/ObjectWithManager.vm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ObjectWithManager.vm	19 Aug 2003 09:48:51 -0000	1.5
  +++ ObjectWithManager.vm	21 Jan 2004 19:57:22 -0000	1.6
  @@ -68,6 +68,7 @@
           new ${table.JavaName}Peer();
   
   #if (!$table.isAlias())
  +  ## member variables
     #foreach ($col in $table.Columns)
       #set ( $cjtype = $col.JavaNative )
       #set ( $clo=$col.UncapitalisedJavaName )
  @@ -93,11 +94,13 @@
         #elseif ($cjtype == "StringKey")
           #set ( $quote = '"' )
           #set ($defVal = "= new StringKey($quote$defaultValue$quote)")
  +      #elseif ($cjtype == 'Byte')
  +        #set ($defVal = "= new ${cjtype}((byte) $defaultValue)")
         #else
           #if (!$col.isPrimitive() && $cjtype != "String")
             #set ( $defaultValue = "new ${cjtype}($defaultValue)" )
           #end
  -        #set ($defVal = "=$quote$defaultValue$quote")
  +        #set ($defVal = " = $quote$defaultValue$quote")
         #end
       #end
   
  @@ -105,6 +108,7 @@
       private $cjtype $clo$defVal;
     #end
   
  +  ## getter and setter methods
     #foreach ($col in $table.Columns)
       #set ( $cfc=$col.JavaName )
       #set ( $clo=$col.UncapitalisedJavaName )
  @@ -112,6 +116,7 @@
   
       /**
        * Get the $cfc
  +     *
        * @return $cjtype
        */
       public $cjtype get${cfc}()
  @@ -133,8 +138,10 @@
   
       /**
        * Set the value of $cfc
  +     *
  +     * @param v new value
        */
  -    public void set${cfc}($cjtype v ) $throwsClause
  +    public void set${cfc}($cjtype v) $throwsClause
       {
       #if (($cjtype == "NumberKey") || ($cjtype == "StringKey") || ($cjtype == "DateKey"))
           if (v != null && v.getValue() == null)
  @@ -207,11 +214,11 @@
             #end
   
           // update associated $tblFK.JavaName
  -        if ($collName != null )
  +        if ($collName != null)
           {
               for (int i = 0; i < ${collName}.size(); i++)
               {
  -                ((${tblFK.JavaName})${collName}.get(i))
  +                ((${tblFK.JavaName}) ${collName}.get(i))
                           .set${colFK.JavaName}(v);
               }
           }
  @@ -219,7 +226,6 @@
         #end
       #end
       }
  -
     #end
   #end
   
  @@ -255,6 +261,7 @@
        * Declares an association between this object and a $interfaceName object
        *
        * @param $interfaceName v
  +     * @throws TorqueException
        */
       public void set${pVarName}($interfaceName v) throws TorqueException
       {
  @@ -269,7 +276,7 @@
           #set ($coldefval = $column.DefaultValue)
               set${column.JavaName}($coldefval);
         #else
  -            set${column.JavaName}(($column.JavaNative)null);
  +            set${column.JavaName}(($column.JavaNative) null);
         #end
           }
           else
  @@ -330,7 +337,7 @@
       public void set${pVarName}Key(ObjectKey key) throws TorqueException
       {
       #if ($fk.LocalColumns.size() > 1)
  -        SimpleKey[] keys = (SimpleKey[])key.getValue();
  +        SimpleKey[] keys = (SimpleKey[]) key.getValue();
         #set ($i = 0)
         #foreach ($colName in $fk.LocalColumns)
           #set ($col = $table.getColumn($colName) )
  @@ -407,7 +414,6 @@
         #end
       #end
       }
  -
     #end   ## end of foreach loop over foreign keys
   
     ##
  @@ -463,7 +469,8 @@
        * Method called to associate a $tblFK.JavaName object to this object
        * through the $className foreign key attribute
        *
  -     * @param $className l
  +     * @param l $className
  +     * @throws TorqueException
        */
       public void add${relColMs}($className l) throws TorqueException
       {
  @@ -480,6 +487,8 @@
        * If this collection has already been initialized, returns
        * the collection. Otherwise returns the results of
        * get${relCol}(new Criteria())
  +     *
  +     * @throws TorqueException
        */
       public List get${relCol}() throws TorqueException
       {
  @@ -498,6 +507,8 @@
        * If this $table.JavaName is new, it will return
        * an empty collection or the current collection, the criteria
        * is ignored on a new object.
  +     *
  +     * @throws TorqueException
        */
       public List get${relCol}(Criteria criteria) throws TorqueException
       {
  @@ -530,7 +541,7 @@
           #set ( $column = $table.getColumn($columnName) )
           #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
           #set ( $colFK = $tblFK.getColumn($colFKName) )
  -                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}()
);
  +                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
         #end
                   if (!last${relCol}Criteria.equals(criteria))
                   {
  @@ -555,7 +566,7 @@
       {
           if ($collName == null)
           {
  -            $collName = get${relCol}(new Criteria(10),con);
  +            $collName = get${relCol}(new Criteria(10), con);
           }
           return $collName;
       }
  @@ -572,7 +583,8 @@
        * referenced objects can also be obtained using a Connection
        * that is taken as input
        */
  -    public List get${relCol}(Criteria criteria,Connection con) throws TorqueException
  +    public List get${relCol}(Criteria criteria, Connection con)
  +            throws TorqueException
       {
           if ($collName == null)
           {
  @@ -586,9 +598,9 @@
           #set ( $column = $table.getColumn($columnName) )
           #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
           #set ( $colFK = $tblFK.getColumn($colFKName) )
  -                 criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}()
);
  +                 criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
         #end
  -                 $collName = ${className}Peer.doSelect(criteria,con);
  +                 $collName = ${className}Peer.doSelect(criteria, con);
                }
            }
            else
  @@ -599,15 +611,15 @@
                    // the following code is to determine if a new query is
                    // called for.  If the criteria is the same as the last
                    // one, just return the collection.
  -    #foreach ($columnName in $fk.ForeignColumns)
  +      #foreach ($columnName in $fk.ForeignColumns)
           #set ( $column = $table.getColumn($columnName) )
           #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
           #set ( $colFK = $tblFK.getColumn($colFKName) )
  -                 criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}()
);
  -    #end
  +                 criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
  +      #end
                    if (!last${relCol}Criteria.equals(criteria))
                    {
  -                     $collName = ${className}Peer.doSelect(criteria,con);
  +                     $collName = ${className}Peer.doSelect(criteria, con);
                    }
                }
            }
  @@ -623,7 +635,6 @@
   
   ## ------------------------------------------------------------
   ##
  -
         #if ($countFK >= 1)
           #set ( $lastTable = "" )
           #foreach ($fk2 in $tblFK.ForeignKeys)
  @@ -705,7 +716,7 @@
                 #set ( $column = $table.getColumn($columnName) )
                 #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
                 #set ( $colFK = $tblFK.getColumn($colFKName) )
  -                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}()
);
  +                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
               #end
                   $collName = ${className}Peer.doSelectJoin${relCol2}(criteria);
               }
  @@ -720,7 +731,7 @@
                 #set ( $column = $table.getColumn($columnName) )
                 #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
                 #set ( $colFK = $tblFK.getColumn($colFKName) )
  -                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}()
);
  +                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
               #end
               if (!last${relCol}Criteria.equals(criteria))
               {
  @@ -756,7 +767,7 @@
       {
           if ($collName == null)
           {
  -            if ( isNew() )
  +            if (isNew())
               {
                  $collName = new ArrayList();
               }
  @@ -766,7 +777,7 @@
          #set ( $column = $table.getColumn($columnName) )
          #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
          #set ( $colFK = $tblFK.getColumn($colFKName) )
  -                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}()
);
  +                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
      #end
                   $collName = ${className}Peer.doSelectJoinAllExcept${table.JavaName}${suffix}(criteria);
               }
  @@ -781,9 +792,9 @@
          #set ( $column = $table.getColumn($columnName) )
          #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
          #set ( $colFK = $tblFK.getColumn($colFKName) )
  -                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}()
);
  +                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
      #end
  -            if ( !last${relCol}Criteria.equals(criteria)  )
  +            if (!last${relCol}Criteria.equals(criteria))
               {
                   $collName = ${className}Peer.doSelectJoinAllExcept${table.JavaName}${suffix}(criteria);
               }
  @@ -809,6 +820,8 @@
   
       /**
        * Generate a list of field names.
  +     *
  +     * @return a list of field names
        */
       public static synchronized List getFieldNames()
       {
  @@ -824,8 +837,10 @@
       }
   
       /**
  -     * Retrieves a field from the object by name passed in
  -     * as a String.
  +     * Retrieves a field from the object by name passed in as a String.
  +     *
  +     * @param name field name
  +     * @return value
        */
       public Object getByName(String name)
       {
  @@ -862,6 +877,9 @@
        * Retrieves a field from the object by name passed in
        * as a String.  The String must be one of the static
        * Strings defined in this Class' Peer.
  +     *
  +     * @param name peer name
  +     * @return value
        */
       public Object getByPeerName(String name)
       {
  @@ -869,7 +887,7 @@
       #set ( $cfc = $col.JavaName )
       #set ( $cup=$col.Name.toUpperCase() )
       #set ( $cjtype = $col.JavaNative )
  -        if (name.equals(${table.JavaName}Peer.$cup ))
  +        if (name.equals(${table.JavaName}Peer.$cup))
           {
       #if ($cjtype == "int")
               return new Integer(get${cfc}());
  @@ -898,6 +916,9 @@
       /**
        * Retrieves a field from the object by Position as specified
        * in the xml schema.  Zero-based.
  +     *
  +     * @param pos position in xml schema
  +     * @return value
        */
       public Object getByPosition(int pos)
       {
  @@ -905,7 +926,7 @@
     #foreach ($col in $table.Columns)
       #set ( $cfc = $col.JavaName )
       #set ( $cjtype = $col.JavaNative )
  -        if ( pos == $i )
  +        if (pos == $i)
           {
       #if ($cjtype == "int")
               return new Integer(get${cfc}());
  @@ -937,6 +958,8 @@
       /**
        * Stores the object in the database.  If the object is new,
        * it inserts it; otherwise an update is performed.
  +     *
  +     * @throws $saveException
        */
       public void save() throws $saveException
       {
  @@ -948,12 +971,12 @@
           {
               if (isNew())
               {
  -                ${table.JavaName}Peer.doInsert(($table.JavaName)this);
  +                ${table.JavaName}Peer.doInsert(($table.JavaName) this);
                   setNew(false);
               }
               else
               {
  -                ${table.JavaName}Peer.doUpdate(($table.JavaName)this);
  +                ${table.JavaName}Peer.doUpdate(($table.JavaName) this);
               }
           }
     #end
  @@ -967,6 +990,9 @@
        * auto-generated conditionally and therefore needs to be
        * in this file instead of in the super class, BaseObject.
     #end
  +     *
  +     * @param dbName
  +     * @throws TorqueException
        */
       public void save(String dbName) throws TorqueException
       {
  @@ -988,17 +1014,17 @@
           {
               try
               {
  -                con = Torque.getConnection( dbName );
  +                con = Torque.getConnection(dbName);
                   if (isNew())
                   {
                       ${table.JavaName}Peer
  -                        .doInsert(($table.JavaName)this, con);
  +                        .doInsert(($table.JavaName) this, con);
                       setNew(false);
                   }
                   else
                   {
                       ${table.JavaName}Peer
  -                        .doUpdate(($table.JavaName)this, con);
  +                        .doUpdate(($table.JavaName) this, con);
                   }
               }
               finally
  @@ -1020,6 +1046,9 @@
        * is meant to be used as part of a transaction, otherwise use
        * the save() method and the connection details will be handled
        * internally
  +     *
  +     * @param con
  +     * @throws TorqueException
        */
       public void save(Connection con) throws TorqueException
       {
  @@ -1057,12 +1086,12 @@
               {
                   if (isNew())
                   {
  -                    ${table.JavaName}Peer.doInsert(($table.JavaName)this, con);
  +                    ${table.JavaName}Peer.doInsert(($table.JavaName) this, con);
                       setNew(false);
                   }
                   else
                   {
  -                    ${table.JavaName}Peer.doUpdate(($table.JavaName)this, con);
  +                    ${table.JavaName}Peer.doUpdate(($table.JavaName) this, con);
                   }
   
     #if ($table.PrimaryKey.size() > 0)
  @@ -1096,11 +1125,11 @@
             #set ( $relCol = "${className}sRelatedBy$relCol" )
           #end
           #set ( $collName = "coll$relCol" )
  -            if ($collName != null )
  +            if ($collName != null)
               {
                   for (int i = 0; i < ${collName}.size(); i++)
                   {
  -                    ((${className})${collName}.get(i)).save(con);
  +                    ((${className}) ${collName}.get(i)).save(con);
                   }
               }
         #end
  @@ -1150,10 +1179,11 @@
       /**
        * Set the PrimaryKey using ObjectKey.
        *
  -     * @param ObjectKey $clo
  +     * @param $clo ObjectKey
        */
       public void setPrimaryKey(ObjectKey $clo)
  -        $throwsClause {
  +        $throwsClause
  +    {
       #if ($cjtype == "short")
           set${col.JavaName}(((NumberKey)$clo).shortValue());
       #elseif($cjtype == "int")
  @@ -1191,6 +1221,8 @@
   
       /**
        * Set the PrimaryKey using a String.
  +     *
  +     * @param key
        */
       public void setPrimaryKey(String key) $throwsClause
       {
  @@ -1233,8 +1265,11 @@
   
       private final SimpleKey[] pks = new SimpleKey[$table.PrimaryKey.size()];
       private final ComboKey comboPK = new ComboKey(pks);
  +
       /**
        * Set the PrimaryKey with an ObjectKey
  +     *
  +     * @param key
        */
       public void setPrimaryKey(ObjectKey key) throws TorqueException
       {
  @@ -1288,7 +1323,7 @@
       #end
        */
       public void setPrimaryKey($argList)
  -        $throwsClause 
  +        $throwsClause
       {
       #foreach ($col in $table.PrimaryKey)
           set${col.JavaName}($col.UncapitalisedJavaName);
  @@ -1358,7 +1393,8 @@
        * 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.
  +     * It then fills all the association collections and sets the
  +     * related objects to isNew=true.
     #end
        */
     #if ($table.ChildrenColumn || $table.isAbstract())
  @@ -1378,11 +1414,11 @@
         #if($col.Primitive)
           #set ($coldefval = "0")
           #set ($coldefval = $col.DefaultValue)
  -          copyObj.set${col.JavaName}($coldefval);
  +        copyObj.set${col.JavaName}($coldefval);
         #else
           #set ( $pkid = "null" )
           #set ( $cjtype = $col.JavaNative )
  -          copyObj.set${col.JavaName}((${cjtype})${pkid});
  +        copyObj.set${col.JavaName}((${cjtype})${pkid});
         #end
       #end
     #end
  @@ -1435,4 +1471,16 @@
           return peer;
       }
   #end
  +
  +    public String toString()
  +    {
  +        StringBuffer str = new StringBuffer();
  +        str.append("$table.JavaName:\n");
  +#foreach ($col in $table.Columns)
  +        str.append("$col.JavaName = ")
  +           .append(get${col.JavaName}())
  +           .append("\n");
  +#end
  +        return(str.toString());
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message