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 ObjectWithManager.vm Object.vm
Date Thu, 22 Jan 2004 01:06:50 GMT
mpoeschl    2004/01/21 17:06:50

  Modified:    xdocs    Tag: TORQUE_3_1_BRANCH release-changes.xml
               src/rttest Tag: TORQUE_3_1_BRANCH test-schema.xml
               src/generator/src/templates/om Tag: TORQUE_3_1_BRANCH
                        ObjectWithManager.vm Object.vm
  Log:
  backport fixes for TRQS97 and TRQS190
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.3.2.4   +7 -0      db-torque/xdocs/release-changes.xml
  
  Index: release-changes.xml
  ===================================================================
  RCS file: /home/cvs/db-torque/xdocs/release-changes.xml,v
  retrieving revision 1.3.2.3
  retrieving revision 1.3.2.4
  diff -u -r1.3.2.3 -r1.3.2.4
  --- release-changes.xml	5 Dec 2003 05:04:10 -0000	1.3.2.3
  +++ release-changes.xml	22 Jan 2004 01:06:50 -0000	1.3.2.4
  @@ -18,8 +18,15 @@
   <p>
     <ul>
       <li>
  +      TRQS97: Fix bad syntax in generated model when using primary keys of
  +      short or byte.
  +    </li>
  +    <li>
         TRQS149: For PostgreSQL the LONGVARCHAR datatype now maps to 
         <em>text</em> rather than <em>bytea</em>.
  +    </li>
  +    <li>
  +      TRQS190: Error on "byte" data type generation rules.
       </li>
       <li>
         Upgraded to commons-pool-1.1 and commons-dbcp-1.1
  
  
  
  No                   revision
  No                   revision
  1.16.2.1  +16 -1     db-torque/src/rttest/test-schema.xml
  
  Index: test-schema.xml
  ===================================================================
  RCS file: /home/cvs/db-torque/src/rttest/test-schema.xml,v
  retrieving revision 1.16
  retrieving revision 1.16.2.1
  diff -u -r1.16 -r1.16.2.1
  --- test-schema.xml	24 Aug 2003 14:38:50 -0000	1.16
  +++ test-schema.xml	22 Jan 2004 01:06:50 -0000	1.16.2.1
  @@ -153,5 +153,20 @@
       <column name="bint_value" required="true" type="BOOLEANINT" />
       <column name="bchar_value" required="true" type="BOOLEANCHAR" />
     </table>
  -  
  +
  +  <!-- TRQS97 -->
  +  <table name="LEAGUES_OBJECT" description="Contains all leagues">
  +    <column name="LEAGUEID" primaryKey="true" required="true" type="TINYINT" javaType="object"/>
  +    <column name="LEAGUENAME" required="false" size="100" type="VARCHAR"/>
  +    <column name="LEAGUEYEAR" required="false" type="INTEGER" javaType="object"/>
  +    <column name="LEAGUESCORETYPE" required="false" type="SMALLINT" default="0" javaType="object"/>
  +  </table>
  +
  +  <table name="LEAGUES_PRIMITIVE" description="Contains all leagues">
  +    <column name="LEAGUEID" primaryKey="true" required="true" type="TINYINT" javaType="primitive"/>
  +    <column name="LEAGUENAME" required="false" size="100" type="VARCHAR"/>
  +    <column name="LEAGUEYEAR" required="false" type="INTEGER" javaType="primitive"/>
  +    <column name="LEAGUESCORETYPE" required="false" type="SMALLINT" default="0" javaType="primitive"/>
  +  </table>
  +
   </database>
  
  
  
  No                   revision
  No                   revision
  1.5.2.1   +102 -33   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.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- ObjectWithManager.vm	19 Aug 2003 09:48:51 -0000	1.5
  +++ ObjectWithManager.vm	22 Jan 2004 01:06:50 -0000	1.5.2.1
  @@ -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,16 @@
         #elseif ($cjtype == "StringKey")
           #set ( $quote = '"' )
           #set ($defVal = "= new StringKey($quote$defaultValue$quote)")
  +      #elseif ($cjtype == 'Byte')
  +        #set ($defVal = "= new ${cjtype}((byte) $defaultValue)")
  +      #elseif ($cjtype == "Short")
  +        #set ( $quote = '"' )
  +        #set ($defVal = "= new Short($quote$defaultValue$quote)")             
         #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 +111,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 +119,7 @@
   
       /**
        * Get the $cfc
  +     *
        * @return $cjtype
        */
       public $cjtype get${cfc}()
  @@ -133,8 +141,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 +217,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 +229,6 @@
         #end
       #end
       }
  -
     #end
   #end
   
  @@ -255,6 +264,7 @@
        * Declares an association between this object and a $interfaceName object
        *
        * @param $interfaceName v
  +     * @throws TorqueException
        */
       public void set${pVarName}($interfaceName v) throws TorqueException
       {
  @@ -262,14 +272,21 @@
         #set ( $column = $table.getColumn($columnName) )
         #set ( $colFKName = $fk.LocalForeignMapping.get($columnName) )
         #set ( $colFK = $tblFK.getColumn($colFKName) )
  +      #set ( $fktype = $colFK.JavaNative )
  +      #set ( $casttype = "" )
           if (v == null)
           {
         #if($colFK.Primitive)
  -        #set ($coldefval = "0")
  +        #if ($fktype == "short")
  +          #set ($casttype = "(short)")
  +        #elseif($fktype == "byte")
  +          #set ($casttype = "(byte)")
  +        #end
  +        #set ($coldefval =  "0") 
           #set ($coldefval = $column.DefaultValue)
  -            set${column.JavaName}($coldefval);
  +            set${column.JavaName}($casttype $coldefval);
         #else
  -            set${column.JavaName}(($column.JavaNative)null);
  +            set${column.JavaName}(($column.JavaNative) null);
         #end
           }
           else
  @@ -300,6 +317,12 @@
         #set ( $argsize = $argsize + 1 )
       #end
   
  +    /**
  +     * Get the associated $interfaceName object
  +     *
  +     * @return the associated $interfaceName object
  +     * @throws TorqueException
  +     */
       public $interfaceName get${pVarName}() throws TorqueException
       {
           if ( $conditional )
  @@ -343,7 +366,7 @@
           set${col.JavaName}(((NumberKey) keys[$i]).longValue());
           #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")
           set${col.JavaName}(((NumberKey) keys[$i]).floatValue());
  @@ -355,7 +378,7 @@
           set${col.JavaName}(new Integer(((NumberKey) keys[$i]).intValue()));
           #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")
           set${col.JavaName}(new Float(((NumberKey) keys[$i]).floatValue()));
  @@ -382,7 +405,7 @@
           set${col.JavaName}(((NumberKey) key).longValue());
         #elseif($fktype == "BigDecimal")
           set${col.JavaName}(((NumberKey) key).getBigDecimal());
  -      #elseif($fktype == "byte") )
  +      #elseif($fktype == "byte")
           set${col.JavaName}(((NumberKey) key).byteValue());
         #elseif($fktype == "float")
           set${col.JavaName}(((NumberKey) key).floatValue());
  @@ -394,7 +417,7 @@
           set${col.JavaName}(new Integer(((NumberKey) key).intValue()));
         #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")
           set${col.JavaName}(new Float(((NumberKey) key).floatValue()));
  @@ -407,7 +430,6 @@
         #end
       #end
       }
  -
     #end   ## end of foreach loop over foreign keys
   
     ##
  @@ -463,7 +485,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 +503,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 +523,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
       {
  @@ -623,7 +650,6 @@
   
   ## ------------------------------------------------------------
   ##
  -
         #if ($countFK >= 1)
           #set ( $lastTable = "" )
           #foreach ($fk2 in $tblFK.ForeignKeys)
  @@ -756,7 +782,7 @@
       {
           if ($collName == null)
           {
  -            if ( isNew() )
  +            if (isNew())
               {
                  $collName = new ArrayList();
               }
  @@ -809,6 +835,8 @@
   
       /**
        * Generate a list of field names.
  +     *
  +     * @return a list of field names
        */
       public static synchronized List getFieldNames()
       {
  @@ -824,8 +852,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 +892,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 +902,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 +931,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 +941,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 +973,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
       {
  @@ -967,6 +1005,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 +1029,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 +1061,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
       {
  @@ -1096,7 +1140,7 @@
             #set ( $relCol = "${className}sRelatedBy$relCol" )
           #end
           #set ( $collName = "coll$relCol" )
  -            if ($collName != null )
  +            if ($collName != null)
               {
                   for (int i = 0; i < ${collName}.size(); i++)
                   {
  @@ -1162,7 +1206,7 @@
           set${col.JavaName}(((NumberKey)$clo).longValue());
       #elseif($cjtype == "BigDecimal")
           set${col.JavaName}(((NumberKey)$clo).getBigDecimal());
  -    #elseif($cjtype == "byte") )
  +    #elseif($cjtype == "byte")
           set${col.JavaName}(((NumberKey)$clo).byteValue());
       #elseif($cjtype == "float")
           set${col.JavaName}(((NumberKey)$clo).floatValue());
  @@ -1174,7 +1218,7 @@
           set${col.JavaName}(new Integer(((NumberKey)$clo).intValue()));
       #elseif($cjtype == "Long")
           set${col.JavaName}(new Long(((NumberKey)$clo).longValue()));
  -    #elseif($cjtype == "Byte") )
  +    #elseif($cjtype == "Byte")
           set${col.JavaName}(new Byte(((NumberKey)$clo).byteValue()));
       #elseif($cjtype == "Float")
           set${col.JavaName}(new Float(((NumberKey)$clo).floatValue()));
  @@ -1191,6 +1235,8 @@
   
       /**
        * Set the PrimaryKey using a String.
  +     *
  +     * @param key
        */
       public void setPrimaryKey(String key) $throwsClause
       {
  @@ -1202,7 +1248,7 @@
           set${col.JavaName}(Long.parseLong(key));
       #elseif($cjtype == "BigDecimal")
           set${col.JavaName}(new BigDecimal(key));
  -    #elseif($cjtype == "byte") )
  +    #elseif($cjtype == "byte")
           set${col.JavaName}(Byte.parseByte(key));
       #elseif($cjtype == "float")
           set${col.JavaName}(Float.parseFloat(key));
  @@ -1214,7 +1260,7 @@
           set${col.JavaName}(new Integer(key));
       #elseif($cjtype == "Long")
           set${col.JavaName}(new Long(key));
  -    #elseif($cjtype == "Byte") )
  +    #elseif($cjtype == "Byte")
           set${col.JavaName}(new Byte(key));
       #elseif($cjtype == "Float")
           set${col.JavaName}(new Float(key));
  @@ -1233,8 +1279,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
       {
  @@ -1251,7 +1300,7 @@
           set${pk.JavaName}(((NumberKey)keys[$i]).longValue());
         #elseif($pktype == "BigDecimal")
           set${pk.JavaName}(((NumberKey)keys[$i]).getBigDecimal());
  -      #elseif($pktype == "byte") )
  +      #elseif($pktype == "byte")
           set${pk.JavaName}(((NumberKey)keys[$i]).byteValue());
         #elseif($pktype == "float")
           set${pk.JavaName}(((NumberKey)keys[$i]).floatValue());
  @@ -1263,7 +1312,7 @@
           set${pk.JavaName}(new Integer(((NumberKey)keys[$i]).intValue()));
         #elseif($pktype == "Long")
           set${pk.JavaName}(new Long(((NumberKey)keys[$i]).longValue()));
  -      #elseif($pktype == "Byte") )
  +      #elseif($pktype == "Byte")
           set${pk.JavaName}(new Byte(((NumberKey)keys[$i]).byteValue()));
         #elseif($pktype == "Float")
           set${pk.JavaName}(new Float(((NumberKey)keys[$i]).floatValue()));
  @@ -1358,7 +1407,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())
  @@ -1376,9 +1426,16 @@
     #foreach ($col in $table.Columns)
       #if ($col.isPrimaryKey())
         #if($col.Primitive)
  -        #set ($coldefval = "0")
  +		#set ($fktype = $col.JavaNative)
  +	    #set ($casttype = "")
  +        #if ($fktype == "short")
  +          #set ($casttype = "(short)")
  +        #elseif($fktype == "byte")
  +          #set ($casttype = "(byte)")
  +        #end
  +        #set ($coldefval = "0") 
           #set ($coldefval = $col.DefaultValue)
  -          copyObj.set${col.JavaName}($coldefval);
  +        copyObj.set${col.JavaName}($casttype $coldefval);
         #else
           #set ( $pkid = "null" )
           #set ( $cjtype = $col.JavaNative )
  @@ -1435,4 +1492,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());
  +    }
   }
  
  
  
  1.7.2.2   +43 -27    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.2.1
  retrieving revision 1.7.2.2
  diff -u -r1.7.2.1 -r1.7.2.2
  --- Object.vm	11 Sep 2003 22:46:09 -0000	1.7.2.1
  +++ Object.vm	22 Jan 2004 01:06:50 -0000	1.7.2.2
  @@ -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)
  @@ -93,6 +93,11 @@
         #elseif ($cjtype == "StringKey")
           #set ( $quote = '"' )
           #set ($defVal = "= new StringKey($quote$defaultValue$quote)")
  +      #elseif ($cjtype == 'Byte')
  +        #set ($defVal = "= new ${cjtype}((byte) $defaultValue)")
  +      #elseif ($cjtype == "Short")
  +        #set ( $quote = '"' )
  +        #set ($defVal = "= new Short($quote$defaultValue$quote)")             
         #else
           #if (!$col.isPrimitive() && $cjtype != "String")
             #set ( $defaultValue = "new ${cjtype}($defaultValue)" )
  @@ -263,21 +268,28 @@
         #set ( $column = $table.getColumn($columnName) )
         #set ( $colFKName = $fk.LocalForeignMapping.get($columnName) )
         #set ( $colFK = $tblFK.getColumn($colFKName) )
  +      #set ( $fktype = $colFK.JavaNative )
  +      #set ( $casttype = "" )
           if (v == null)
           {
  -        #if($colFK.Primitive)
  -          #set ($coldefval = "0")
  -          #set ($coldefval = $column.DefaultValue)
  -            set${column.JavaName}($coldefval);
  -          #else
  +      #if($colFK.Primitive)
  +        #if ($fktype == "short")
  +          #set ($casttype = "(short)")
  +        #elseif($fktype == "byte")
  +          #set ($casttype = "(byte)")
  +        #end
  +        #set ($coldefval =  "0") 
  +        #set ($coldefval = $column.DefaultValue)
  +            set${column.JavaName}($casttype $coldefval);
  +      #else
               set${column.JavaName}(($column.JavaNative) null);
  -          #end
  +      #end
           }
           else
           {
               set${column.JavaName}(v.get${colFK.JavaName}());
           }
  -        #end
  +    #end
           $varName = v;
       }
   
  @@ -344,13 +356,13 @@
        * 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
       {
  @@ -369,7 +381,7 @@
           set${col.JavaName}(((NumberKey) keys[$i]).longValue());
             #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")
           set${col.JavaName}(((NumberKey) keys[$i]).floatValue());
  @@ -381,7 +393,7 @@
           set${col.JavaName}(new Integer(((NumberKey) keys[$i]).intValue()));
             #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")
           set${col.JavaName}(new Float(((NumberKey) keys[$i]).floatValue()));
  @@ -407,7 +419,7 @@
           set${col.JavaName}(((NumberKey) key).longValue());
           #elseif($fktype == "BigDecimal")
           set${col.JavaName}(((NumberKey) key).getBigDecimal());
  -        #elseif($fktype == "byte") )
  +        #elseif($fktype == "byte")
           set${col.JavaName}(((NumberKey) key).byteValue());
           #elseif($fktype == "float")
           set${col.JavaName}(((NumberKey) key).floatValue());
  @@ -419,7 +431,7 @@
           set${col.JavaName}(new Integer(((NumberKey) key).intValue()));
           #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")
           set${col.JavaName}(new Float(((NumberKey) key).floatValue()));
  @@ -1183,7 +1195,6 @@
   
   ## PrimaryKey methods
   #if (!$table.isAlias())
  -
     #set ( $throwsClause = "" )
     #set ( $argList = "" )
     #set ( $argList2 = "" )
  @@ -1221,7 +1232,7 @@
           set${col.JavaName}(((NumberKey) key).longValue());
       #elseif($cjtype == "BigDecimal")
           set${col.JavaName}(((NumberKey) key).getBigDecimal());
  -    #elseif($cjtype == "byte") )
  +    #elseif($cjtype == "byte")
           set${col.JavaName}(((NumberKey) key).byteValue());
       #elseif($cjtype == "float")
           set${col.JavaName}(((NumberKey) key).floatValue());
  @@ -1233,7 +1244,7 @@
           set${col.JavaName}(new Integer(((NumberKey) key).intValue()));
       #elseif($cjtype == "Long")
           set${col.JavaName}(new Long(((NumberKey) key).longValue()));
  -    #elseif($cjtype == "Byte") )
  +    #elseif($cjtype == "Byte")
           set${col.JavaName}(new Byte(((NumberKey) key).byteValue()));
       #elseif($cjtype == "Float")
           set${col.JavaName}(new Float(((NumberKey) key).floatValue()));
  @@ -1242,9 +1253,9 @@
       #elseif($cjtype == "String")
           set${col.JavaName}(key.toString());
       #elseif($cjtype == "Date")
  -        set${col.JavaName}(((DateKey)key).getDate());
  +        set${col.JavaName}(((DateKey) key).getDate());
       #else
  -        set${col.JavaName}(($cjtype)key);
  +        set${col.JavaName}(($cjtype) key);
       #end
       }
   
  @@ -1263,7 +1274,7 @@
           set${col.JavaName}(Long.parseLong(key));
       #elseif($cjtype == "BigDecimal")
           set${col.JavaName}(new BigDecimal(key));
  -    #elseif($cjtype == "byte") )
  +    #elseif($cjtype == "byte")
           set${col.JavaName}(Byte.parseByte(key));
       #elseif($cjtype == "float")
           set${col.JavaName}(Float.parseFloat(key));
  @@ -1275,7 +1286,7 @@
           set${col.JavaName}(new Integer(key));
       #elseif($cjtype == "Long")
           set${col.JavaName}(new Long(key));
  -    #elseif($cjtype == "Byte") )
  +    #elseif($cjtype == "Byte")
           set${col.JavaName}(new Byte(key));
       #elseif($cjtype == "Float")
           set${col.JavaName}(new Float(key));
  @@ -1315,7 +1326,7 @@
           set${pk.JavaName}(((NumberKey)keys[$i]).longValue());
         #elseif($pktype == "BigDecimal")
           set${pk.JavaName}(((NumberKey)keys[$i]).getBigDecimal());
  -      #elseif($pktype == "byte") )
  +      #elseif($pktype == "byte")
           set${pk.JavaName}(((NumberKey)keys[$i]).byteValue());
         #elseif($pktype == "float")
           set${pk.JavaName}(((NumberKey)keys[$i]).floatValue());
  @@ -1327,7 +1338,7 @@
           set${pk.JavaName}(new Integer(((NumberKey)keys[$i]).intValue()));
         #elseif($pktype == "Long")
           set${pk.JavaName}(new Long(((NumberKey)keys[$i]).longValue()));
  -      #elseif($pktype == "Byte") )
  +      #elseif($pktype == "Byte")
           set${pk.JavaName}(new Byte(((NumberKey)keys[$i]).byteValue()));
         #elseif($pktype == "Float")
           set${pk.JavaName}(new Float(((NumberKey)keys[$i]).floatValue()));
  @@ -1387,7 +1398,6 @@
           return null;
     #end
       }
  -
   #end ##ends if(!$table.isAlias())
   
   #if ($addIntakeRetrievable)
  @@ -1445,9 +1455,16 @@
     #foreach ($col in $table.Columns)
       #if ($col.isPrimaryKey())
         #if($col.Primitive)
  -        #set ($coldefval = "0")
  +		#set ($fktype = $col.JavaNative)
  +	    #set ($casttype = "")
  +        #if ($fktype == "short")
  +          #set ($casttype = "(short)")
  +        #elseif($fktype == "byte")
  +          #set ($casttype = "(byte)")
  +        #end
  +        #set ($coldefval = "0") 
           #set ($coldefval = $col.DefaultValue)
  -        copyObj.set${col.JavaName}($coldefval);
  +        copyObj.set${col.JavaName}($casttype $coldefval);
         #else
           #set ( $pkid = "null" )
           #set ( $cjtype = $col.JavaNative )
  @@ -1490,7 +1507,6 @@
         #end
       #end
     #end
  -
           return copyObj;
       }
   #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