You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Daniel Rall <dl...@finemaltcoding.com> on 2002/02/27 04:53:43 UTC

Re: [PATCH] Standardizing OM for throwing TorqueException (2/3)

-                throw e;
+                throw new TorqueException(e);
             }
         }
         else
@@ -1235,11 +1361,11 @@
      * @param criteria A Criteria.
      * @param dbCon A DBConnection.
      * @return Vector of Record objects.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector doSelect(Criteria criteria,
                                   DBConnection dbCon)
-        throws Exception
+        throws TorqueException
     {
         return executeQuery( createQueryString(criteria),
                              criteria.isSingleRecord(), dbCon );
@@ -1252,10 +1378,10 @@
      *
      * @param queryString A String with the sql statement to execute.
      * @return Vector of Record objects.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector executeQuery(String queryString)
-        throws Exception
+        throws TorqueException
     {
         return executeQuery(queryString, Torque.getDefaultDB(), false);
     }
@@ -1268,11 +1394,11 @@
      * @param queryString A String with the sql statement to execute.
      * @param dbName The database to connect to.
      * @return Vector of Record objects.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector executeQuery(String queryString,
                                       String dbName)
-        throws Exception
+        throws TorqueException
     {
         return executeQuery(queryString, dbName, false);
     }
@@ -1285,12 +1411,12 @@
      * @param singleRecord Whether or not we want to select only a
      * single record.
      * @return Vector of Record objects.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector executeQuery(String queryString,
                                       String dbName,
                                       boolean singleRecord)
-        throws Exception
+        throws TorqueException
     {
         return executeQuery(queryString, 0, -1, dbName, singleRecord);
     }
@@ -1304,12 +1430,12 @@
      * single record.
      * @param dbCon A DBConnection.
      * @return Vector of Record objects.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector executeQuery(String queryString,
                                       boolean singleRecord,
                                       DBConnection dbCon)
-        throws Exception
+        throws TorqueException
     {
         return executeQuery(queryString, 0, -1, singleRecord, dbCon);
     }
@@ -1325,14 +1451,14 @@
      * @param singleRecord Whether or not we want to select only a
      * single record.
      * @return Vector of Record objects.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector executeQuery(String queryString,
                                       int start,
                                       int numberOfResults,
                                       String dbName,
                                       boolean singleRecord)
-        throws Exception
+        throws TorqueException
     {
         DBConnection db = null;
         Vector results = null;
@@ -1362,16 +1488,24 @@
      * single record.
      * @param dbCon A DBConnection.
      * @return Vector of Record objects.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector executeQuery(String queryString,
                                       int start,
                                       int numberOfResults,
                                       boolean singleRecord,
                                       DBConnection dbCon)
-        throws Exception
+        throws TorqueException
     {
-        Connection connection = dbCon.getConnection();
+        Connection connection = null;
+        try
+        {
+            connection = dbCon.getConnection();
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
+        }
 
         QueryDataSet qds = null;
         Vector results = new Vector();
@@ -1385,9 +1519,22 @@
             results = getSelectResults( qds, start, numberOfResults,
                                         singleRecord);
         }
+        catch (Exception e)
+        {
+            throw new TorqueException(e);
+        }
         finally
         {
-            if (qds != null) qds.close();
+            if (qds != null)
+            {
+                try
+                {
+                    qds.close();
+                }
+                catch (Exception ignored)
+                {
+                }
+            }
         }
         return results;
     }
@@ -1399,10 +1546,10 @@
      *
      * @param qds A QueryDataSet.
      * @return Vector of Record objects.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector getSelectResults( QueryDataSet qds )
-        throws Exception
+        throws TorqueException
     {
         return getSelectResults( qds, 0, -1, false);
     }
@@ -1414,11 +1561,11 @@
      * @param qds A QueryDataSet.
      * @param singleRecord Whether or not we want to select only a
      * single record.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector getSelectResults( QueryDataSet qds,
                                            boolean singleRecord )
-        throws Exception
+        throws TorqueException
     {
         return getSelectResults(qds, 0, -1, singleRecord);
     }
@@ -1432,12 +1579,12 @@
      * @param numberOfResults The number of results to return.
      * @param singleRecord Whether or not we want to select only a
      * single record.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector getSelectResults( QueryDataSet qds,
                                            int numberOfResults,
                                            boolean singleRecord )
-        throws Exception
+        throws TorqueException
     {
         Vector results = null;
         if (numberOfResults != 0)
@@ -1457,35 +1604,42 @@
      * @param numberOfResults The number of results to return.
      * @param singleRecord Whether or not we want to select only a
      * single record.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static Vector getSelectResults( QueryDataSet qds,
                                            int start,
                                            int numberOfResults,
                                            boolean singleRecord )
-        throws Exception
+        throws TorqueException
     {
         Vector results;
-        if ( numberOfResults <= 0 )
-        {
-            results = new Vector();
-            qds.fetchRecords();
-        }
-        else
-        {
-            results = new Vector(numberOfResults);
-            qds.fetchRecords(start, numberOfResults);
-        }
-        if ( qds.size() > 1 && singleRecord )
+        try
         {
-            handleMultipleRecords(qds);
-        }
+            if ( numberOfResults <= 0 )
+            {
+                results = new Vector();
+                qds.fetchRecords();
+            }
+            else
+            {
+                results = new Vector(numberOfResults);
+                qds.fetchRecords(start, numberOfResults);
+            }
+            if ( qds.size() > 1 && singleRecord )
+            {
+                handleMultipleRecords(qds);
+            }
 
-        // Return a Vector of Record objects.
-        for ( int i=0; i<qds.size(); i++ )
+            // Return a Vector of Record objects.
+            for ( int i=0; i<qds.size(); i++ )
+            {
+                Record rec = qds.getRecord(i);
+                results.addElement(rec);
+            }
+        }
+        catch (Exception e)
         {
-            Record rec = qds.getRecord(i);
-            results.addElement(rec);
+            throw new TorqueException(e);
         }
         return results;
     }
@@ -1497,10 +1651,10 @@
      * @param criteria A Criteria.
      * @return ColumnMap if the Criteria object contains a primary
      * key, or null if it doesn't.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     private static ColumnMap getPrimaryKey(Criteria criteria)
-        throws Exception
+        throws TorqueException
     {
         // Assume all the keys are for the same table.
         String key = (String)criteria.keys().nextElement();
@@ -1512,9 +1666,13 @@
         {
             DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
             if (dbMap == null)
-                throw new Exception ("dbMap is null");
+            {
+                throw new TorqueException("dbMap is null");
+            }
             if (dbMap.getTable(table) == null)
-                throw new Exception ("dbMap.getTable() is null");
+            {
+                throw new TorqueException("dbMap.getTable() is null");
+            }
 
             ColumnMap[] columns = dbMap.getTable(table).getColumns();
 
@@ -1551,10 +1709,10 @@
      *
      * @param updateValues A Criteria object containing values used in
      * set clause.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static void doUpdate(Criteria updateValues)
-        throws Exception
+        throws TorqueException
     {
         boolean doTransaction =
             updateValues.containsObjectColumn(updateValues.getDbName());
@@ -1609,11 +1767,11 @@
      * @param updateValues A Criteria object containing values used in
      * set clause.
      * @param dbCon A DBConnection.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static void doUpdate(Criteria updateValues,
                                 DBConnection dbCon)
-        throws Exception
+        throws TorqueException
     {
         ColumnMap pk = getPrimaryKey(updateValues);
         Criteria selectCriteria = null;
@@ -1627,7 +1785,7 @@
         }
         else
         {
-            throw new Exception("BasePeer.doUpdate(criteria) - no PK specified");
+            throw new TorqueException("No PK specified for database update");
         }
 
         doUpdate( selectCriteria, updateValues, dbCon );
@@ -1650,11 +1808,11 @@
      * in where clause.
      * @param updateValues A Criteria object containing values used in
      * set clause.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static void doUpdate(Criteria selectCriteria,
                                 Criteria updateValues)
-        throws Exception
+        throws TorqueException
     {
         boolean doTransaction =
             updateValues.containsObjectColumn(selectCriteria.getDbName());
@@ -1704,25 +1862,34 @@
      * @param updateValues A Criteria object containing values used in
      * set clause.
      * @param dbCon A DBConnection.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static void doUpdate(Criteria selectCriteria,
                                 Criteria updateValues,
                                 DBConnection dbCon)
-        throws Exception
+        throws TorqueException
     {
         DB db = Torque.getDB( selectCriteria.getDbName() );
         DatabaseMap dbMap =
             Torque.getDatabaseMap( selectCriteria.getDbName() );
-        Connection connection = dbCon.getConnection();
+        Connection connection = null;
+        try
+        {
+            connection = dbCon.getConnection();
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
+        }
 
         // Set up a list of required tables.  StringStack.add()
         // only adds element if it is unique.
         StringStack tables = new StringStack();
-        Enumeration e = selectCriteria.keys();
-        while(e.hasMoreElements())
+        Enumeration enum = selectCriteria.keys();
+        while (enum.hasMoreElements())
         {
-            tables.add(selectCriteria.getTableName( (String)e.nextElement() ));
+            tables.add( selectCriteria.getTableName
+                        ((String) enum.nextElement()) );
         }
 
         for (int i=0; i<tables.size(); i++)
@@ -1779,11 +1946,22 @@
                         .insertOrUpdateRecord(rec, tables.get(i), updateValues);
                 }
             }
+            catch (Exception e)
+            {
+                throw new TorqueException(e);
+            }
             finally
             {
                 if (tds != null)
                 {
-                    tds.close();
+                    try
+                    {
+                        tds.close();
+                    }
+                    catch (Exception e)
+                    {
+                        throw new TorqueException(e);
+                    }
                 }
             }
         }
@@ -1796,10 +1974,10 @@
      *
      * @param stmt A String with the sql statement to execute.
      * @return The number of rows affected.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static int executeStatement(String stmt)
-        throws Exception
+        throws TorqueException
     {
         return executeStatement(stmt, Torque.getDefaultDB());
     }
@@ -1815,7 +1993,7 @@
      * @exception Exception, a generic exception.  */
     public static int executeStatement(String stmt,
                                        String dbName)
-        throws Exception
+        throws TorqueException
     {
         DBConnection db = null;
         int rowCount = -1;
@@ -1842,26 +2020,45 @@
      * @param stmt A String with the sql statement to execute.
      * @param dbCon A DBConnection.
      * @return The number of rows affected.
-     * @exception Exception, a generic exception.
+     * @exception TorqueException
      */
     public static int executeStatement(String stmt,
                                        DBConnection dbCon)
-        throws Exception
+        throws TorqueException
     {
-        Connection con = dbCon.getConnection();
-        Statement statement = null;
         int rowCount = -1;
+        Statement statement = null;
+        Connection con = null;
+        try
+        {
+            dbCon.getConnection();
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
+        }
 
         try
         {
             statement = con.createStatement();
             rowCount = statement.executeUpdate( stmt );
         }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
+        }
         finally
         {
             if (statement != null)
             {
-                statement.close();
+                try
+                {
+                    statement.close();
+                }
+                catch (SQLException e)
+                {
+                    throw new TorqueException(e);
+                }
             }
         }
         return rowCount;
@@ -1879,17 +2076,17 @@
      * @exception Exception Couldn't handle multiple records.
      */
     protected static void handleMultipleRecords(DataSet ds)
-        throws Exception
+        throws TorqueException
     {
-        throw new Exception(
-            "Criteria expected single Record and Multiple Records were selected.");
+        throw new TorqueException("Criteria expected single Record and " +
+                                  "Multiple Records were selected");
     }
 
     /**
      * @deprecated Use the better-named handleMultipleRecords() instead.
      */
     protected static void handleMultiple(DataSet ds)
-        throws Exception
+        throws TorqueException
     {
         handleMultipleRecords(ds);
     }
@@ -1903,7 +2100,7 @@
      *
      */
     public static MapBuilder getMapBuilder()
-        throws Exception
+        throws TorqueException
     {
         return getMapBuilder(DEFAULT_MAP_BUILDER.trim());
     }
@@ -1989,7 +2186,7 @@
      * @exception Exception Error performing database query.
      */
     public static Vector doPSSelect(Criteria criteria, DBConnection dbCon)
-        throws Exception
+        throws TorqueException
     {
         Vector v = null;
 
@@ -2030,11 +2227,22 @@
                 }
             }
         }
+        catch (Exception e)
+        {
+            throw new TorqueException(e);
+        }
         finally
         {
             if (stmt != null)
             {
-                stmt.close();
+                try
+                {
+                    stmt.close();
+                }
+                catch (SQLException e)
+                {
+                    throw new TorqueException(e);
+                }
             }
         }
 
@@ -2070,7 +2278,7 @@
     public static void createPreparedStatement(Criteria criteria,
                                                StringBuffer queryString,
                                                List params)
-        throws Exception
+        throws TorqueException
     {
         DB db = Torque.getDB( criteria.getDbName() );
         DatabaseMap dbMap = Torque.getDatabaseMap( criteria.getDbName() );
@@ -2104,7 +2312,7 @@
             String columnName = select.get(i);
             if (columnName.indexOf('.') == -1)
             {
-                throw getMalformedColumnNameException("select", columnName);
+                throwMalformedColumnNameException("select", columnName);
             }
             String tableName = null;
             selectClause.add(columnName);
@@ -2194,11 +2402,11 @@
                 String join2 = (String)criteria.getJoinR().get(i);
                 if (join1.indexOf('.') == -1)
                 {
-                    throw getMalformedColumnNameException("join",join1);
+                    throwMalformedColumnNameException("join",join1);
                 }
                 if (join2.indexOf('.') == -1)
                 {
-                    throw getMalformedColumnNameException("join",join2);
+                    throwMalformedColumnNameException("join",join2);
                 }
 
                 String tableName = join1.substring(0, join1.indexOf('.'));
@@ -2253,7 +2461,7 @@
                 String orderByColumn = orderBy.get(i);
                 if (orderByColumn.indexOf('.') == -1)
                 {
-                    throw getMalformedColumnNameException("order by",orderByColumn);
+                    throwMalformedColumnNameException("order by",orderByColumn);
                 }
                 String table = orderByColumn.substring(0,orderByColumn.indexOf('.') );
                 // See if there's a space (between the column list and sort
@@ -2324,23 +2532,23 @@
     }
 
     /**
-     * return an Exception with the malformed column name error message.
-     * The error message looks like this:<p>
+     * Throws a TorqueException with the malformed column name error
+     * message.  The error message looks like this:<p>
      *
      * <code>
-     *     malformed column name in Criteria [criteriaPhrase]:
+     *     Malformed column name in Criteria [criteriaPhrase]:
      *     '[columnName]' is not of the form 'table.column'
      * </code>
      *
      * @param criteriaPhrase a String, one of "select", "join", or "order by"
      * @param columnName a String containing the offending column name
      */
-    private static Exception getMalformedColumnNameException(String criteriaPhrase,
-                                                             String columnName)
-    {
-        return new Exception("malformed column name in Criteria "
-                             + criteriaPhrase + ": '"
-                             + columnName
-                             + "' is not of the form 'table.column'");
+    private static void throwMalformedColumnNameException
+        (String criteriaPhrase, String columnName)
+        throws TorqueException
+    {
+        throw new TorqueException("Malformed column name in Criteria " +
+                                  criteriaPhrase + ": '" + columnName +
+                                  "' is not of the form 'table.column'");
     }
 }
Index: java/org/apache/torque/util/Criteria.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/util/Criteria.java,v
retrieving revision 1.10
diff -u -r1.10 Criteria.java
--- java/org/apache/torque/util/Criteria.java	12 Feb 2002 20:24:47 -0000	1.10
+++ java/org/apache/torque/util/Criteria.java	26 Feb 2002 18:48:40 -0000
@@ -69,6 +69,7 @@
 import java.util.Set;
 import java.util.Vector;
 import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
 import org.apache.torque.adapter.DB;
 import org.apache.torque.map.DatabaseMap;
 import org.apache.torque.map.TableMap;
@@ -382,9 +383,10 @@
      * Object column.
      *
      * @return A boolean.
-     * @exception Exception, a generic exception.
+     * @throws TorqueException Any exceptions caught during processing will be
+     *         rethrown wrapped into a TorqueException.
      */
-    public boolean containsObjectColumn() throws Exception
+    public boolean containsObjectColumn() throws TorqueException
     {
         return containsObjectColumn(dbName);
     }
@@ -395,10 +397,11 @@
      *
      * @param databaseMapName A String.
      * @return A boolean.
-     * @exception Exception, a generic exception.
+     * @throws TorqueException Any exceptions caught during processing will be
+     *         rethrown wrapped into a TorqueException.
      */
     public boolean containsObjectColumn(String databaseMapName)
-        throws Exception
+        throws TorqueException
     {
         // Peer or application may have noted the existence of a blob
         // so we can save the lookup.
Index: java/org/apache/torque/util/SqlExpression.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/util/SqlExpression.java,v
retrieving revision 1.11
diff -u -r1.11 SqlExpression.java
--- java/org/apache/torque/util/SqlExpression.java	26 Feb 2002 17:51:18 -0000	1.11
+++ java/org/apache/torque/util/SqlExpression.java	26 Feb 2002 18:48:41 -0000
@@ -62,6 +62,7 @@
 import org.apache.torque.om.DateKey;
 import org.apache.torque.om.ObjectKey;
 import org.apache.torque.om.StringKey;
+import org.apache.torque.TorqueException;
 import org.apache.commons.util.StringStack;
 
 /**
@@ -174,12 +175,13 @@
      * !=, LIKE, etc.
      * @return A simple SQL expression, e.g. UPPER(table_a.column_a)
      * LIKE UPPER('ab%c').
-     * @exception Exception, a generic exception.
+     * @throws TorqueException Any exceptions caught during processing will be
+     *         rethrown wrapped into a TorqueException.
      */
     public static String build( String columnName,
                                 Object criteria,
                                 SqlEnum comparison )
-        throws Exception
+        throws TorqueException
     {
         // 'db' can be null because 'ignoreCase' is null
         return build( columnName, criteria, comparison, false, null );
@@ -199,14 +201,15 @@
      * functions.
      * @return A simple sql expression, e.g. UPPER(table_a.column_a)
      * LIKE UPPER('ab%c').
-     * @exception Exception, a generic exception.
+     * @throws TorqueException Any exceptions caught during processing will be
+     *         rethrown wrapped into a TorqueException.
      */
     public static String build( String columnName,
                                 Object criteria,
                                 SqlEnum comparison,
                                 boolean ignoreCase,
                                 DB db )
-        throws Exception
+        throws TorqueException
     {
         int addlength = (ignoreCase ? 40 : 20);
         StringBuffer sb = new StringBuffer(columnName.length() + addlength );
Index: templates/om/MapBuilder.vm
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/MapBuilder.vm,v
retrieving revision 1.7
diff -u -r1.7 MapBuilder.vm
--- templates/om/MapBuilder.vm	30 Dec 2001 16:30:15 -0000	1.7
+++ templates/om/MapBuilder.vm	26 Feb 2002 18:48:42 -0000
@@ -3,6 +3,7 @@
 import java.util.*;
 import java.math.*;
 import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
 import org.apache.torque.map.MapBuilder;
 import org.apache.torque.map.DatabaseMap;
 import org.apache.torque.map.TableMap;
@@ -77,7 +78,7 @@
     /** 
      * The doBuild() method builds the DatabaseMap 
      */
-    public void doBuild() throws Exception
+    public void doBuild() throws TorqueException
     {
         dbMap = Torque.getDatabaseMap("$table.Database.Name");
 
Index: templates/om/Object.vm
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/Object.vm,v
retrieving revision 1.18
diff -u -r1.18 Object.vm
--- templates/om/Object.vm	27 Dec 2001 18:28:59 -0000	1.18
+++ templates/om/Object.vm	26 Feb 2002 18:48:44 -0000
@@ -15,6 +15,7 @@
 import java.util.*;
 import java.math.*;
 import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
 import org.apache.torque.om.*;
 import org.apache.torque.util.BasePeer;
 import org.apache.torque.util.Criteria;
@@ -102,11 +103,11 @@
         #set ( $throwsClause = "" )
         #if ($complexObjectModel)
           #if ($col.isForeignKey())
-            #set ( $throwsClause = "throws Exception" )
+            #set ( $throwsClause = "throws TorqueException" )
           #end    
           #if ( $col.Referrers.size() > 0 )
             #if ($throwsClause == "")
-              #set ( $throwsClause = "throws Exception" )
+              #set ( $throwsClause = "throws TorqueException" )
             #end
           #end
         #end
@@ -235,7 +236,7 @@
      *
      * @param $className v
      */
-    public void set${pVarName}($className v) throws Exception
+    public void set${pVarName}($className v) throws TorqueException
     {
    #foreach ($columnName in $fk.LocalColumns)
     #set ( $column = $table.getColumn($columnName) )
@@ -265,7 +266,7 @@
    #end
    #set ( $pCollName = "${table.JavaName}s$relCol" )
     
-    public $className get${pVarName}() throws Exception
+    public $className get${pVarName}() throws TorqueException
     {
         if ( $varName==null && ($conditional) )
         {
@@ -302,7 +303,7 @@
      * overridden in <code>$table.JavaName</code>.
 #end
      */
-    public void set${pVarName}Key(ObjectKey key) throws Exception
+    public void set${pVarName}Key(ObjectKey key) throws TorqueException
     {
     #if ($fk.LocalColumns.size() > 1)
         SimpleKey[] keys = (SimpleKey[])key.getValue();
@@ -371,7 +372,7 @@
      *
      * @param $className l
      */
-    public void add${relColMs}($className l) throws Exception
+    public void add${relColMs}($className l) throws TorqueException
     {
         get${relCol}().add(l);
         l.set${table.JavaName}${suffix}(($table.JavaName)this);
@@ -387,7 +388,7 @@
      * the collection. Otherwise returns the results of 
      * get${relCol}(new Criteria())
      */
-    public Vector get${relCol}() throws Exception
+    public Vector get${relCol}() throws TorqueException
     {
         if ($collName == null)
         {
@@ -405,7 +406,7 @@
      * an empty collection or the current collection, the criteria
      * is ignored on a new object. 
      */
-    public Vector get${relCol}(Criteria criteria) throws Exception
+    public Vector get${relCol}(Criteria criteria) throws TorqueException
     {
         if ($collName == null)
         {
@@ -518,7 +519,7 @@
      * actually need in ${table.JavaName}.
      */
     protected Vector get${relCol}Join${relCol2}(Criteria criteria) 
-        throws Exception
+        throws TorqueException
     {
         if ($collName == null)
         {
@@ -576,7 +577,7 @@
      * actually need in ${table.JavaName}.
      */
     protected Vector get${relCol}JoinAllExcept${table.JavaName}(Criteria criteria) 
-        throws Exception
+        throws TorqueException
     {
         if ($collName == null)
         {
@@ -765,7 +766,7 @@
      * Stores the object in the database.  If the object is new,
      * it inserts it; otherwise an update is performed.
      */
-    public void save() throws Exception
+    public void save() throws TorqueException
     {
  #if ($complexObjectModel)
             save(${table.JavaName}Peer.getMapBuilder()
@@ -795,7 +796,7 @@
      * in this file instead of in the super class, BaseObject.
 #end
      */
-    public void save(String dbName) throws Exception
+    public void save(String dbName) throws TorqueException
     {
         DBConnection dbCon = null;
  #if ($complexObjectModel)
@@ -804,7 +805,7 @@
             dbCon = BasePeer.beginTransaction(dbName);
             save(dbCon);
         }
-        catch(Exception e)
+        catch(TorqueException e)
         {
             BasePeer.rollBackTransaction(dbCon);
             throw e;
@@ -850,7 +851,7 @@
      * the save() method and the connection details will be handled
      * internally
      */
-    public void save(DBConnection dbCon) throws Exception
+    public void save(DBConnection dbCon) throws TorqueException
     {
   #if ($complexObjectModel)
       if (!alreadyInSave)
@@ -943,7 +944,7 @@
 #foreach ($col in $table.PrimaryKeys)
     #if ($complexObjectModel)
         #if ( $col.isForeignKey() || ($col.Referrers.size() > 0) )
-            #set ( $throwsClause = "throws Exception" )
+            #set ( $throwsClause = "throws TorqueException" )
         #end
     #end
 
@@ -985,7 +986,7 @@
     /** 
      * Set the PrimaryKey with an ObjectKey
      */
-    public void setPrimaryKey(ObjectKey key) throws Exception
+    public void setPrimaryKey(ObjectKey key) throws TorqueException
     {
         SimpleKey[] keys = (SimpleKey[])key.getValue();
     #set ($i = 0)
@@ -1029,7 +1030,7 @@
     /** 
      * Set the PrimaryKey using a String.
      */
-    public void setPrimaryKey(String key) throws Exception
+    public void setPrimaryKey(String key) throws TorqueException
     {
         int prevPos = 0;
 
@@ -1089,7 +1090,7 @@
      * of its class.
      */
     public void setQueryKey(String key) 
-        throws Exception
+        throws TorqueException
     {
         setPrimaryKey(key);
     }
@@ -1105,10 +1106,10 @@
 #end
      */
 #if ($table.ChildrenColumn || $table.isAbstract()) 
-    public $table.JavaName copyInto($table.JavaName copyObj) throws Exception
+    public $table.JavaName copyInto($table.JavaName copyObj) throws TorqueException
     {
 #else
-    public $table.JavaName copy() throws Exception
+    public $table.JavaName copy() throws TorqueException
     {
         $table.JavaName copyObj = new ${table.JavaName}();
 #end
Index: templates/om/Peer.vm
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/Peer.vm,v
retrieving revision 1.14
diff -u -r1.14 Peer.vm
--- templates/om/Peer.vm	4 Feb 2002 18:01:54 -0000	1.14
+++ templates/om/Peer.vm	26 Feb 2002 18:48:47 -0000
@@ -29,22 +29,22 @@
   *
 #end
   */
-public abstract class $basePrefix${table.JavaName}Peer 
+public abstract class $basePrefix${table.JavaName}Peer
     extends $table.BasePeer
 {
 #if (!$table.isAlias())
 
     /** the default database name for this class */
     public static final String DATABASE_NAME = "$table.Database.Name";
- 
+
      /** the table name for this class */
     public static final String TABLE_NAME = "$table.Name";
- 
-    /** 
-     * @returns the map builder for this peer 
+
+    /**
+     * @returns the map builder for this peer
      */
     public static MapBuilder getMapBuilder()
-        throws Exception
+        throws TorqueException
     {
         return getMapBuilder(${table.JavaName}MapBuilder.CLASS_NAME);
     }
@@ -89,7 +89,7 @@
     public static final int numColumns =  $table.NumColumns;
 
     /** A class that can be returned by this peer. */
-    protected static final String CLASSNAME_DEFAULT = 
+    protected static final String CLASSNAME_DEFAULT =
         "${package}.$table.JavaName";
 
     /** A class that can be returned by this peer. */
@@ -100,7 +100,7 @@
     {
         Class c = null;
         try
-        { 
+        {
             c = Class.forName(className);
         }
         catch (Throwable t)
@@ -127,22 +127,32 @@
      * resultset MUST return columns in the right order.  You can use
      * getFieldNames() in BaseObject to get the correct sequence.
      */
-    public static Vector resultSet2Objects (java.sql.ResultSet results) throws Exception
+    public static Vector resultSet2Objects (java.sql.ResultSet results) throws TorqueException
     {
-        QueryDataSet qds = null;
-        Vector rows = null;
         try
         {
-            qds = new QueryDataSet( results );
-            rows = getSelectResults( qds );
+            QueryDataSet qds = null;
+            Vector rows = null;
+            try
+            {
+                qds = new QueryDataSet( results );
+                rows = getSelectResults( qds );
+            }
+            finally
+            {
+                if (qds != null) qds.close();
+            }
+
+            return populateObjects (rows);
         }
-        finally
+        catch (SQLException e)
         {
-            if (qds != null) qds.close();
+            throw new TorqueException(e);
+        }
+        catch (DataSetException e)
+        {
+            throw new TorqueException(e);
         }
-
-        return populateObjects (rows);

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>