db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: db-torque/src/generator/src/templates/om Object.vm ObjectWithManager.vm
Date Thu, 06 Jan 2005 19:04:19 GMT
dlr         2005/01/06 11:04:19

  Modified:    src/generator/src/templates/om Object.vm
                        ObjectWithManager.vm
  Log:
  [second attempt] Fix the Java source code generation failure for OM
  class whose corresponding table lacks a PK.
  
  Observed behavior before this patch:
  
  Compilation error in BaseYourObject.setQueryKey(String) due to throws
  delcaration mismatch between Torque's BaseObject.setPrimaryKey(String)
  method and lack of generated setPrimaryKey(String) method.  Had the
  override been generated, it would've had a throws declaration of
  TorqueException, instead of Exception as declared by BaseObject.
  
    [javac] .../BaseYourObject.java:392:9:392:26: Semantic Error: The
    method "void setPrimaryKey(java.lang.String $1) throws
    java.lang.Exception;" can throw the checked exception
    "java.lang.Exception", so its invocation must be enclosed in a try
    statement that catches the exception, or else this method must be
    declared to throw the exception.
  
  * src/generator/src/templates/om/Object.vm
  * src/generator/src/templates/om/ObjectWithManager.vm
    Wrap the invocation of setPrimaryKey(String) in a try/catch block to
    re-throw Exception as TorqueException in the setQueryKey(String)
    method.
  
  CollabNet-internal issue: PCN33929
  
  Revision  Changes    Path
  1.20      +14 -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.19
  retrieving revision 1.20
  diff -u -u -r1.19 -r1.20
  --- Object.vm	6 Jan 2005 19:01:35 -0000	1.19
  +++ Object.vm	6 Jan 2005 19:04:19 -0000	1.20
  @@ -1424,7 +1424,21 @@
       public void setQueryKey(String key)
           throws TorqueException
       {
  +  ## Work around the fact that BaseObject.setPrimaryKey() declares
  +  ## that it throws Exception instead of TorqueException.
  +  #set ($tableHasPrimaryKey = $table.PrimaryKey.size() > 0)
  +  #if (!$tableHasPrimaryKey)
  +        try
  +        {
  +  #end
           setPrimaryKey(key);
  +  #if (!$tableHasPrimaryKey)
  +        }
  +        catch (Exception e)
  +        {
  +            throw new TorqueException("Unable to set query key", e);
  +        }
  +  #end
       }
   #end
   
  
  
  
  1.15      +15 -1     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.14
  retrieving revision 1.15
  diff -u -u -r1.14 -r1.15
  --- ObjectWithManager.vm	6 Jan 2005 19:01:35 -0000	1.14
  +++ ObjectWithManager.vm	6 Jan 2005 19:04:19 -0000	1.15
  @@ -1110,7 +1110,8 @@
                       ${table.JavaName}Peer.doUpdate(($table.JavaName) this, con);
                   }
   
  -  #if ($table.PrimaryKey.size() > 0)
  +  #set ($tableHasPrimaryKey = $table.PrimaryKey.size() > 0)
  +  #if ($tableHasPrimaryKey)
       #set ($interfaceName = $table.JavaName)
       #if ($table.Interface)
         #set ($interfaceName = $table.Interface)
  @@ -1400,7 +1401,20 @@
       public void setQueryKey(String key)
           throws TorqueException
       {
  +  ## Work around the fact that BaseObject.setPrimaryKey() declares
  +  ## that it throws Exception instead of TorqueException.
  +  #if (!$tableHasPrimaryKey)
  +        try
  +        {
  +  #end
           setPrimaryKey(key);
  +  #if (!$tableHasPrimaryKey)
  +        }
  +        catch (Exception e)
  +        {
  +            throw new TorqueException("Unable to set query key", e);
  +        }
  +  #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