db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henn...@apache.org
Subject cvs commit: db-torque/src/generator/xdocs properties-reference.xml
Date Thu, 11 Sep 2003 22:51:39 GMT
henning     2003/09/11 15:51:39

  Modified:    src/generator/src/conf build.properties default.properties
               src/generator/src/templates/om Object.vm Peer.vm
               src/generator/xdocs properties-reference.xml
  Log:
  Add a new property "objectIsCaching" that controls whether or not the created
  object classes cache their foreign key relations or not. This is necessary if
  the application considers torque to be "just a java object mapper" and not a
  more complex tool that also keeps internal relationships.
  
  Default is that the object cache their informations, which is the same as the
  3.1 release.
  
  Revision  Changes    Path
  1.2       +7 -1      db-torque/src/generator/src/conf/build.properties
  
  Index: build.properties
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/conf/build.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.properties	10 Feb 2003 13:22:37 -0000	1.1
  +++ build.properties	11 Sep 2003 22:51:39 -0000	1.2
  @@ -83,6 +83,12 @@
   # useManagers
   #   If true, Torque will generate Manager classes that use JCS for caching.
   #   Still considered experimental.
  +#
  +# objectIsCaching
  +#   If true, Torque generates data objects that cache their foreign
  +#   key relationships. If this is not desired (because the underlying objects
  +#   can be manipulated from other code), set this property to false. This currently
  +#   cannot combined with the manager setting from above.
   # -------------------------------------------------------------------
   
   torque.targetPackage = org.apache.torque
  @@ -95,7 +101,7 @@
   torque.complexObjectModel = true
   torque.useClasspath = false
   torque.useManagers = false
  -
  +torque.objectIsCaching = true
   
   # -------------------------------------------------------------------
   #
  
  
  
  1.4       +2 -0      db-torque/src/generator/src/conf/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/conf/default.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- default.properties	20 Jul 2003 15:41:43 -0000	1.3
  +++ default.properties	11 Sep 2003 22:51:39 -0000	1.4
  @@ -104,6 +104,7 @@
   complexObjectModel = true
   useManagers = false
   useClasspath = false
  +objectIsCaching = true
   
   torque.addGetByNameMethod = ${addGetByNameMethod}
   torque.addIntakeRetrievable = ${addIntakeRetrievable}
  @@ -115,6 +116,7 @@
   torque.saveException = Exception
   torque.useClasspath = ${useClasspath}
   torque.useManagers = ${useManagers}
  +torque.objectIsCaching = true
   
   torque.omzip.src.base = false
   torque.omzip.src.extension = false
  
  
  
  1.8       +40 -0     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Object.vm	19 Aug 2003 09:48:51 -0000	1.7
  +++ Object.vm	11 Sep 2003 22:51:39 -0000	1.8
  @@ -206,6 +206,7 @@
               #set ( $collName = "coll${tblFK.JavaName}s" )
             #end
   
  +          #if ($objectIsCaching)
           // update associated $tblFK.JavaName
           if ($collName != null)
           {
  @@ -218,6 +219,7 @@
           #end
         #end
       #end
  +    #end
       }
     #end
   #end
  @@ -458,6 +460,7 @@
         #end
         #set ( $collName = "coll$relCol" )
   
  +      #if ($objectIsCaching)
       /**
        * Collection to store aggregation of $collName
        */
  @@ -493,6 +496,7 @@
        * The criteria used to select the current contents of $collName
        */
       private Criteria last${relCol}Criteria = null;
  +      #end
   
       /**
        * If this collection has already been initialized, returns
  @@ -503,11 +507,15 @@
        */
       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
       }
   
       /**
  @@ -523,6 +531,7 @@
        */
       public List get${relCol}(Criteria criteria) throws TorqueException
       {
  +      #if ($objectIsCaching)
           if ($collName == null)
           {
               if (isNew())
  @@ -548,12 +557,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}());
         #end
  +      #if ($objectIsCaching)
                   if (!last${relCol}Criteria.equals(criteria))
                   {
                       $collName = ${className}Peer.doSelect(criteria);
  @@ -563,6 +574,9 @@
           last${relCol}Criteria = criteria;
   
           return $collName;
  +      #else
  +                return ${className}Peer.doSelect(criteria);
  +      #end
       }
   
       /**
  @@ -575,11 +589,15 @@
        */
       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
       }
   
       /**
  @@ -597,6 +615,7 @@
       public List get${relCol}(Criteria criteria, Connection con)
               throws TorqueException
       {
  +      #if ($objectIsCaching)
           if ($collName == null)
           {
               if (isNew())
  @@ -622,12 +641,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}());
         #end
  +      #if ($objectIsCaching)
                    if (!last${relCol}Criteria.equals(criteria))
                    {
                        $collName = ${className}Peer.doSelect(criteria, con);
  @@ -637,6 +658,9 @@
            last${relCol}Criteria = criteria;
   
            return $collName;
  +      #else
  +                 return ${className}Peer.doSelect(criteria, con);
  +      #end
        }
   
         #set ( $countFK = 0 )
  @@ -715,6 +739,7 @@
       protected List get${relCol}Join${relCol2}(Criteria criteria)
           throws TorqueException
       {
  +            #if ($objectIsCaching)
           if ($collName == null)
           {
               if (isNew())
  @@ -737,6 +762,7 @@
               // 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
               boolean newCriteria = true;
               #foreach ($columnName in $fk.ForeignColumns)
                 #set ( $column = $table.getColumn($columnName) )
  @@ -744,6 +770,7 @@
                 #set ( $colFK = $tblFK.getColumn($colFKName) )
               criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
               #end
  +            #if ($objectIsCaching)
               if (!last${relCol}Criteria.equals(criteria))
               {
                   $collName = ${className}Peer.doSelectJoin${relCol2}(criteria);
  @@ -752,6 +779,9 @@
           last${relCol}Criteria = criteria;
   
           return $collName;
  +            #else
  +            return ${className}Peer.doSelectJoin${relCol2}(criteria);
  +            #end
       }
             #end 
           #end 
  @@ -776,6 +806,7 @@
       protected List get${relCol}JoinAllExcept${table.JavaName}(Criteria criteria)
           throws TorqueException
       {
  +   #if ($objectIsCaching)
           if ($collName == null)
           {
               if (isNew())
  @@ -798,6 +829,7 @@
               // 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
               boolean newCriteria = true;
      #foreach ($columnName in $fk.ForeignColumns)
          #set ( $column = $table.getColumn($columnName) )
  @@ -805,6 +837,7 @@
          #set ( $colFK = $tblFK.getColumn($colFKName) )
                   criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
      #end
  +   #if ($objectIsCaching)
               if (!last${relCol}Criteria.equals(criteria))
               {
                   $collName = ${className}Peer.doSelectJoinAllExcept${table.JavaName}${suffix}(criteria);
  @@ -813,6 +846,9 @@
           last${relCol}Criteria = criteria;
   
           return $collName;
  +   #else 
  +            return ${className}Peer.doSelectJoinAllExcept${table.JavaName}${suffix}(criteria);
  +   #end
       }
   
     #end
  @@ -1126,6 +1162,7 @@
           #end
           #set ( $collName = "coll$relCol" )
   
  +        #if ($objectIsCaching)
               if ($collName != null)
               {
                   for (int i = 0; i < ${collName}.size(); i++)
  @@ -1136,6 +1173,7 @@
         #end
       #end
     #end
  +  #end
     #if ($complexObjectModel)
               alreadyInSave = false;
           }
  @@ -1432,6 +1470,7 @@
             #end
           #end
   
  +        #if ($objectIsCaching)
           #if ($relCol == "")
             #set ( $pCollName = "${className}s" )
             #set ( $pCollNameNoS = "${className}" )
  @@ -1446,6 +1485,7 @@
               $className obj = ($className) v.get(i);
               copyObj.add$pCollNameNoS(obj.copy());
           }
  +        #end
           #set ( $list = "" )
         #end
       #end
  
  
  
  1.6       +8 -0      db-torque/src/generator/src/templates/om/Peer.vm
  
  Index: Peer.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/om/Peer.vm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Peer.vm	25 Aug 2003 16:35:20 -0000	1.5
  +++ Peer.vm	11 Sep 2003 22:51:39 -0000	1.6
  @@ -1326,14 +1326,18 @@
                   if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
                   {
                       newObject = false;
  +          #if ($objectIsCaching)
                       temp_obj2.add${collThisTableMs}(obj1);
  +          #end
                       break;
                   }
               }
               if (newObject)
               {
  +          #if ($objectIsCaching)
                   obj2.init${collThisTable}();
                   obj2.add${collThisTableMs}(obj1);
  +          #end
               }
               results.add(obj1);
           }
  @@ -1524,14 +1528,18 @@
                   if (temp_obj${index}.getPrimaryKey().equals(obj${index}.getPrimaryKey()))
                   {
                       newObject = false;
  +                #if ($objectIsCaching)
                       temp_obj${index}.add${collThisTableMs}(obj1);
  +                #end
                       break;
                   }
               }
               if (newObject)
               {
  +                #if ($objectIsCaching)
                   obj${index}.init${collThisTable}();
                   obj${index}.add${collThisTableMs}(obj1);
  +                #end
               }
                 #end
               #end
  
  
  
  1.5       +10 -0     db-torque/src/generator/xdocs/properties-reference.xml
  
  Index: properties-reference.xml
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/xdocs/properties-reference.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- properties-reference.xml	20 Aug 2003 01:28:43 -0000	1.4
  +++ properties-reference.xml	11 Sep 2003 22:51:39 -0000	1.5
  @@ -298,6 +298,16 @@
       If true, Torque will generate Manager classes that use JCS for caching.
       Still considered experimental.
     </td>
  +<tr>
  +  <td><code> torque.objectIsCaching </code></td>
  +  <td><code> true </code></td>
  +  <td>
  +    If true, Torque generates data objects that cache their foreign
  +    key relationships. If this is not desired (because the underlying objects
  +    can be manipulated from other code), set this property to false. This currently
  +    cannot combined with the manager setting from above.
  +  </td>
  +</tr>
   </tr>
   
   
  
  
  

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