0001: package org.tigris.scarab.om;
0002:
0003: import java.math.BigDecimal;
0004: import java.sql.Connection;
0005: import java.sql.SQLException;
0006: import java.util.ArrayList;
0007: import java.util.Date;
0008: import java.util.Iterator;
0009: import java.util.LinkedList;
0010: import java.util.List;
0011:
0012: import org.apache.torque.NoRowsException;
0013: import org.apache.torque.TooManyRowsException;
0014: import org.apache.torque.Torque;
0015: import org.apache.torque.TorqueException;
0016: import org.apache.torque.map.MapBuilder;
0017: import org.apache.torque.map.TableMap;
0018: import org.apache.torque.om.DateKey;
0019: import org.apache.torque.om.NumberKey;
0020: import org.apache.torque.om.StringKey;
0021: import org.apache.torque.om.ObjectKey;
0022: import org.apache.torque.om.SimpleKey;
0023: import org.apache.torque.util.BasePeer;
0024: import org.apache.torque.util.Criteria;
0025:
0026: import com.workingdogs.village.DataSetException;
0027: import com.workingdogs.village.QueryDataSet;
0028: import com.workingdogs.village.Record;
0029:
0030: // Local classes
0031: import org.tigris.scarab.om.map.*;
0032:
0033: /**
0034: */
0035: public abstract class BaseMITListItemPeer extends BasePeer {
0036:
0037: /** the default database name for this class */
0038: public static final String DATABASE_NAME = "scarab";
0039:
0040: /** the table name for this class */
0041: public static final String TABLE_NAME = "SCARAB_MIT_LISTITEM";
0042:
0043: /**
0044: * @return the map builder for this peer
0045: * @throws TorqueException Any exceptions caught during processing will be
0046: * rethrown wrapped into a TorqueException.
0047: */
0048: public static MapBuilder getMapBuilder() throws TorqueException {
0049: return getMapBuilder(MITListItemMapBuilder.CLASS_NAME);
0050: }
0051:
0052: /** the column name for the ITEM_ID field */
0053: public static final String ITEM_ID;
0054: /** the column name for the MODULE_ID field */
0055: public static final String MODULE_ID;
0056: /** the column name for the ISSUE_TYPE_ID field */
0057: public static final String ISSUE_TYPE_ID;
0058: /** the column name for the LIST_ID field */
0059: public static final String LIST_ID;
0060:
0061: static {
0062: ITEM_ID = "SCARAB_MIT_LISTITEM.ITEM_ID";
0063: MODULE_ID = "SCARAB_MIT_LISTITEM.MODULE_ID";
0064: ISSUE_TYPE_ID = "SCARAB_MIT_LISTITEM.ISSUE_TYPE_ID";
0065: LIST_ID = "SCARAB_MIT_LISTITEM.LIST_ID";
0066: if (Torque.isInit()) {
0067: try {
0068: getMapBuilder(MITListItemMapBuilder.CLASS_NAME);
0069: } catch (Exception e) {
0070: log.error("Could not initialize Peer", e);
0071: throw new RuntimeException(e);
0072: }
0073: } else {
0074: Torque.registerMapBuilder(MITListItemMapBuilder.CLASS_NAME);
0075: }
0076: }
0077:
0078: /** number of columns for this peer */
0079: public static final int numColumns = 4;
0080:
0081: /** A class that can be returned by this peer. */
0082: protected static final String CLASSNAME_DEFAULT = "org.tigris.scarab.om.MITListItem";
0083:
0084: /** A class that can be returned by this peer. */
0085: protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
0086:
0087: /**
0088: * Class object initialization method.
0089: *
0090: * @param className name of the class to initialize
0091: * @return the initialized class
0092: */
0093: private static Class initClass(String className) {
0094: Class c = null;
0095: try {
0096: c = Class.forName(className);
0097: } catch (Throwable t) {
0098: log
0099: .error(
0100: "A FATAL ERROR has occurred which should not "
0101: + "have happened under any circumstance. Please notify "
0102: + "the Torque developers <torque-dev@db.apache.org> "
0103: + "and give as many details as possible (including the error "
0104: + "stack trace).", t);
0105:
0106: // Error objects should always be propogated.
0107: if (t instanceof Error) {
0108: throw (Error) t.fillInStackTrace();
0109: }
0110: }
0111: return c;
0112: }
0113:
0114: /**
0115: * Get the list of objects for a ResultSet. Please not that your
0116: * resultset MUST return columns in the right order. You can use
0117: * getFieldNames() in BaseObject to get the correct sequence.
0118: *
0119: * @param results the ResultSet
0120: * @return the list of objects
0121: * @throws TorqueException Any exceptions caught during processing will be
0122: * rethrown wrapped into a TorqueException.
0123: */
0124: public static List resultSet2Objects(java.sql.ResultSet results)
0125: throws TorqueException {
0126: try {
0127: QueryDataSet qds = null;
0128: List rows = null;
0129: try {
0130: qds = new QueryDataSet(results);
0131: rows = getSelectResults(qds);
0132: } finally {
0133: if (qds != null) {
0134: qds.close();
0135: }
0136: }
0137:
0138: return populateObjects(rows);
0139: } catch (SQLException e) {
0140: throw new TorqueException(e);
0141: } catch (DataSetException e) {
0142: throw new TorqueException(e);
0143: }
0144: }
0145:
0146: /**
0147: * Method to do inserts.
0148: *
0149: * @param criteria object used to create the INSERT statement.
0150: * @throws TorqueException Any exceptions caught during processing will be
0151: * rethrown wrapped into a TorqueException.
0152: */
0153: public static ObjectKey doInsert(Criteria criteria)
0154: throws TorqueException {
0155: return BaseMITListItemPeer
0156: .doInsert(criteria, (Connection) null);
0157: }
0158:
0159: /**
0160: * Method to do inserts. This method is to be used during a transaction,
0161: * otherwise use the doInsert(Criteria) method. It will take care of
0162: * the connection details internally.
0163: *
0164: * @param criteria object used to create the INSERT statement.
0165: * @param con the connection to use
0166: * @throws TorqueException Any exceptions caught during processing will be
0167: * rethrown wrapped into a TorqueException.
0168: */
0169: public static ObjectKey doInsert(Criteria criteria, Connection con)
0170: throws TorqueException {
0171: correctBooleans(criteria);
0172:
0173: setDbName(criteria);
0174:
0175: if (con == null) {
0176: return BasePeer.doInsert(criteria);
0177: } else {
0178: return BasePeer.doInsert(criteria, con);
0179: }
0180: }
0181:
0182: /**
0183: * Add all the columns needed to create a new object.
0184: *
0185: * @param criteria object containing the columns to add.
0186: * @throws TorqueException Any exceptions caught during processing will be
0187: * rethrown wrapped into a TorqueException.
0188: */
0189: public static void addSelectColumns(Criteria criteria)
0190: throws TorqueException {
0191: criteria.addSelectColumn(ITEM_ID);
0192: criteria.addSelectColumn(MODULE_ID);
0193: criteria.addSelectColumn(ISSUE_TYPE_ID);
0194: criteria.addSelectColumn(LIST_ID);
0195: }
0196:
0197: /**
0198: * changes the boolean values in the criteria to the appropriate type,
0199: * whenever a booleanchar or booleanint column is involved.
0200: * This enables the user to create criteria using Boolean values
0201: * for booleanchar or booleanint columns
0202: * @param criteria the criteria in which the boolean values should be corrected
0203: */
0204: public static void correctBooleans(Criteria criteria) {
0205: }
0206:
0207: /**
0208: * Create a new object of type cls from a resultset row starting
0209: * from a specified offset. This is done so that you can select
0210: * other rows than just those needed for this object. You may
0211: * for example want to create two objects from the same row.
0212: *
0213: * @throws TorqueException Any exceptions caught during processing will be
0214: * rethrown wrapped into a TorqueException.
0215: */
0216: public static MITListItem row2Object(Record row, int offset,
0217: Class cls) throws TorqueException {
0218: try {
0219: MITListItem obj = (MITListItem) cls.newInstance();
0220: MITListItemPeer.populateObject(row, offset, obj);
0221: obj.setModified(false);
0222: obj.setNew(false);
0223:
0224: return obj;
0225: } catch (InstantiationException e) {
0226: throw new TorqueException(e);
0227: } catch (IllegalAccessException e) {
0228: throw new TorqueException(e);
0229: }
0230: }
0231:
0232: /**
0233: * Populates an object from a resultset row starting
0234: * from a specified offset. This is done so that you can select
0235: * other rows than just those needed for this object. You may
0236: * for example want to create two objects from the same row.
0237: *
0238: * @throws TorqueException Any exceptions caught during processing will be
0239: * rethrown wrapped into a TorqueException.
0240: */
0241: public static void populateObject(Record row, int offset,
0242: MITListItem obj) throws TorqueException {
0243: try {
0244: obj.setItemId(row.getValue(offset + 0).asLongObj());
0245: obj.setModuleId(row.getValue(offset + 1).asIntegerObj());
0246: obj.setIssueTypeId(row.getValue(offset + 2).asIntegerObj());
0247: obj.setListId(row.getValue(offset + 3).asLongObj());
0248: } catch (DataSetException e) {
0249: throw new TorqueException(e);
0250: }
0251: }
0252:
0253: /**
0254: * Method to do selects.
0255: *
0256: * @param criteria object used to create the SELECT statement.
0257: * @return List of selected Objects
0258: * @throws TorqueException Any exceptions caught during processing will be
0259: * rethrown wrapped into a TorqueException.
0260: */
0261: public static List doSelect(Criteria criteria)
0262: throws TorqueException {
0263: return populateObjects(doSelectVillageRecords(criteria));
0264: }
0265:
0266: /**
0267: * Method to do selects within a transaction.
0268: *
0269: * @param criteria object used to create the SELECT statement.
0270: * @param con the connection to use
0271: * @return List of selected Objects
0272: * @throws TorqueException Any exceptions caught during processing will be
0273: * rethrown wrapped into a TorqueException.
0274: */
0275: public static List doSelect(Criteria criteria, Connection con)
0276: throws TorqueException {
0277: return populateObjects(doSelectVillageRecords(criteria, con));
0278: }
0279:
0280: /**
0281: * Grabs the raw Village records to be formed into objects.
0282: * This method handles connections internally. The Record objects
0283: * returned by this method should be considered readonly. Do not
0284: * alter the data and call save(), your results may vary, but are
0285: * certainly likely to result in hard to track MT bugs.
0286: *
0287: * @throws TorqueException Any exceptions caught during processing will be
0288: * rethrown wrapped into a TorqueException.
0289: */
0290: public static List doSelectVillageRecords(Criteria criteria)
0291: throws TorqueException {
0292: return BaseMITListItemPeer.doSelectVillageRecords(criteria,
0293: (Connection) null);
0294: }
0295:
0296: /**
0297: * Grabs the raw Village records to be formed into objects.
0298: * This method should be used for transactions
0299: *
0300: * @param criteria object used to create the SELECT statement.
0301: * @param con the connection to use
0302: * @throws TorqueException Any exceptions caught during processing will be
0303: * rethrown wrapped into a TorqueException.
0304: */
0305: public static List doSelectVillageRecords(Criteria criteria,
0306: Connection con) throws TorqueException {
0307: if (criteria.getSelectColumns().size() == 0) {
0308: addSelectColumns(criteria);
0309: }
0310: correctBooleans(criteria);
0311:
0312: setDbName(criteria);
0313:
0314: // BasePeer returns a List of Value (Village) arrays. The array
0315: // order follows the order columns were placed in the Select clause.
0316: if (con == null) {
0317: return BasePeer.doSelect(criteria);
0318: } else {
0319: return BasePeer.doSelect(criteria, con);
0320: }
0321: }
0322:
0323: /**
0324: * The returned List will contain objects of the default type or
0325: * objects that inherit from the default.
0326: *
0327: * @throws TorqueException Any exceptions caught during processing will be
0328: * rethrown wrapped into a TorqueException.
0329: */
0330: public static List populateObjects(List records)
0331: throws TorqueException {
0332: List results = new ArrayList(records.size());
0333:
0334: // populate the object(s)
0335: for (int i = 0; i < records.size(); i++) {
0336: Record row = (Record) records.get(i);
0337: results.add(MITListItemPeer.row2Object(row, 1,
0338: MITListItemPeer.getOMClass()));
0339: }
0340: return results;
0341: }
0342:
0343: /**
0344: * The class that the Peer will make instances of.
0345: * If the BO is abstract then you must implement this method
0346: * in the BO.
0347: *
0348: * @throws TorqueException Any exceptions caught during processing will be
0349: * rethrown wrapped into a TorqueException.
0350: */
0351: public static Class getOMClass() throws TorqueException {
0352: return CLASS_DEFAULT;
0353: }
0354:
0355: /**
0356: * Method to do updates.
0357: *
0358: * @param criteria object containing data that is used to create the UPDATE
0359: * statement.
0360: * @throws TorqueException Any exceptions caught during processing will be
0361: * rethrown wrapped into a TorqueException.
0362: */
0363: public static void doUpdate(Criteria criteria)
0364: throws TorqueException {
0365: BaseMITListItemPeer.doUpdate(criteria, (Connection) null);
0366: }
0367:
0368: /**
0369: * Method to do updates. This method is to be used during a transaction,
0370: * otherwise use the doUpdate(Criteria) method. It will take care of
0371: * the connection details internally.
0372: *
0373: * @param criteria object containing data that is used to create the UPDATE
0374: * statement.
0375: * @param con the connection to use
0376: * @throws TorqueException Any exceptions caught during processing will be
0377: * rethrown wrapped into a TorqueException.
0378: */
0379: public static void doUpdate(Criteria criteria, Connection con)
0380: throws TorqueException {
0381: Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
0382: correctBooleans(criteria);
0383:
0384: selectCriteria.put(ITEM_ID, criteria.remove(ITEM_ID));
0385:
0386: setDbName(criteria);
0387:
0388: if (con == null) {
0389: BasePeer.doUpdate(selectCriteria, criteria);
0390: } else {
0391: BasePeer.doUpdate(selectCriteria, criteria, con);
0392: }
0393: }
0394:
0395: /**
0396: * Method to do deletes.
0397: *
0398: * @param criteria object containing data that is used DELETE from database.
0399: * @throws TorqueException Any exceptions caught during processing will be
0400: * rethrown wrapped into a TorqueException.
0401: */
0402: public static void doDelete(Criteria criteria)
0403: throws TorqueException {
0404: MITListItemPeer.doDelete(criteria, (Connection) null);
0405: }
0406:
0407: /**
0408: * Method to do deletes. This method is to be used during a transaction,
0409: * otherwise use the doDelete(Criteria) method. It will take care of
0410: * the connection details internally.
0411: *
0412: * @param criteria object containing data that is used DELETE from database.
0413: * @param con the connection to use
0414: * @throws TorqueException Any exceptions caught during processing will be
0415: * rethrown wrapped into a TorqueException.
0416: */
0417: public static void doDelete(Criteria criteria, Connection con)
0418: throws TorqueException {
0419: correctBooleans(criteria);
0420:
0421: setDbName(criteria);
0422:
0423: if (con == null) {
0424: BasePeer.doDelete(criteria);
0425: } else {
0426: BasePeer.doDelete(criteria, con);
0427: }
0428: }
0429:
0430: /**
0431: * Method to do selects
0432: *
0433: * @throws TorqueException Any exceptions caught during processing will be
0434: * rethrown wrapped into a TorqueException.
0435: */
0436: public static List doSelect(MITListItem obj) throws TorqueException {
0437: return doSelect(buildSelectCriteria(obj));
0438: }
0439:
0440: /**
0441: * Method to do inserts
0442: *
0443: * @throws TorqueException Any exceptions caught during processing will be
0444: * rethrown wrapped into a TorqueException.
0445: */
0446: public static void doInsert(MITListItem obj) throws TorqueException {
0447: obj.setPrimaryKey(doInsert(buildCriteria(obj)));
0448: obj.setNew(false);
0449: obj.setModified(false);
0450: }
0451:
0452: /**
0453: * @param obj the data object to update in the database.
0454: * @throws TorqueException Any exceptions caught during processing will be
0455: * rethrown wrapped into a TorqueException.
0456: */
0457: public static void doUpdate(MITListItem obj) throws TorqueException {
0458: doUpdate(buildCriteria(obj));
0459: obj.setModified(false);
0460: }
0461:
0462: /**
0463: * @param obj the data object to delete in the database.
0464: * @throws TorqueException Any exceptions caught during processing will be
0465: * rethrown wrapped into a TorqueException.
0466: */
0467: public static void doDelete(MITListItem obj) throws TorqueException {
0468: doDelete(buildSelectCriteria(obj));
0469: }
0470:
0471: /**
0472: * Method to do inserts. This method is to be used during a transaction,
0473: * otherwise use the doInsert(MITListItem) method. It will take
0474: * care of the connection details internally.
0475: *
0476: * @param obj the data object to insert into the database.
0477: * @param con the connection to use
0478: * @throws TorqueException Any exceptions caught during processing will be
0479: * rethrown wrapped into a TorqueException.
0480: */
0481: public static void doInsert(MITListItem obj, Connection con)
0482: throws TorqueException {
0483: obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
0484: obj.setNew(false);
0485: obj.setModified(false);
0486: }
0487:
0488: /**
0489: * Method to do update. This method is to be used during a transaction,
0490: * otherwise use the doUpdate(MITListItem) method. It will take
0491: * care of the connection details internally.
0492: *
0493: * @param obj the data object to update in the database.
0494: * @param con the connection to use
0495: * @throws TorqueException Any exceptions caught during processing will be
0496: * rethrown wrapped into a TorqueException.
0497: */
0498: public static void doUpdate(MITListItem obj, Connection con)
0499: throws TorqueException {
0500: doUpdate(buildCriteria(obj), con);
0501: obj.setModified(false);
0502: }
0503:
0504: /**
0505: * Method to delete. This method is to be used during a transaction,
0506: * otherwise use the doDelete(MITListItem) method. It will take
0507: * care of the connection details internally.
0508: *
0509: * @param obj the data object to delete in the database.
0510: * @param con the connection to use
0511: * @throws TorqueException Any exceptions caught during processing will be
0512: * rethrown wrapped into a TorqueException.
0513: */
0514: public static void doDelete(MITListItem obj, Connection con)
0515: throws TorqueException {
0516: doDelete(buildSelectCriteria(obj), con);
0517: }
0518:
0519: /**
0520: * Method to do deletes.
0521: *
0522: * @param pk ObjectKey that is used DELETE from database.
0523: * @throws TorqueException Any exceptions caught during processing will be
0524: * rethrown wrapped into a TorqueException.
0525: */
0526: public static void doDelete(ObjectKey pk) throws TorqueException {
0527: BaseMITListItemPeer.doDelete(pk, (Connection) null);
0528: }
0529:
0530: /**
0531: * Method to delete. This method is to be used during a transaction,
0532: * otherwise use the doDelete(ObjectKey) method. It will take
0533: * care of the connection details internally.
0534: *
0535: * @param pk the primary key for the object to delete in the database.
0536: * @param con the connection to use
0537: * @throws TorqueException Any exceptions caught during processing will be
0538: * rethrown wrapped into a TorqueException.
0539: */
0540: public static void doDelete(ObjectKey pk, Connection con)
0541: throws TorqueException {
0542: doDelete(buildCriteria(pk), con);
0543: }
0544:
0545: /** Build a Criteria object from an ObjectKey */
0546: public static Criteria buildCriteria(ObjectKey pk) {
0547: Criteria criteria = new Criteria();
0548: criteria.add(ITEM_ID, pk);
0549: return criteria;
0550: }
0551:
0552: /** Build a Criteria object from the data object for this peer */
0553: public static Criteria buildCriteria(MITListItem obj) {
0554: Criteria criteria = new Criteria(DATABASE_NAME);
0555: if (!obj.isNew())
0556: criteria.add(ITEM_ID, obj.getItemId());
0557: criteria.add(MODULE_ID, obj.getModuleId());
0558: criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
0559: criteria.add(LIST_ID, obj.getListId());
0560: return criteria;
0561: }
0562:
0563: /** Build a Criteria object from the data object for this peer, skipping all binary columns */
0564: public static Criteria buildSelectCriteria(MITListItem obj) {
0565: Criteria criteria = new Criteria(DATABASE_NAME);
0566: if (!obj.isNew()) {
0567: criteria.add(ITEM_ID, obj.getItemId());
0568: }
0569: criteria.add(MODULE_ID, obj.getModuleId());
0570: criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
0571: criteria.add(LIST_ID, obj.getListId());
0572: return criteria;
0573: }
0574:
0575: /**
0576: * Retrieve a single object by pk
0577: *
0578: * @param pk the primary key
0579: * @throws TorqueException Any exceptions caught during processing will be
0580: * rethrown wrapped into a TorqueException.
0581: * @throws NoRowsException Primary key was not found in database.
0582: * @throws TooManyRowsException Primary key was not found in database.
0583: */
0584: public static MITListItem retrieveByPK(Long pk)
0585: throws TorqueException, NoRowsException,
0586: TooManyRowsException {
0587: return retrieveByPK(SimpleKey.keyFor(pk));
0588: }
0589:
0590: /**
0591: * Retrieve a single object by pk
0592: *
0593: * @param pk the primary key
0594: * @param con the connection to use
0595: * @throws TorqueException Any exceptions caught during processing will be
0596: * rethrown wrapped into a TorqueException.
0597: * @throws NoRowsException Primary key was not found in database.
0598: * @throws TooManyRowsException Primary key was not found in database.
0599: */
0600: public static MITListItem retrieveByPK(Long pk, Connection con)
0601: throws TorqueException, NoRowsException,
0602: TooManyRowsException {
0603: return retrieveByPK(SimpleKey.keyFor(pk), con);
0604: }
0605:
0606: /**
0607: * Retrieve a single object by pk
0608: *
0609: * @param pk the primary key
0610: * @throws TorqueException Any exceptions caught during processing will be
0611: * rethrown wrapped into a TorqueException.
0612: * @throws NoRowsException Primary key was not found in database.
0613: * @throws TooManyRowsException Primary key was not found in database.
0614: */
0615: public static MITListItem retrieveByPK(ObjectKey pk)
0616: throws TorqueException, NoRowsException,
0617: TooManyRowsException {
0618: Connection db = null;
0619: MITListItem retVal = null;
0620: try {
0621: db = Torque.getConnection(DATABASE_NAME);
0622: retVal = retrieveByPK(pk, db);
0623: } finally {
0624: Torque.closeConnection(db);
0625: }
0626: return retVal;
0627: }
0628:
0629: /**
0630: * Retrieve a single object by pk
0631: *
0632: * @param pk the primary key
0633: * @param con the connection to use
0634: * @throws TorqueException Any exceptions caught during processing will be
0635: * rethrown wrapped into a TorqueException.
0636: * @throws NoRowsException Primary key was not found in database.
0637: * @throws TooManyRowsException Primary key was not found in database.
0638: */
0639: public static MITListItem retrieveByPK(ObjectKey pk, Connection con)
0640: throws TorqueException, NoRowsException,
0641: TooManyRowsException {
0642: Criteria criteria = buildCriteria(pk);
0643: List v = doSelect(criteria, con);
0644: if (v.size() == 0) {
0645: throw new NoRowsException("Failed to select a row.");
0646: } else if (v.size() > 1) {
0647: throw new TooManyRowsException(
0648: "Failed to select only one row.");
0649: } else {
0650: return (MITListItem) v.get(0);
0651: }
0652: }
0653:
0654: /**
0655: * Retrieve a multiple objects by pk
0656: *
0657: * @param pks List of primary keys
0658: * @throws TorqueException Any exceptions caught during processing will be
0659: * rethrown wrapped into a TorqueException.
0660: */
0661: public static List retrieveByPKs(List pks) throws TorqueException {
0662: Connection db = null;
0663: List retVal = null;
0664: try {
0665: db = Torque.getConnection(DATABASE_NAME);
0666: retVal = retrieveByPKs(pks, db);
0667: } finally {
0668: Torque.closeConnection(db);
0669: }
0670: return retVal;
0671: }
0672:
0673: /**
0674: * Retrieve a multiple objects by pk
0675: *
0676: * @param pks List of primary keys
0677: * @param dbcon the connection to use
0678: * @throws TorqueException Any exceptions caught during processing will be
0679: * rethrown wrapped into a TorqueException.
0680: */
0681: public static List retrieveByPKs(List pks, Connection dbcon)
0682: throws TorqueException {
0683: List objs = null;
0684: if (pks == null || pks.size() == 0) {
0685: objs = new LinkedList();
0686: } else {
0687: Criteria criteria = new Criteria();
0688: criteria.addIn(ITEM_ID, pks);
0689: objs = doSelect(criteria, dbcon);
0690: }
0691: return objs;
0692: }
0693:
0694: /**
0695: * selects a collection of MITListItem objects pre-filled with their
0696: * MITList objects.
0697: *
0698: * This method is protected by default in order to keep the public
0699: * api reasonable. You can provide public methods for those you
0700: * actually need in MITListItemPeer.
0701: *
0702: * @throws TorqueException Any exceptions caught during processing will be
0703: * rethrown wrapped into a TorqueException.
0704: */
0705: protected static List doSelectJoinMITList(Criteria criteria)
0706: throws TorqueException {
0707: return doSelectJoinMITList(criteria, null);
0708: }
0709:
0710: /**
0711: * selects a collection of MITListItem objects pre-filled with their
0712: * MITList objects.
0713: *
0714: * This method is protected by default in order to keep the public
0715: * api reasonable. You can provide public methods for those you
0716: * actually need in MITListItemPeer.
0717: *
0718: * @throws TorqueException Any exceptions caught during processing will be
0719: * rethrown wrapped into a TorqueException.
0720: */
0721: protected static List doSelectJoinMITList(Criteria criteria,
0722: Connection conn) throws TorqueException {
0723: setDbName(criteria);
0724:
0725: MITListItemPeer.addSelectColumns(criteria);
0726: int offset = numColumns + 1;
0727: MITListPeer.addSelectColumns(criteria);
0728:
0729: criteria.addJoin(MITListItemPeer.LIST_ID, MITListPeer.LIST_ID);
0730:
0731: correctBooleans(criteria);
0732:
0733: List rows;
0734: if (conn == null) {
0735: rows = BasePeer.doSelect(criteria);
0736: } else {
0737: rows = BasePeer.doSelect(criteria, conn);
0738: }
0739:
0740: List results = new ArrayList();
0741:
0742: for (int i = 0; i < rows.size(); i++) {
0743: Record row = (Record) rows.get(i);
0744:
0745: Class omClass = MITListItemPeer.getOMClass();
0746: MITListItem obj1 = (MITListItem) MITListItemPeer
0747: .row2Object(row, 1, omClass);
0748: omClass = MITListPeer.getOMClass();
0749: MITList obj2 = (MITList) MITListPeer.row2Object(row,
0750: offset, omClass);
0751:
0752: boolean newObject = true;
0753: for (int j = 0; j < results.size(); j++) {
0754: MITListItem temp_obj1 = (MITListItem) results.get(j);
0755: MITList temp_obj2 = (MITList) temp_obj1.getMITList();
0756: if (temp_obj2.getPrimaryKey().equals(
0757: obj2.getPrimaryKey())) {
0758: newObject = false;
0759: temp_obj2.addMITListItem(obj1);
0760: break;
0761: }
0762: }
0763: if (newObject) {
0764: obj2.initMITListItems();
0765: obj2.addMITListItem(obj1);
0766: }
0767: results.add(obj1);
0768: }
0769: return results;
0770: }
0771:
0772: /**
0773: * selects a collection of MITListItem objects pre-filled with their
0774: * ScarabModule objects.
0775: *
0776: * This method is protected by default in order to keep the public
0777: * api reasonable. You can provide public methods for those you
0778: * actually need in MITListItemPeer.
0779: *
0780: * @throws TorqueException Any exceptions caught during processing will be
0781: * rethrown wrapped into a TorqueException.
0782: */
0783: protected static List doSelectJoinScarabModule(Criteria criteria)
0784: throws TorqueException {
0785: return doSelectJoinScarabModule(criteria, null);
0786: }
0787:
0788: /**
0789: * selects a collection of MITListItem objects pre-filled with their
0790: * ScarabModule objects.
0791: *
0792: * This method is protected by default in order to keep the public
0793: * api reasonable. You can provide public methods for those you
0794: * actually need in MITListItemPeer.
0795: *
0796: * @throws TorqueException Any exceptions caught during processing will be
0797: * rethrown wrapped into a TorqueException.
0798: */
0799: protected static List doSelectJoinScarabModule(Criteria criteria,
0800: Connection conn) throws TorqueException {
0801: setDbName(criteria);
0802:
0803: MITListItemPeer.addSelectColumns(criteria);
0804: int offset = numColumns + 1;
0805: ScarabModulePeer.addSelectColumns(criteria);
0806:
0807: criteria.addJoin(MITListItemPeer.MODULE_ID,
0808: ScarabModulePeer.MODULE_ID);
0809:
0810: correctBooleans(criteria);
0811:
0812: List rows;
0813: if (conn == null) {
0814: rows = BasePeer.doSelect(criteria);
0815: } else {
0816: rows = BasePeer.doSelect(criteria, conn);
0817: }
0818:
0819: List results = new ArrayList();
0820:
0821: for (int i = 0; i < rows.size(); i++) {
0822: Record row = (Record) rows.get(i);
0823:
0824: Class omClass = MITListItemPeer.getOMClass();
0825: MITListItem obj1 = (MITListItem) MITListItemPeer
0826: .row2Object(row, 1, omClass);
0827: omClass = ScarabModulePeer.getOMClass(row, offset);
0828: ScarabModule obj2 = (ScarabModule) ScarabModulePeer
0829: .row2Object(row, offset, omClass);
0830:
0831: boolean newObject = true;
0832: for (int j = 0; j < results.size(); j++) {
0833: MITListItem temp_obj1 = (MITListItem) results.get(j);
0834: ScarabModule temp_obj2 = (ScarabModule) temp_obj1
0835: .getModule();
0836: if (temp_obj2.getPrimaryKey().equals(
0837: obj2.getPrimaryKey())) {
0838: newObject = false;
0839: temp_obj2.addMITListItem(obj1);
0840: break;
0841: }
0842: }
0843: if (newObject) {
0844: obj2.initMITListItems();
0845: obj2.addMITListItem(obj1);
0846: }
0847: results.add(obj1);
0848: }
0849: return results;
0850: }
0851:
0852: /**
0853: * selects a collection of MITListItem objects pre-filled with their
0854: * IssueType objects.
0855: *
0856: * This method is protected by default in order to keep the public
0857: * api reasonable. You can provide public methods for those you
0858: * actually need in MITListItemPeer.
0859: *
0860: * @throws TorqueException Any exceptions caught during processing will be
0861: * rethrown wrapped into a TorqueException.
0862: */
0863: protected static List doSelectJoinIssueType(Criteria criteria)
0864: throws TorqueException {
0865: return doSelectJoinIssueType(criteria, null);
0866: }
0867:
0868: /**
0869: * selects a collection of MITListItem objects pre-filled with their
0870: * IssueType objects.
0871: *
0872: * This method is protected by default in order to keep the public
0873: * api reasonable. You can provide public methods for those you
0874: * actually need in MITListItemPeer.
0875: *
0876: * @throws TorqueException Any exceptions caught during processing will be
0877: * rethrown wrapped into a TorqueException.
0878: */
0879: protected static List doSelectJoinIssueType(Criteria criteria,
0880: Connection conn) throws TorqueException {
0881: setDbName(criteria);
0882:
0883: MITListItemPeer.addSelectColumns(criteria);
0884: int offset = numColumns + 1;
0885: IssueTypePeer.addSelectColumns(criteria);
0886:
0887: criteria.addJoin(MITListItemPeer.ISSUE_TYPE_ID,
0888: IssueTypePeer.ISSUE_TYPE_ID);
0889:
0890: correctBooleans(criteria);
0891:
0892: List rows;
0893: if (conn == null) {
0894: rows = BasePeer.doSelect(criteria);
0895: } else {
0896: rows = BasePeer.doSelect(criteria, conn);
0897: }
0898:
0899: List results = new ArrayList();
0900:
0901: for (int i = 0; i < rows.size(); i++) {
0902: Record row = (Record) rows.get(i);
0903:
0904: Class omClass = MITListItemPeer.getOMClass();
0905: MITListItem obj1 = (MITListItem) MITListItemPeer
0906: .row2Object(row, 1, omClass);
0907: omClass = IssueTypePeer.getOMClass();
0908: IssueType obj2 = (IssueType) IssueTypePeer.row2Object(row,
0909: offset, omClass);
0910:
0911: boolean newObject = true;
0912: for (int j = 0; j < results.size(); j++) {
0913: MITListItem temp_obj1 = (MITListItem) results.get(j);
0914: IssueType temp_obj2 = (IssueType) temp_obj1
0915: .getIssueType();
0916: if (temp_obj2.getPrimaryKey().equals(
0917: obj2.getPrimaryKey())) {
0918: newObject = false;
0919: temp_obj2.addMITListItem(obj1);
0920: break;
0921: }
0922: }
0923: if (newObject) {
0924: obj2.initMITListItems();
0925: obj2.addMITListItem(obj1);
0926: }
0927: results.add(obj1);
0928: }
0929: return results;
0930: }
0931:
0932: /**
0933: * selects a collection of MITListItem objects pre-filled with
0934: * all related objects.
0935: *
0936: * This method is protected by default in order to keep the public
0937: * api reasonable. You can provide public methods for those you
0938: * actually need in MITListItemPeer.
0939: *
0940: * @throws TorqueException Any exceptions caught during processing will be
0941: * rethrown wrapped into a TorqueException.
0942: */
0943: protected static List doSelectJoinAllExceptMITList(Criteria criteria)
0944: throws TorqueException {
0945: return doSelectJoinAllExceptMITList(criteria, null);
0946: }
0947:
0948: /**
0949: * selects a collection of MITListItem objects pre-filled with
0950: * all related objects.
0951: *
0952: * This method is protected by default in order to keep the public
0953: * api reasonable. You can provide public methods for those you
0954: * actually need in MITListItemPeer.
0955: *
0956: * @throws TorqueException Any exceptions caught during processing will be
0957: * rethrown wrapped into a TorqueException.
0958: */
0959: protected static List doSelectJoinAllExceptMITList(
0960: Criteria criteria, Connection conn) throws TorqueException {
0961: setDbName(criteria);
0962:
0963: addSelectColumns(criteria);
0964: int offset2 = numColumns + 1;
0965:
0966: ScarabModulePeer.addSelectColumns(criteria);
0967: criteria.addJoin(MITListItemPeer.MODULE_ID,
0968: ScarabModulePeer.MODULE_ID);
0969: int offset3 = offset2 + ScarabModulePeer.numColumns;
0970:
0971: IssueTypePeer.addSelectColumns(criteria);
0972: criteria.addJoin(MITListItemPeer.ISSUE_TYPE_ID,
0973: IssueTypePeer.ISSUE_TYPE_ID);
0974:
0975: correctBooleans(criteria);
0976:
0977: List rows;
0978: if (conn == null) {
0979: rows = BasePeer.doSelect(criteria);
0980: } else {
0981: rows = BasePeer.doSelect(criteria, conn);
0982: }
0983:
0984: List results = new ArrayList();
0985:
0986: for (int i = 0; i < rows.size(); i++) {
0987: Record row = (Record) rows.get(i);
0988:
0989: Class omClass = MITListItemPeer.getOMClass();
0990: MITListItem obj1 = (MITListItem) MITListItemPeer
0991: .row2Object(row, 1, omClass);
0992:
0993: omClass = ScarabModulePeer.getOMClass(row, offset2);
0994: ScarabModule obj2 = (ScarabModule) ScarabModulePeer
0995: .row2Object(row, offset2, omClass);
0996:
0997: boolean newObject = true;
0998: for (int j = 0; j < results.size(); j++) {
0999: MITListItem temp_obj1 = (MITListItem) results.get(j);
1000: ScarabModule temp_obj2 = (ScarabModule) temp_obj1
1001: .getModule();
1002: if (temp_obj2.getPrimaryKey().equals(
1003: obj2.getPrimaryKey())) {
1004: newObject = false;
1005: temp_obj2.addMITListItem(obj1);
1006: break;
1007: }
1008: }
1009: if (newObject) {
1010: obj2.initMITListItems();
1011: obj2.addMITListItem(obj1);
1012: }
1013:
1014: omClass = IssueTypePeer.getOMClass();
1015: IssueType obj3 = (IssueType) IssueTypePeer.row2Object(row,
1016: offset3, omClass);
1017:
1018: newObject = true;
1019: for (int j = 0; j < results.size(); j++) {
1020: MITListItem temp_obj1 = (MITListItem) results.get(j);
1021: IssueType temp_obj3 = (IssueType) temp_obj1
1022: .getIssueType();
1023: if (temp_obj3.getPrimaryKey().equals(
1024: obj3.getPrimaryKey())) {
1025: newObject = false;
1026: temp_obj3.addMITListItem(obj1);
1027: break;
1028: }
1029: }
1030: if (newObject) {
1031: obj3.initMITListItems();
1032: obj3.addMITListItem(obj1);
1033: }
1034: results.add(obj1);
1035: }
1036: return results;
1037: }
1038:
1039: /**
1040: * selects a collection of MITListItem objects pre-filled with
1041: * all related objects.
1042: *
1043: * This method is protected by default in order to keep the public
1044: * api reasonable. You can provide public methods for those you
1045: * actually need in MITListItemPeer.
1046: *
1047: * @throws TorqueException Any exceptions caught during processing will be
1048: * rethrown wrapped into a TorqueException.
1049: */
1050: protected static List doSelectJoinAllExceptScarabModule(
1051: Criteria criteria) throws TorqueException {
1052: return doSelectJoinAllExceptScarabModule(criteria, null);
1053: }
1054:
1055: /**
1056: * selects a collection of MITListItem objects pre-filled with
1057: * all related objects.
1058: *
1059: * This method is protected by default in order to keep the public
1060: * api reasonable. You can provide public methods for those you
1061: * actually need in MITListItemPeer.
1062: *
1063: * @throws TorqueException Any exceptions caught during processing will be
1064: * rethrown wrapped into a TorqueException.
1065: */
1066: protected static List doSelectJoinAllExceptScarabModule(
1067: Criteria criteria, Connection conn) throws TorqueException {
1068: setDbName(criteria);
1069:
1070: addSelectColumns(criteria);
1071: int offset2 = numColumns + 1;
1072:
1073: MITListPeer.addSelectColumns(criteria);
1074: criteria.addJoin(MITListItemPeer.LIST_ID, MITListPeer.LIST_ID);
1075: int offset3 = offset2 + MITListPeer.numColumns;
1076:
1077: IssueTypePeer.addSelectColumns(criteria);
1078: criteria.addJoin(MITListItemPeer.ISSUE_TYPE_ID,
1079: IssueTypePeer.ISSUE_TYPE_ID);
1080:
1081: correctBooleans(criteria);
1082:
1083: List rows;
1084: if (conn == null) {
1085: rows = BasePeer.doSelect(criteria);
1086: } else {
1087: rows = BasePeer.doSelect(criteria, conn);
1088: }
1089:
1090: List results = new ArrayList();
1091:
1092: for (int i = 0; i < rows.size(); i++) {
1093: Record row = (Record) rows.get(i);
1094:
1095: Class omClass = MITListItemPeer.getOMClass();
1096: MITListItem obj1 = (MITListItem) MITListItemPeer
1097: .row2Object(row, 1, omClass);
1098:
1099: omClass = MITListPeer.getOMClass();
1100: MITList obj2 = (MITList) MITListPeer.row2Object(row,
1101: offset2, omClass);
1102:
1103: boolean newObject = true;
1104: for (int j = 0; j < results.size(); j++) {
1105: MITListItem temp_obj1 = (MITListItem) results.get(j);
1106: MITList temp_obj2 = (MITList) temp_obj1.getMITList();
1107: if (temp_obj2.getPrimaryKey().equals(
1108: obj2.getPrimaryKey())) {
1109: newObject = false;
1110: temp_obj2.addMITListItem(obj1);
1111: break;
1112: }
1113: }
1114: if (newObject) {
1115: obj2.initMITListItems();
1116: obj2.addMITListItem(obj1);
1117: }
1118:
1119: omClass = IssueTypePeer.getOMClass();
1120: IssueType obj3 = (IssueType) IssueTypePeer.row2Object(row,
1121: offset3, omClass);
1122:
1123: newObject = true;
1124: for (int j = 0; j < results.size(); j++) {
1125: MITListItem temp_obj1 = (MITListItem) results.get(j);
1126: IssueType temp_obj3 = (IssueType) temp_obj1
1127: .getIssueType();
1128: if (temp_obj3.getPrimaryKey().equals(
1129: obj3.getPrimaryKey())) {
1130: newObject = false;
1131: temp_obj3.addMITListItem(obj1);
1132: break;
1133: }
1134: }
1135: if (newObject) {
1136: obj3.initMITListItems();
1137: obj3.addMITListItem(obj1);
1138: }
1139: results.add(obj1);
1140: }
1141: return results;
1142: }
1143:
1144: /**
1145: * selects a collection of MITListItem objects pre-filled with
1146: * all related objects.
1147: *
1148: * This method is protected by default in order to keep the public
1149: * api reasonable. You can provide public methods for those you
1150: * actually need in MITListItemPeer.
1151: *
1152: * @throws TorqueException Any exceptions caught during processing will be
1153: * rethrown wrapped into a TorqueException.
1154: */
1155: protected static List doSelectJoinAllExceptIssueType(
1156: Criteria criteria) throws TorqueException {
1157: return doSelectJoinAllExceptIssueType(criteria, null);
1158: }
1159:
1160: /**
1161: * selects a collection of MITListItem objects pre-filled with
1162: * all related objects.
1163: *
1164: * This method is protected by default in order to keep the public
1165: * api reasonable. You can provide public methods for those you
1166: * actually need in MITListItemPeer.
1167: *
1168: * @throws TorqueException Any exceptions caught during processing will be
1169: * rethrown wrapped into a TorqueException.
1170: */
1171: protected static List doSelectJoinAllExceptIssueType(
1172: Criteria criteria, Connection conn) throws TorqueException {
1173: setDbName(criteria);
1174:
1175: addSelectColumns(criteria);
1176: int offset2 = numColumns + 1;
1177:
1178: MITListPeer.addSelectColumns(criteria);
1179: criteria.addJoin(MITListItemPeer.LIST_ID, MITListPeer.LIST_ID);
1180: int offset3 = offset2 + MITListPeer.numColumns;
1181:
1182: ScarabModulePeer.addSelectColumns(criteria);
1183: criteria.addJoin(MITListItemPeer.MODULE_ID,
1184: ScarabModulePeer.MODULE_ID);
1185:
1186: correctBooleans(criteria);
1187:
1188: List rows;
1189: if (conn == null) {
1190: rows = BasePeer.doSelect(criteria);
1191: } else {
1192: rows = BasePeer.doSelect(criteria, conn);
1193: }
1194:
1195: List results = new ArrayList();
1196:
1197: for (int i = 0; i < rows.size(); i++) {
1198: Record row = (Record) rows.get(i);
1199:
1200: Class omClass = MITListItemPeer.getOMClass();
1201: MITListItem obj1 = (MITListItem) MITListItemPeer
1202: .row2Object(row, 1, omClass);
1203:
1204: omClass = MITListPeer.getOMClass();
1205: MITList obj2 = (MITList) MITListPeer.row2Object(row,
1206: offset2, omClass);
1207:
1208: boolean newObject = true;
1209: for (int j = 0; j < results.size(); j++) {
1210: MITListItem temp_obj1 = (MITListItem) results.get(j);
1211: MITList temp_obj2 = (MITList) temp_obj1.getMITList();
1212: if (temp_obj2.getPrimaryKey().equals(
1213: obj2.getPrimaryKey())) {
1214: newObject = false;
1215: temp_obj2.addMITListItem(obj1);
1216: break;
1217: }
1218: }
1219: if (newObject) {
1220: obj2.initMITListItems();
1221: obj2.addMITListItem(obj1);
1222: }
1223:
1224: omClass = ScarabModulePeer.getOMClass(row, offset3);
1225: ScarabModule obj3 = (ScarabModule) ScarabModulePeer
1226: .row2Object(row, offset3, omClass);
1227:
1228: newObject = true;
1229: for (int j = 0; j < results.size(); j++) {
1230: MITListItem temp_obj1 = (MITListItem) results.get(j);
1231: ScarabModule temp_obj3 = (ScarabModule) temp_obj1
1232: .getModule();
1233: if (temp_obj3.getPrimaryKey().equals(
1234: obj3.getPrimaryKey())) {
1235: newObject = false;
1236: temp_obj3.addMITListItem(obj1);
1237: break;
1238: }
1239: }
1240: if (newObject) {
1241: obj3.initMITListItems();
1242: obj3.addMITListItem(obj1);
1243: }
1244:
1245: results.add(obj1);
1246: }
1247: return results;
1248: }
1249:
1250: /**
1251: * Returns the TableMap related to this peer. This method is not
1252: * needed for general use but a specific application could have a need.
1253: *
1254: * @throws TorqueException Any exceptions caught during processing will be
1255: * rethrown wrapped into a TorqueException.
1256: */
1257: protected static TableMap getTableMap() throws TorqueException {
1258: return Torque.getDatabaseMap(DATABASE_NAME)
1259: .getTable(TABLE_NAME);
1260: }
1261:
1262: private static void setDbName(Criteria crit) {
1263: // Set the correct dbName if it has not been overridden
1264: // crit.getDbName will return the same object if not set to
1265: // another value so == check is okay and faster
1266: if (crit.getDbName() == Torque.getDefaultDB()) {
1267: crit.setDbName(DATABASE_NAME);
1268: }
1269: }
1270: }
|