View Javadoc

    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.TorqueRuntimeException;
    17  import org.apache.torque.map.MapBuilder;
    18  import org.apache.torque.map.TableMap;
    19  import org.apache.torque.om.DateKey;
    20  import org.apache.torque.om.NumberKey;
    21  import org.apache.torque.om.StringKey;
    22  import org.apache.torque.om.ObjectKey;
    23  import org.apache.torque.om.SimpleKey;
    24  import org.apache.torque.util.BasePeer;
    25  import org.apache.torque.util.Criteria;
    26
    27  import com.workingdogs.village.DataSetException;
    28  import com.workingdogs.village.QueryDataSet;
    29  import com.workingdogs.village.Record;
    30
    31  // Local classes
    32  import org.apache.turbine.services.security.torque.om.map.*;
    33
    34
    35
    36
    37  /**
    38   * This class was autogenerated by Torque on:
    39   *
    40   * [Thu Jun 23 17:25:46 CEST 2011]
    41   *
    42   */
    43  public abstract class BaseTurbineGroupPeer
    44      extends BasePeer
    45  {
    46      /** Serial version */
    47      private static final long serialVersionUID = 1308842746584L;
    48
    49
    50      /** the default database name for this class */
    51      public static final String DATABASE_NAME;
    52
    53       /** the table name for this class */
    54      public static final String TABLE_NAME;
    55
    56      /**
    57       * @return the map builder for this peer
    58       * @throws TorqueException Any exceptions caught during processing will be
    59       *         rethrown wrapped into a TorqueException.
    60       * @deprecated Torque.getMapBuilder(TurbineGroupMapBuilder.CLASS_NAME) instead
    61       */
    62      public static MapBuilder getMapBuilder()
    63          throws TorqueException
    64      {
    65          return Torque.getMapBuilder(TurbineGroupMapBuilder.CLASS_NAME);
    66      }
    67
    68      /** the column name for the GROUP_ID field */
    69      public static final String GROUP_ID;
    70      /** the column name for the GROUP_NAME field */
    71      public static final String GROUP_NAME;
    72
    73      static
    74      {
    75          DATABASE_NAME = "default";
    76          TABLE_NAME = "TURBINE_GROUP";
    77
    78          GROUP_ID = "TURBINE_GROUP.GROUP_ID";
    79          GROUP_NAME = "TURBINE_GROUP.GROUP_NAME";
    80          if (Torque.isInit())
    81          {
    82              try
    83              {
    84                  Torque.getMapBuilder(TurbineGroupMapBuilder.CLASS_NAME);
    85              }
    86              catch (TorqueException e)
    87              {
    88                  log.error("Could not initialize Peer", e);
    89                  throw new TorqueRuntimeException(e);
    90              }
    91          }
    92          else
    93          {
    94              Torque.registerMapBuilder(TurbineGroupMapBuilder.CLASS_NAME);
    95          }
    96      }
    97
    98      /** number of columns for this peer */
    99      public static final int numColumns =  2;
    100
    101     /** A class that can be returned by this peer. */
    102     protected static final String CLASSNAME_DEFAULT =
    103         "org.apache.turbine.services.security.torque.om.TurbineGroup";
    104
    105     /** A class that can be returned by this peer. */
    106     protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
    107
    108     /**
    109      * Class object initialization method.
    110      *
    111      * @param className name of the class to initialize
    112      * @return the initialized class
    113      */
    114     private static Class initClass(String className)
    115     {
    116         Class c = null;
    117         try
    118         {
    119             c = Class.forName(className);
    120         }
    121         catch (Throwable t)
    122         {
    123             log.error("A FATAL ERROR has occurred which should not "
    124                 + "have happened under any circumstance.  Please notify "
    125                 + "the Torque developers <torque-dev@db.apache.org> "
    126                 + "and give as many details as possible (including the error "
    127                 + "stack trace).", t);
    128
    129             // Error objects should always be propagated.
    130             if (t instanceof Error)
    131             {
    132                 throw (Error) t.fillInStackTrace();
    133             }
    134         }
    135         return c;
    136     }
    137
    138     /**
    139      * Get the list of objects for a ResultSet.  Please not that your
    140      * resultset MUST return columns in the right order.  You can use
    141      * getFieldNames() in BaseObject to get the correct sequence.
    142      *
    143      * @param results the ResultSet
    144      * @return the list of objects
    145      * @throws TorqueException Any exceptions caught during processing will be
    146      *         rethrown wrapped into a TorqueException.
    147      */
    148     public static List<TurbineGroup> resultSet2Objects(java.sql.ResultSet results)
    149             throws TorqueException
    150     {
    151         try
    152         {
    153             QueryDataSet qds = null;
    154             List<Record> rows = null;
    155             try
    156             {
    157                 qds = new QueryDataSet(results);
    158                 rows = getSelectResults(qds);
    159             }
    160             finally
    161             {
    162                 if (qds != null)
    163                 {
    164                     qds.close();
    165                 }
    166             }
    167
    168             return populateObjects(rows);
    169         }
    170         catch (SQLException e)
    171         {
    172             throw new TorqueException(e);
    173         }
    174         catch (DataSetException e)
    175         {
    176             throw new TorqueException(e);
    177         }
    178     }
    179
    180
    181
    182     /**
    183      * Method to do inserts.
    184      *
    185      * @param criteria object used to create the INSERT statement.
    186      * @throws TorqueException Any exceptions caught during processing will be
    187      *         rethrown wrapped into a TorqueException.
    188      */
    189     public static ObjectKey doInsert(Criteria criteria)
    190         throws TorqueException
    191     {
    192         return BaseTurbineGroupPeer
    193             .doInsert(criteria, (Connection) null);
    194     }
    195
    196     /**
    197      * Method to do inserts.  This method is to be used during a transaction,
    198      * otherwise use the doInsert(Criteria) method.  It will take care of
    199      * the connection details internally.
    200      *
    201      * @param criteria object used to create the INSERT statement.
    202      * @param con the connection to use
    203      * @throws TorqueException Any exceptions caught during processing will be
    204      *         rethrown wrapped into a TorqueException.
    205      */
    206     public static ObjectKey doInsert(Criteria criteria, Connection con)
    207         throws TorqueException
    208     {
    209         correctBooleans(criteria);
    210
    211         setDbName(criteria);
    212
    213         if (con == null)
    214         {
    215             return BasePeer.doInsert(criteria);
    216         }
    217         else
    218         {
    219             return BasePeer.doInsert(criteria, con);
    220         }
    221     }
    222
    223     /**
    224      * Add all the columns needed to create a new object.
    225      *
    226      * @param criteria object containing the columns to add.
    227      * @throws TorqueException Any exceptions caught during processing will be
    228      *         rethrown wrapped into a TorqueException.
    229      */
    230     public static void addSelectColumns(Criteria criteria)
    231             throws TorqueException
    232     {
    233         criteria.addSelectColumn(GROUP_ID);
    234         criteria.addSelectColumn(GROUP_NAME);
    235     }
    236
    237     /**
    238      * changes the boolean values in the criteria to the appropriate type,
    239      * whenever a booleanchar or booleanint column is involved.
    240      * This enables the user to create criteria using Boolean values
    241      * for booleanchar or booleanint columns
    242      * @param criteria the criteria in which the boolean values should be corrected
    243      * @throws TorqueException if the database map for the criteria cannot be
    244                obtained.
    245      */
    246     public static void correctBooleans(Criteria criteria) throws TorqueException
    247     {
    248         correctBooleans(criteria, getTableMap());
    249     }
    250
    251     /**
    252      * Create a new object of type cls from a resultset row starting
    253      * from a specified offset.  This is done so that you can select
    254      * other rows than just those needed for this object.  You may
    255      * for example want to create two objects from the same row.
    256      *
    257      * @throws TorqueException Any exceptions caught during processing will be
    258      *         rethrown wrapped into a TorqueException.
    259      */
    260     public static TurbineGroup row2Object(Record row,
    261                                              int offset,
    262                                              Class cls)
    263         throws TorqueException
    264     {
    265         try
    266         {
    267             TurbineGroup obj = (TurbineGroup) cls.newInstance();
    268             TurbineGroupPeer.populateObject(row, offset, obj);
    269                 obj.setModified(false);
    270             obj.setNew(false);
    271
    272             return obj;
    273         }
    274         catch (InstantiationException e)
    275         {
    276             throw new TorqueException(e);
    277         }
    278         catch (IllegalAccessException e)
    279         {
    280             throw new TorqueException(e);
    281         }
    282     }
    283
    284     /**
    285      * Populates an object from a resultset row starting
    286      * from a specified offset.  This is done so that you can select
    287      * other rows than just those needed for this object.  You may
    288      * for example want to create two objects from the same row.
    289      *
    290      * @throws TorqueException Any exceptions caught during processing will be
    291      *         rethrown wrapped into a TorqueException.
    292      */
    293     public static void populateObject(Record row,
    294                                       int offset,
    295                                       TurbineGroup obj)
    296         throws TorqueException
    297     {
    298         try
    299         {
    300             obj.setGroupId(row.getValue(offset + 0).asInt());
    301             obj.setName(row.getValue(offset + 1).asString());
    302         }
    303         catch (DataSetException e)
    304         {
    305             throw new TorqueException(e);
    306         }
    307     }
    308
    309     /**
    310      * Method to do selects.
    311      *
    312      * @param criteria object used to create the SELECT statement.
    313      * @return List of selected Objects
    314      * @throws TorqueException Any exceptions caught during processing will be
    315      *         rethrown wrapped into a TorqueException.
    316      */
    317     public static List<TurbineGroup> doSelect(Criteria criteria) throws TorqueException
    318     {
    319         return populateObjects(doSelectVillageRecords(criteria));
    320     }
    321
    322     /**
    323      * Method to do selects within a transaction.
    324      *
    325      * @param criteria object used to create the SELECT statement.
    326      * @param con the connection to use
    327      * @return List of selected Objects
    328      * @throws TorqueException Any exceptions caught during processing will be
    329      *         rethrown wrapped into a TorqueException.
    330      */
    331     public static List<TurbineGroup> doSelect(Criteria criteria, Connection con)
    332         throws TorqueException
    333     {
    334         return populateObjects(doSelectVillageRecords(criteria, con));
    335     }
    336
    337     /**
    338      * Grabs the raw Village records to be formed into objects.
    339      * This method handles connections internally.  The Record objects
    340      * returned by this method should be considered readonly.  Do not
    341      * alter the data and call save(), your results may vary, but are
    342      * certainly likely to result in hard to track MT bugs.
    343      *
    344      * @throws TorqueException Any exceptions caught during processing will be
    345      *         rethrown wrapped into a TorqueException.
    346      */
    347     public static List<Record> doSelectVillageRecords(Criteria criteria)
    348         throws TorqueException
    349     {
    350         return BaseTurbineGroupPeer
    351             .doSelectVillageRecords(criteria, (Connection) null);
    352     }
    353
    354     /**
    355      * Grabs the raw Village records to be formed into objects.
    356      * This method should be used for transactions
    357      *
    358      * @param criteria object used to create the SELECT statement.
    359      * @param con the connection to use
    360      * @throws TorqueException Any exceptions caught during processing will be
    361      *         rethrown wrapped into a TorqueException.
    362      */
    363     public static List<Record> doSelectVillageRecords(Criteria criteria, Connection con)
    364         throws TorqueException
    365     {
    366         if (criteria.getSelectColumns().size() == 0)
    367         {
    368             addSelectColumns(criteria);
    369         }
    370         correctBooleans(criteria);
    371
    372         setDbName(criteria);
    373
    374         // BasePeer returns a List of Value (Village) arrays.  The array
    375         // order follows the order columns were placed in the Select clause.
    376         if (con == null)
    377         {
    378             return BasePeer.doSelect(criteria);
    379         }
    380         else
    381         {
    382             return BasePeer.doSelect(criteria, con);
    383         }
    384     }
    385
    386     /**
    387      * The returned List will contain objects of the default type or
    388      * objects that inherit from the default.
    389      *
    390      * @throws TorqueException Any exceptions caught during processing will be
    391      *         rethrown wrapped into a TorqueException.
    392      */
    393     public static List<TurbineGroup> populateObjects(List<Record> records)
    394         throws TorqueException
    395     {
    396         List<TurbineGroup> results = new ArrayList<TurbineGroup>(records.size());
    397
    398         // populate the object(s)
    399         for (int i = 0; i < records.size(); i++)
    400         {
    401             Record row =  records.get(i);
    402             results.add(TurbineGroupPeer.row2Object(row, 1,
    403                 TurbineGroupPeer.getOMClass()));
    404         }
    405         return results;
    406     }
    407
    408
    409     /**
    410      * The class that the Peer will make instances of.
    411      * If the BO is abstract then you must implement this method
    412      * in the BO.
    413      *
    414      * @throws TorqueException Any exceptions caught during processing will be
    415      *         rethrown wrapped into a TorqueException.
    416      */
    417     public static Class getOMClass()
    418         throws TorqueException
    419     {
    420         return CLASS_DEFAULT;
    421     }
    422
    423     /**
    424      * Method to do updates.
    425      *
    426      * @param criteria object containing data that is used to create the UPDATE
    427      *        statement.
    428      * @throws TorqueException Any exceptions caught during processing will be
    429      *         rethrown wrapped into a TorqueException.
    430      */
    431     public static void doUpdate(Criteria criteria) throws TorqueException
    432     {
    433          BaseTurbineGroupPeer
    434             .doUpdate(criteria, (Connection) null);
    435     }
    436
    437     /**
    438      * Method to do updates.  This method is to be used during a transaction,
    439      * otherwise use the doUpdate(Criteria) method.  It will take care of
    440      * the connection details internally.
    441      *
    442      * @param criteria object containing data that is used to create the UPDATE
    443      *        statement.
    444      * @param con the connection to use
    445      * @throws TorqueException Any exceptions caught during processing will be
    446      *         rethrown wrapped into a TorqueException.
    447      */
    448     public static void doUpdate(Criteria criteria, Connection con)
    449         throws TorqueException
    450     {
    451         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
    452         correctBooleans(criteria);
    453
    454
    455          selectCriteria.put(GROUP_ID, criteria.remove(GROUP_ID));
    456
    457
    458         setDbName(criteria);
    459
    460         if (con == null)
    461         {
    462             BasePeer.doUpdate(selectCriteria, criteria);
    463         }
    464         else
    465         {
    466             BasePeer.doUpdate(selectCriteria, criteria, con);
    467         }
    468     }
    469
    470     /**
    471      * Method to do deletes.
    472      *
    473      * @param criteria object containing data that is used DELETE from database.
    474      * @throws TorqueException Any exceptions caught during processing will be
    475      *         rethrown wrapped into a TorqueException.
    476      */
    477      public static void doDelete(Criteria criteria) throws TorqueException
    478      {
    479          TurbineGroupPeer
    480             .doDelete(criteria, (Connection) null);
    481      }
    482
    483     /**
    484      * Method to do deletes.  This method is to be used during a transaction,
    485      * otherwise use the doDelete(Criteria) method.  It will take care of
    486      * the connection details internally.
    487      *
    488      * @param criteria object containing data that is used DELETE from database.
    489      * @param con the connection to use
    490      * @throws TorqueException Any exceptions caught during processing will be
    491      *         rethrown wrapped into a TorqueException.
    492      */
    493      public static void doDelete(Criteria criteria, Connection con)
    494         throws TorqueException
    495      {
    496         correctBooleans(criteria);
    497
    498         setDbName(criteria);
    499
    500         if (con == null)
    501         {
    502             BasePeer.doDelete(criteria, TABLE_NAME);
    503         }
    504         else
    505         {
    506             BasePeer.doDelete(criteria, TABLE_NAME, con);
    507         }
    508      }
    509
    510     /**
    511      * Method to do selects
    512      *
    513      * @throws TorqueException Any exceptions caught during processing will be
    514      *         rethrown wrapped into a TorqueException.
    515      */
    516     public static List<TurbineGroup> doSelect(TurbineGroup obj) throws TorqueException
    517     {
    518         return doSelect(buildSelectCriteria(obj));
    519     }
    520
    521     /**
    522      * Method to do inserts
    523      *
    524      * @throws TorqueException Any exceptions caught during processing will be
    525      *         rethrown wrapped into a TorqueException.
    526      */
    527     public static void doInsert(TurbineGroup obj) throws TorqueException
    528     {
    529         obj.setPrimaryKey(doInsert(buildCriteria(obj)));
    530         obj.setNew(false);
    531         obj.setModified(false);
    532     }
    533
    534     /**
    535      * @param obj the data object to update in the database.
    536      * @throws TorqueException Any exceptions caught during processing will be
    537      *         rethrown wrapped into a TorqueException.
    538      */
    539     public static void doUpdate(TurbineGroup obj) throws TorqueException
    540     {
    541         doUpdate(buildCriteria(obj));
    542         obj.setModified(false);
    543     }
    544
    545     /**
    546      * @param obj the data object to delete in the database.
    547      * @throws TorqueException Any exceptions caught during processing will be
    548      *         rethrown wrapped into a TorqueException.
    549      */
    550     public static void doDelete(TurbineGroup obj) throws TorqueException
    551     {
    552         doDelete(buildSelectCriteria(obj));
    553     }
    554
    555     /**
    556      * Method to do inserts.  This method is to be used during a transaction,
    557      * otherwise use the doInsert(TurbineGroup) method.  It will take
    558      * care of the connection details internally.
    559      *
    560      * @param obj the data object to insert into the database.
    561      * @param con the connection to use
    562      * @throws TorqueException Any exceptions caught during processing will be
    563      *         rethrown wrapped into a TorqueException.
    564      */
    565     public static void doInsert(TurbineGroup obj, Connection con)
    566         throws TorqueException
    567     {
    568         obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
    569         obj.setNew(false);
    570         obj.setModified(false);
    571     }
    572
    573     /**
    574      * Method to do update.  This method is to be used during a transaction,
    575      * otherwise use the doUpdate(TurbineGroup) method.  It will take
    576      * care of the connection details internally.
    577      *
    578      * @param obj the data object to update in the database.
    579      * @param con the connection to use
    580      * @throws TorqueException Any exceptions caught during processing will be
    581      *         rethrown wrapped into a TorqueException.
    582      */
    583     public static void doUpdate(TurbineGroup obj, Connection con)
    584         throws TorqueException
    585     {
    586         doUpdate(buildCriteria(obj), con);
    587         obj.setModified(false);
    588     }
    589
    590     /**
    591      * Method to delete.  This method is to be used during a transaction,
    592      * otherwise use the doDelete(TurbineGroup) method.  It will take
    593      * care of the connection details internally.
    594      *
    595      * @param obj the data object to delete in the database.
    596      * @param con the connection to use
    597      * @throws TorqueException Any exceptions caught during processing will be
    598      *         rethrown wrapped into a TorqueException.
    599      */
    600     public static void doDelete(TurbineGroup obj, Connection con)
    601         throws TorqueException
    602     {
    603         doDelete(buildSelectCriteria(obj), con);
    604     }
    605
    606     /**
    607      * Method to do deletes.
    608      *
    609      * @param pk ObjectKey that is used DELETE from database.
    610      * @throws TorqueException Any exceptions caught during processing will be
    611      *         rethrown wrapped into a TorqueException.
    612      */
    613     public static void doDelete(ObjectKey pk) throws TorqueException
    614     {
    615         BaseTurbineGroupPeer
    616            .doDelete(pk, (Connection) null);
    617     }
    618
    619     /**
    620      * Method to delete.  This method is to be used during a transaction,
    621      * otherwise use the doDelete(ObjectKey) method.  It will take
    622      * care of the connection details internally.
    623      *
    624      * @param pk the primary key for the object to delete in the database.
    625      * @param con the connection to use
    626      * @throws TorqueException Any exceptions caught during processing will be
    627      *         rethrown wrapped into a TorqueException.
    628      */
    629     public static void doDelete(ObjectKey pk, Connection con)
    630         throws TorqueException
    631     {
    632         doDelete(buildCriteria(pk), con);
    633     }
    634
    635     /** Build a Criteria object from an ObjectKey */
    636     public static Criteria buildCriteria( ObjectKey pk )
    637     {
    638         Criteria criteria = new Criteria();
    639             criteria.add(GROUP_ID, pk);
    640         return criteria;
    641      }
    642
    643     /** Build a Criteria object from the data object for this peer */
    644     public static Criteria buildCriteria( TurbineGroup obj )
    645     {
    646         Criteria criteria = new Criteria(DATABASE_NAME);
    647         if (!obj.isNew())
    648         criteria.add(GROUP_ID, obj.getGroupId());
    649         criteria.add(GROUP_NAME, obj.getName());
    650         return criteria;
    651     }
    652
    653     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
    654     public static Criteria buildSelectCriteria( TurbineGroup obj )
    655     {
    656         Criteria criteria = new Criteria(DATABASE_NAME);
    657         if (!obj.isNew())
    658         {
    659             criteria.add(GROUP_ID, obj.getGroupId());
    660         }
    661             criteria.add(GROUP_NAME, obj.getName());
    662         return criteria;
    663     }
    664
    665
    666     /**
    667      * Retrieve a single object by pk
    668      *
    669      * @param pk the primary key
    670      * @throws TorqueException Any exceptions caught during processing will be
    671      *         rethrown wrapped into a TorqueException.
    672      * @throws NoRowsException Primary key was not found in database.
    673      * @throws TooManyRowsException Primary key was not found in database.
    674      */
    675     public static TurbineGroup retrieveByPK(int pk)
    676         throws TorqueException, NoRowsException, TooManyRowsException
    677     {
    678         return retrieveByPK(SimpleKey.keyFor(pk));
    679     }
    680
    681     /**
    682      * Retrieve a single object by pk
    683      *
    684      * @param pk the primary key
    685      * @param con the connection to use
    686      * @throws TorqueException Any exceptions caught during processing will be
    687      *         rethrown wrapped into a TorqueException.
    688      * @throws NoRowsException Primary key was not found in database.
    689      * @throws TooManyRowsException Primary key was not found in database.
    690      */
    691     public static TurbineGroup retrieveByPK(int pk, Connection con)
    692         throws TorqueException, NoRowsException, TooManyRowsException
    693     {
    694         return retrieveByPK(SimpleKey.keyFor(pk), con);
    695     }
    696
    697     /**
    698      * Retrieve a single object by pk
    699      *
    700      * @param pk the primary key
    701      * @throws TorqueException Any exceptions caught during processing will be
    702      *         rethrown wrapped into a TorqueException.
    703      * @throws NoRowsException Primary key was not found in database.
    704      * @throws TooManyRowsException Primary key was not found in database.
    705      */
    706     public static TurbineGroup retrieveByPK(ObjectKey pk)
    707         throws TorqueException, NoRowsException, TooManyRowsException
    708     {
    709         Connection db = null;
    710         TurbineGroup retVal = null;
    711         try
    712         {
    713             db = Torque.getConnection(DATABASE_NAME);
    714             retVal = retrieveByPK(pk, db);
    715         }
    716         finally
    717         {
    718             Torque.closeConnection(db);
    719         }
    720         return retVal;
    721     }
    722
    723     /**
    724      * Retrieve a single object by pk
    725      *
    726      * @param pk the primary key
    727      * @param con the connection to use
    728      * @throws TorqueException Any exceptions caught during processing will be
    729      *         rethrown wrapped into a TorqueException.
    730      * @throws NoRowsException Primary key was not found in database.
    731      * @throws TooManyRowsException Primary key was not found in database.
    732      */
    733     public static TurbineGroup retrieveByPK(ObjectKey pk, Connection con)
    734         throws TorqueException, NoRowsException, TooManyRowsException
    735     {
    736         Criteria criteria = buildCriteria(pk);
    737         List<TurbineGroup> v = doSelect(criteria, con);
    738         if (v.size() == 0)
    739         {
    740             throw new NoRowsException("Failed to select a row.");
    741         }
    742         else if (v.size() > 1)
    743         {
    744             throw new TooManyRowsException("Failed to select only one row.");
    745         }
    746         else
    747         {
    748             return (TurbineGroup)v.get(0);
    749         }
    750     }
    751
    752     /**
    753      * Retrieve a multiple objects by pk
    754      *
    755      * @param pks List of primary keys
    756      * @throws TorqueException Any exceptions caught during processing will be
    757      *         rethrown wrapped into a TorqueException.
    758      */
    759     public static List<TurbineGroup> retrieveByPKs(List<ObjectKey> pks)
    760         throws TorqueException
    761     {
    762         Connection db = null;
    763         List<TurbineGroup> retVal = null;
    764         try
    765         {
    766            db = Torque.getConnection(DATABASE_NAME);
    767            retVal = retrieveByPKs(pks, db);
    768         }
    769         finally
    770         {
    771             Torque.closeConnection(db);
    772         }
    773         return retVal;
    774     }
    775
    776     /**
    777      * Retrieve a multiple objects by pk
    778      *
    779      * @param pks List of primary keys
    780      * @param dbcon the connection to use
    781      * @throws TorqueException Any exceptions caught during processing will be
    782      *         rethrown wrapped into a TorqueException.
    783      */
    784     public static List<TurbineGroup> retrieveByPKs( List<ObjectKey> pks, Connection dbcon )
    785         throws TorqueException
    786     {
    787         List<TurbineGroup> objs = null;
    788         if (pks == null || pks.size() == 0)
    789         {
    790             objs = new LinkedList<TurbineGroup>();
    791         }
    792         else
    793         {
    794             Criteria criteria = new Criteria();
    795             criteria.addIn( GROUP_ID, pks );
    796         objs = doSelect(criteria, dbcon);
    797         }
    798         return objs;
    799     }
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810     /**
    811      * Returns the TableMap related to this peer.
    812      *
    813      * @throws TorqueException Any exceptions caught during processing will be
    814      *         rethrown wrapped into a TorqueException.
    815      */
    816     public static TableMap getTableMap()
    817         throws TorqueException
    818     {
    819         return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
    820     }
    821
    822     private static void setDbName(Criteria crit)
    823     {
    824         // Set the correct dbName if it has not been overridden
    825         // crit.getDbName will return the same object if not set to
    826         // another value so == check is okay and faster
    827         if (crit.getDbName() == Torque.getDefaultDB())
    828         {
    829             crit.setDbName(DATABASE_NAME);
    830         }
    831     }
    832
    833
    834     // The following methods wrap some methods in BasePeer
    835     // to have more support for Java5 generic types in the Peer
    836
    837     /**
    838      * Utility method which executes a given sql statement.  This
    839      * method should be used for select statements only.  Use
    840      * executeStatement for update, insert, and delete operations.
    841      *
    842      * @param queryString A String with the sql statement to execute.
    843      * @return List of Record objects.
    844      * @throws TorqueException Any exceptions caught during processing will be
    845      *         rethrown wrapped into a TorqueException.
    846      * @see org.apache.torque.util.BasePeer#executeQuery(String)
    847      */
    848     public static List<Record> executeQuery(String queryString) throws TorqueException
    849     {
    850         return BasePeer.executeQuery(queryString);
    851     }
    852
    853     /**
    854      * Utility method which executes a given sql statement.  This
    855      * method should be used for select statements only.  Use
    856      * executeStatement for update, insert, and delete operations.
    857      *
    858      * @param queryString A String with the sql statement to execute.
    859      * @param dbName The database to connect to.
    860      * @return List of Record objects.
    861      * @throws TorqueException Any exceptions caught during processing will be
    862      *         rethrown wrapped into a TorqueException.
    863      * @see org.apache.torque.util.BasePeer#executeQuery(String,String)
    864      */
    865     public static List<Record> executeQuery(String queryString, String dbName)
    866         throws TorqueException
    867     {
    868         return BasePeer.executeQuery(queryString,dbName);
    869     }
    870
    871
    872     /**
    873      * Method for performing a SELECT.  Returns all results.
    874      *
    875      * @param queryString A String with the sql statement to execute.
    876      * @param dbName The database to connect to.
    877      * @param singleRecord Whether or not we want to select only a
    878      * single record.
    879      * @return List of Record objects.
    880      * @throws TorqueException Any exceptions caught during processing will be
    881      *         rethrown wrapped into a TorqueException.
    882      * @see org.apache.torque.util.BasePeer#executeQuery(String,String,boolean)
    883      */
    884     public static List<Record> executeQuery(
    885         String queryString,
    886         String dbName,
    887         boolean singleRecord)
    888         throws TorqueException
    889     {
    890         return BasePeer.executeQuery(queryString,dbName,singleRecord);
    891     }
    892
    893     /**
    894      * Method for performing a SELECT.  Returns all results.
    895      *
    896      * @param queryString A String with the sql statement to execute.
    897      * @param singleRecord Whether or not we want to select only a
    898      * single record.
    899      * @param con A Connection.
    900      * @return List of Record objects.
    901      * @throws TorqueException Any exceptions caught during processing will be
    902      *         rethrown wrapped into a TorqueException.
    903      * @see org.apache.torque.util.BasePeer#executeQuery(String,boolean,Connection)
    904      */
    905     public static List<Record> executeQuery(
    906         String queryString,
    907         boolean singleRecord,
    908         Connection con)
    909         throws TorqueException
    910     {
    911         return BasePeer.executeQuery(queryString,singleRecord,con);
    912     }
    913
    914     /**
    915      * Method for performing a SELECT.
    916      *
    917      * @param queryString A String with the sql statement to execute.
    918      * @param start The first row to return.
    919      * @param numberOfResults The number of rows to return.
    920      * @param dbName The database to connect to.
    921      * @param singleRecord Whether or not we want to select only a
    922      * single record.
    923      * @return List of Record objects.
    924      * @throws TorqueException Any exceptions caught during processing will be
    925      *         rethrown wrapped into a TorqueException.
    926      * @see org.apache.torque.util.BasePeer#executeQuery(String,int,int,String,boolean)
    927      */
    928     public static List<Record> executeQuery(
    929         String queryString,
    930         int start,
    931         int numberOfResults,
    932         String dbName,
    933         boolean singleRecord)
    934         throws TorqueException
    935     {
    936         return BasePeer.executeQuery(queryString,start,numberOfResults,dbName,singleRecord);
    937     }
    938
    939     /**
    940      * Method for performing a SELECT.  Returns all results.
    941      *
    942      * @param queryString A String with the sql statement to execute.
    943      * @param start The first row to return.
    944      * @param numberOfResults The number of rows to return.
    945      * @param singleRecord Whether or not we want to select only a
    946      * single record.
    947      * @param con A Connection.
    948      * @return List of Record objects.
    949      * @throws TorqueException Any exceptions caught during processing will be
    950      *         rethrown wrapped into a TorqueException.
    951      * @see org.apache.torque.util.BasePeer#executeQuery(String,int,int,String,boolean,Connection)
    952      */
    953     public static List<Record> executeQuery(
    954         String queryString,
    955         int start,
    956         int numberOfResults,
    957         boolean singleRecord,
    958         Connection con)
    959         throws TorqueException
    960     {
    961         return BasePeer.executeQuery(queryString,start,numberOfResults,singleRecord,con);
    962     }
    963
    964     /**
    965      * Returns all records in a QueryDataSet as a List of Record
    966      * objects.  Used for functionality like util.LargeSelect.
    967      *
    968      * @see #getSelectResults(QueryDataSet, int, int, boolean)
    969      * @param qds the QueryDataSet
    970      * @return a List of Record objects
    971      * @throws TorqueException Any exceptions caught during processing will be
    972      *         rethrown wrapped into a TorqueException.
    973      * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet)
    974      */
    975     public static List<Record> getSelectResults(QueryDataSet qds)
    976         throws TorqueException
    977     {
    978         return BasePeer.getSelectResults(qds);
    979     }
    980
    981     /**
    982      * Returns all records in a QueryDataSet as a List of Record
    983      * objects.  Used for functionality like util.LargeSelect.
    984      *
    985      * @see #getSelectResults(QueryDataSet, int, int, boolean)
    986      * @param qds the QueryDataSet
    987      * @param singleRecord
    988      * @return a List of Record objects
    989      * @throws TorqueException Any exceptions caught during processing will be
    990      *         rethrown wrapped into a TorqueException.
    991      * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,boolean)
    992      */
    993     public static List<Record> getSelectResults(QueryDataSet qds, boolean singleRecord)
    994         throws TorqueException
    995     {
    996         return BasePeer.getSelectResults(qds,singleRecord);
    997     }
    998
    999     /**
    1000      * Returns numberOfResults records in a QueryDataSet as a List
    1001      * of Record objects.  Starting at record 0.  Used for
    1002      * functionality like util.LargeSelect.
    1003      *
    1004      * @see #getSelectResults(QueryDataSet, int, int, boolean)
    1005      * @param qds the QueryDataSet
    1006      * @param numberOfResults
    1007      * @param singleRecord
    1008      * @return a List of Record objects
    1009      * @throws TorqueException Any exceptions caught during processing will be
    1010      *         rethrown wrapped into a TorqueException.
    1011      * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,int,boolean)
    1012      */
    1013     public static List<Record> getSelectResults(
    1014         QueryDataSet qds,
    1015         int numberOfResults,
    1016         boolean singleRecord)
    1017         throws TorqueException
    1018     {
    1019         return BasePeer.getSelectResults(qds,numberOfResults,singleRecord);
    1020     }
    1021
    1022     /**
    1023      * Returns numberOfResults records in a QueryDataSet as a List
    1024      * of Record objects.  Starting at record start.  Used for
    1025      * functionality like util.LargeSelect.
    1026      *
    1027      * @param qds The <code>QueryDataSet</code> to extract results
    1028      * from.
    1029      * @param start The index from which to start retrieving
    1030      * <code>Record</code> objects from the data set.
    1031      * @param numberOfResults The number of results to return (or
    1032      * <code> -1</code> for all results).
    1033      * @param singleRecord Whether or not we want to select only a
    1034      * single record.
    1035      * @return A <code>List</code> of <code>Record</code> objects.
    1036      * @exception TorqueException If any <code>Exception</code> occurs.
    1037      * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,int,int,boolean)
    1038      */
    1039     public static List getSelectResults(
    1040         QueryDataSet qds,
    1041         int start,
    1042         int numberOfResults,
    1043         boolean singleRecord)
    1044         throws TorqueException
    1045     {
    1046         return BasePeer.getSelectResults(qds,start,numberOfResults,singleRecord);
    1047     }
    1048
    1049     /**
    1050      * Performs a SQL <code>select</code> using a PreparedStatement.
    1051      * Note: this method does not handle null criteria values.
    1052      *
    1053      * @param criteria
    1054      * @param con
    1055      * @return a List of Record objects.
    1056      * @throws TorqueException Error performing database query.
    1057      * @see org.apache.torque.util.BasePeer#doPSSelect(Criteria,Connection)
    1058      */
    1059     public static List<Record> doPSSelect(Criteria criteria, Connection con)
    1060         throws TorqueException
    1061     {
    1062         return BasePeer.doPSSelect(criteria,con);
    1063     }
    1064
    1065     /**
    1066      * Do a Prepared Statement select according to the given criteria
    1067      *
    1068      * @param criteria
    1069      * @return a List of Record objects.
    1070      * @throws TorqueException Any exceptions caught during processing will be
    1071      *         rethrown wrapped into a TorqueException.
    1072      * @see org.apache.torque.util.BasePeer#doPSSelect(Criteria)
    1073      */
    1074     public static List<Record> doPSSelect(Criteria criteria) throws TorqueException
    1075     {
    1076         return BasePeer.doPSSelect(criteria);
    1077     }
    1078 }