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 BaseQueryPeer 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_QUERY";
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(QueryMapBuilder.CLASS_NAME);
0050: }
0051:
0052: /** the column name for the QUERY_ID field */
0053: public static final String QUERY_ID;
0054: /** the column name for the USER_ID field */
0055: public static final String USER_ID;
0056: /** the column name for the NAME field */
0057: public static final String NAME;
0058: /** the column name for the DESCRIPTION field */
0059: public static final String DESCRIPTION;
0060: /** the column name for the VALUE field */
0061: public static final String VALUE;
0062: /** the column name for the SCOPE_ID field */
0063: public static final String SCOPE_ID;
0064: /** the column name for the ISSUE_TYPE_ID field */
0065: public static final String ISSUE_TYPE_ID;
0066: /** the column name for the MODULE_ID field */
0067: public static final String MODULE_ID;
0068: /** the column name for the LIST_ID field */
0069: public static final String LIST_ID;
0070: /** the column name for the DELETED field */
0071: public static final String DELETED;
0072: /** the column name for the APPROVED field */
0073: public static final String APPROVED;
0074: /** the column name for the CREATED_DATE field */
0075: public static final String CREATED_DATE;
0076: /** the column name for the SUBSCRIPTION_FREQUENCY_ID field */
0077: public static final String SUBSCRIPTION_FREQUENCY_ID;
0078: /** the column name for the HOME_PAGE field */
0079: public static final String HOME_PAGE;
0080: /** the column name for the PREFERRED_ORDER field */
0081: public static final String PREFERRED_ORDER;
0082:
0083: static {
0084: QUERY_ID = "SCARAB_QUERY.QUERY_ID";
0085: USER_ID = "SCARAB_QUERY.USER_ID";
0086: NAME = "SCARAB_QUERY.NAME";
0087: DESCRIPTION = "SCARAB_QUERY.DESCRIPTION";
0088: VALUE = "SCARAB_QUERY.VALUE";
0089: SCOPE_ID = "SCARAB_QUERY.SCOPE_ID";
0090: ISSUE_TYPE_ID = "SCARAB_QUERY.ISSUE_TYPE_ID";
0091: MODULE_ID = "SCARAB_QUERY.MODULE_ID";
0092: LIST_ID = "SCARAB_QUERY.LIST_ID";
0093: DELETED = "SCARAB_QUERY.DELETED";
0094: APPROVED = "SCARAB_QUERY.APPROVED";
0095: CREATED_DATE = "SCARAB_QUERY.CREATED_DATE";
0096: SUBSCRIPTION_FREQUENCY_ID = "SCARAB_QUERY.SUBSCRIPTION_FREQUENCY_ID";
0097: HOME_PAGE = "SCARAB_QUERY.HOME_PAGE";
0098: PREFERRED_ORDER = "SCARAB_QUERY.PREFERRED_ORDER";
0099: if (Torque.isInit()) {
0100: try {
0101: getMapBuilder(QueryMapBuilder.CLASS_NAME);
0102: } catch (Exception e) {
0103: log.error("Could not initialize Peer", e);
0104: throw new RuntimeException(e);
0105: }
0106: } else {
0107: Torque.registerMapBuilder(QueryMapBuilder.CLASS_NAME);
0108: }
0109: }
0110:
0111: /** number of columns for this peer */
0112: public static final int numColumns = 15;
0113:
0114: /** A class that can be returned by this peer. */
0115: protected static final String CLASSNAME_DEFAULT = "org.tigris.scarab.om.Query";
0116:
0117: /** A class that can be returned by this peer. */
0118: protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
0119:
0120: /**
0121: * Class object initialization method.
0122: *
0123: * @param className name of the class to initialize
0124: * @return the initialized class
0125: */
0126: private static Class initClass(String className) {
0127: Class c = null;
0128: try {
0129: c = Class.forName(className);
0130: } catch (Throwable t) {
0131: log
0132: .error(
0133: "A FATAL ERROR has occurred which should not "
0134: + "have happened under any circumstance. Please notify "
0135: + "the Torque developers <torque-dev@db.apache.org> "
0136: + "and give as many details as possible (including the error "
0137: + "stack trace).", t);
0138:
0139: // Error objects should always be propogated.
0140: if (t instanceof Error) {
0141: throw (Error) t.fillInStackTrace();
0142: }
0143: }
0144: return c;
0145: }
0146:
0147: /**
0148: * Get the list of objects for a ResultSet. Please not that your
0149: * resultset MUST return columns in the right order. You can use
0150: * getFieldNames() in BaseObject to get the correct sequence.
0151: *
0152: * @param results the ResultSet
0153: * @return the list of objects
0154: * @throws TorqueException Any exceptions caught during processing will be
0155: * rethrown wrapped into a TorqueException.
0156: */
0157: public static List resultSet2Objects(java.sql.ResultSet results)
0158: throws TorqueException {
0159: try {
0160: QueryDataSet qds = null;
0161: List rows = null;
0162: try {
0163: qds = new QueryDataSet(results);
0164: rows = getSelectResults(qds);
0165: } finally {
0166: if (qds != null) {
0167: qds.close();
0168: }
0169: }
0170:
0171: return populateObjects(rows);
0172: } catch (SQLException e) {
0173: throw new TorqueException(e);
0174: } catch (DataSetException e) {
0175: throw new TorqueException(e);
0176: }
0177: }
0178:
0179: /**
0180: * Method to do inserts.
0181: *
0182: * @param criteria object used to create the INSERT statement.
0183: * @throws TorqueException Any exceptions caught during processing will be
0184: * rethrown wrapped into a TorqueException.
0185: */
0186: public static ObjectKey doInsert(Criteria criteria)
0187: throws TorqueException {
0188: return BaseQueryPeer.doInsert(criteria, (Connection) null);
0189: }
0190:
0191: /**
0192: * Method to do inserts. This method is to be used during a transaction,
0193: * otherwise use the doInsert(Criteria) method. It will take care of
0194: * the connection details internally.
0195: *
0196: * @param criteria object used to create the INSERT statement.
0197: * @param con the connection to use
0198: * @throws TorqueException Any exceptions caught during processing will be
0199: * rethrown wrapped into a TorqueException.
0200: */
0201: public static ObjectKey doInsert(Criteria criteria, Connection con)
0202: throws TorqueException {
0203: correctBooleans(criteria);
0204:
0205: setDbName(criteria);
0206:
0207: if (con == null) {
0208: return BasePeer.doInsert(criteria);
0209: } else {
0210: return BasePeer.doInsert(criteria, con);
0211: }
0212: }
0213:
0214: /**
0215: * Add all the columns needed to create a new object.
0216: *
0217: * @param criteria object containing the columns to add.
0218: * @throws TorqueException Any exceptions caught during processing will be
0219: * rethrown wrapped into a TorqueException.
0220: */
0221: public static void addSelectColumns(Criteria criteria)
0222: throws TorqueException {
0223: criteria.addSelectColumn(QUERY_ID);
0224: criteria.addSelectColumn(USER_ID);
0225: criteria.addSelectColumn(NAME);
0226: criteria.addSelectColumn(DESCRIPTION);
0227: criteria.addSelectColumn(VALUE);
0228: criteria.addSelectColumn(SCOPE_ID);
0229: criteria.addSelectColumn(ISSUE_TYPE_ID);
0230: criteria.addSelectColumn(MODULE_ID);
0231: criteria.addSelectColumn(LIST_ID);
0232: criteria.addSelectColumn(DELETED);
0233: criteria.addSelectColumn(APPROVED);
0234: criteria.addSelectColumn(CREATED_DATE);
0235: criteria.addSelectColumn(SUBSCRIPTION_FREQUENCY_ID);
0236: criteria.addSelectColumn(HOME_PAGE);
0237: criteria.addSelectColumn(PREFERRED_ORDER);
0238: }
0239:
0240: /**
0241: * changes the boolean values in the criteria to the appropriate type,
0242: * whenever a booleanchar or booleanint column is involved.
0243: * This enables the user to create criteria using Boolean values
0244: * for booleanchar or booleanint columns
0245: * @param criteria the criteria in which the boolean values should be corrected
0246: */
0247: public static void correctBooleans(Criteria criteria) {
0248: // check for conversion from boolean to int
0249: if (criteria.containsKey(DELETED)) {
0250: Object possibleBoolean = criteria.get(DELETED);
0251: if (possibleBoolean instanceof Boolean) {
0252: criteria.add(DELETED, ((Boolean) possibleBoolean)
0253: .booleanValue() ? 1 : 0);
0254: }
0255: }
0256: // check for conversion from boolean to int
0257: if (criteria.containsKey(APPROVED)) {
0258: Object possibleBoolean = criteria.get(APPROVED);
0259: if (possibleBoolean instanceof Boolean) {
0260: criteria.add(APPROVED, ((Boolean) possibleBoolean)
0261: .booleanValue() ? 1 : 0);
0262: }
0263: }
0264: // check for conversion from boolean to int
0265: if (criteria.containsKey(HOME_PAGE)) {
0266: Object possibleBoolean = criteria.get(HOME_PAGE);
0267: if (possibleBoolean instanceof Boolean) {
0268: criteria.add(HOME_PAGE, ((Boolean) possibleBoolean)
0269: .booleanValue() ? 1 : 0);
0270: }
0271: }
0272: }
0273:
0274: /**
0275: * Create a new object of type cls from a resultset row starting
0276: * from a specified offset. This is done so that you can select
0277: * other rows than just those needed for this object. You may
0278: * for example want to create two objects from the same row.
0279: *
0280: * @throws TorqueException Any exceptions caught during processing will be
0281: * rethrown wrapped into a TorqueException.
0282: */
0283: public static Query row2Object(Record row, int offset, Class cls)
0284: throws TorqueException {
0285: try {
0286: Query obj = (Query) cls.newInstance();
0287: QueryPeer.populateObject(row, offset, obj);
0288: obj.setModified(false);
0289: obj.setNew(false);
0290:
0291: return obj;
0292: } catch (InstantiationException e) {
0293: throw new TorqueException(e);
0294: } catch (IllegalAccessException e) {
0295: throw new TorqueException(e);
0296: }
0297: }
0298:
0299: /**
0300: * Populates an object from a resultset row starting
0301: * from a specified offset. This is done so that you can select
0302: * other rows than just those needed for this object. You may
0303: * for example want to create two objects from the same row.
0304: *
0305: * @throws TorqueException Any exceptions caught during processing will be
0306: * rethrown wrapped into a TorqueException.
0307: */
0308: public static void populateObject(Record row, int offset, Query obj)
0309: throws TorqueException {
0310: try {
0311: obj.setQueryId(row.getValue(offset + 0).asLongObj());
0312: obj.setUserId(row.getValue(offset + 1).asIntegerObj());
0313: obj.setName(row.getValue(offset + 2).asString());
0314: obj.setDescription(row.getValue(offset + 3).asString());
0315: obj.setValue(row.getValue(offset + 4).asString());
0316: obj.setScopeId(row.getValue(offset + 5).asIntegerObj());
0317: obj.setIssueTypeId(row.getValue(offset + 6).asIntegerObj());
0318: obj.setModuleId(row.getValue(offset + 7).asIntegerObj());
0319: obj.setListId(row.getValue(offset + 8).asLongObj());
0320: obj.setDeleted(row.getValue(offset + 9).asBoolean());
0321: obj.setApproved(row.getValue(offset + 10).asBoolean());
0322: obj.setCreatedDate(row.getValue(offset + 11).asUtilDate());
0323: obj.setSubscriptionFrequencyId(row.getValue(offset + 12)
0324: .asIntegerObj());
0325: obj.setHomePage(row.getValue(offset + 13).asBoolean());
0326: obj.setOrder(row.getValue(offset + 14).asInt());
0327: } catch (DataSetException e) {
0328: throw new TorqueException(e);
0329: }
0330: }
0331:
0332: /**
0333: * Method to do selects.
0334: *
0335: * @param criteria object used to create the SELECT statement.
0336: * @return List of selected Objects
0337: * @throws TorqueException Any exceptions caught during processing will be
0338: * rethrown wrapped into a TorqueException.
0339: */
0340: public static List doSelect(Criteria criteria)
0341: throws TorqueException {
0342: return populateObjects(doSelectVillageRecords(criteria));
0343: }
0344:
0345: /**
0346: * Method to do selects within a transaction.
0347: *
0348: * @param criteria object used to create the SELECT statement.
0349: * @param con the connection to use
0350: * @return List of selected Objects
0351: * @throws TorqueException Any exceptions caught during processing will be
0352: * rethrown wrapped into a TorqueException.
0353: */
0354: public static List doSelect(Criteria criteria, Connection con)
0355: throws TorqueException {
0356: return populateObjects(doSelectVillageRecords(criteria, con));
0357: }
0358:
0359: /**
0360: * Grabs the raw Village records to be formed into objects.
0361: * This method handles connections internally. The Record objects
0362: * returned by this method should be considered readonly. Do not
0363: * alter the data and call save(), your results may vary, but are
0364: * certainly likely to result in hard to track MT bugs.
0365: *
0366: * @throws TorqueException Any exceptions caught during processing will be
0367: * rethrown wrapped into a TorqueException.
0368: */
0369: public static List doSelectVillageRecords(Criteria criteria)
0370: throws TorqueException {
0371: return BaseQueryPeer.doSelectVillageRecords(criteria,
0372: (Connection) null);
0373: }
0374:
0375: /**
0376: * Grabs the raw Village records to be formed into objects.
0377: * This method should be used for transactions
0378: *
0379: * @param criteria object used to create the SELECT statement.
0380: * @param con the connection to use
0381: * @throws TorqueException Any exceptions caught during processing will be
0382: * rethrown wrapped into a TorqueException.
0383: */
0384: public static List doSelectVillageRecords(Criteria criteria,
0385: Connection con) throws TorqueException {
0386: if (criteria.getSelectColumns().size() == 0) {
0387: addSelectColumns(criteria);
0388: }
0389: correctBooleans(criteria);
0390:
0391: setDbName(criteria);
0392:
0393: // BasePeer returns a List of Value (Village) arrays. The array
0394: // order follows the order columns were placed in the Select clause.
0395: if (con == null) {
0396: return BasePeer.doSelect(criteria);
0397: } else {
0398: return BasePeer.doSelect(criteria, con);
0399: }
0400: }
0401:
0402: /**
0403: * The returned List will contain objects of the default type or
0404: * objects that inherit from the default.
0405: *
0406: * @throws TorqueException Any exceptions caught during processing will be
0407: * rethrown wrapped into a TorqueException.
0408: */
0409: public static List populateObjects(List records)
0410: throws TorqueException {
0411: List results = new ArrayList(records.size());
0412:
0413: // populate the object(s)
0414: for (int i = 0; i < records.size(); i++) {
0415: Record row = (Record) records.get(i);
0416: results.add(QueryPeer.row2Object(row, 1, QueryPeer
0417: .getOMClass()));
0418: }
0419: return results;
0420: }
0421:
0422: /**
0423: * The class that the Peer will make instances of.
0424: * If the BO is abstract then you must implement this method
0425: * in the BO.
0426: *
0427: * @throws TorqueException Any exceptions caught during processing will be
0428: * rethrown wrapped into a TorqueException.
0429: */
0430: public static Class getOMClass() throws TorqueException {
0431: return CLASS_DEFAULT;
0432: }
0433:
0434: /**
0435: * Method to do updates.
0436: *
0437: * @param criteria object containing data that is used to create the UPDATE
0438: * statement.
0439: * @throws TorqueException Any exceptions caught during processing will be
0440: * rethrown wrapped into a TorqueException.
0441: */
0442: public static void doUpdate(Criteria criteria)
0443: throws TorqueException {
0444: BaseQueryPeer.doUpdate(criteria, (Connection) null);
0445: }
0446:
0447: /**
0448: * Method to do updates. This method is to be used during a transaction,
0449: * otherwise use the doUpdate(Criteria) method. It will take care of
0450: * the connection details internally.
0451: *
0452: * @param criteria object containing data that is used to create the UPDATE
0453: * statement.
0454: * @param con the connection to use
0455: * @throws TorqueException Any exceptions caught during processing will be
0456: * rethrown wrapped into a TorqueException.
0457: */
0458: public static void doUpdate(Criteria criteria, Connection con)
0459: throws TorqueException {
0460: Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
0461: correctBooleans(criteria);
0462:
0463: selectCriteria.put(QUERY_ID, criteria.remove(QUERY_ID));
0464:
0465: setDbName(criteria);
0466:
0467: if (con == null) {
0468: BasePeer.doUpdate(selectCriteria, criteria);
0469: } else {
0470: BasePeer.doUpdate(selectCriteria, criteria, con);
0471: }
0472: }
0473:
0474: /**
0475: * Method to do deletes.
0476: *
0477: * @param criteria object containing data that is used DELETE from database.
0478: * @throws TorqueException Any exceptions caught during processing will be
0479: * rethrown wrapped into a TorqueException.
0480: */
0481: public static void doDelete(Criteria criteria)
0482: throws TorqueException {
0483: QueryPeer.doDelete(criteria, (Connection) null);
0484: }
0485:
0486: /**
0487: * Method to do deletes. This method is to be used during a transaction,
0488: * otherwise use the doDelete(Criteria) method. It will take care of
0489: * the connection details internally.
0490: *
0491: * @param criteria object containing data that is used DELETE from database.
0492: * @param con the connection to use
0493: * @throws TorqueException Any exceptions caught during processing will be
0494: * rethrown wrapped into a TorqueException.
0495: */
0496: public static void doDelete(Criteria criteria, Connection con)
0497: throws TorqueException {
0498: correctBooleans(criteria);
0499:
0500: setDbName(criteria);
0501:
0502: if (con == null) {
0503: BasePeer.doDelete(criteria);
0504: } else {
0505: BasePeer.doDelete(criteria, con);
0506: }
0507: }
0508:
0509: /**
0510: * Method to do selects
0511: *
0512: * @throws TorqueException Any exceptions caught during processing will be
0513: * rethrown wrapped into a TorqueException.
0514: */
0515: public static List doSelect(Query obj) throws TorqueException {
0516: return doSelect(buildSelectCriteria(obj));
0517: }
0518:
0519: /**
0520: * Method to do inserts
0521: *
0522: * @throws TorqueException Any exceptions caught during processing will be
0523: * rethrown wrapped into a TorqueException.
0524: */
0525: public static void doInsert(Query obj) throws TorqueException {
0526: obj.setPrimaryKey(doInsert(buildCriteria(obj)));
0527: obj.setNew(false);
0528: obj.setModified(false);
0529: }
0530:
0531: /**
0532: * @param obj the data object to update in the database.
0533: * @throws TorqueException Any exceptions caught during processing will be
0534: * rethrown wrapped into a TorqueException.
0535: */
0536: public static void doUpdate(Query obj) throws TorqueException {
0537: doUpdate(buildCriteria(obj));
0538: obj.setModified(false);
0539: }
0540:
0541: /**
0542: * @param obj the data object to delete in the database.
0543: * @throws TorqueException Any exceptions caught during processing will be
0544: * rethrown wrapped into a TorqueException.
0545: */
0546: public static void doDelete(Query obj) throws TorqueException {
0547: doDelete(buildSelectCriteria(obj));
0548: }
0549:
0550: /**
0551: * Method to do inserts. This method is to be used during a transaction,
0552: * otherwise use the doInsert(Query) method. It will take
0553: * care of the connection details internally.
0554: *
0555: * @param obj the data object to insert into the database.
0556: * @param con the connection to use
0557: * @throws TorqueException Any exceptions caught during processing will be
0558: * rethrown wrapped into a TorqueException.
0559: */
0560: public static void doInsert(Query obj, Connection con)
0561: throws TorqueException {
0562: obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
0563: obj.setNew(false);
0564: obj.setModified(false);
0565: }
0566:
0567: /**
0568: * Method to do update. This method is to be used during a transaction,
0569: * otherwise use the doUpdate(Query) method. It will take
0570: * care of the connection details internally.
0571: *
0572: * @param obj the data object to update in the database.
0573: * @param con the connection to use
0574: * @throws TorqueException Any exceptions caught during processing will be
0575: * rethrown wrapped into a TorqueException.
0576: */
0577: public static void doUpdate(Query obj, Connection con)
0578: throws TorqueException {
0579: doUpdate(buildCriteria(obj), con);
0580: obj.setModified(false);
0581: }
0582:
0583: /**
0584: * Method to delete. This method is to be used during a transaction,
0585: * otherwise use the doDelete(Query) method. It will take
0586: * care of the connection details internally.
0587: *
0588: * @param obj the data object to delete in the database.
0589: * @param con the connection to use
0590: * @throws TorqueException Any exceptions caught during processing will be
0591: * rethrown wrapped into a TorqueException.
0592: */
0593: public static void doDelete(Query obj, Connection con)
0594: throws TorqueException {
0595: doDelete(buildSelectCriteria(obj), con);
0596: }
0597:
0598: /**
0599: * Method to do deletes.
0600: *
0601: * @param pk ObjectKey that is used DELETE from database.
0602: * @throws TorqueException Any exceptions caught during processing will be
0603: * rethrown wrapped into a TorqueException.
0604: */
0605: public static void doDelete(ObjectKey pk) throws TorqueException {
0606: BaseQueryPeer.doDelete(pk, (Connection) null);
0607: }
0608:
0609: /**
0610: * Method to delete. This method is to be used during a transaction,
0611: * otherwise use the doDelete(ObjectKey) method. It will take
0612: * care of the connection details internally.
0613: *
0614: * @param pk the primary key for the object to delete in the database.
0615: * @param con the connection to use
0616: * @throws TorqueException Any exceptions caught during processing will be
0617: * rethrown wrapped into a TorqueException.
0618: */
0619: public static void doDelete(ObjectKey pk, Connection con)
0620: throws TorqueException {
0621: doDelete(buildCriteria(pk), con);
0622: }
0623:
0624: /** Build a Criteria object from an ObjectKey */
0625: public static Criteria buildCriteria(ObjectKey pk) {
0626: Criteria criteria = new Criteria();
0627: criteria.add(QUERY_ID, pk);
0628: return criteria;
0629: }
0630:
0631: /** Build a Criteria object from the data object for this peer */
0632: public static Criteria buildCriteria(Query obj) {
0633: Criteria criteria = new Criteria(DATABASE_NAME);
0634: if (!obj.isNew())
0635: criteria.add(QUERY_ID, obj.getQueryId());
0636: criteria.add(USER_ID, obj.getUserId());
0637: criteria.add(NAME, obj.getName());
0638: criteria.add(DESCRIPTION, obj.getDescription());
0639: criteria.add(VALUE, obj.getValue());
0640: criteria.add(SCOPE_ID, obj.getScopeId());
0641: criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
0642: criteria.add(MODULE_ID, obj.getModuleId());
0643: criteria.add(LIST_ID, obj.getListId());
0644: criteria.add(DELETED, obj.getDeleted());
0645: criteria.add(APPROVED, obj.getApproved());
0646: criteria.add(CREATED_DATE, obj.getCreatedDate());
0647: criteria.add(SUBSCRIPTION_FREQUENCY_ID, obj
0648: .getSubscriptionFrequencyId());
0649: criteria.add(HOME_PAGE, obj.getHomePage());
0650: criteria.add(PREFERRED_ORDER, obj.getOrder());
0651: return criteria;
0652: }
0653:
0654: /** Build a Criteria object from the data object for this peer, skipping all binary columns */
0655: public static Criteria buildSelectCriteria(Query obj) {
0656: Criteria criteria = new Criteria(DATABASE_NAME);
0657: if (!obj.isNew()) {
0658: criteria.add(QUERY_ID, obj.getQueryId());
0659: }
0660: criteria.add(USER_ID, obj.getUserId());
0661: criteria.add(NAME, obj.getName());
0662: criteria.add(DESCRIPTION, obj.getDescription());
0663: criteria.add(VALUE, obj.getValue());
0664: criteria.add(SCOPE_ID, obj.getScopeId());
0665: criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
0666: criteria.add(MODULE_ID, obj.getModuleId());
0667: criteria.add(LIST_ID, obj.getListId());
0668: criteria.add(DELETED, obj.getDeleted());
0669: criteria.add(APPROVED, obj.getApproved());
0670: criteria.add(CREATED_DATE, obj.getCreatedDate());
0671: criteria.add(SUBSCRIPTION_FREQUENCY_ID, obj
0672: .getSubscriptionFrequencyId());
0673: criteria.add(HOME_PAGE, obj.getHomePage());
0674: criteria.add(PREFERRED_ORDER, obj.getOrder());
0675: return criteria;
0676: }
0677:
0678: /**
0679: * Retrieve a single object by pk
0680: *
0681: * @param pk the primary key
0682: * @throws TorqueException Any exceptions caught during processing will be
0683: * rethrown wrapped into a TorqueException.
0684: * @throws NoRowsException Primary key was not found in database.
0685: * @throws TooManyRowsException Primary key was not found in database.
0686: */
0687: public static Query retrieveByPK(Long pk) throws TorqueException,
0688: NoRowsException, TooManyRowsException {
0689: return retrieveByPK(SimpleKey.keyFor(pk));
0690: }
0691:
0692: /**
0693: * Retrieve a single object by pk
0694: *
0695: * @param pk the primary key
0696: * @param con the connection to use
0697: * @throws TorqueException Any exceptions caught during processing will be
0698: * rethrown wrapped into a TorqueException.
0699: * @throws NoRowsException Primary key was not found in database.
0700: * @throws TooManyRowsException Primary key was not found in database.
0701: */
0702: public static Query retrieveByPK(Long pk, Connection con)
0703: throws TorqueException, NoRowsException,
0704: TooManyRowsException {
0705: return retrieveByPK(SimpleKey.keyFor(pk), con);
0706: }
0707:
0708: /**
0709: * Retrieve a single object by pk
0710: *
0711: * @param pk the primary key
0712: * @throws TorqueException Any exceptions caught during processing will be
0713: * rethrown wrapped into a TorqueException.
0714: * @throws NoRowsException Primary key was not found in database.
0715: * @throws TooManyRowsException Primary key was not found in database.
0716: */
0717: public static Query retrieveByPK(ObjectKey pk)
0718: throws TorqueException, NoRowsException,
0719: TooManyRowsException {
0720: Connection db = null;
0721: Query retVal = null;
0722: try {
0723: db = Torque.getConnection(DATABASE_NAME);
0724: retVal = retrieveByPK(pk, db);
0725: } finally {
0726: Torque.closeConnection(db);
0727: }
0728: return retVal;
0729: }
0730:
0731: /**
0732: * Retrieve a single object by pk
0733: *
0734: * @param pk the primary key
0735: * @param con the connection to use
0736: * @throws TorqueException Any exceptions caught during processing will be
0737: * rethrown wrapped into a TorqueException.
0738: * @throws NoRowsException Primary key was not found in database.
0739: * @throws TooManyRowsException Primary key was not found in database.
0740: */
0741: public static Query retrieveByPK(ObjectKey pk, Connection con)
0742: throws TorqueException, NoRowsException,
0743: TooManyRowsException {
0744: Criteria criteria = buildCriteria(pk);
0745: List v = doSelect(criteria, con);
0746: if (v.size() == 0) {
0747: throw new NoRowsException("Failed to select a row.");
0748: } else if (v.size() > 1) {
0749: throw new TooManyRowsException(
0750: "Failed to select only one row.");
0751: } else {
0752: return (Query) v.get(0);
0753: }
0754: }
0755:
0756: /**
0757: * Retrieve a multiple objects by pk
0758: *
0759: * @param pks List of primary keys
0760: * @throws TorqueException Any exceptions caught during processing will be
0761: * rethrown wrapped into a TorqueException.
0762: */
0763: public static List retrieveByPKs(List pks) throws TorqueException {
0764: Connection db = null;
0765: List retVal = null;
0766: try {
0767: db = Torque.getConnection(DATABASE_NAME);
0768: retVal = retrieveByPKs(pks, db);
0769: } finally {
0770: Torque.closeConnection(db);
0771: }
0772: return retVal;
0773: }
0774:
0775: /**
0776: * Retrieve a multiple objects by pk
0777: *
0778: * @param pks List of primary keys
0779: * @param dbcon the connection to use
0780: * @throws TorqueException Any exceptions caught during processing will be
0781: * rethrown wrapped into a TorqueException.
0782: */
0783: public static List retrieveByPKs(List pks, Connection dbcon)
0784: throws TorqueException {
0785: List objs = null;
0786: if (pks == null || pks.size() == 0) {
0787: objs = new LinkedList();
0788: } else {
0789: Criteria criteria = new Criteria();
0790: criteria.addIn(QUERY_ID, pks);
0791: objs = doSelect(criteria, dbcon);
0792: }
0793: return objs;
0794: }
0795:
0796: /**
0797: * selects a collection of Query objects pre-filled with their
0798: * ScarabUserImpl objects.
0799: *
0800: * This method is protected by default in order to keep the public
0801: * api reasonable. You can provide public methods for those you
0802: * actually need in QueryPeer.
0803: *
0804: * @throws TorqueException Any exceptions caught during processing will be
0805: * rethrown wrapped into a TorqueException.
0806: */
0807: protected static List doSelectJoinScarabUserImpl(Criteria criteria)
0808: throws TorqueException {
0809: return doSelectJoinScarabUserImpl(criteria, null);
0810: }
0811:
0812: /**
0813: * selects a collection of Query objects pre-filled with their
0814: * ScarabUserImpl objects.
0815: *
0816: * This method is protected by default in order to keep the public
0817: * api reasonable. You can provide public methods for those you
0818: * actually need in QueryPeer.
0819: *
0820: * @throws TorqueException Any exceptions caught during processing will be
0821: * rethrown wrapped into a TorqueException.
0822: */
0823: protected static List doSelectJoinScarabUserImpl(Criteria criteria,
0824: Connection conn) throws TorqueException {
0825: setDbName(criteria);
0826:
0827: QueryPeer.addSelectColumns(criteria);
0828: int offset = numColumns + 1;
0829: ScarabUserImplPeer.addSelectColumns(criteria);
0830:
0831: criteria.addJoin(QueryPeer.USER_ID, ScarabUserImplPeer.USER_ID);
0832:
0833: correctBooleans(criteria);
0834:
0835: List rows;
0836: if (conn == null) {
0837: rows = BasePeer.doSelect(criteria);
0838: } else {
0839: rows = BasePeer.doSelect(criteria, conn);
0840: }
0841:
0842: List results = new ArrayList();
0843:
0844: for (int i = 0; i < rows.size(); i++) {
0845: Record row = (Record) rows.get(i);
0846:
0847: Class omClass = QueryPeer.getOMClass();
0848: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
0849: omClass = ScarabUserImplPeer.getOMClass();
0850: ScarabUserImpl obj2 = (ScarabUserImpl) ScarabUserImplPeer
0851: .row2Object(row, offset, omClass);
0852:
0853: boolean newObject = true;
0854: for (int j = 0; j < results.size(); j++) {
0855: Query temp_obj1 = (Query) results.get(j);
0856: ScarabUserImpl temp_obj2 = (ScarabUserImpl) temp_obj1
0857: .getScarabUser();
0858: if (temp_obj2.getPrimaryKey().equals(
0859: obj2.getPrimaryKey())) {
0860: newObject = false;
0861: temp_obj2.addQuery(obj1);
0862: break;
0863: }
0864: }
0865: if (newObject) {
0866: obj2.initQuerys();
0867: obj2.addQuery(obj1);
0868: }
0869: results.add(obj1);
0870: }
0871: return results;
0872: }
0873:
0874: /**
0875: * selects a collection of Query objects pre-filled with their
0876: * Scope objects.
0877: *
0878: * This method is protected by default in order to keep the public
0879: * api reasonable. You can provide public methods for those you
0880: * actually need in QueryPeer.
0881: *
0882: * @throws TorqueException Any exceptions caught during processing will be
0883: * rethrown wrapped into a TorqueException.
0884: */
0885: protected static List doSelectJoinScope(Criteria criteria)
0886: throws TorqueException {
0887: return doSelectJoinScope(criteria, null);
0888: }
0889:
0890: /**
0891: * selects a collection of Query objects pre-filled with their
0892: * Scope objects.
0893: *
0894: * This method is protected by default in order to keep the public
0895: * api reasonable. You can provide public methods for those you
0896: * actually need in QueryPeer.
0897: *
0898: * @throws TorqueException Any exceptions caught during processing will be
0899: * rethrown wrapped into a TorqueException.
0900: */
0901: protected static List doSelectJoinScope(Criteria criteria,
0902: Connection conn) throws TorqueException {
0903: setDbName(criteria);
0904:
0905: QueryPeer.addSelectColumns(criteria);
0906: int offset = numColumns + 1;
0907: ScopePeer.addSelectColumns(criteria);
0908:
0909: criteria.addJoin(QueryPeer.SCOPE_ID, ScopePeer.SCOPE_ID);
0910:
0911: correctBooleans(criteria);
0912:
0913: List rows;
0914: if (conn == null) {
0915: rows = BasePeer.doSelect(criteria);
0916: } else {
0917: rows = BasePeer.doSelect(criteria, conn);
0918: }
0919:
0920: List results = new ArrayList();
0921:
0922: for (int i = 0; i < rows.size(); i++) {
0923: Record row = (Record) rows.get(i);
0924:
0925: Class omClass = QueryPeer.getOMClass();
0926: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
0927: omClass = ScopePeer.getOMClass();
0928: Scope obj2 = (Scope) ScopePeer.row2Object(row, offset,
0929: omClass);
0930:
0931: boolean newObject = true;
0932: for (int j = 0; j < results.size(); j++) {
0933: Query temp_obj1 = (Query) results.get(j);
0934: Scope temp_obj2 = (Scope) temp_obj1.getScope();
0935: if (temp_obj2.getPrimaryKey().equals(
0936: obj2.getPrimaryKey())) {
0937: newObject = false;
0938: temp_obj2.addQuery(obj1);
0939: break;
0940: }
0941: }
0942: if (newObject) {
0943: obj2.initQuerys();
0944: obj2.addQuery(obj1);
0945: }
0946: results.add(obj1);
0947: }
0948: return results;
0949: }
0950:
0951: /**
0952: * selects a collection of Query objects pre-filled with their
0953: * ScarabModule objects.
0954: *
0955: * This method is protected by default in order to keep the public
0956: * api reasonable. You can provide public methods for those you
0957: * actually need in QueryPeer.
0958: *
0959: * @throws TorqueException Any exceptions caught during processing will be
0960: * rethrown wrapped into a TorqueException.
0961: */
0962: protected static List doSelectJoinScarabModule(Criteria criteria)
0963: throws TorqueException {
0964: return doSelectJoinScarabModule(criteria, null);
0965: }
0966:
0967: /**
0968: * selects a collection of Query objects pre-filled with their
0969: * ScarabModule objects.
0970: *
0971: * This method is protected by default in order to keep the public
0972: * api reasonable. You can provide public methods for those you
0973: * actually need in QueryPeer.
0974: *
0975: * @throws TorqueException Any exceptions caught during processing will be
0976: * rethrown wrapped into a TorqueException.
0977: */
0978: protected static List doSelectJoinScarabModule(Criteria criteria,
0979: Connection conn) throws TorqueException {
0980: setDbName(criteria);
0981:
0982: QueryPeer.addSelectColumns(criteria);
0983: int offset = numColumns + 1;
0984: ScarabModulePeer.addSelectColumns(criteria);
0985:
0986: criteria.addJoin(QueryPeer.MODULE_ID,
0987: ScarabModulePeer.MODULE_ID);
0988:
0989: correctBooleans(criteria);
0990:
0991: List rows;
0992: if (conn == null) {
0993: rows = BasePeer.doSelect(criteria);
0994: } else {
0995: rows = BasePeer.doSelect(criteria, conn);
0996: }
0997:
0998: List results = new ArrayList();
0999:
1000: for (int i = 0; i < rows.size(); i++) {
1001: Record row = (Record) rows.get(i);
1002:
1003: Class omClass = QueryPeer.getOMClass();
1004: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
1005: omClass = ScarabModulePeer.getOMClass(row, offset);
1006: ScarabModule obj2 = (ScarabModule) ScarabModulePeer
1007: .row2Object(row, offset, omClass);
1008:
1009: boolean newObject = true;
1010: for (int j = 0; j < results.size(); j++) {
1011: Query temp_obj1 = (Query) results.get(j);
1012: ScarabModule temp_obj2 = (ScarabModule) temp_obj1
1013: .getModule();
1014: if (temp_obj2.getPrimaryKey().equals(
1015: obj2.getPrimaryKey())) {
1016: newObject = false;
1017: temp_obj2.addQuery(obj1);
1018: break;
1019: }
1020: }
1021: if (newObject) {
1022: obj2.initQuerys();
1023: obj2.addQuery(obj1);
1024: }
1025: results.add(obj1);
1026: }
1027: return results;
1028: }
1029:
1030: /**
1031: * selects a collection of Query objects pre-filled with their
1032: * IssueType objects.
1033: *
1034: * This method is protected by default in order to keep the public
1035: * api reasonable. You can provide public methods for those you
1036: * actually need in QueryPeer.
1037: *
1038: * @throws TorqueException Any exceptions caught during processing will be
1039: * rethrown wrapped into a TorqueException.
1040: */
1041: protected static List doSelectJoinIssueType(Criteria criteria)
1042: throws TorqueException {
1043: return doSelectJoinIssueType(criteria, null);
1044: }
1045:
1046: /**
1047: * selects a collection of Query objects pre-filled with their
1048: * IssueType objects.
1049: *
1050: * This method is protected by default in order to keep the public
1051: * api reasonable. You can provide public methods for those you
1052: * actually need in QueryPeer.
1053: *
1054: * @throws TorqueException Any exceptions caught during processing will be
1055: * rethrown wrapped into a TorqueException.
1056: */
1057: protected static List doSelectJoinIssueType(Criteria criteria,
1058: Connection conn) throws TorqueException {
1059: setDbName(criteria);
1060:
1061: QueryPeer.addSelectColumns(criteria);
1062: int offset = numColumns + 1;
1063: IssueTypePeer.addSelectColumns(criteria);
1064:
1065: criteria.addJoin(QueryPeer.ISSUE_TYPE_ID,
1066: IssueTypePeer.ISSUE_TYPE_ID);
1067:
1068: correctBooleans(criteria);
1069:
1070: List rows;
1071: if (conn == null) {
1072: rows = BasePeer.doSelect(criteria);
1073: } else {
1074: rows = BasePeer.doSelect(criteria, conn);
1075: }
1076:
1077: List results = new ArrayList();
1078:
1079: for (int i = 0; i < rows.size(); i++) {
1080: Record row = (Record) rows.get(i);
1081:
1082: Class omClass = QueryPeer.getOMClass();
1083: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
1084: omClass = IssueTypePeer.getOMClass();
1085: IssueType obj2 = (IssueType) IssueTypePeer.row2Object(row,
1086: offset, omClass);
1087:
1088: boolean newObject = true;
1089: for (int j = 0; j < results.size(); j++) {
1090: Query temp_obj1 = (Query) results.get(j);
1091: IssueType temp_obj2 = (IssueType) temp_obj1
1092: .getIssueType();
1093: if (temp_obj2.getPrimaryKey().equals(
1094: obj2.getPrimaryKey())) {
1095: newObject = false;
1096: temp_obj2.addQuery(obj1);
1097: break;
1098: }
1099: }
1100: if (newObject) {
1101: obj2.initQuerys();
1102: obj2.addQuery(obj1);
1103: }
1104: results.add(obj1);
1105: }
1106: return results;
1107: }
1108:
1109: /**
1110: * selects a collection of Query objects pre-filled with their
1111: * MITList objects.
1112: *
1113: * This method is protected by default in order to keep the public
1114: * api reasonable. You can provide public methods for those you
1115: * actually need in QueryPeer.
1116: *
1117: * @throws TorqueException Any exceptions caught during processing will be
1118: * rethrown wrapped into a TorqueException.
1119: */
1120: protected static List doSelectJoinMITList(Criteria criteria)
1121: throws TorqueException {
1122: return doSelectJoinMITList(criteria, null);
1123: }
1124:
1125: /**
1126: * selects a collection of Query objects pre-filled with their
1127: * MITList objects.
1128: *
1129: * This method is protected by default in order to keep the public
1130: * api reasonable. You can provide public methods for those you
1131: * actually need in QueryPeer.
1132: *
1133: * @throws TorqueException Any exceptions caught during processing will be
1134: * rethrown wrapped into a TorqueException.
1135: */
1136: protected static List doSelectJoinMITList(Criteria criteria,
1137: Connection conn) throws TorqueException {
1138: setDbName(criteria);
1139:
1140: QueryPeer.addSelectColumns(criteria);
1141: int offset = numColumns + 1;
1142: MITListPeer.addSelectColumns(criteria);
1143:
1144: criteria.addJoin(QueryPeer.LIST_ID, MITListPeer.LIST_ID);
1145:
1146: correctBooleans(criteria);
1147:
1148: List rows;
1149: if (conn == null) {
1150: rows = BasePeer.doSelect(criteria);
1151: } else {
1152: rows = BasePeer.doSelect(criteria, conn);
1153: }
1154:
1155: List results = new ArrayList();
1156:
1157: for (int i = 0; i < rows.size(); i++) {
1158: Record row = (Record) rows.get(i);
1159:
1160: Class omClass = QueryPeer.getOMClass();
1161: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
1162: omClass = MITListPeer.getOMClass();
1163: MITList obj2 = (MITList) MITListPeer.row2Object(row,
1164: offset, omClass);
1165:
1166: boolean newObject = true;
1167: for (int j = 0; j < results.size(); j++) {
1168: Query temp_obj1 = (Query) results.get(j);
1169: MITList temp_obj2 = (MITList) temp_obj1.getMITList();
1170: if (temp_obj2.getPrimaryKey().equals(
1171: obj2.getPrimaryKey())) {
1172: newObject = false;
1173: temp_obj2.addQuery(obj1);
1174: break;
1175: }
1176: }
1177: if (newObject) {
1178: obj2.initQuerys();
1179: obj2.addQuery(obj1);
1180: }
1181: results.add(obj1);
1182: }
1183: return results;
1184: }
1185:
1186: /**
1187: * selects a collection of Query objects pre-filled with their
1188: * Frequency objects.
1189: *
1190: * This method is protected by default in order to keep the public
1191: * api reasonable. You can provide public methods for those you
1192: * actually need in QueryPeer.
1193: *
1194: * @throws TorqueException Any exceptions caught during processing will be
1195: * rethrown wrapped into a TorqueException.
1196: */
1197: protected static List doSelectJoinFrequency(Criteria criteria)
1198: throws TorqueException {
1199: return doSelectJoinFrequency(criteria, null);
1200: }
1201:
1202: /**
1203: * selects a collection of Query objects pre-filled with their
1204: * Frequency objects.
1205: *
1206: * This method is protected by default in order to keep the public
1207: * api reasonable. You can provide public methods for those you
1208: * actually need in QueryPeer.
1209: *
1210: * @throws TorqueException Any exceptions caught during processing will be
1211: * rethrown wrapped into a TorqueException.
1212: */
1213: protected static List doSelectJoinFrequency(Criteria criteria,
1214: Connection conn) throws TorqueException {
1215: setDbName(criteria);
1216:
1217: QueryPeer.addSelectColumns(criteria);
1218: int offset = numColumns + 1;
1219: FrequencyPeer.addSelectColumns(criteria);
1220:
1221: criteria.addJoin(QueryPeer.SUBSCRIPTION_FREQUENCY_ID,
1222: FrequencyPeer.FREQUENCY_ID);
1223:
1224: correctBooleans(criteria);
1225:
1226: List rows;
1227: if (conn == null) {
1228: rows = BasePeer.doSelect(criteria);
1229: } else {
1230: rows = BasePeer.doSelect(criteria, conn);
1231: }
1232:
1233: List results = new ArrayList();
1234:
1235: for (int i = 0; i < rows.size(); i++) {
1236: Record row = (Record) rows.get(i);
1237:
1238: Class omClass = QueryPeer.getOMClass();
1239: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
1240: omClass = FrequencyPeer.getOMClass();
1241: Frequency obj2 = (Frequency) FrequencyPeer.row2Object(row,
1242: offset, omClass);
1243:
1244: boolean newObject = true;
1245: for (int j = 0; j < results.size(); j++) {
1246: Query temp_obj1 = (Query) results.get(j);
1247: Frequency temp_obj2 = (Frequency) temp_obj1
1248: .getFrequency();
1249: if (temp_obj2.getPrimaryKey().equals(
1250: obj2.getPrimaryKey())) {
1251: newObject = false;
1252: temp_obj2.addQuery(obj1);
1253: break;
1254: }
1255: }
1256: if (newObject) {
1257: obj2.initQuerys();
1258: obj2.addQuery(obj1);
1259: }
1260: results.add(obj1);
1261: }
1262: return results;
1263: }
1264:
1265: /**
1266: * selects a collection of Query objects pre-filled with
1267: * all related objects.
1268: *
1269: * This method is protected by default in order to keep the public
1270: * api reasonable. You can provide public methods for those you
1271: * actually need in QueryPeer.
1272: *
1273: * @throws TorqueException Any exceptions caught during processing will be
1274: * rethrown wrapped into a TorqueException.
1275: */
1276: protected static List doSelectJoinAllExceptScarabUserImpl(
1277: Criteria criteria) throws TorqueException {
1278: return doSelectJoinAllExceptScarabUserImpl(criteria, null);
1279: }
1280:
1281: /**
1282: * selects a collection of Query objects pre-filled with
1283: * all related objects.
1284: *
1285: * This method is protected by default in order to keep the public
1286: * api reasonable. You can provide public methods for those you
1287: * actually need in QueryPeer.
1288: *
1289: * @throws TorqueException Any exceptions caught during processing will be
1290: * rethrown wrapped into a TorqueException.
1291: */
1292: protected static List doSelectJoinAllExceptScarabUserImpl(
1293: Criteria criteria, Connection conn) throws TorqueException {
1294: setDbName(criteria);
1295:
1296: addSelectColumns(criteria);
1297: int offset2 = numColumns + 1;
1298:
1299: ScopePeer.addSelectColumns(criteria);
1300: criteria.addJoin(QueryPeer.SCOPE_ID, ScopePeer.SCOPE_ID);
1301: int offset3 = offset2 + ScopePeer.numColumns;
1302:
1303: ScarabModulePeer.addSelectColumns(criteria);
1304: criteria.addJoin(QueryPeer.MODULE_ID,
1305: ScarabModulePeer.MODULE_ID);
1306: int offset4 = offset3 + ScarabModulePeer.numColumns;
1307:
1308: IssueTypePeer.addSelectColumns(criteria);
1309: criteria.addJoin(QueryPeer.ISSUE_TYPE_ID,
1310: IssueTypePeer.ISSUE_TYPE_ID);
1311: int offset5 = offset4 + IssueTypePeer.numColumns;
1312:
1313: MITListPeer.addSelectColumns(criteria);
1314: criteria.addJoin(QueryPeer.LIST_ID, MITListPeer.LIST_ID);
1315: int offset6 = offset5 + MITListPeer.numColumns;
1316:
1317: FrequencyPeer.addSelectColumns(criteria);
1318: criteria.addJoin(QueryPeer.SUBSCRIPTION_FREQUENCY_ID,
1319: FrequencyPeer.FREQUENCY_ID);
1320:
1321: correctBooleans(criteria);
1322:
1323: List rows;
1324: if (conn == null) {
1325: rows = BasePeer.doSelect(criteria);
1326: } else {
1327: rows = BasePeer.doSelect(criteria, conn);
1328: }
1329:
1330: List results = new ArrayList();
1331:
1332: for (int i = 0; i < rows.size(); i++) {
1333: Record row = (Record) rows.get(i);
1334:
1335: Class omClass = QueryPeer.getOMClass();
1336: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
1337:
1338: omClass = ScopePeer.getOMClass();
1339: Scope obj2 = (Scope) ScopePeer.row2Object(row, offset2,
1340: omClass);
1341:
1342: boolean newObject = true;
1343: for (int j = 0; j < results.size(); j++) {
1344: Query temp_obj1 = (Query) results.get(j);
1345: Scope temp_obj2 = (Scope) temp_obj1.getScope();
1346: if (temp_obj2.getPrimaryKey().equals(
1347: obj2.getPrimaryKey())) {
1348: newObject = false;
1349: temp_obj2.addQuery(obj1);
1350: break;
1351: }
1352: }
1353: if (newObject) {
1354: obj2.initQuerys();
1355: obj2.addQuery(obj1);
1356: }
1357:
1358: omClass = ScarabModulePeer.getOMClass(row, offset3);
1359: ScarabModule obj3 = (ScarabModule) ScarabModulePeer
1360: .row2Object(row, offset3, omClass);
1361:
1362: newObject = true;
1363: for (int j = 0; j < results.size(); j++) {
1364: Query temp_obj1 = (Query) results.get(j);
1365: ScarabModule temp_obj3 = (ScarabModule) temp_obj1
1366: .getModule();
1367: if (temp_obj3.getPrimaryKey().equals(
1368: obj3.getPrimaryKey())) {
1369: newObject = false;
1370: temp_obj3.addQuery(obj1);
1371: break;
1372: }
1373: }
1374: if (newObject) {
1375: obj3.initQuerys();
1376: obj3.addQuery(obj1);
1377: }
1378:
1379: omClass = IssueTypePeer.getOMClass();
1380: IssueType obj4 = (IssueType) IssueTypePeer.row2Object(row,
1381: offset4, omClass);
1382:
1383: newObject = true;
1384: for (int j = 0; j < results.size(); j++) {
1385: Query temp_obj1 = (Query) results.get(j);
1386: IssueType temp_obj4 = (IssueType) temp_obj1
1387: .getIssueType();
1388: if (temp_obj4.getPrimaryKey().equals(
1389: obj4.getPrimaryKey())) {
1390: newObject = false;
1391: temp_obj4.addQuery(obj1);
1392: break;
1393: }
1394: }
1395: if (newObject) {
1396: obj4.initQuerys();
1397: obj4.addQuery(obj1);
1398: }
1399:
1400: omClass = MITListPeer.getOMClass();
1401: MITList obj5 = (MITList) MITListPeer.row2Object(row,
1402: offset5, omClass);
1403:
1404: newObject = true;
1405: for (int j = 0; j < results.size(); j++) {
1406: Query temp_obj1 = (Query) results.get(j);
1407: MITList temp_obj5 = (MITList) temp_obj1.getMITList();
1408: if (temp_obj5.getPrimaryKey().equals(
1409: obj5.getPrimaryKey())) {
1410: newObject = false;
1411: temp_obj5.addQuery(obj1);
1412: break;
1413: }
1414: }
1415: if (newObject) {
1416: obj5.initQuerys();
1417: obj5.addQuery(obj1);
1418: }
1419:
1420: omClass = FrequencyPeer.getOMClass();
1421: Frequency obj6 = (Frequency) FrequencyPeer.row2Object(row,
1422: offset6, omClass);
1423:
1424: newObject = true;
1425: for (int j = 0; j < results.size(); j++) {
1426: Query temp_obj1 = (Query) results.get(j);
1427: Frequency temp_obj6 = (Frequency) temp_obj1
1428: .getFrequency();
1429: if (temp_obj6.getPrimaryKey().equals(
1430: obj6.getPrimaryKey())) {
1431: newObject = false;
1432: temp_obj6.addQuery(obj1);
1433: break;
1434: }
1435: }
1436: if (newObject) {
1437: obj6.initQuerys();
1438: obj6.addQuery(obj1);
1439: }
1440: results.add(obj1);
1441: }
1442: return results;
1443: }
1444:
1445: /**
1446: * selects a collection of Query objects pre-filled with
1447: * all related objects.
1448: *
1449: * This method is protected by default in order to keep the public
1450: * api reasonable. You can provide public methods for those you
1451: * actually need in QueryPeer.
1452: *
1453: * @throws TorqueException Any exceptions caught during processing will be
1454: * rethrown wrapped into a TorqueException.
1455: */
1456: protected static List doSelectJoinAllExceptScope(Criteria criteria)
1457: throws TorqueException {
1458: return doSelectJoinAllExceptScope(criteria, null);
1459: }
1460:
1461: /**
1462: * selects a collection of Query objects pre-filled with
1463: * all related objects.
1464: *
1465: * This method is protected by default in order to keep the public
1466: * api reasonable. You can provide public methods for those you
1467: * actually need in QueryPeer.
1468: *
1469: * @throws TorqueException Any exceptions caught during processing will be
1470: * rethrown wrapped into a TorqueException.
1471: */
1472: protected static List doSelectJoinAllExceptScope(Criteria criteria,
1473: Connection conn) throws TorqueException {
1474: setDbName(criteria);
1475:
1476: addSelectColumns(criteria);
1477: int offset2 = numColumns + 1;
1478:
1479: ScarabUserImplPeer.addSelectColumns(criteria);
1480: criteria.addJoin(QueryPeer.USER_ID, ScarabUserImplPeer.USER_ID);
1481: int offset3 = offset2 + ScarabUserImplPeer.numColumns;
1482:
1483: ScarabModulePeer.addSelectColumns(criteria);
1484: criteria.addJoin(QueryPeer.MODULE_ID,
1485: ScarabModulePeer.MODULE_ID);
1486: int offset4 = offset3 + ScarabModulePeer.numColumns;
1487:
1488: IssueTypePeer.addSelectColumns(criteria);
1489: criteria.addJoin(QueryPeer.ISSUE_TYPE_ID,
1490: IssueTypePeer.ISSUE_TYPE_ID);
1491: int offset5 = offset4 + IssueTypePeer.numColumns;
1492:
1493: MITListPeer.addSelectColumns(criteria);
1494: criteria.addJoin(QueryPeer.LIST_ID, MITListPeer.LIST_ID);
1495: int offset6 = offset5 + MITListPeer.numColumns;
1496:
1497: FrequencyPeer.addSelectColumns(criteria);
1498: criteria.addJoin(QueryPeer.SUBSCRIPTION_FREQUENCY_ID,
1499: FrequencyPeer.FREQUENCY_ID);
1500:
1501: correctBooleans(criteria);
1502:
1503: List rows;
1504: if (conn == null) {
1505: rows = BasePeer.doSelect(criteria);
1506: } else {
1507: rows = BasePeer.doSelect(criteria, conn);
1508: }
1509:
1510: List results = new ArrayList();
1511:
1512: for (int i = 0; i < rows.size(); i++) {
1513: Record row = (Record) rows.get(i);
1514:
1515: Class omClass = QueryPeer.getOMClass();
1516: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
1517:
1518: omClass = ScarabUserImplPeer.getOMClass();
1519: ScarabUserImpl obj2 = (ScarabUserImpl) ScarabUserImplPeer
1520: .row2Object(row, offset2, omClass);
1521:
1522: boolean newObject = true;
1523: for (int j = 0; j < results.size(); j++) {
1524: Query temp_obj1 = (Query) results.get(j);
1525: ScarabUserImpl temp_obj2 = (ScarabUserImpl) temp_obj1
1526: .getScarabUser();
1527: if (temp_obj2.getPrimaryKey().equals(
1528: obj2.getPrimaryKey())) {
1529: newObject = false;
1530: temp_obj2.addQuery(obj1);
1531: break;
1532: }
1533: }
1534: if (newObject) {
1535: obj2.initQuerys();
1536: obj2.addQuery(obj1);
1537: }
1538:
1539: omClass = ScarabModulePeer.getOMClass(row, offset3);
1540: ScarabModule obj3 = (ScarabModule) ScarabModulePeer
1541: .row2Object(row, offset3, omClass);
1542:
1543: newObject = true;
1544: for (int j = 0; j < results.size(); j++) {
1545: Query temp_obj1 = (Query) results.get(j);
1546: ScarabModule temp_obj3 = (ScarabModule) temp_obj1
1547: .getModule();
1548: if (temp_obj3.getPrimaryKey().equals(
1549: obj3.getPrimaryKey())) {
1550: newObject = false;
1551: temp_obj3.addQuery(obj1);
1552: break;
1553: }
1554: }
1555: if (newObject) {
1556: obj3.initQuerys();
1557: obj3.addQuery(obj1);
1558: }
1559:
1560: omClass = IssueTypePeer.getOMClass();
1561: IssueType obj4 = (IssueType) IssueTypePeer.row2Object(row,
1562: offset4, omClass);
1563:
1564: newObject = true;
1565: for (int j = 0; j < results.size(); j++) {
1566: Query temp_obj1 = (Query) results.get(j);
1567: IssueType temp_obj4 = (IssueType) temp_obj1
1568: .getIssueType();
1569: if (temp_obj4.getPrimaryKey().equals(
1570: obj4.getPrimaryKey())) {
1571: newObject = false;
1572: temp_obj4.addQuery(obj1);
1573: break;
1574: }
1575: }
1576: if (newObject) {
1577: obj4.initQuerys();
1578: obj4.addQuery(obj1);
1579: }
1580:
1581: omClass = MITListPeer.getOMClass();
1582: MITList obj5 = (MITList) MITListPeer.row2Object(row,
1583: offset5, omClass);
1584:
1585: newObject = true;
1586: for (int j = 0; j < results.size(); j++) {
1587: Query temp_obj1 = (Query) results.get(j);
1588: MITList temp_obj5 = (MITList) temp_obj1.getMITList();
1589: if (temp_obj5.getPrimaryKey().equals(
1590: obj5.getPrimaryKey())) {
1591: newObject = false;
1592: temp_obj5.addQuery(obj1);
1593: break;
1594: }
1595: }
1596: if (newObject) {
1597: obj5.initQuerys();
1598: obj5.addQuery(obj1);
1599: }
1600:
1601: omClass = FrequencyPeer.getOMClass();
1602: Frequency obj6 = (Frequency) FrequencyPeer.row2Object(row,
1603: offset6, omClass);
1604:
1605: newObject = true;
1606: for (int j = 0; j < results.size(); j++) {
1607: Query temp_obj1 = (Query) results.get(j);
1608: Frequency temp_obj6 = (Frequency) temp_obj1
1609: .getFrequency();
1610: if (temp_obj6.getPrimaryKey().equals(
1611: obj6.getPrimaryKey())) {
1612: newObject = false;
1613: temp_obj6.addQuery(obj1);
1614: break;
1615: }
1616: }
1617: if (newObject) {
1618: obj6.initQuerys();
1619: obj6.addQuery(obj1);
1620: }
1621: results.add(obj1);
1622: }
1623: return results;
1624: }
1625:
1626: /**
1627: * selects a collection of Query objects pre-filled with
1628: * all related objects.
1629: *
1630: * This method is protected by default in order to keep the public
1631: * api reasonable. You can provide public methods for those you
1632: * actually need in QueryPeer.
1633: *
1634: * @throws TorqueException Any exceptions caught during processing will be
1635: * rethrown wrapped into a TorqueException.
1636: */
1637: protected static List doSelectJoinAllExceptScarabModule(
1638: Criteria criteria) throws TorqueException {
1639: return doSelectJoinAllExceptScarabModule(criteria, null);
1640: }
1641:
1642: /**
1643: * selects a collection of Query objects pre-filled with
1644: * all related objects.
1645: *
1646: * This method is protected by default in order to keep the public
1647: * api reasonable. You can provide public methods for those you
1648: * actually need in QueryPeer.
1649: *
1650: * @throws TorqueException Any exceptions caught during processing will be
1651: * rethrown wrapped into a TorqueException.
1652: */
1653: protected static List doSelectJoinAllExceptScarabModule(
1654: Criteria criteria, Connection conn) throws TorqueException {
1655: setDbName(criteria);
1656:
1657: addSelectColumns(criteria);
1658: int offset2 = numColumns + 1;
1659:
1660: ScarabUserImplPeer.addSelectColumns(criteria);
1661: criteria.addJoin(QueryPeer.USER_ID, ScarabUserImplPeer.USER_ID);
1662: int offset3 = offset2 + ScarabUserImplPeer.numColumns;
1663:
1664: ScopePeer.addSelectColumns(criteria);
1665: criteria.addJoin(QueryPeer.SCOPE_ID, ScopePeer.SCOPE_ID);
1666: int offset4 = offset3 + ScopePeer.numColumns;
1667:
1668: IssueTypePeer.addSelectColumns(criteria);
1669: criteria.addJoin(QueryPeer.ISSUE_TYPE_ID,
1670: IssueTypePeer.ISSUE_TYPE_ID);
1671: int offset5 = offset4 + IssueTypePeer.numColumns;
1672:
1673: MITListPeer.addSelectColumns(criteria);
1674: criteria.addJoin(QueryPeer.LIST_ID, MITListPeer.LIST_ID);
1675: int offset6 = offset5 + MITListPeer.numColumns;
1676:
1677: FrequencyPeer.addSelectColumns(criteria);
1678: criteria.addJoin(QueryPeer.SUBSCRIPTION_FREQUENCY_ID,
1679: FrequencyPeer.FREQUENCY_ID);
1680:
1681: correctBooleans(criteria);
1682:
1683: List rows;
1684: if (conn == null) {
1685: rows = BasePeer.doSelect(criteria);
1686: } else {
1687: rows = BasePeer.doSelect(criteria, conn);
1688: }
1689:
1690: List results = new ArrayList();
1691:
1692: for (int i = 0; i < rows.size(); i++) {
1693: Record row = (Record) rows.get(i);
1694:
1695: Class omClass = QueryPeer.getOMClass();
1696: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
1697:
1698: omClass = ScarabUserImplPeer.getOMClass();
1699: ScarabUserImpl obj2 = (ScarabUserImpl) ScarabUserImplPeer
1700: .row2Object(row, offset2, omClass);
1701:
1702: boolean newObject = true;
1703: for (int j = 0; j < results.size(); j++) {
1704: Query temp_obj1 = (Query) results.get(j);
1705: ScarabUserImpl temp_obj2 = (ScarabUserImpl) temp_obj1
1706: .getScarabUser();
1707: if (temp_obj2.getPrimaryKey().equals(
1708: obj2.getPrimaryKey())) {
1709: newObject = false;
1710: temp_obj2.addQuery(obj1);
1711: break;
1712: }
1713: }
1714: if (newObject) {
1715: obj2.initQuerys();
1716: obj2.addQuery(obj1);
1717: }
1718:
1719: omClass = ScopePeer.getOMClass();
1720: Scope obj3 = (Scope) ScopePeer.row2Object(row, offset3,
1721: omClass);
1722:
1723: newObject = true;
1724: for (int j = 0; j < results.size(); j++) {
1725: Query temp_obj1 = (Query) results.get(j);
1726: Scope temp_obj3 = (Scope) temp_obj1.getScope();
1727: if (temp_obj3.getPrimaryKey().equals(
1728: obj3.getPrimaryKey())) {
1729: newObject = false;
1730: temp_obj3.addQuery(obj1);
1731: break;
1732: }
1733: }
1734: if (newObject) {
1735: obj3.initQuerys();
1736: obj3.addQuery(obj1);
1737: }
1738:
1739: omClass = IssueTypePeer.getOMClass();
1740: IssueType obj4 = (IssueType) IssueTypePeer.row2Object(row,
1741: offset4, omClass);
1742:
1743: newObject = true;
1744: for (int j = 0; j < results.size(); j++) {
1745: Query temp_obj1 = (Query) results.get(j);
1746: IssueType temp_obj4 = (IssueType) temp_obj1
1747: .getIssueType();
1748: if (temp_obj4.getPrimaryKey().equals(
1749: obj4.getPrimaryKey())) {
1750: newObject = false;
1751: temp_obj4.addQuery(obj1);
1752: break;
1753: }
1754: }
1755: if (newObject) {
1756: obj4.initQuerys();
1757: obj4.addQuery(obj1);
1758: }
1759:
1760: omClass = MITListPeer.getOMClass();
1761: MITList obj5 = (MITList) MITListPeer.row2Object(row,
1762: offset5, omClass);
1763:
1764: newObject = true;
1765: for (int j = 0; j < results.size(); j++) {
1766: Query temp_obj1 = (Query) results.get(j);
1767: MITList temp_obj5 = (MITList) temp_obj1.getMITList();
1768: if (temp_obj5.getPrimaryKey().equals(
1769: obj5.getPrimaryKey())) {
1770: newObject = false;
1771: temp_obj5.addQuery(obj1);
1772: break;
1773: }
1774: }
1775: if (newObject) {
1776: obj5.initQuerys();
1777: obj5.addQuery(obj1);
1778: }
1779:
1780: omClass = FrequencyPeer.getOMClass();
1781: Frequency obj6 = (Frequency) FrequencyPeer.row2Object(row,
1782: offset6, omClass);
1783:
1784: newObject = true;
1785: for (int j = 0; j < results.size(); j++) {
1786: Query temp_obj1 = (Query) results.get(j);
1787: Frequency temp_obj6 = (Frequency) temp_obj1
1788: .getFrequency();
1789: if (temp_obj6.getPrimaryKey().equals(
1790: obj6.getPrimaryKey())) {
1791: newObject = false;
1792: temp_obj6.addQuery(obj1);
1793: break;
1794: }
1795: }
1796: if (newObject) {
1797: obj6.initQuerys();
1798: obj6.addQuery(obj1);
1799: }
1800: results.add(obj1);
1801: }
1802: return results;
1803: }
1804:
1805: /**
1806: * selects a collection of Query objects pre-filled with
1807: * all related objects.
1808: *
1809: * This method is protected by default in order to keep the public
1810: * api reasonable. You can provide public methods for those you
1811: * actually need in QueryPeer.
1812: *
1813: * @throws TorqueException Any exceptions caught during processing will be
1814: * rethrown wrapped into a TorqueException.
1815: */
1816: protected static List doSelectJoinAllExceptIssueType(
1817: Criteria criteria) throws TorqueException {
1818: return doSelectJoinAllExceptIssueType(criteria, null);
1819: }
1820:
1821: /**
1822: * selects a collection of Query objects pre-filled with
1823: * all related objects.
1824: *
1825: * This method is protected by default in order to keep the public
1826: * api reasonable. You can provide public methods for those you
1827: * actually need in QueryPeer.
1828: *
1829: * @throws TorqueException Any exceptions caught during processing will be
1830: * rethrown wrapped into a TorqueException.
1831: */
1832: protected static List doSelectJoinAllExceptIssueType(
1833: Criteria criteria, Connection conn) throws TorqueException {
1834: setDbName(criteria);
1835:
1836: addSelectColumns(criteria);
1837: int offset2 = numColumns + 1;
1838:
1839: ScarabUserImplPeer.addSelectColumns(criteria);
1840: criteria.addJoin(QueryPeer.USER_ID, ScarabUserImplPeer.USER_ID);
1841: int offset3 = offset2 + ScarabUserImplPeer.numColumns;
1842:
1843: ScopePeer.addSelectColumns(criteria);
1844: criteria.addJoin(QueryPeer.SCOPE_ID, ScopePeer.SCOPE_ID);
1845: int offset4 = offset3 + ScopePeer.numColumns;
1846:
1847: ScarabModulePeer.addSelectColumns(criteria);
1848: criteria.addJoin(QueryPeer.MODULE_ID,
1849: ScarabModulePeer.MODULE_ID);
1850: int offset5 = offset4 + ScarabModulePeer.numColumns;
1851:
1852: MITListPeer.addSelectColumns(criteria);
1853: criteria.addJoin(QueryPeer.LIST_ID, MITListPeer.LIST_ID);
1854: int offset6 = offset5 + MITListPeer.numColumns;
1855:
1856: FrequencyPeer.addSelectColumns(criteria);
1857: criteria.addJoin(QueryPeer.SUBSCRIPTION_FREQUENCY_ID,
1858: FrequencyPeer.FREQUENCY_ID);
1859:
1860: correctBooleans(criteria);
1861:
1862: List rows;
1863: if (conn == null) {
1864: rows = BasePeer.doSelect(criteria);
1865: } else {
1866: rows = BasePeer.doSelect(criteria, conn);
1867: }
1868:
1869: List results = new ArrayList();
1870:
1871: for (int i = 0; i < rows.size(); i++) {
1872: Record row = (Record) rows.get(i);
1873:
1874: Class omClass = QueryPeer.getOMClass();
1875: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
1876:
1877: omClass = ScarabUserImplPeer.getOMClass();
1878: ScarabUserImpl obj2 = (ScarabUserImpl) ScarabUserImplPeer
1879: .row2Object(row, offset2, omClass);
1880:
1881: boolean newObject = true;
1882: for (int j = 0; j < results.size(); j++) {
1883: Query temp_obj1 = (Query) results.get(j);
1884: ScarabUserImpl temp_obj2 = (ScarabUserImpl) temp_obj1
1885: .getScarabUser();
1886: if (temp_obj2.getPrimaryKey().equals(
1887: obj2.getPrimaryKey())) {
1888: newObject = false;
1889: temp_obj2.addQuery(obj1);
1890: break;
1891: }
1892: }
1893: if (newObject) {
1894: obj2.initQuerys();
1895: obj2.addQuery(obj1);
1896: }
1897:
1898: omClass = ScopePeer.getOMClass();
1899: Scope obj3 = (Scope) ScopePeer.row2Object(row, offset3,
1900: omClass);
1901:
1902: newObject = true;
1903: for (int j = 0; j < results.size(); j++) {
1904: Query temp_obj1 = (Query) results.get(j);
1905: Scope temp_obj3 = (Scope) temp_obj1.getScope();
1906: if (temp_obj3.getPrimaryKey().equals(
1907: obj3.getPrimaryKey())) {
1908: newObject = false;
1909: temp_obj3.addQuery(obj1);
1910: break;
1911: }
1912: }
1913: if (newObject) {
1914: obj3.initQuerys();
1915: obj3.addQuery(obj1);
1916: }
1917:
1918: omClass = ScarabModulePeer.getOMClass(row, offset4);
1919: ScarabModule obj4 = (ScarabModule) ScarabModulePeer
1920: .row2Object(row, offset4, omClass);
1921:
1922: newObject = true;
1923: for (int j = 0; j < results.size(); j++) {
1924: Query temp_obj1 = (Query) results.get(j);
1925: ScarabModule temp_obj4 = (ScarabModule) temp_obj1
1926: .getModule();
1927: if (temp_obj4.getPrimaryKey().equals(
1928: obj4.getPrimaryKey())) {
1929: newObject = false;
1930: temp_obj4.addQuery(obj1);
1931: break;
1932: }
1933: }
1934: if (newObject) {
1935: obj4.initQuerys();
1936: obj4.addQuery(obj1);
1937: }
1938:
1939: omClass = MITListPeer.getOMClass();
1940: MITList obj5 = (MITList) MITListPeer.row2Object(row,
1941: offset5, omClass);
1942:
1943: newObject = true;
1944: for (int j = 0; j < results.size(); j++) {
1945: Query temp_obj1 = (Query) results.get(j);
1946: MITList temp_obj5 = (MITList) temp_obj1.getMITList();
1947: if (temp_obj5.getPrimaryKey().equals(
1948: obj5.getPrimaryKey())) {
1949: newObject = false;
1950: temp_obj5.addQuery(obj1);
1951: break;
1952: }
1953: }
1954: if (newObject) {
1955: obj5.initQuerys();
1956: obj5.addQuery(obj1);
1957: }
1958:
1959: omClass = FrequencyPeer.getOMClass();
1960: Frequency obj6 = (Frequency) FrequencyPeer.row2Object(row,
1961: offset6, omClass);
1962:
1963: newObject = true;
1964: for (int j = 0; j < results.size(); j++) {
1965: Query temp_obj1 = (Query) results.get(j);
1966: Frequency temp_obj6 = (Frequency) temp_obj1
1967: .getFrequency();
1968: if (temp_obj6.getPrimaryKey().equals(
1969: obj6.getPrimaryKey())) {
1970: newObject = false;
1971: temp_obj6.addQuery(obj1);
1972: break;
1973: }
1974: }
1975: if (newObject) {
1976: obj6.initQuerys();
1977: obj6.addQuery(obj1);
1978: }
1979: results.add(obj1);
1980: }
1981: return results;
1982: }
1983:
1984: /**
1985: * selects a collection of Query objects pre-filled with
1986: * all related objects.
1987: *
1988: * This method is protected by default in order to keep the public
1989: * api reasonable. You can provide public methods for those you
1990: * actually need in QueryPeer.
1991: *
1992: * @throws TorqueException Any exceptions caught during processing will be
1993: * rethrown wrapped into a TorqueException.
1994: */
1995: protected static List doSelectJoinAllExceptMITList(Criteria criteria)
1996: throws TorqueException {
1997: return doSelectJoinAllExceptMITList(criteria, null);
1998: }
1999:
2000: /**
2001: * selects a collection of Query objects pre-filled with
2002: * all related objects.
2003: *
2004: * This method is protected by default in order to keep the public
2005: * api reasonable. You can provide public methods for those you
2006: * actually need in QueryPeer.
2007: *
2008: * @throws TorqueException Any exceptions caught during processing will be
2009: * rethrown wrapped into a TorqueException.
2010: */
2011: protected static List doSelectJoinAllExceptMITList(
2012: Criteria criteria, Connection conn) throws TorqueException {
2013: setDbName(criteria);
2014:
2015: addSelectColumns(criteria);
2016: int offset2 = numColumns + 1;
2017:
2018: ScarabUserImplPeer.addSelectColumns(criteria);
2019: criteria.addJoin(QueryPeer.USER_ID, ScarabUserImplPeer.USER_ID);
2020: int offset3 = offset2 + ScarabUserImplPeer.numColumns;
2021:
2022: ScopePeer.addSelectColumns(criteria);
2023: criteria.addJoin(QueryPeer.SCOPE_ID, ScopePeer.SCOPE_ID);
2024: int offset4 = offset3 + ScopePeer.numColumns;
2025:
2026: ScarabModulePeer.addSelectColumns(criteria);
2027: criteria.addJoin(QueryPeer.MODULE_ID,
2028: ScarabModulePeer.MODULE_ID);
2029: int offset5 = offset4 + ScarabModulePeer.numColumns;
2030:
2031: IssueTypePeer.addSelectColumns(criteria);
2032: criteria.addJoin(QueryPeer.ISSUE_TYPE_ID,
2033: IssueTypePeer.ISSUE_TYPE_ID);
2034: int offset6 = offset5 + IssueTypePeer.numColumns;
2035:
2036: FrequencyPeer.addSelectColumns(criteria);
2037: criteria.addJoin(QueryPeer.SUBSCRIPTION_FREQUENCY_ID,
2038: FrequencyPeer.FREQUENCY_ID);
2039:
2040: correctBooleans(criteria);
2041:
2042: List rows;
2043: if (conn == null) {
2044: rows = BasePeer.doSelect(criteria);
2045: } else {
2046: rows = BasePeer.doSelect(criteria, conn);
2047: }
2048:
2049: List results = new ArrayList();
2050:
2051: for (int i = 0; i < rows.size(); i++) {
2052: Record row = (Record) rows.get(i);
2053:
2054: Class omClass = QueryPeer.getOMClass();
2055: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
2056:
2057: omClass = ScarabUserImplPeer.getOMClass();
2058: ScarabUserImpl obj2 = (ScarabUserImpl) ScarabUserImplPeer
2059: .row2Object(row, offset2, omClass);
2060:
2061: boolean newObject = true;
2062: for (int j = 0; j < results.size(); j++) {
2063: Query temp_obj1 = (Query) results.get(j);
2064: ScarabUserImpl temp_obj2 = (ScarabUserImpl) temp_obj1
2065: .getScarabUser();
2066: if (temp_obj2.getPrimaryKey().equals(
2067: obj2.getPrimaryKey())) {
2068: newObject = false;
2069: temp_obj2.addQuery(obj1);
2070: break;
2071: }
2072: }
2073: if (newObject) {
2074: obj2.initQuerys();
2075: obj2.addQuery(obj1);
2076: }
2077:
2078: omClass = ScopePeer.getOMClass();
2079: Scope obj3 = (Scope) ScopePeer.row2Object(row, offset3,
2080: omClass);
2081:
2082: newObject = true;
2083: for (int j = 0; j < results.size(); j++) {
2084: Query temp_obj1 = (Query) results.get(j);
2085: Scope temp_obj3 = (Scope) temp_obj1.getScope();
2086: if (temp_obj3.getPrimaryKey().equals(
2087: obj3.getPrimaryKey())) {
2088: newObject = false;
2089: temp_obj3.addQuery(obj1);
2090: break;
2091: }
2092: }
2093: if (newObject) {
2094: obj3.initQuerys();
2095: obj3.addQuery(obj1);
2096: }
2097:
2098: omClass = ScarabModulePeer.getOMClass(row, offset4);
2099: ScarabModule obj4 = (ScarabModule) ScarabModulePeer
2100: .row2Object(row, offset4, omClass);
2101:
2102: newObject = true;
2103: for (int j = 0; j < results.size(); j++) {
2104: Query temp_obj1 = (Query) results.get(j);
2105: ScarabModule temp_obj4 = (ScarabModule) temp_obj1
2106: .getModule();
2107: if (temp_obj4.getPrimaryKey().equals(
2108: obj4.getPrimaryKey())) {
2109: newObject = false;
2110: temp_obj4.addQuery(obj1);
2111: break;
2112: }
2113: }
2114: if (newObject) {
2115: obj4.initQuerys();
2116: obj4.addQuery(obj1);
2117: }
2118:
2119: omClass = IssueTypePeer.getOMClass();
2120: IssueType obj5 = (IssueType) IssueTypePeer.row2Object(row,
2121: offset5, omClass);
2122:
2123: newObject = true;
2124: for (int j = 0; j < results.size(); j++) {
2125: Query temp_obj1 = (Query) results.get(j);
2126: IssueType temp_obj5 = (IssueType) temp_obj1
2127: .getIssueType();
2128: if (temp_obj5.getPrimaryKey().equals(
2129: obj5.getPrimaryKey())) {
2130: newObject = false;
2131: temp_obj5.addQuery(obj1);
2132: break;
2133: }
2134: }
2135: if (newObject) {
2136: obj5.initQuerys();
2137: obj5.addQuery(obj1);
2138: }
2139:
2140: omClass = FrequencyPeer.getOMClass();
2141: Frequency obj6 = (Frequency) FrequencyPeer.row2Object(row,
2142: offset6, omClass);
2143:
2144: newObject = true;
2145: for (int j = 0; j < results.size(); j++) {
2146: Query temp_obj1 = (Query) results.get(j);
2147: Frequency temp_obj6 = (Frequency) temp_obj1
2148: .getFrequency();
2149: if (temp_obj6.getPrimaryKey().equals(
2150: obj6.getPrimaryKey())) {
2151: newObject = false;
2152: temp_obj6.addQuery(obj1);
2153: break;
2154: }
2155: }
2156: if (newObject) {
2157: obj6.initQuerys();
2158: obj6.addQuery(obj1);
2159: }
2160: results.add(obj1);
2161: }
2162: return results;
2163: }
2164:
2165: /**
2166: * selects a collection of Query objects pre-filled with
2167: * all related objects.
2168: *
2169: * This method is protected by default in order to keep the public
2170: * api reasonable. You can provide public methods for those you
2171: * actually need in QueryPeer.
2172: *
2173: * @throws TorqueException Any exceptions caught during processing will be
2174: * rethrown wrapped into a TorqueException.
2175: */
2176: protected static List doSelectJoinAllExceptFrequency(
2177: Criteria criteria) throws TorqueException {
2178: return doSelectJoinAllExceptFrequency(criteria, null);
2179: }
2180:
2181: /**
2182: * selects a collection of Query objects pre-filled with
2183: * all related objects.
2184: *
2185: * This method is protected by default in order to keep the public
2186: * api reasonable. You can provide public methods for those you
2187: * actually need in QueryPeer.
2188: *
2189: * @throws TorqueException Any exceptions caught during processing will be
2190: * rethrown wrapped into a TorqueException.
2191: */
2192: protected static List doSelectJoinAllExceptFrequency(
2193: Criteria criteria, Connection conn) throws TorqueException {
2194: setDbName(criteria);
2195:
2196: addSelectColumns(criteria);
2197: int offset2 = numColumns + 1;
2198:
2199: ScarabUserImplPeer.addSelectColumns(criteria);
2200: criteria.addJoin(QueryPeer.USER_ID, ScarabUserImplPeer.USER_ID);
2201: int offset3 = offset2 + ScarabUserImplPeer.numColumns;
2202:
2203: ScopePeer.addSelectColumns(criteria);
2204: criteria.addJoin(QueryPeer.SCOPE_ID, ScopePeer.SCOPE_ID);
2205: int offset4 = offset3 + ScopePeer.numColumns;
2206:
2207: ScarabModulePeer.addSelectColumns(criteria);
2208: criteria.addJoin(QueryPeer.MODULE_ID,
2209: ScarabModulePeer.MODULE_ID);
2210: int offset5 = offset4 + ScarabModulePeer.numColumns;
2211:
2212: IssueTypePeer.addSelectColumns(criteria);
2213: criteria.addJoin(QueryPeer.ISSUE_TYPE_ID,
2214: IssueTypePeer.ISSUE_TYPE_ID);
2215: int offset6 = offset5 + IssueTypePeer.numColumns;
2216:
2217: MITListPeer.addSelectColumns(criteria);
2218: criteria.addJoin(QueryPeer.LIST_ID, MITListPeer.LIST_ID);
2219:
2220: correctBooleans(criteria);
2221:
2222: List rows;
2223: if (conn == null) {
2224: rows = BasePeer.doSelect(criteria);
2225: } else {
2226: rows = BasePeer.doSelect(criteria, conn);
2227: }
2228:
2229: List results = new ArrayList();
2230:
2231: for (int i = 0; i < rows.size(); i++) {
2232: Record row = (Record) rows.get(i);
2233:
2234: Class omClass = QueryPeer.getOMClass();
2235: Query obj1 = (Query) QueryPeer.row2Object(row, 1, omClass);
2236:
2237: omClass = ScarabUserImplPeer.getOMClass();
2238: ScarabUserImpl obj2 = (ScarabUserImpl) ScarabUserImplPeer
2239: .row2Object(row, offset2, omClass);
2240:
2241: boolean newObject = true;
2242: for (int j = 0; j < results.size(); j++) {
2243: Query temp_obj1 = (Query) results.get(j);
2244: ScarabUserImpl temp_obj2 = (ScarabUserImpl) temp_obj1
2245: .getScarabUser();
2246: if (temp_obj2.getPrimaryKey().equals(
2247: obj2.getPrimaryKey())) {
2248: newObject = false;
2249: temp_obj2.addQuery(obj1);
2250: break;
2251: }
2252: }
2253: if (newObject) {
2254: obj2.initQuerys();
2255: obj2.addQuery(obj1);
2256: }
2257:
2258: omClass = ScopePeer.getOMClass();
2259: Scope obj3 = (Scope) ScopePeer.row2Object(row, offset3,
2260: omClass);
2261:
2262: newObject = true;
2263: for (int j = 0; j < results.size(); j++) {
2264: Query temp_obj1 = (Query) results.get(j);
2265: Scope temp_obj3 = (Scope) temp_obj1.getScope();
2266: if (temp_obj3.getPrimaryKey().equals(
2267: obj3.getPrimaryKey())) {
2268: newObject = false;
2269: temp_obj3.addQuery(obj1);
2270: break;
2271: }
2272: }
2273: if (newObject) {
2274: obj3.initQuerys();
2275: obj3.addQuery(obj1);
2276: }
2277:
2278: omClass = ScarabModulePeer.getOMClass(row, offset4);
2279: ScarabModule obj4 = (ScarabModule) ScarabModulePeer
2280: .row2Object(row, offset4, omClass);
2281:
2282: newObject = true;
2283: for (int j = 0; j < results.size(); j++) {
2284: Query temp_obj1 = (Query) results.get(j);
2285: ScarabModule temp_obj4 = (ScarabModule) temp_obj1
2286: .getModule();
2287: if (temp_obj4.getPrimaryKey().equals(
2288: obj4.getPrimaryKey())) {
2289: newObject = false;
2290: temp_obj4.addQuery(obj1);
2291: break;
2292: }
2293: }
2294: if (newObject) {
2295: obj4.initQuerys();
2296: obj4.addQuery(obj1);
2297: }
2298:
2299: omClass = IssueTypePeer.getOMClass();
2300: IssueType obj5 = (IssueType) IssueTypePeer.row2Object(row,
2301: offset5, omClass);
2302:
2303: newObject = true;
2304: for (int j = 0; j < results.size(); j++) {
2305: Query temp_obj1 = (Query) results.get(j);
2306: IssueType temp_obj5 = (IssueType) temp_obj1
2307: .getIssueType();
2308: if (temp_obj5.getPrimaryKey().equals(
2309: obj5.getPrimaryKey())) {
2310: newObject = false;
2311: temp_obj5.addQuery(obj1);
2312: break;
2313: }
2314: }
2315: if (newObject) {
2316: obj5.initQuerys();
2317: obj5.addQuery(obj1);
2318: }
2319:
2320: omClass = MITListPeer.getOMClass();
2321: MITList obj6 = (MITList) MITListPeer.row2Object(row,
2322: offset6, omClass);
2323:
2324: newObject = true;
2325: for (int j = 0; j < results.size(); j++) {
2326: Query temp_obj1 = (Query) results.get(j);
2327: MITList temp_obj6 = (MITList) temp_obj1.getMITList();
2328: if (temp_obj6.getPrimaryKey().equals(
2329: obj6.getPrimaryKey())) {
2330: newObject = false;
2331: temp_obj6.addQuery(obj1);
2332: break;
2333: }
2334: }
2335: if (newObject) {
2336: obj6.initQuerys();
2337: obj6.addQuery(obj1);
2338: }
2339:
2340: results.add(obj1);
2341: }
2342: return results;
2343: }
2344:
2345: /**
2346: * Returns the TableMap related to this peer. This method is not
2347: * needed for general use but a specific application could have a need.
2348: *
2349: * @throws TorqueException Any exceptions caught during processing will be
2350: * rethrown wrapped into a TorqueException.
2351: */
2352: protected static TableMap getTableMap() throws TorqueException {
2353: return Torque.getDatabaseMap(DATABASE_NAME)
2354: .getTable(TABLE_NAME);
2355: }
2356:
2357: private static void setDbName(Criteria crit) {
2358: // Set the correct dbName if it has not been overridden
2359: // crit.getDbName will return the same object if not set to
2360: // another value so == check is okay and faster
2361: if (crit.getDbName() == Torque.getDefaultDB()) {
2362: crit.setDbName(DATABASE_NAME);
2363: }
2364: }
2365: }
|