db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject cvs commit: db-torque/src/generator/src/templates/om ObjectWithManager.vm
Date Wed, 16 Mar 2005 07:11:34 GMT
tfischer    2005/03/15 23:11:34

  Modified:    xdocs    changes.xml
               src/generator/src/templates/om ObjectWithManager.vm
  Log:
  Synchronizing Object.vm with ObjectWithManager.vm, second bit
  Thanks to Thomas Vandahl for the patch
  See TRQS289
  
  Revision  Changes    Path
  1.149     +10 -1     db-torque/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/db-torque/xdocs/changes.xml,v
  retrieving revision 1.148
  retrieving revision 1.149
  diff -u -r1.148 -r1.149
  --- changes.xml	14 Mar 2005 09:37:08 -0000	1.148
  +++ changes.xml	16 Mar 2005 07:11:34 -0000	1.149
  @@ -30,7 +30,16 @@
     <release version="3.2-dev" date="in CVS">
       <action type="add" dev="tfischer">
         TRQS289: Added Thomas Vandahl's Patch to synchronize Object.vm
  -      to ObjectWithManager.vm.
  +      with ObjectWithManager.vm.
  +      This contains the following:
  +      <ul>
  +        <li>The interface attribute is now supported for objects without managers</li>
  +        <li>The correctSetters now also work for objects with managers</li>
  +        <li>The behavior for objectIsCaching=false for objects with managers
  +          now matches the behaviour of objects without managers</li>
  +        <li>tabs and spaces formatting</li>
  +      </ul>
  +      
       </action>
       <action type="add" dev="tfischer">
         TRQS263: Add support for oracle datatype timestamp; 
  
  
  
  1.18      +220 -150  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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ObjectWithManager.vm	16 Feb 2005 09:24:11 -0000	1.17
  +++ ObjectWithManager.vm	16 Mar 2005 07:11:34 -0000	1.18
  @@ -196,9 +196,9 @@
           #end
   
           #if($colFK.Primitive)
  -        if ($varName != null && !(${varName}.get${colFK.JavaName}() == v))
  +        if ($varName != null && !(${varName}.${colFK.GetterName}() == v))
           #else
  -        if ($varName != null && !ObjectUtils.equals(${varName}.get${colFK.JavaName}(),
v))
  +        if ($varName != null && !ObjectUtils.equals(${varName}.${colFK.GetterName}(),
v))
           #end
           {
               $varName = null;
  @@ -216,15 +216,17 @@
               #set ( $collName = "coll${tblFK.JavaName}s" )
             #end
   
  +          #if ($objectIsCaching)
           // update associated $tblFK.JavaName
           if ($collName != null)
           {
               for (int i = 0; i < ${collName}.size(); i++)
               {
                   ((${tblFK.JavaName}) ${collName}.get(i))
  -                        .set${colFK.JavaName}(v);
  +                        .${colFK.SetterName}(v);
               }
           }
  +          #end
           #end
         #end
       #end
  @@ -256,8 +258,11 @@
       #if ($relCol != "")
         #set ( $relCol = "RelatedBy$relCol" )
       #end
  +
       #set ( $pVarName = "$interfaceName$relCol" )
       #set ( $varName = "a$pVarName" )
  +    #set ( $retVal = $pVars.add($pVarName) )
  +    #set ( $retVal = $aVars.add($varName) )
       private $interfaceName $varName;
   
       /**
  @@ -284,14 +289,14 @@
           #end
           #set ($coldefval =  "0") 
           #set ($coldefval = $column.DefaultValue)
  -            set${column.JavaName}($casttype $coldefval);
  +            ${column.SetterName}($casttype $coldefval);
         #else
  -            set${column.JavaName}(($column.JavaNative) null);
  +            ${column.SetterName}(($column.JavaNative) null);
         #end
           }
           else
           {
  -            set${column.JavaName}(v.get${colFK.JavaName}());
  +            ${column.SetterName}(v.${colFK.GetterName}());
           }
       #end
           $varName = v;
  @@ -307,11 +312,11 @@
         #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}get${column.JavaName}()>0" )
  +        #set ( $conditional = "$conditional${and}this.${clo} != 0" )
         #else
  -        #set ( $conditional = "$conditional${and}!ObjectUtils.equals(get${column.JavaName}(),
null)" )
  +        #set ( $conditional = "$conditional${and}!ObjectUtils.equals(this.${clo}, null)"
)
         #end
  -      #set ( $arglist = "$arglist${comma}SimpleKey.keyFor(get${column.JavaName}())" )
  +      #set ( $arglist = "$arglist${comma}SimpleKey.keyFor(this.${clo})" )
         #set ( $and = " && " )
         #set ( $comma = ", " )
         #set ( $argsize = $argsize + 1 )
  @@ -325,7 +330,7 @@
        */
       public $interfaceName get${pVarName}() throws TorqueException
       {
  -        if ( $conditional )
  +        if ($varName == null && ($conditional))
           {
       #if ($argsize > 1)
               SimpleKey[] keys = { $arglist };
  @@ -359,35 +364,35 @@
           #set ($col = $table.getColumn($colName) )
           #set ($fktype = $col.JavaNative)
           #if ($fktype == "short")
  -        set${col.JavaName}(((NumberKey) keys[$i]).shortValue());
  +        ${col.SetterName}(((NumberKey) keys[$i]).shortValue());
           #elseif($fktype == "int")
  -        set${col.JavaName}(((NumberKey) keys[$i]).intValue());
  +        ${col.SetterName}(((NumberKey) keys[$i]).intValue());
           #elseif($fktype == "long")
  -        set${col.JavaName}(((NumberKey) keys[$i]).longValue());
  +        ${col.SetterName}(((NumberKey) keys[$i]).longValue());
           #elseif($fktype == "BigDecimal")
  -        set${col.JavaName}(((NumberKey) keys[$i]).getBigDecimal());
  +        ${col.SetterName}(((NumberKey) keys[$i]).getBigDecimal());
           #elseif($fktype == "byte")
  -        set${col.JavaName}(((NumberKey) keys[$i]).byteValue());
  +        ${col.SetterName}(((NumberKey) keys[$i]).byteValue());
           #elseif($fktype == "float")
  -        set${col.JavaName}(((NumberKey) keys[$i]).floatValue());
  +        ${col.SetterName}(((NumberKey) keys[$i]).floatValue());
           #elseif($fktype == "double")
  -        set${col.JavaName}(((NumberKey) keys[$i]).doubleValue());
  +        ${col.SetterName}(((NumberKey) keys[$i]).doubleValue());
           #elseif($fktype == "Short")
  -        set${col.JavaName}(new Short(((NumberKey) keys[$i]).shortValue()));
  +        ${col.SetterName}(new Short(((NumberKey) keys[$i]).shortValue()));
           #elseif($fktype == "Integer")
  -        set${col.JavaName}(new Integer(((NumberKey) keys[$i]).intValue()));
  +        ${col.SetterName}(new Integer(((NumberKey) keys[$i]).intValue()));
           #elseif($fktype == "Long")
  -        set${col.JavaName}(new Long(((NumberKey) keys[$i]).longValue()));
  +        ${col.SetterName}(new Long(((NumberKey) keys[$i]).longValue()));
           #elseif($fktype == "Byte")
  -        set${col.JavaName}(new Byte(((NumberKey) keys[$i]).byteValue()));
  +        ${col.SetterName}(new Byte(((NumberKey) keys[$i]).byteValue()));
           #elseif($fktype == "Float")
  -        set${col.JavaName}(new Float(((NumberKey) keys[$i]).floatValue()));
  +        ${col.SetterName}(new Float(((NumberKey) keys[$i]).floatValue()));
           #elseif($fktype == "Double")
  -        set${col.JavaName}(new Double(((NumberKey) keys[$i]).doubleValue()));
  +        ${col.SetterName}(new Double(((NumberKey) keys[$i]).doubleValue()));
           #elseif($fktype == "String")
  -        set${col.JavaName}(keys[$i].toString());
  +        ${col.SetterName}(keys[$i].toString());
           #elseif($fktype == "Date")
  -        set${col.JavaName}(((DateKey)keys[$i]).getDate());
  +        ${col.SetterName}(((DateKey)keys[$i]).getDate());
           #end
   
           #set ( $i = $i + 1 )
  @@ -398,35 +403,35 @@
   
         #set ($fktype = $col.JavaNative)
         #if ($fktype == "short")
  -        set${col.JavaName}(((NumberKey) key).shortValue());
  +        ${col.SetterName}(((NumberKey) key).shortValue());
         #elseif($fktype == "int")
  -        set${col.JavaName}(((NumberKey) key).intValue());
  +        ${col.SetterName}(((NumberKey) key).intValue());
         #elseif($fktype == "long")
  -        set${col.JavaName}(((NumberKey) key).longValue());
  +        ${col.SetterName}(((NumberKey) key).longValue());
         #elseif($fktype == "BigDecimal")
  -        set${col.JavaName}(((NumberKey) key).getBigDecimal());
  +        ${col.SetterName}(((NumberKey) key).getBigDecimal());
         #elseif($fktype == "byte")
  -        set${col.JavaName}(((NumberKey) key).byteValue());
  +        ${col.SetterName}(((NumberKey) key).byteValue());
         #elseif($fktype == "float")
  -        set${col.JavaName}(((NumberKey) key).floatValue());
  +        ${col.SetterName}(((NumberKey) key).floatValue());
         #elseif($fktype == "double")
  -        set${col.JavaName}(((NumberKey) key).doubleValue());
  +        ${col.SetterName}(((NumberKey) key).doubleValue());
         #elseif($fktype == "Short")
  -        set${col.JavaName}(new Short(((NumberKey) key).shortValue()));
  +        ${col.SetterName}(new Short(((NumberKey) key).shortValue()));
         #elseif($fktype == "Integer")
  -        set${col.JavaName}(new Integer(((NumberKey) key).intValue()));
  +        ${col.SetterName}(new Integer(((NumberKey) key).intValue()));
         #elseif($fktype == "Long")
  -        set${col.JavaName}(new Long(((NumberKey) key).longValue()));
  +        ${col.SetterName}(new Long(((NumberKey) key).longValue()));
         #elseif($fktype == "Byte")
  -        set${col.JavaName}(new Byte(((NumberKey) key).byteValue()));
  +        ${col.SetterName}(new Byte(((NumberKey) key).byteValue()));
         #elseif($fktype == "Float")
  -        set${col.JavaName}(new Float(((NumberKey) key).floatValue()));
  +        ${col.SetterName}(new Float(((NumberKey) key).floatValue()));
         #elseif($fktype == "Double")
  -        set${col.JavaName}(new Double(((NumberKey) key).doubleValue()));
  +        ${col.SetterName}(new Double(((NumberKey) key).doubleValue()));
         #elseif($fktype == "String")
  -        set${col.JavaName}(key.toString());
  +        ${col.SetterName}(key.toString());
         #elseif($fktype == "Date")
  -        set${col.JavaName}(((DateKey)key).getDate());
  +        ${col.SetterName}(((DateKey)key).getDate());
         #end
       #end
       }
  @@ -458,6 +463,7 @@
         #end
         #set ( $collName = "coll$relCol" )
   
  +      #if ($objectIsCaching)
       /**
        * Collection to store aggregation of $collName
        */
  @@ -476,10 +482,10 @@
           }
       }
   
  -      #set ($interfaceName = $table.JavaName)
  -      #if ($table.Interface)
  -        #set ($interfaceName = $table.Interface)
  -      #end
  +        #set ($interfaceName = $table.JavaName)
  +        #if ($table.Interface)
  +          #set ($interfaceName = $table.Interface)
  +        #end
   
       /**
        * Method called to associate a $tblFK.JavaName object to this object
  @@ -491,34 +497,47 @@
       public void add${relColMs}($className l) throws TorqueException
       {
           get${relCol}().add(l);
  -        l.set${interfaceName}${suffix}(($table.JavaName)this);
  +        l.set${interfaceName}${suffix}(($table.JavaName) this);
       }
   
       /**
        * The criteria used to select the current contents of $collName
        */
       private Criteria last${relCol}Criteria = null;
  +      #end
   
       /**
  +      #if ($objectIsCaching)
        * If this collection has already been initialized, returns
        * the collection. Otherwise returns the results of
        * get${relCol}(new Criteria())
  +      #else
  +     * A wrapper for get${relCol}(new Criteria())
  +      #end
        *
        * @throws TorqueException
        */
       public List get${relCol}() throws TorqueException
       {
  +      #if ($objectIsCaching)
           if ($collName == null)
           {
               $collName = get${relCol}(new Criteria(10));
           }
           return $collName;
  +      #else
  +        return get${relCol}(new Criteria(10));
  +      #end
       }
   
       /**
  +      #if ($objectIsCaching)
        * If this collection has already been initialized with
        * an identical criteria, it returns the collection.
        * Otherwise if this $table.JavaName has previously
  +      #else
  +     * If this $table.JavaName has previously
  +      #end
        * been saved, it will retrieve related ${relCol} from storage.
        * If this $table.JavaName is new, it will return
        * an empty collection or the current collection, the criteria
  @@ -528,6 +547,7 @@
        */
       public List get${relCol}(Criteria criteria) throws TorqueException
       {
  +      #if ($objectIsCaching)
           if ($collName == null)
           {
               if (isNew())
  @@ -536,12 +556,12 @@
               }
               else
               {
  -      #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
  +        #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()}, ${column.GetterName}()
);
  +        #end
                   $collName = ${className}Peer.doSelect(criteria);
               }
           }
  @@ -553,12 +573,14 @@
                   // 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.
  +      #end
         #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}());
  +                criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, ${column.GetterName}());
         #end
  +      #if ($objectIsCaching)
                   if (!last${relCol}Criteria.equals(criteria))
                   {
                       $collName = ${className}Peer.doSelect(criteria);
  @@ -568,29 +590,44 @@
           last${relCol}Criteria = criteria;
   
           return $collName;
  +      #else
  +                return ${className}Peer.doSelect(criteria);
  +      #end
       }
   
       /**
  +      #if ($objectIsCaching)
        * If this collection has already been initialized, returns
        * the collection. Otherwise returns the results of
        * get${relCol}(new Criteria(),Connection)
  +      #else
  +     * A wrapper for get${relCol}(new Criteria(),Connection)
  +      #end
        * This method takes in the Connection also as input so that
        * referenced objects can also be obtained using a Connection
        * that is taken as input
        */
       public List get${relCol}(Connection con) throws TorqueException
       {
  +      #if ($objectIsCaching)
           if ($collName == null)
           {
               $collName = get${relCol}(new Criteria(10), con);
           }
           return $collName;
  +      #else
  +        return get${relCol}(new Criteria(10), con);
  +      #end
       }
   
       /**
  +      #if ($objectIsCaching)
        * If this collection has already been initialized with
        * an identical criteria, it returns the collection.
        * Otherwise if this $table.JavaName has previously
  +      #else
  +     * If this $table.JavaName has previously
  +      #end
        * been saved, it will retrieve related ${relCol} from storage.
        * If this $table.JavaName is new, it will return
        * an empty collection or the current collection, the criteria
  @@ -602,6 +639,7 @@
       public List get${relCol}(Criteria criteria, Connection con)
               throws TorqueException
       {
  +      #if ($objectIsCaching)
           if ($collName == null)
           {
               if (isNew())
  @@ -610,12 +648,12 @@
               }
               else
               {
  -      #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
  +        #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()}, ${column.GetterName}());
  +        #end
                    $collName = ${className}Peer.doSelect(criteria, con);
                }
            }
  @@ -627,12 +665,14 @@
                    // 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.
  +      #end
         #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}());
  +                 criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, ${column.GetterName}());
         #end
  +      #if ($objectIsCaching)
                    if (!last${relCol}Criteria.equals(criteria))
                    {
                        $collName = ${className}Peer.doSelect(criteria, con);
  @@ -642,6 +682,9 @@
            last${relCol}Criteria = criteria;
   
            return $collName;
  +      #else
  +                 return ${className}Peer.doSelect(criteria, con);
  +      #end
        }
   
         #set ( $countFK = 0 )
  @@ -707,9 +750,13 @@
             #if ($doJoinGet)
   
       /**
  +            #if ($objectIsCaching)
        * If this collection has already been initialized with
        * an identical criteria, it returns the collection.
        * Otherwise if this $table.JavaName is new, it will return
  +            #else
  +     * If this $table.JavaName is new, this method will return
  +            #end
        * an empty collection; or if this $table.JavaName has previously
        * been saved, it will retrieve related ${relCol} from storage.
        *
  @@ -720,6 +767,7 @@
       protected List get${relCol}Join${relCol2}(Criteria criteria)
           throws TorqueException
       {
  +            #if ($objectIsCaching)
           if ($collName == null)
           {
               if (isNew())
  @@ -728,12 +776,12 @@
               }
               else
               {
  -            #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
  +              #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()}, ${column.GetterName}());
  +              #end
                   $collName = ${className}Peer.doSelectJoin${relCol2}(criteria);
               }
           }
  @@ -742,13 +790,14 @@
               // 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.
  -
  +            #end
               #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}());
  +            criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, ${column.GetterName}());
               #end
  +            #if ($objectIsCaching)
               if (!last${relCol}Criteria.equals(criteria))
               {
                   $collName = ${className}Peer.doSelectJoin${relCol2}(criteria);
  @@ -757,6 +806,9 @@
           last${relCol}Criteria = criteria;
   
           return $collName;
  +            #else
  +        return ${className}Peer.doSelectJoin${relCol2}(criteria);
  +            #end
       }
             #end 
           #end 
  @@ -768,9 +820,13 @@
     #if ($countFK > 2)
   
       /**
  +    #if ($objectIsCaching)
        * If this collection has already been initialized with
        * an identical criteria, it returns the collection.
        * Otherwise if this $table.JavaName is new, it will return
  +    #else
  +     * If this $table.JavaName is new, this method will return
  +    #end
        * an empty collection; or if this $table.JavaName has previously
        * been saved, it will retrieve related ${relCol} from storage.
        *
  @@ -781,6 +837,7 @@
       protected List get${relCol}JoinAllExcept${table.JavaName}(Criteria criteria)
           throws TorqueException
       {
  +    #if ($objectIsCaching)
           if ($collName == null)
           {
               if (isNew())
  @@ -789,12 +846,12 @@
               }
               else
               {
  -   #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
  +      #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()}, ${column.GetterName}());
  +      #end
                   $collName = ${className}Peer.doSelectJoinAllExcept${table.JavaName}${suffix}(criteria);
               }
           }
  @@ -803,13 +860,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.
  +    #end
   
  -   #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
  +    #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()}, ${column.GetterName}());
  +    #end
  +    #if ($objectIsCaching)
               if (!last${relCol}Criteria.equals(criteria))
               {
                   $collName = ${className}Peer.doSelectJoinAllExcept${table.JavaName}${suffix}(criteria);
  @@ -818,6 +877,9 @@
           last${relCol}Criteria = criteria;
   
           return $collName;
  +    #else 
  +        return ${className}Peer.doSelectJoinAllExcept${table.JavaName}${suffix}(criteria);
  +    #end
       }
   
     #end
  @@ -1144,6 +1206,7 @@
             #set ( $relCol = "${className}sRelatedBy$relCol" )
           #end
           #set ( $collName = "coll$relCol" )
  +        #if ($objectIsCaching)
               if ($collName != null)
               {
                   for (int i = 0; i < ${collName}.size(); i++)
  @@ -1151,6 +1214,7 @@
                       ((${className}) ${collName}.get(i)).save(con);
                   }
               }
  +        #end
         #end
       #end
     #end
  @@ -1160,11 +1224,11 @@
     #end
       }
   #end
  +#if ($tableHasPrimaryKey)
   
  -#if ($table.PrimaryKey.size() > 0)
       /**
        * Specify whether to cache the object after saving to the db.
  -     * This method returns false
  +     * This method returns true
        */
       protected boolean isCacheOnSave()
       {
  @@ -1198,42 +1262,43 @@
       /**
        * Set the PrimaryKey using ObjectKey.
        *
  -     * @param $clo ObjectKey
  +     * @param key $clo ObjectKey
        */
  -    public void setPrimaryKey(ObjectKey $clo)
  -        $throwsClause {
  +    public void setPrimaryKey(ObjectKey key)
  +        $throwsClause
  +    {
       #if ($cjtype == "short")
  -        set${col.JavaName}(((NumberKey)$clo).shortValue());
  +        ${col.SetterName}(((NumberKey) key).shortValue());
       #elseif($cjtype == "int")
  -        set${col.JavaName}(((NumberKey)$clo).intValue());
  +        ${col.SetterName}(((NumberKey) key).intValue());
       #elseif($cjtype == "long")
  -        set${col.JavaName}(((NumberKey)$clo).longValue());
  +        ${col.SetterName}(((NumberKey) key).longValue());
       #elseif($cjtype == "BigDecimal")
  -        set${col.JavaName}(((NumberKey)$clo).getBigDecimal());
  +        ${col.SetterName}(((NumberKey) key).getBigDecimal());
       #elseif($cjtype == "byte")
  -        set${col.JavaName}(((NumberKey)$clo).byteValue());
  +        ${col.SetterName}(((NumberKey) key).byteValue());
       #elseif($cjtype == "float")
  -        set${col.JavaName}(((NumberKey)$clo).floatValue());
  +        ${col.SetterName}(((NumberKey) key).floatValue());
       #elseif($cjtype == "double")
  -        set${col.JavaName}(((NumberKey)$clo).doubleValue());
  +        ${col.SetterName}(((NumberKey) key).doubleValue());
       #elseif($cjtype == "Short")
  -        set${col.JavaName}(new Short(((NumberKey)$clo).shortValue()));
  +        ${col.SetterName}(new Short(((NumberKey) key).shortValue()));
       #elseif($cjtype == "Integer")
  -        set${col.JavaName}(new Integer(((NumberKey)$clo).intValue()));
  +        ${col.SetterName}(new Integer(((NumberKey) key).intValue()));
       #elseif($cjtype == "Long")
  -        set${col.JavaName}(new Long(((NumberKey)$clo).longValue()));
  +        ${col.SetterName}(new Long(((NumberKey) key).longValue()));
       #elseif($cjtype == "Byte")
  -        set${col.JavaName}(new Byte(((NumberKey)$clo).byteValue()));
  +        ${col.SetterName}(new Byte(((NumberKey) key).byteValue()));
       #elseif($cjtype == "Float")
  -        set${col.JavaName}(new Float(((NumberKey)$clo).floatValue()));
  +        ${col.SetterName}(new Float(((NumberKey) key).floatValue()));
       #elseif($cjtype == "Double")
  -        set${col.JavaName}(new Double(((NumberKey)$clo).doubleValue()));
  +        ${col.SetterName}(new Double(((NumberKey) key).doubleValue()));
       #elseif($cjtype == "String")
  -        set${col.JavaName}(${clo}.toString());
  +        ${col.SetterName}(key.toString());
       #elseif($cjtype == "Date")
  -        set${col.JavaName}(((DateKey)$clo).getDate());
  +        ${col.SetterName}(((DateKey) key).getDate());
       #else
  -        set${col.JavaName}(($cjtype)$clo);
  +        ${col.SetterName}(($cjtype) key);
       #end
       }
   
  @@ -1245,37 +1310,37 @@
       public void setPrimaryKey(String key) $throwsClause
       {
       #if ($cjtype == "short")
  -        set${col.JavaName}(Short.parseShort(key));
  +        ${col.SetterName}(Short.parseShort(key));
       #elseif($cjtype == "int")
  -        set${col.JavaName}(Integer.parseInt(key));
  +        ${col.SetterName}(Integer.parseInt(key));
       #elseif($cjtype == "long")
  -        set${col.JavaName}(Long.parseLong(key));
  +        ${col.SetterName}(Long.parseLong(key));
       #elseif($cjtype == "BigDecimal")
  -        set${col.JavaName}(new BigDecimal(key));
  +        ${col.SetterName}(new BigDecimal(key));
       #elseif($cjtype == "byte")
  -        set${col.JavaName}(Byte.parseByte(key));
  +        ${col.SetterName}(Byte.parseByte(key));
       #elseif($cjtype == "float")
  -        set${col.JavaName}(Float.parseFloat(key));
  +        ${col.SetterName}(Float.parseFloat(key));
       #elseif($cjtype == "double")
  -        set${col.JavaName}(Double.parseDouble(key));
  +        ${col.SetterName}(Double.parseDouble(key));
       #elseif($cjtype == "Short")
  -        set${col.JavaName}(new Short(key));
  +        ${col.SetterName}(new Short(key));
       #elseif($cjtype == "Integer")
  -        set${col.JavaName}(new Integer(key));
  +        ${col.SetterName}(new Integer(key));
       #elseif($cjtype == "Long")
  -        set${col.JavaName}(new Long(key));
  +        ${col.SetterName}(new Long(key));
       #elseif($cjtype == "Byte")
  -        set${col.JavaName}(new Byte(key));
  +        ${col.SetterName}(new Byte(key));
       #elseif($cjtype == "Float")
  -        set${col.JavaName}(new Float(key));
  +        ${col.SetterName}(new Float(key));
       #elseif($cjtype == "Double")
  -        set${col.JavaName}(new Double(key));
  +        ${col.SetterName}(new Double(key));
       #elseif($cjtype == "String")
  -        set${col.JavaName}(key);
  +        ${col.SetterName}(key);
       #elseif($cjtype == "Date")
  -        set${col.JavaName}(new Date(key));
  +        ${col.SetterName}(new Date(key));
       #else
  -        set${col.JavaName}(new ${cjtype}(key));
  +        ${col.SetterName}(new ${cjtype}(key));
       #end
       }
   
  @@ -1297,35 +1362,35 @@
       #foreach ($pk in $table.PrimaryKey)
         #set ($pktype = $pk.JavaNative)
         #if ($pktype == "short")
  -        set${pk.JavaName}(((NumberKey)keys[$i]).shortValue());
  +        ${pk.SetterName}(((NumberKey)keys[$i]).shortValue());
         #elseif($pktype == "int")
  -        set${pk.JavaName}(((NumberKey)keys[$i]).intValue());
  +        ${pk.SetterName}(((NumberKey)keys[$i]).intValue());
         #elseif($pktype == "long")
  -        set${pk.JavaName}(((NumberKey)keys[$i]).longValue());
  +        ${pk.SetterName}(((NumberKey)keys[$i]).longValue());
         #elseif($pktype == "BigDecimal")
  -        set${pk.JavaName}(((NumberKey)keys[$i]).getBigDecimal());
  +        ${pk.SetterName}(((NumberKey)keys[$i]).getBigDecimal());
         #elseif($pktype == "byte")
  -        set${pk.JavaName}(((NumberKey)keys[$i]).byteValue());
  +        ${pk.SetterName}(((NumberKey)keys[$i]).byteValue());
         #elseif($pktype == "float")
  -        set${pk.JavaName}(((NumberKey)keys[$i]).floatValue());
  +        ${pk.SetterName}(((NumberKey)keys[$i]).floatValue());
         #elseif($pktype == "double")
  -        set${pk.JavaName}(((NumberKey)keys[$i]).doubleValue());
  +        ${pk.SetterName}(((NumberKey)keys[$i]).doubleValue());
         #elseif($pktype == "Short")
  -        set${pk.JavaName}(new Short(((NumberKey)keys[$i]).shortValue()));
  +        ${pk.SetterName}(new Short(((NumberKey)keys[$i]).shortValue()));
         #elseif($pktype == "Integer")
  -        set${pk.JavaName}(new Integer(((NumberKey)keys[$i]).intValue()));
  +        ${pk.SetterName}(new Integer(((NumberKey)keys[$i]).intValue()));
         #elseif($pktype == "Long")
  -        set${pk.JavaName}(new Long(((NumberKey)keys[$i]).longValue()));
  +        ${pk.SetterName}(new Long(((NumberKey)keys[$i]).longValue()));
         #elseif($pktype == "Byte")
  -        set${pk.JavaName}(new Byte(((NumberKey)keys[$i]).byteValue()));
  +        ${pk.SetterName}(new Byte(((NumberKey)keys[$i]).byteValue()));
         #elseif($pktype == "Float")
  -        set${pk.JavaName}(new Float(((NumberKey)keys[$i]).floatValue()));
  +        ${pk.SetterName}(new Float(((NumberKey)keys[$i]).floatValue()));
         #elseif($pktype == "Double")
  -        set${pk.JavaName}(new Double(((NumberKey)keys[$i]).doubleValue()));
  +        ${pk.SetterName}(new Double(((NumberKey)keys[$i]).doubleValue()));
         #elseif($pktype == "String")
  -        set${pk.JavaName}(keys[$i].toString());
  +        ${pk.SetterName}(keys[$i].toString());
         #elseif($pktype == "Date")
  -        set${pk.JavaName}(((DateKey)keys[$i]).getDate());
  +        ${pk.SetterName}(((DateKey)keys[$i]).getDate());
         #end
         #set ( $i = $i + 1 )
       #end
  @@ -1344,7 +1409,7 @@
           $throwsClause
       {
       #foreach ($col in $table.PrimaryKey)
  -        set${col.JavaName}($col.UncapitalisedJavaName);
  +        ${col.SetterName}($col.UncapitalisedJavaName);
       #end
       }
   
  @@ -1364,11 +1429,11 @@
       public ObjectKey getPrimaryKey()
       {
     #if ($table.PrimaryKey.size() == 1)
  -        return SimpleKey.keyFor(get${table.PrimaryKey.get(0).JavaName}());
  +        return SimpleKey.keyFor(${table.PrimaryKey.get(0).GetterName}());
     #elseif ($table.PrimaryKey.size() > 1)
       #set ($i = 0)
       #foreach ($pk in $table.PrimaryKey)
  -        pks[$i] = SimpleKey.keyFor(get${pk.JavaName}());
  +        pks[$i] = SimpleKey.keyFor(${pk.GetterName}());
         #set ($i = $i +1)
       #end
           return comboPK;
  @@ -1428,23 +1493,26 @@
        * related objects to isNew=true.
     #end
        */
  -  #if ($table.ChildrenColumn || $table.isAbstract())
  -    public $table.JavaName copyInto($table.JavaName copyObj) throws TorqueException
  -    {
  +  #if ($table.isAbstract())
  +    public abstract $table.JavaName copy() throws TorqueException;
     #else
       public $table.JavaName copy() throws TorqueException
       {
  -        $table.JavaName copyObj = new ${table.JavaName}();
  +        return copyInto(new ${table.JavaName}());
  +    }
     #end
  +
  +    protected $table.JavaName copyInto($table.JavaName copyObj) throws TorqueException
  +    {
     #foreach ($col in $table.Columns)
  -        copyObj.set${col.JavaName}($col.UncapitalisedJavaName);
  +        copyObj.${col.SetterName}($col.UncapitalisedJavaName);
     #end
   
     #foreach ($col in $table.Columns)
       #if ($col.isPrimaryKey())
         #if($col.Primitive)
  -		#set ($fktype = $col.JavaNative)
  -	    #set ($casttype = "")
  +        #set ($fktype = $col.JavaNative)
  +        #set ($casttype = "")
           #if ($fktype == "short")
             #set ($casttype = "(short)")
           #elseif($fktype == "byte")
  @@ -1452,11 +1520,11 @@
           #end
           #set ($coldefval = "0") 
           #set ($coldefval = $col.DefaultValue)
  -        copyObj.set${col.JavaName}($casttype $coldefval);
  +        copyObj.${col.SetterName}($casttype $coldefval);
         #else
           #set ( $pkid = "null" )
           #set ( $cjtype = $col.JavaNative )
  -        copyObj.set${col.JavaName}((${cjtype})${pkid});
  +        copyObj.${col.SetterName}((${cjtype})${pkid});
         #end
       #end
     #end
  @@ -1475,13 +1543,14 @@
             #end
           #end
   
  -        #if ($relCol == "")
  -          #set ( $pCollName = "${className}s" )
  -          #set ( $pCollNameNoS = "${className}" )
  -        #else
  -          #set ( $pCollName = "${className}sRelatedBy$relCol" )
  -          #set ( $pCollNameNoS = "${className}RelatedBy$relCol" )
  -        #end
  +        #if ($objectIsCaching)
  +          #if ($relCol == "")
  +            #set ( $pCollName = "${className}s" )
  +            #set ( $pCollNameNoS = "${className}" )
  +          #else
  +            #set ( $pCollName = "${className}sRelatedBy$relCol" )
  +            #set ( $pCollNameNoS = "${className}RelatedBy$relCol" )
  +          #end
   
           ${list}v = get${pCollName}();
           for (int i = 0; i < v.size(); i++)
  @@ -1489,6 +1558,7 @@
               $className obj = ($className) v.get(i);
               copyObj.add$pCollNameNoS(obj.copy());
           }
  +        #end
           #set ( $list = "" )
         #end
       #end
  
  
  

---------------------------------------------------------------------
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