Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 57835 invoked from network); 6 Jan 2005 18:36:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 6 Jan 2005 18:36:50 -0000 Received: (qmail 11949 invoked by uid 500); 6 Jan 2005 18:36:49 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 11904 invoked by uid 500); 6 Jan 2005 18:36:49 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 11888 invoked by uid 500); 6 Jan 2005 18:36:48 -0000 Received: (qmail 11885 invoked by uid 99); 6 Jan 2005 18:36:48 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 06 Jan 2005 10:36:48 -0800 Received: (qmail 57813 invoked by uid 1164); 6 Jan 2005 18:36:47 -0000 Date: 6 Jan 2005 18:36:47 -0000 Message-ID: <20050106183647.57812.qmail@minotaur.apache.org> From: dlr@apache.org To: db-torque-cvs@apache.org Subject: cvs commit: db-torque/src/generator/src/templates/om Object.vm ObjectWithManager.vm X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N dlr 2005/01/06 10:36:47 Modified: src/generator/src/templates/om Object.vm ObjectWithManager.vm Log: 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.18 +13 -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.17 retrieving revision 1.18 diff -u -u -r1.17 -r1.18 --- Object.vm 20 Oct 2004 01:28:18 -0000 1.17 +++ Object.vm 6 Jan 2005 18:36:47 -0000 1.18 @@ -1424,7 +1424,20 @@ 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) + { + } + #end } #end 1.13 +14 -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.12 retrieving revision 1.13 diff -u -u -r1.12 -r1.13 --- ObjectWithManager.vm 20 Oct 2004 01:28:18 -0000 1.12 +++ ObjectWithManager.vm 6 Jan 2005 18:36:47 -0000 1.13 @@ -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,19 @@ 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) + { + } + #end } #end --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org