Coverage report

  %line %branch
org.apache.turbine.services.security.torque.om.BaseTurbineGroupPeer
41% 
81% 

 1  
 package org.apache.turbine.services.security.torque.om;
 2  
 
 3  
 import java.math.BigDecimal;
 4  
 import java.sql.Connection;
 5  
 import java.sql.SQLException;
 6  
 import java.util.ArrayList;
 7  
 import java.util.Date;
 8  
 import java.util.Iterator;
 9  
 import java.util.LinkedList;
 10  
 import java.util.List;
 11  
 
 12  
 import org.apache.torque.NoRowsException;
 13  
 import org.apache.torque.TooManyRowsException;
 14  
 import org.apache.torque.Torque;
 15  
 import org.apache.torque.TorqueException;
 16  
 import org.apache.torque.map.MapBuilder;
 17  
 import org.apache.torque.map.TableMap;
 18  
 import org.apache.torque.om.DateKey;
 19  
 import org.apache.torque.om.NumberKey;
 20  
 import org.apache.torque.om.StringKey;
 21  
 import org.apache.torque.om.ObjectKey;
 22  
 import org.apache.torque.om.SimpleKey;
 23  
 import org.apache.torque.util.BasePeer;
 24  
 import org.apache.torque.util.Criteria;
 25  
 
 26  
 import com.workingdogs.village.DataSetException;
 27  
 import com.workingdogs.village.QueryDataSet;
 28  
 import com.workingdogs.village.Record;
 29  
 
 30  
 // Local classes
 31  
 import org.apache.turbine.services.security.torque.om.map.*;
 32  
 
 33  
 
 34  
 /**
 35  
  * This class was autogenerated by Torque on:
 36  
  *
 37  
  * [Mon Oct 03 14:24:58 CEST 2005]
 38  
  *
 39  
  */
 40  16
 public abstract class BaseTurbineGroupPeer
 41  
     extends BasePeer
 42  
 {
 43  
 
 44  
     /** the default database name for this class */
 45  
     public static final String DATABASE_NAME = "default";
 46  
 
 47  
      /** the table name for this class */
 48  
     public static final String TABLE_NAME = "TURBINE_GROUP";
 49  
 
 50  
     /**
 51  
      * @return the map builder for this peer
 52  
      * @throws TorqueException Any exceptions caught during processing will be
 53  
      *         rethrown wrapped into a TorqueException.
 54  
      */
 55  
     public static MapBuilder getMapBuilder()
 56  
         throws TorqueException
 57  
     {
 58  0
         return getMapBuilder(TurbineGroupMapBuilder.CLASS_NAME);
 59  
     }
 60  
 
 61  
       /** the column name for the GROUP_ID field */
 62  
     public static final String GROUP_ID;
 63  
       /** the column name for the GROUP_NAME field */
 64  
     public static final String GROUP_NAME;
 65  
   
 66  
     static
 67  8
     {
 68  16
           GROUP_ID = "TURBINE_GROUP.GROUP_ID";
 69  16
           GROUP_NAME = "TURBINE_GROUP.GROUP_NAME";
 70  16
           if (Torque.isInit())
 71  
         {
 72  
             try
 73  
             {
 74  16
                 getMapBuilder(TurbineGroupMapBuilder.CLASS_NAME);
 75  8
             }
 76  0
             catch (Exception e)
 77  
             {
 78  0
                 log.error("Could not initialize Peer", e);
 79  16
             }
 80  
         }
 81  
         else
 82  
         {
 83  0
             Torque.registerMapBuilder(TurbineGroupMapBuilder.CLASS_NAME);
 84  
         }
 85  
     }
 86  
  
 87  
     /** number of columns for this peer */
 88  
     public static final int numColumns =  2;
 89  
 
 90  
     /** A class that can be returned by this peer. */
 91  
     protected static final String CLASSNAME_DEFAULT =
 92  
         "org.apache.turbine.services.security.torque.om.TurbineGroup";
 93  
 
 94  
     /** A class that can be returned by this peer. */
 95  16
     protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
 96  
 
 97  
     /**
 98  
      * Class object initialization method.
 99  
      *
 100  
      * @param className name of the class to initialize
 101  
      * @return the initialized class
 102  
      */
 103  
     private static Class initClass(String className)
 104  
     {
 105  16
         Class c = null;
 106  
         try
 107  
         {
 108  16
             c = Class.forName(className);
 109  8
         }
 110  0
         catch (Throwable t)
 111  
         {
 112  0
             log.error("A FATAL ERROR has occurred which should not "
 113  
                 + "have happened under any circumstance.  Please notify "
 114  
                 + "the Torque developers <torque-dev@db.apache.org> "
 115  
                 + "and give as many details as possible (including the error "
 116  
                 + "stack trace).", t);
 117  
 
 118  
             // Error objects should always be propogated.
 119  0
             if (t instanceof Error)
 120  
             {
 121  0
                 throw (Error) t.fillInStackTrace();
 122  
             }
 123  8
         }
 124  16
         return c;
 125  
     }
 126  
 
 127  
     /**
 128  
      * Get the list of objects for a ResultSet.  Please not that your
 129  
      * resultset MUST return columns in the right order.  You can use
 130  
      * getFieldNames() in BaseObject to get the correct sequence.
 131  
      *
 132  
      * @param results the ResultSet
 133  
      * @return the list of objects
 134  
      * @throws TorqueException Any exceptions caught during processing will be
 135  
      *         rethrown wrapped into a TorqueException.
 136  
      */
 137  
     public static List resultSet2Objects(java.sql.ResultSet results)
 138  
             throws TorqueException
 139  
     {
 140  
         try
 141  
         {
 142  0
             QueryDataSet qds = null;
 143  0
             List rows = null;
 144  
             try
 145  
             {
 146  0
                 qds = new QueryDataSet(results);
 147  0
                 rows = getSelectResults(qds);
 148  
             }
 149  
             finally
 150  
             {
 151  0
                 if (qds != null)
 152  
                 {
 153  0
                     qds.close();
 154  
                 }
 155  
             }
 156  
 
 157  0
             return populateObjects(rows);
 158  
         }
 159  0
         catch (SQLException e)
 160  
         {
 161  0
             throw new TorqueException(e);
 162  
         }
 163  0
         catch (DataSetException e)
 164  
         {
 165  0
             throw new TorqueException(e);
 166  
         }
 167  
     }
 168  
 
 169  
 
 170  
   
 171  
     /**
 172  
      * Method to do inserts.
 173  
      *
 174  
      * @param criteria object used to create the INSERT statement.
 175  
      * @throws TorqueException Any exceptions caught during processing will be
 176  
      *         rethrown wrapped into a TorqueException.
 177  
      */
 178  
     public static ObjectKey doInsert(Criteria criteria)
 179  
         throws TorqueException
 180  
     {
 181  4
         return BaseTurbineGroupPeer
 182  
             .doInsert(criteria, (Connection) null);
 183  
     }
 184  
 
 185  
     /**
 186  
      * Method to do inserts.  This method is to be used during a transaction,
 187  
      * otherwise use the doInsert(Criteria) method.  It will take care of
 188  
      * the connection details internally.
 189  
      *
 190  
      * @param criteria object used to create the INSERT statement.
 191  
      * @param con the connection to use
 192  
      * @throws TorqueException Any exceptions caught during processing will be
 193  
      *         rethrown wrapped into a TorqueException.
 194  
      */
 195  
     public static ObjectKey doInsert(Criteria criteria, Connection con)
 196  
         throws TorqueException
 197  
     {
 198  
               
 199  4
         setDbName(criteria);
 200  
 
 201  4
         if (con == null)
 202  
         {
 203  4
             return BasePeer.doInsert(criteria);
 204  
         }
 205  
         else
 206  
         {
 207  0
             return BasePeer.doInsert(criteria, con);
 208  
         }
 209  
     }
 210  
 
 211  
     /**
 212  
      * Add all the columns needed to create a new object.
 213  
      *
 214  
      * @param criteria object containing the columns to add.
 215  
      * @throws TorqueException Any exceptions caught during processing will be
 216  
      *         rethrown wrapped into a TorqueException.
 217  
      */
 218  
     public static void addSelectColumns(Criteria criteria)
 219  
             throws TorqueException
 220  
     {
 221  104
           criteria.addSelectColumn(GROUP_ID);
 222  104
           criteria.addSelectColumn(GROUP_NAME);
 223  104
       }
 224  
 
 225  
     /**
 226  
      * Create a new object of type cls from a resultset row starting
 227  
      * from a specified offset.  This is done so that you can select
 228  
      * other rows than just those needed for this object.  You may
 229  
      * for example want to create two objects from the same row.
 230  
      *
 231  
      * @throws TorqueException Any exceptions caught during processing will be
 232  
      *         rethrown wrapped into a TorqueException.
 233  
      */
 234  
     public static TurbineGroup row2Object(Record row,
 235  
                                              int offset,
 236  
                                              Class cls)
 237  
         throws TorqueException
 238  
     {
 239  
         try
 240  
         {
 241  222
             TurbineGroup obj = (TurbineGroup) cls.newInstance();
 242  222
             TurbineGroupPeer.populateObject(row, offset, obj);
 243  222
                   obj.setModified(false);
 244  222
               obj.setNew(false);
 245  
 
 246  222
             return obj;
 247  
         }
 248  0
         catch (InstantiationException e)
 249  
         {
 250  0
             throw new TorqueException(e);
 251  
         }
 252  0
         catch (IllegalAccessException e)
 253  
         {
 254  0
             throw new TorqueException(e);
 255  
         }
 256  
     }
 257  
 
 258  
     /**
 259  
      * Populates an object from a resultset row starting
 260  
      * from a specified offset.  This is done so that you can select
 261  
      * other rows than just those needed for this object.  You may
 262  
      * for example want to create two objects from the same row.
 263  
      *
 264  
      * @throws TorqueException Any exceptions caught during processing will be
 265  
      *         rethrown wrapped into a TorqueException.
 266  
      */
 267  
     public static void populateObject(Record row,
 268  
                                       int offset,
 269  
                                       TurbineGroup obj)
 270  
         throws TorqueException
 271  
     {
 272  
         try
 273  
         {
 274  222
                 obj.setGroupId(row.getValue(offset + 0).asInt());
 275  222
                   obj.setName(row.getValue(offset + 1).asString());
 276  111
               }
 277  0
         catch (DataSetException e)
 278  
         {
 279  0
             throw new TorqueException(e);
 280  111
         }
 281  222
     }
 282  
 
 283  
     /**
 284  
      * Method to do selects.
 285  
      *
 286  
      * @param criteria object used to create the SELECT statement.
 287  
      * @return List of selected Objects
 288  
      * @throws TorqueException Any exceptions caught during processing will be
 289  
      *         rethrown wrapped into a TorqueException.
 290  
      */
 291  
     public static List doSelect(Criteria criteria) throws TorqueException
 292  
     {
 293  104
         return populateObjects(doSelectVillageRecords(criteria));
 294  
     }
 295  
 
 296  
     /**
 297  
      * Method to do selects within a transaction.
 298  
      *
 299  
      * @param criteria object used to create the SELECT statement.
 300  
      * @param con the connection to use
 301  
      * @return List of selected Objects
 302  
      * @throws TorqueException Any exceptions caught during processing will be
 303  
      *         rethrown wrapped into a TorqueException.
 304  
      */
 305  
     public static List doSelect(Criteria criteria, Connection con)
 306  
         throws TorqueException
 307  
     {
 308  0
         return populateObjects(doSelectVillageRecords(criteria, con));
 309  
     }
 310  
 
 311  
     /**
 312  
      * Grabs the raw Village records to be formed into objects.
 313  
      * This method handles connections internally.  The Record objects
 314  
      * returned by this method should be considered readonly.  Do not
 315  
      * alter the data and call save(), your results may vary, but are
 316  
      * certainly likely to result in hard to track MT bugs.
 317  
      *
 318  
      * @throws TorqueException Any exceptions caught during processing will be
 319  
      *         rethrown wrapped into a TorqueException.
 320  
      */
 321  
     public static List doSelectVillageRecords(Criteria criteria)
 322  
         throws TorqueException
 323  
     {
 324  104
         return BaseTurbineGroupPeer
 325  
             .doSelectVillageRecords(criteria, (Connection) null);
 326  
     }
 327  
 
 328  
     /**
 329  
      * Grabs the raw Village records to be formed into objects.
 330  
      * This method should be used for transactions
 331  
      *
 332  
      * @param criteria object used to create the SELECT statement.
 333  
      * @param con the connection to use
 334  
      * @throws TorqueException Any exceptions caught during processing will be
 335  
      *         rethrown wrapped into a TorqueException.
 336  
      */
 337  
     public static List doSelectVillageRecords(Criteria criteria, Connection con)
 338  
         throws TorqueException
 339  
     {
 340  104
         if (criteria.getSelectColumns().size() == 0)
 341  
         {
 342  104
             addSelectColumns(criteria);
 343  
         }
 344  
 
 345  
               
 346  104
         setDbName(criteria);
 347  
 
 348  
         // BasePeer returns a List of Value (Village) arrays.  The array
 349  
         // order follows the order columns were placed in the Select clause.
 350  104
         if (con == null)
 351  
         {
 352  104
             return BasePeer.doSelect(criteria);
 353  
         }
 354  
         else
 355  
         {
 356  0
             return BasePeer.doSelect(criteria, con);
 357  
         }
 358  
     }
 359  
 
 360  
     /**
 361  
      * The returned List will contain objects of the default type or
 362  
      * objects that inherit from the default.
 363  
      *
 364  
      * @throws TorqueException Any exceptions caught during processing will be
 365  
      *         rethrown wrapped into a TorqueException.
 366  
      */
 367  
     public static List populateObjects(List records)
 368  
         throws TorqueException
 369  
     {
 370  104
         List results = new ArrayList(records.size());
 371  
 
 372  
         // populate the object(s)
 373  326
         for (int i = 0; i < records.size(); i++)
 374  
         {
 375  222
             Record row = (Record) records.get(i);
 376  222
               results.add(TurbineGroupPeer.row2Object(row, 1,
 377  
                 TurbineGroupPeer.getOMClass()));
 378  
           }
 379  104
         return results;
 380  
     }
 381  
  
 382  
 
 383  
     /**
 384  
      * The class that the Peer will make instances of.
 385  
      * If the BO is abstract then you must implement this method
 386  
      * in the BO.
 387  
      *
 388  
      * @throws TorqueException Any exceptions caught during processing will be
 389  
      *         rethrown wrapped into a TorqueException.
 390  
      */
 391  
     public static Class getOMClass()
 392  
         throws TorqueException
 393  
     {
 394  238
         return CLASS_DEFAULT;
 395  
     }
 396  
 
 397  
     /**
 398  
      * Method to do updates.
 399  
      *
 400  
      * @param criteria object containing data that is used to create the UPDATE
 401  
      *        statement.
 402  
      * @throws TorqueException Any exceptions caught during processing will be
 403  
      *         rethrown wrapped into a TorqueException.
 404  
      */
 405  
     public static void doUpdate(Criteria criteria) throws TorqueException
 406  
     {
 407  4
          BaseTurbineGroupPeer
 408  
             .doUpdate(criteria, (Connection) null);
 409  4
     }
 410  
 
 411  
     /**
 412  
      * Method to do updates.  This method is to be used during a transaction,
 413  
      * otherwise use the doUpdate(Criteria) method.  It will take care of
 414  
      * the connection details internally.
 415  
      *
 416  
      * @param criteria object containing data that is used to create the UPDATE
 417  
      *        statement.
 418  
      * @param con the connection to use
 419  
      * @throws TorqueException Any exceptions caught during processing will be
 420  
      *         rethrown wrapped into a TorqueException.
 421  
      */
 422  
     public static void doUpdate(Criteria criteria, Connection con)
 423  
         throws TorqueException
 424  
     {
 425  4
         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
 426  4
                    selectCriteria.put(GROUP_ID, criteria.remove(GROUP_ID));
 427  
                 
 428  4
         setDbName(criteria);
 429  
 
 430  4
         if (con == null)
 431  
         {
 432  4
             BasePeer.doUpdate(selectCriteria, criteria);
 433  
         }
 434  
         else
 435  
         {
 436  0
             BasePeer.doUpdate(selectCriteria, criteria, con);
 437  
         }
 438  4
     }
 439  
 
 440  
     /**
 441  
      * Method to do deletes.
 442  
      *
 443  
      * @param criteria object containing data that is used DELETE from database.
 444  
      * @throws TorqueException Any exceptions caught during processing will be
 445  
      *         rethrown wrapped into a TorqueException.
 446  
      */
 447  
      public static void doDelete(Criteria criteria) throws TorqueException
 448  
      {
 449  2
          TurbineGroupPeer
 450  
             .doDelete(criteria, (Connection) null);
 451  2
      }
 452  
 
 453  
     /**
 454  
      * Method to do deletes.  This method is to be used during a transaction,
 455  
      * otherwise use the doDelete(Criteria) method.  It will take care of
 456  
      * the connection details internally.
 457  
      *
 458  
      * @param criteria object containing data that is used DELETE from database.
 459  
      * @param con the connection to use
 460  
      * @throws TorqueException Any exceptions caught during processing will be
 461  
      *         rethrown wrapped into a TorqueException.
 462  
      */
 463  
      public static void doDelete(Criteria criteria, Connection con)
 464  
         throws TorqueException
 465  
      {
 466  
               
 467  2
         setDbName(criteria);
 468  
 
 469  2
         if (con == null)
 470  
         {
 471  2
             BasePeer.doDelete(criteria);
 472  
         }
 473  
         else
 474  
         {
 475  0
             BasePeer.doDelete(criteria, con);
 476  
         }
 477  2
      }
 478  
 
 479  
     /**
 480  
      * Method to do selects
 481  
      *
 482  
      * @throws TorqueException Any exceptions caught during processing will be
 483  
      *         rethrown wrapped into a TorqueException.
 484  
      */
 485  
     public static List doSelect(TurbineGroup obj) throws TorqueException
 486  
     {
 487  0
         return doSelect(buildSelectCriteria(obj));
 488  
     }
 489  
 
 490  
     /**
 491  
      * Method to do inserts
 492  
      *
 493  
      * @throws TorqueException Any exceptions caught during processing will be
 494  
      *         rethrown wrapped into a TorqueException.
 495  
      */
 496  
     public static void doInsert(TurbineGroup obj) throws TorqueException
 497  
     {
 498  0
           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
 499  0
           obj.setNew(false);
 500  0
         obj.setModified(false);
 501  0
     }
 502  
 
 503  
     /**
 504  
      * @param obj the data object to update in the database.
 505  
      * @throws TorqueException Any exceptions caught during processing will be
 506  
      *         rethrown wrapped into a TorqueException.
 507  
      */
 508  
     public static void doUpdate(TurbineGroup obj) throws TorqueException
 509  
     {
 510  0
         doUpdate(buildCriteria(obj));
 511  0
         obj.setModified(false);
 512  0
     }
 513  
 
 514  
     /**
 515  
      * @param obj the data object to delete in the database.
 516  
      * @throws TorqueException Any exceptions caught during processing will be
 517  
      *         rethrown wrapped into a TorqueException.
 518  
      */
 519  
     public static void doDelete(TurbineGroup obj) throws TorqueException
 520  
     {
 521  0
         doDelete(buildSelectCriteria(obj));
 522  0
     }
 523  
 
 524  
     /**
 525  
      * Method to do inserts.  This method is to be used during a transaction,
 526  
      * otherwise use the doInsert(TurbineGroup) method.  It will take
 527  
      * care of the connection details internally.
 528  
      *
 529  
      * @param obj the data object to insert into the database.
 530  
      * @param con the connection to use
 531  
      * @throws TorqueException Any exceptions caught during processing will be
 532  
      *         rethrown wrapped into a TorqueException.
 533  
      */
 534  
     public static void doInsert(TurbineGroup obj, Connection con)
 535  
         throws TorqueException
 536  
     {
 537  0
           obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
 538  0
           obj.setNew(false);
 539  0
         obj.setModified(false);
 540  0
     }
 541  
 
 542  
     /**
 543  
      * Method to do update.  This method is to be used during a transaction,
 544  
      * otherwise use the doUpdate(TurbineGroup) method.  It will take
 545  
      * care of the connection details internally.
 546  
      *
 547  
      * @param obj the data object to update in the database.
 548  
      * @param con the connection to use
 549  
      * @throws TorqueException Any exceptions caught during processing will be
 550  
      *         rethrown wrapped into a TorqueException.
 551  
      */
 552  
     public static void doUpdate(TurbineGroup obj, Connection con)
 553  
         throws TorqueException
 554  
     {
 555  0
         doUpdate(buildCriteria(obj), con);
 556  0
         obj.setModified(false);
 557  0
     }
 558  
 
 559  
     /**
 560  
      * Method to delete.  This method is to be used during a transaction,
 561  
      * otherwise use the doDelete(TurbineGroup) method.  It will take
 562  
      * care of the connection details internally.
 563  
      *
 564  
      * @param obj the data object to delete in the database.
 565  
      * @param con the connection to use
 566  
      * @throws TorqueException Any exceptions caught during processing will be
 567  
      *         rethrown wrapped into a TorqueException.
 568  
      */
 569  
     public static void doDelete(TurbineGroup obj, Connection con)
 570  
         throws TorqueException
 571  
     {
 572  0
         doDelete(buildSelectCriteria(obj), con);
 573  0
     }
 574  
 
 575  
     /**
 576  
      * Method to do deletes.
 577  
      *
 578  
      * @param pk ObjectKey that is used DELETE from database.
 579  
      * @throws TorqueException Any exceptions caught during processing will be
 580  
      *         rethrown wrapped into a TorqueException.
 581  
      */
 582  
     public static void doDelete(ObjectKey pk) throws TorqueException
 583  
     {
 584  0
         BaseTurbineGroupPeer
 585  
            .doDelete(pk, (Connection) null);
 586  0
     }
 587  
 
 588  
     /**
 589  
      * Method to delete.  This method is to be used during a transaction,
 590  
      * otherwise use the doDelete(ObjectKey) method.  It will take
 591  
      * care of the connection details internally.
 592  
      *
 593  
      * @param pk the primary key for the object to delete in the database.
 594  
      * @param con the connection to use
 595  
      * @throws TorqueException Any exceptions caught during processing will be
 596  
      *         rethrown wrapped into a TorqueException.
 597  
      */
 598  
     public static void doDelete(ObjectKey pk, Connection con)
 599  
         throws TorqueException
 600  
     {
 601  0
         doDelete(buildCriteria(pk), con);
 602  0
     }
 603  
 
 604  
     /** Build a Criteria object from an ObjectKey */
 605  
     public static Criteria buildCriteria( ObjectKey pk )
 606  
     {
 607  0
         Criteria criteria = new Criteria();
 608  0
               criteria.add(GROUP_ID, pk);
 609  0
           return criteria;
 610  
      }
 611  
 
 612  
     /** Build a Criteria object from the data object for this peer */
 613  
     public static Criteria buildCriteria( TurbineGroup obj )
 614  
     {
 615  10
         Criteria criteria = new Criteria(DATABASE_NAME);
 616  10
               if (!obj.isNew())
 617  6
             criteria.add(GROUP_ID, obj.getGroupId());
 618  10
               criteria.add(GROUP_NAME, obj.getName());
 619  10
           return criteria;
 620  
     }
 621  
 
 622  
     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
 623  
     public static Criteria buildSelectCriteria( TurbineGroup obj )
 624  
     {
 625  0
         Criteria criteria = new Criteria(DATABASE_NAME);
 626  0
               if (!obj.isNew())
 627  0
                     criteria.add(GROUP_ID, obj.getGroupId());
 628  0
                           criteria.add(GROUP_NAME, obj.getName());
 629  0
               return criteria;
 630  
     }
 631  
  
 632  
     
 633  
         /**
 634  
      * Retrieve a single object by pk
 635  
      *
 636  
      * @param pk the primary key
 637  
      * @throws TorqueException Any exceptions caught during processing will be
 638  
      *         rethrown wrapped into a TorqueException.
 639  
      * @throws NoRowsException Primary key was not found in database.
 640  
      * @throws TooManyRowsException Primary key was not found in database.
 641  
      */
 642  
     public static TurbineGroup retrieveByPK(int pk)
 643  
         throws TorqueException, NoRowsException, TooManyRowsException
 644  
     {
 645  0
         return retrieveByPK(SimpleKey.keyFor(pk));
 646  
     }
 647  
 
 648  
     /**
 649  
      * Retrieve a single object by pk
 650  
      *
 651  
      * @param pk the primary key
 652  
      * @param con the connection to use
 653  
      * @throws TorqueException Any exceptions caught during processing will be
 654  
      *         rethrown wrapped into a TorqueException.
 655  
      * @throws NoRowsException Primary key was not found in database.
 656  
      * @throws TooManyRowsException Primary key was not found in database.
 657  
      */
 658  
     public static TurbineGroup retrieveByPK(int pk, Connection con)
 659  
         throws TorqueException, NoRowsException, TooManyRowsException
 660  
     {
 661  0
         return retrieveByPK(SimpleKey.keyFor(pk), con);
 662  
     }
 663  
   
 664  
     /**
 665  
      * Retrieve a single object by pk
 666  
      *
 667  
      * @param pk the primary key
 668  
      * @throws TorqueException Any exceptions caught during processing will be
 669  
      *         rethrown wrapped into a TorqueException.
 670  
      * @throws NoRowsException Primary key was not found in database.
 671  
      * @throws TooManyRowsException Primary key was not found in database.
 672  
      */
 673  
     public static TurbineGroup retrieveByPK(ObjectKey pk)
 674  
         throws TorqueException, NoRowsException, TooManyRowsException
 675  
     {
 676  0
         Connection db = null;
 677  0
         TurbineGroup retVal = null;
 678  
         try
 679  
         {
 680  0
             db = Torque.getConnection(DATABASE_NAME);
 681  0
             retVal = retrieveByPK(pk, db);
 682  
         }
 683  
         finally
 684  
         {
 685  0
             Torque.closeConnection(db);
 686  0
         }
 687  0
         return(retVal);
 688  
     }
 689  
 
 690  
     /**
 691  
      * Retrieve a single object by pk
 692  
      *
 693  
      * @param pk the primary key
 694  
      * @param con the connection to use
 695  
      * @throws TorqueException Any exceptions caught during processing will be
 696  
      *         rethrown wrapped into a TorqueException.
 697  
      * @throws NoRowsException Primary key was not found in database.
 698  
      * @throws TooManyRowsException Primary key was not found in database.
 699  
      */
 700  
     public static TurbineGroup retrieveByPK(ObjectKey pk, Connection con)
 701  
         throws TorqueException, NoRowsException, TooManyRowsException
 702  
     {
 703  0
         Criteria criteria = buildCriteria(pk);
 704  0
         List v = doSelect(criteria, con);
 705  0
         if (v.size() == 0)
 706  
         {
 707  0
             throw new NoRowsException("Failed to select a row.");
 708  
         }
 709  0
         else if (v.size() > 1)
 710  
         {
 711  0
             throw new TooManyRowsException("Failed to select only one row.");
 712  
         }
 713  
         else
 714  
         {
 715  0
             return (TurbineGroup)v.get(0);
 716  
         }
 717  
     }
 718  
 
 719  
     /**
 720  
      * Retrieve a multiple objects by pk
 721  
      *
 722  
      * @param pks List of primary keys
 723  
      * @throws TorqueException Any exceptions caught during processing will be
 724  
      *         rethrown wrapped into a TorqueException.
 725  
      */
 726  
     public static List retrieveByPKs(List pks)
 727  
         throws TorqueException
 728  
     {
 729  0
         Connection db = null;
 730  0
         List retVal = null;
 731  
         try
 732  
         {
 733  0
            db = Torque.getConnection(DATABASE_NAME);
 734  0
            retVal = retrieveByPKs(pks, db);
 735  
         }
 736  
         finally
 737  
         {
 738  0
             Torque.closeConnection(db);
 739  0
         }
 740  0
         return(retVal);
 741  
     }
 742  
 
 743  
     /**
 744  
      * Retrieve a multiple objects by pk
 745  
      *
 746  
      * @param pks List of primary keys
 747  
      * @param dbcon the connection to use
 748  
      * @throws TorqueException Any exceptions caught during processing will be
 749  
      *         rethrown wrapped into a TorqueException.
 750  
      */
 751  
     public static List retrieveByPKs( List pks, Connection dbcon )
 752  
         throws TorqueException
 753  
     {
 754  0
         List objs = null;
 755  0
         if (pks == null || pks.size() == 0)
 756  
         {
 757  0
             objs = new LinkedList();
 758  
         }
 759  
         else
 760  
         {
 761  0
             Criteria criteria = new Criteria();
 762  0
               criteria.addIn( GROUP_ID, pks );
 763  0
           objs = doSelect(criteria, dbcon);
 764  
         }
 765  0
         return objs;
 766  
     }
 767  
 
 768  
  
 769  
 
 770  
 
 771  
 
 772  
         
 773  
   
 774  
   
 775  
     
 776  
   
 777  
       /**
 778  
      * Returns the TableMap related to this peer.  This method is not
 779  
      * needed for general use but a specific application could have a need.
 780  
      *
 781  
      * @throws TorqueException Any exceptions caught during processing will be
 782  
      *         rethrown wrapped into a TorqueException.
 783  
      */
 784  
     protected static TableMap getTableMap()
 785  
         throws TorqueException
 786  
     {
 787  0
         return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
 788  
     }
 789  
    
 790  
     private static void setDbName(Criteria crit)
 791  
     {
 792  
         // Set the correct dbName if it has not been overridden
 793  
         // crit.getDbName will return the same object if not set to
 794  
         // another value so == check is okay and faster
 795  114
         if (crit.getDbName() == Torque.getDefaultDB())
 796  
         {
 797  104
             crit.setDbName(DATABASE_NAME);
 798  
         }
 799  114
     }
 800  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.