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 BaseAttributeValuePeer 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_ISSUE_ATTRIBUTE_VALUE";
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(AttributeValueMapBuilder.CLASS_NAME);
0050: }
0051:
0052: /** the column name for the VALUE_ID field */
0053: public static final String VALUE_ID;
0054: /** the column name for the ISSUE_ID field */
0055: public static final String ISSUE_ID;
0056: /** the column name for the ATTRIBUTE_ID field */
0057: public static final String ATTRIBUTE_ID;
0058: /** the column name for the NUMERIC_VALUE field */
0059: public static final String NUMERIC_VALUE;
0060: /** the column name for the OPTION_ID field */
0061: public static final String OPTION_ID;
0062: /** the column name for the USER_ID field */
0063: public static final String USER_ID;
0064: /** the column name for the VALUE field */
0065: public static final String VALUE;
0066: /** the column name for the DELETED field */
0067: public static final String DELETED;
0068:
0069: static {
0070: VALUE_ID = "SCARAB_ISSUE_ATTRIBUTE_VALUE.VALUE_ID";
0071: ISSUE_ID = "SCARAB_ISSUE_ATTRIBUTE_VALUE.ISSUE_ID";
0072: ATTRIBUTE_ID = "SCARAB_ISSUE_ATTRIBUTE_VALUE.ATTRIBUTE_ID";
0073: NUMERIC_VALUE = "SCARAB_ISSUE_ATTRIBUTE_VALUE.NUMERIC_VALUE";
0074: OPTION_ID = "SCARAB_ISSUE_ATTRIBUTE_VALUE.OPTION_ID";
0075: USER_ID = "SCARAB_ISSUE_ATTRIBUTE_VALUE.USER_ID";
0076: VALUE = "SCARAB_ISSUE_ATTRIBUTE_VALUE.VALUE";
0077: DELETED = "SCARAB_ISSUE_ATTRIBUTE_VALUE.DELETED";
0078: if (Torque.isInit()) {
0079: try {
0080: getMapBuilder(AttributeValueMapBuilder.CLASS_NAME);
0081: } catch (Exception e) {
0082: log.error("Could not initialize Peer", e);
0083: throw new RuntimeException(e);
0084: }
0085: } else {
0086: Torque
0087: .registerMapBuilder(AttributeValueMapBuilder.CLASS_NAME);
0088: }
0089: }
0090:
0091: /** number of columns for this peer */
0092: public static final int numColumns = 8;
0093:
0094: /** A class that can be returned by this peer. */
0095: protected static final String CLASSNAME_DEFAULT = "org.tigris.scarab.om.AttributeValue";
0096:
0097: /** A class that can be returned by this peer. */
0098: protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
0099:
0100: /**
0101: * Class object initialization method.
0102: *
0103: * @param className name of the class to initialize
0104: * @return the initialized class
0105: */
0106: private static Class initClass(String className) {
0107: Class c = null;
0108: try {
0109: c = Class.forName(className);
0110: } catch (Throwable t) {
0111: log
0112: .error(
0113: "A FATAL ERROR has occurred which should not "
0114: + "have happened under any circumstance. Please notify "
0115: + "the Torque developers <torque-dev@db.apache.org> "
0116: + "and give as many details as possible (including the error "
0117: + "stack trace).", t);
0118:
0119: // Error objects should always be propogated.
0120: if (t instanceof Error) {
0121: throw (Error) t.fillInStackTrace();
0122: }
0123: }
0124: return c;
0125: }
0126:
0127: /**
0128: * Get the list of objects for a ResultSet. Please not that your
0129: * resultset MUST return columns in the right order. You can use
0130: * getFieldNames() in BaseObject to get the correct sequence.
0131: *
0132: * @param results the ResultSet
0133: * @return the list of objects
0134: * @throws TorqueException Any exceptions caught during processing will be
0135: * rethrown wrapped into a TorqueException.
0136: */
0137: public static List resultSet2Objects(java.sql.ResultSet results)
0138: throws TorqueException {
0139: try {
0140: QueryDataSet qds = null;
0141: List rows = null;
0142: try {
0143: qds = new QueryDataSet(results);
0144: rows = getSelectResults(qds);
0145: } finally {
0146: if (qds != null) {
0147: qds.close();
0148: }
0149: }
0150:
0151: return populateObjects(rows);
0152: } catch (SQLException e) {
0153: throw new TorqueException(e);
0154: } catch (DataSetException e) {
0155: throw new TorqueException(e);
0156: }
0157: }
0158:
0159: /**
0160: * Method to do inserts.
0161: *
0162: * @param criteria object used to create the INSERT statement.
0163: * @throws TorqueException Any exceptions caught during processing will be
0164: * rethrown wrapped into a TorqueException.
0165: */
0166: public static ObjectKey doInsert(Criteria criteria)
0167: throws TorqueException {
0168: return BaseAttributeValuePeer.doInsert(criteria,
0169: (Connection) null);
0170: }
0171:
0172: /**
0173: * Method to do inserts. This method is to be used during a transaction,
0174: * otherwise use the doInsert(Criteria) method. It will take care of
0175: * the connection details internally.
0176: *
0177: * @param criteria object used to create the INSERT statement.
0178: * @param con the connection to use
0179: * @throws TorqueException Any exceptions caught during processing will be
0180: * rethrown wrapped into a TorqueException.
0181: */
0182: public static ObjectKey doInsert(Criteria criteria, Connection con)
0183: throws TorqueException {
0184: correctBooleans(criteria);
0185:
0186: setDbName(criteria);
0187:
0188: if (con == null) {
0189: return BasePeer.doInsert(criteria);
0190: } else {
0191: return BasePeer.doInsert(criteria, con);
0192: }
0193: }
0194:
0195: /**
0196: * Add all the columns needed to create a new object.
0197: *
0198: * @param criteria object containing the columns to add.
0199: * @throws TorqueException Any exceptions caught during processing will be
0200: * rethrown wrapped into a TorqueException.
0201: */
0202: public static void addSelectColumns(Criteria criteria)
0203: throws TorqueException {
0204: criteria.addSelectColumn(VALUE_ID);
0205: criteria.addSelectColumn(ISSUE_ID);
0206: criteria.addSelectColumn(ATTRIBUTE_ID);
0207: criteria.addSelectColumn(NUMERIC_VALUE);
0208: criteria.addSelectColumn(OPTION_ID);
0209: criteria.addSelectColumn(USER_ID);
0210: criteria.addSelectColumn(VALUE);
0211: criteria.addSelectColumn(DELETED);
0212: }
0213:
0214: /**
0215: * changes the boolean values in the criteria to the appropriate type,
0216: * whenever a booleanchar or booleanint column is involved.
0217: * This enables the user to create criteria using Boolean values
0218: * for booleanchar or booleanint columns
0219: * @param criteria the criteria in which the boolean values should be corrected
0220: */
0221: public static void correctBooleans(Criteria criteria) {
0222: // check for conversion from boolean to int
0223: if (criteria.containsKey(DELETED)) {
0224: Object possibleBoolean = criteria.get(DELETED);
0225: if (possibleBoolean instanceof Boolean) {
0226: criteria.add(DELETED, ((Boolean) possibleBoolean)
0227: .booleanValue() ? 1 : 0);
0228: }
0229: }
0230: }
0231:
0232: /**
0233: * Create a new object of type cls 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 AttributeValue row2Object(Record row, int offset,
0242: Class cls) throws TorqueException {
0243: try {
0244: AttributeValue obj = (AttributeValue) cls.newInstance();
0245: AttributeValuePeer.populateObject(row, offset, obj);
0246: obj.setModified(false);
0247: obj.setNew(false);
0248:
0249: return obj;
0250: } catch (InstantiationException e) {
0251: throw new TorqueException(e);
0252: } catch (IllegalAccessException e) {
0253: throw new TorqueException(e);
0254: }
0255: }
0256:
0257: /**
0258: * Populates an object from a resultset row starting
0259: * from a specified offset. This is done so that you can select
0260: * other rows than just those needed for this object. You may
0261: * for example want to create two objects from the same row.
0262: *
0263: * @throws TorqueException Any exceptions caught during processing will be
0264: * rethrown wrapped into a TorqueException.
0265: */
0266: public static void populateObject(Record row, int offset,
0267: AttributeValue obj) throws TorqueException {
0268: try {
0269: obj.setValueId(row.getValue(offset + 0).asLongObj());
0270: obj.setIssueId(row.getValue(offset + 1).asLongObj());
0271: obj.setAttributeId(row.getValue(offset + 2).asIntegerObj());
0272: obj
0273: .setNumericValue(row.getValue(offset + 3)
0274: .asIntegerObj());
0275: obj.setOptionId(row.getValue(offset + 4).asIntegerObj());
0276: obj.setUserId(row.getValue(offset + 5).asIntegerObj());
0277: obj.setValue(row.getValue(offset + 6).asString());
0278: obj.setDeleted(row.getValue(offset + 7).asBoolean());
0279: } catch (DataSetException e) {
0280: throw new TorqueException(e);
0281: }
0282: }
0283:
0284: /**
0285: * Method to do selects.
0286: *
0287: * @param criteria object used to create the SELECT statement.
0288: * @return List of selected Objects
0289: * @throws TorqueException Any exceptions caught during processing will be
0290: * rethrown wrapped into a TorqueException.
0291: */
0292: public static List doSelect(Criteria criteria)
0293: throws TorqueException {
0294: return populateObjects(doSelectVillageRecords(criteria));
0295: }
0296:
0297: /**
0298: * Method to do selects within a transaction.
0299: *
0300: * @param criteria object used to create the SELECT statement.
0301: * @param con the connection to use
0302: * @return List of selected Objects
0303: * @throws TorqueException Any exceptions caught during processing will be
0304: * rethrown wrapped into a TorqueException.
0305: */
0306: public static List doSelect(Criteria criteria, Connection con)
0307: throws TorqueException {
0308: return populateObjects(doSelectVillageRecords(criteria, con));
0309: }
0310:
0311: /**
0312: * Grabs the raw Village records to be formed into objects.
0313: * This method handles connections internally. The Record objects
0314: * returned by this method should be considered readonly. Do not
0315: * alter the data and call save(), your results may vary, but are
0316: * certainly likely to result in hard to track MT bugs.
0317: *
0318: * @throws TorqueException Any exceptions caught during processing will be
0319: * rethrown wrapped into a TorqueException.
0320: */
0321: public static List doSelectVillageRecords(Criteria criteria)
0322: throws TorqueException {
0323: return BaseAttributeValuePeer.doSelectVillageRecords(criteria,
0324: (Connection) null);
0325: }
0326:
0327: /**
0328: * Grabs the raw Village records to be formed into objects.
0329: * This method should be used for transactions
0330: *
0331: * @param criteria object used to create the SELECT statement.
0332: * @param con the connection to use
0333: * @throws TorqueException Any exceptions caught during processing will be
0334: * rethrown wrapped into a TorqueException.
0335: */
0336: public static List doSelectVillageRecords(Criteria criteria,
0337: Connection con) throws TorqueException {
0338: if (criteria.getSelectColumns().size() == 0) {
0339: addSelectColumns(criteria);
0340: }
0341: correctBooleans(criteria);
0342:
0343: setDbName(criteria);
0344:
0345: // BasePeer returns a List of Value (Village) arrays. The array
0346: // order follows the order columns were placed in the Select clause.
0347: if (con == null) {
0348: return BasePeer.doSelect(criteria);
0349: } else {
0350: return BasePeer.doSelect(criteria, con);
0351: }
0352: }
0353:
0354: /**
0355: * The returned List will contain objects of the default type or
0356: * objects that inherit from the default.
0357: *
0358: * @throws TorqueException Any exceptions caught during processing will be
0359: * rethrown wrapped into a TorqueException.
0360: */
0361: public static List populateObjects(List records)
0362: throws TorqueException {
0363: List results = new ArrayList(records.size());
0364:
0365: // populate the object(s)
0366: for (int i = 0; i < records.size(); i++) {
0367: Record row = (Record) records.get(i);
0368: results.add(AttributeValuePeer.row2Object(row, 1,
0369: AttributeValuePeer.getOMClass(row, 1)));
0370: }
0371: return results;
0372: }
0373:
0374: /**
0375: * The returned Class will contain objects of the default type or
0376: * objects that inherit from the default.
0377: *
0378: * @throws TorqueException Any exceptions caught during processing will be
0379: * rethrown wrapped into a TorqueException.
0380: */
0381: public static Class getOMClass(Record record, int offset)
0382: throws TorqueException {
0383: Class c = null;
0384: try {
0385: c = Class.forName(record.getValue(offset - 1 + 3)
0386: .asString());
0387: } catch (Exception e) {
0388: throw new TorqueException(e);
0389: }
0390: return c;
0391: }
0392:
0393: /**
0394: * The class that the Peer will make instances of.
0395: * If the BO is abstract then you must implement this method
0396: * in the BO.
0397: *
0398: * @throws TorqueException Any exceptions caught during processing will be
0399: * rethrown wrapped into a TorqueException.
0400: */
0401: public static Class getOMClass() throws TorqueException {
0402: String error = "You must implement the getOMClass method in your";
0403: error += " Peer object in order for things to work properly.";
0404: error += " This method should return the proper Class that";
0405: error += " represents the Peer's Business Object.";
0406: throw new TorqueException(error);
0407: }
0408:
0409: /**
0410: * Method to do updates.
0411: *
0412: * @param criteria object containing data that is used to create the UPDATE
0413: * statement.
0414: * @throws TorqueException Any exceptions caught during processing will be
0415: * rethrown wrapped into a TorqueException.
0416: */
0417: public static void doUpdate(Criteria criteria)
0418: throws TorqueException {
0419: BaseAttributeValuePeer.doUpdate(criteria, (Connection) null);
0420: }
0421:
0422: /**
0423: * Method to do updates. This method is to be used during a transaction,
0424: * otherwise use the doUpdate(Criteria) method. It will take care of
0425: * the connection details internally.
0426: *
0427: * @param criteria object containing data that is used to create the UPDATE
0428: * statement.
0429: * @param con the connection to use
0430: * @throws TorqueException Any exceptions caught during processing will be
0431: * rethrown wrapped into a TorqueException.
0432: */
0433: public static void doUpdate(Criteria criteria, Connection con)
0434: throws TorqueException {
0435: Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
0436: correctBooleans(criteria);
0437:
0438: selectCriteria.put(VALUE_ID, criteria.remove(VALUE_ID));
0439:
0440: setDbName(criteria);
0441:
0442: if (con == null) {
0443: BasePeer.doUpdate(selectCriteria, criteria);
0444: } else {
0445: BasePeer.doUpdate(selectCriteria, criteria, con);
0446: }
0447: }
0448:
0449: /**
0450: * Method to do deletes.
0451: *
0452: * @param criteria object containing data that is used DELETE from database.
0453: * @throws TorqueException Any exceptions caught during processing will be
0454: * rethrown wrapped into a TorqueException.
0455: */
0456: public static void doDelete(Criteria criteria)
0457: throws TorqueException {
0458: AttributeValuePeer.doDelete(criteria, (Connection) null);
0459: }
0460:
0461: /**
0462: * Method to do deletes. This method is to be used during a transaction,
0463: * otherwise use the doDelete(Criteria) method. It will take care of
0464: * the connection details internally.
0465: *
0466: * @param criteria object containing data that is used DELETE from database.
0467: * @param con the connection to use
0468: * @throws TorqueException Any exceptions caught during processing will be
0469: * rethrown wrapped into a TorqueException.
0470: */
0471: public static void doDelete(Criteria criteria, Connection con)
0472: throws TorqueException {
0473: correctBooleans(criteria);
0474:
0475: setDbName(criteria);
0476:
0477: if (con == null) {
0478: BasePeer.doDelete(criteria);
0479: } else {
0480: BasePeer.doDelete(criteria, con);
0481: }
0482: }
0483:
0484: /**
0485: * Method to do selects
0486: *
0487: * @throws TorqueException Any exceptions caught during processing will be
0488: * rethrown wrapped into a TorqueException.
0489: */
0490: public static List doSelect(AttributeValue obj)
0491: throws TorqueException {
0492: return doSelect(buildSelectCriteria(obj));
0493: }
0494:
0495: /**
0496: * Method to do inserts
0497: *
0498: * @throws TorqueException Any exceptions caught during processing will be
0499: * rethrown wrapped into a TorqueException.
0500: */
0501: public static void doInsert(AttributeValue obj)
0502: throws TorqueException {
0503: obj.setPrimaryKey(doInsert(buildCriteria(obj)));
0504: obj.setNew(false);
0505: obj.setModified(false);
0506: }
0507:
0508: /**
0509: * @param obj the data object to update in the database.
0510: * @throws TorqueException Any exceptions caught during processing will be
0511: * rethrown wrapped into a TorqueException.
0512: */
0513: public static void doUpdate(AttributeValue obj)
0514: throws TorqueException {
0515: doUpdate(buildCriteria(obj));
0516: obj.setModified(false);
0517: }
0518:
0519: /**
0520: * @param obj the data object to delete in the database.
0521: * @throws TorqueException Any exceptions caught during processing will be
0522: * rethrown wrapped into a TorqueException.
0523: */
0524: public static void doDelete(AttributeValue obj)
0525: throws TorqueException {
0526: doDelete(buildSelectCriteria(obj));
0527: }
0528:
0529: /**
0530: * Method to do inserts. This method is to be used during a transaction,
0531: * otherwise use the doInsert(AttributeValue) method. It will take
0532: * care of the connection details internally.
0533: *
0534: * @param obj the data object to insert into the database.
0535: * @param con the connection to use
0536: * @throws TorqueException Any exceptions caught during processing will be
0537: * rethrown wrapped into a TorqueException.
0538: */
0539: public static void doInsert(AttributeValue obj, Connection con)
0540: throws TorqueException {
0541: obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
0542: obj.setNew(false);
0543: obj.setModified(false);
0544: }
0545:
0546: /**
0547: * Method to do update. This method is to be used during a transaction,
0548: * otherwise use the doUpdate(AttributeValue) method. It will take
0549: * care of the connection details internally.
0550: *
0551: * @param obj the data object to update in the database.
0552: * @param con the connection to use
0553: * @throws TorqueException Any exceptions caught during processing will be
0554: * rethrown wrapped into a TorqueException.
0555: */
0556: public static void doUpdate(AttributeValue obj, Connection con)
0557: throws TorqueException {
0558: doUpdate(buildCriteria(obj), con);
0559: obj.setModified(false);
0560: }
0561:
0562: /**
0563: * Method to delete. This method is to be used during a transaction,
0564: * otherwise use the doDelete(AttributeValue) method. It will take
0565: * care of the connection details internally.
0566: *
0567: * @param obj the data object to delete in the database.
0568: * @param con the connection to use
0569: * @throws TorqueException Any exceptions caught during processing will be
0570: * rethrown wrapped into a TorqueException.
0571: */
0572: public static void doDelete(AttributeValue obj, Connection con)
0573: throws TorqueException {
0574: doDelete(buildSelectCriteria(obj), con);
0575: }
0576:
0577: /**
0578: * Method to do deletes.
0579: *
0580: * @param pk ObjectKey that is used DELETE from database.
0581: * @throws TorqueException Any exceptions caught during processing will be
0582: * rethrown wrapped into a TorqueException.
0583: */
0584: public static void doDelete(ObjectKey pk) throws TorqueException {
0585: BaseAttributeValuePeer.doDelete(pk, (Connection) null);
0586: }
0587:
0588: /**
0589: * Method to delete. This method is to be used during a transaction,
0590: * otherwise use the doDelete(ObjectKey) method. It will take
0591: * care of the connection details internally.
0592: *
0593: * @param pk the primary key for the object to delete in the database.
0594: * @param con the connection to use
0595: * @throws TorqueException Any exceptions caught during processing will be
0596: * rethrown wrapped into a TorqueException.
0597: */
0598: public static void doDelete(ObjectKey pk, Connection con)
0599: throws TorqueException {
0600: doDelete(buildCriteria(pk), con);
0601: }
0602:
0603: /** Build a Criteria object from an ObjectKey */
0604: public static Criteria buildCriteria(ObjectKey pk) {
0605: Criteria criteria = new Criteria();
0606: criteria.add(VALUE_ID, pk);
0607: return criteria;
0608: }
0609:
0610: /** Build a Criteria object from the data object for this peer */
0611: public static Criteria buildCriteria(AttributeValue obj) {
0612: Criteria criteria = new Criteria(DATABASE_NAME);
0613: if (!obj.isNew())
0614: criteria.add(VALUE_ID, obj.getValueId());
0615: criteria.add(ISSUE_ID, obj.getIssueId());
0616: criteria.add(ATTRIBUTE_ID, obj.getAttributeId());
0617: criteria.add(NUMERIC_VALUE, obj.getNumericValue());
0618: criteria.add(OPTION_ID, obj.getOptionId());
0619: criteria.add(USER_ID, obj.getUserId());
0620: criteria.add(VALUE, obj.getValue());
0621: criteria.add(DELETED, obj.getDeleted());
0622: return criteria;
0623: }
0624:
0625: /** Build a Criteria object from the data object for this peer, skipping all binary columns */
0626: public static Criteria buildSelectCriteria(AttributeValue obj) {
0627: Criteria criteria = new Criteria(DATABASE_NAME);
0628: if (!obj.isNew()) {
0629: criteria.add(VALUE_ID, obj.getValueId());
0630: }
0631: criteria.add(ISSUE_ID, obj.getIssueId());
0632: criteria.add(ATTRIBUTE_ID, obj.getAttributeId());
0633: criteria.add(NUMERIC_VALUE, obj.getNumericValue());
0634: criteria.add(OPTION_ID, obj.getOptionId());
0635: criteria.add(USER_ID, obj.getUserId());
0636: criteria.add(VALUE, obj.getValue());
0637: criteria.add(DELETED, obj.getDeleted());
0638: return criteria;
0639: }
0640:
0641: /**
0642: * Retrieve a single object by pk
0643: *
0644: * @param pk the primary key
0645: * @throws TorqueException Any exceptions caught during processing will be
0646: * rethrown wrapped into a TorqueException.
0647: * @throws NoRowsException Primary key was not found in database.
0648: * @throws TooManyRowsException Primary key was not found in database.
0649: */
0650: public static AttributeValue retrieveByPK(Long pk)
0651: throws TorqueException, NoRowsException,
0652: TooManyRowsException {
0653: return retrieveByPK(SimpleKey.keyFor(pk));
0654: }
0655:
0656: /**
0657: * Retrieve a single object by pk
0658: *
0659: * @param pk the primary key
0660: * @param con the connection to use
0661: * @throws TorqueException Any exceptions caught during processing will be
0662: * rethrown wrapped into a TorqueException.
0663: * @throws NoRowsException Primary key was not found in database.
0664: * @throws TooManyRowsException Primary key was not found in database.
0665: */
0666: public static AttributeValue retrieveByPK(Long pk, Connection con)
0667: throws TorqueException, NoRowsException,
0668: TooManyRowsException {
0669: return retrieveByPK(SimpleKey.keyFor(pk), con);
0670: }
0671:
0672: /**
0673: * Retrieve a single object by pk
0674: *
0675: * @param pk the primary key
0676: * @throws TorqueException Any exceptions caught during processing will be
0677: * rethrown wrapped into a TorqueException.
0678: * @throws NoRowsException Primary key was not found in database.
0679: * @throws TooManyRowsException Primary key was not found in database.
0680: */
0681: public static AttributeValue retrieveByPK(ObjectKey pk)
0682: throws TorqueException, NoRowsException,
0683: TooManyRowsException {
0684: Connection db = null;
0685: AttributeValue retVal = null;
0686: try {
0687: db = Torque.getConnection(DATABASE_NAME);
0688: retVal = retrieveByPK(pk, db);
0689: } finally {
0690: Torque.closeConnection(db);
0691: }
0692: return retVal;
0693: }
0694:
0695: /**
0696: * Retrieve a single object by pk
0697: *
0698: * @param pk the primary key
0699: * @param con the connection to use
0700: * @throws TorqueException Any exceptions caught during processing will be
0701: * rethrown wrapped into a TorqueException.
0702: * @throws NoRowsException Primary key was not found in database.
0703: * @throws TooManyRowsException Primary key was not found in database.
0704: */
0705: public static AttributeValue retrieveByPK(ObjectKey pk,
0706: Connection con) throws TorqueException, NoRowsException,
0707: TooManyRowsException {
0708: Criteria criteria = buildCriteria(pk);
0709: List v = doSelect(criteria, con);
0710: if (v.size() == 0) {
0711: throw new NoRowsException("Failed to select a row.");
0712: } else if (v.size() > 1) {
0713: throw new TooManyRowsException(
0714: "Failed to select only one row.");
0715: } else {
0716: return (AttributeValue) v.get(0);
0717: }
0718: }
0719:
0720: /**
0721: * Retrieve a multiple objects by pk
0722: *
0723: * @param pks List of primary keys
0724: * @throws TorqueException Any exceptions caught during processing will be
0725: * rethrown wrapped into a TorqueException.
0726: */
0727: public static List retrieveByPKs(List pks) throws TorqueException {
0728: Connection db = null;
0729: List retVal = null;
0730: try {
0731: db = Torque.getConnection(DATABASE_NAME);
0732: retVal = retrieveByPKs(pks, db);
0733: } finally {
0734: Torque.closeConnection(db);
0735: }
0736: return retVal;
0737: }
0738:
0739: /**
0740: * Retrieve a multiple objects by pk
0741: *
0742: * @param pks List of primary keys
0743: * @param dbcon the connection to use
0744: * @throws TorqueException Any exceptions caught during processing will be
0745: * rethrown wrapped into a TorqueException.
0746: */
0747: public static List retrieveByPKs(List pks, Connection dbcon)
0748: throws TorqueException {
0749: List objs = null;
0750: if (pks == null || pks.size() == 0) {
0751: objs = new LinkedList();
0752: } else {
0753: Criteria criteria = new Criteria();
0754: criteria.addIn(VALUE_ID, pks);
0755: objs = doSelect(criteria, dbcon);
0756: }
0757: return objs;
0758: }
0759:
0760: /**
0761: * selects a collection of AttributeValue objects pre-filled with their
0762: * Issue objects.
0763: *
0764: * This method is protected by default in order to keep the public
0765: * api reasonable. You can provide public methods for those you
0766: * actually need in AttributeValuePeer.
0767: *
0768: * @throws TorqueException Any exceptions caught during processing will be
0769: * rethrown wrapped into a TorqueException.
0770: */
0771: protected static List doSelectJoinIssue(Criteria criteria)
0772: throws TorqueException {
0773: return doSelectJoinIssue(criteria, null);
0774: }
0775:
0776: /**
0777: * selects a collection of AttributeValue objects pre-filled with their
0778: * Issue objects.
0779: *
0780: * This method is protected by default in order to keep the public
0781: * api reasonable. You can provide public methods for those you
0782: * actually need in AttributeValuePeer.
0783: *
0784: * @throws TorqueException Any exceptions caught during processing will be
0785: * rethrown wrapped into a TorqueException.
0786: */
0787: protected static List doSelectJoinIssue(Criteria criteria,
0788: Connection conn) throws TorqueException {
0789: setDbName(criteria);
0790:
0791: AttributeValuePeer.addSelectColumns(criteria);
0792: int offset = numColumns + 1;
0793: IssuePeer.addSelectColumns(criteria);
0794:
0795: criteria.addJoin(AttributeValuePeer.ISSUE_ID,
0796: IssuePeer.ISSUE_ID);
0797:
0798: correctBooleans(criteria);
0799:
0800: List rows;
0801: if (conn == null) {
0802: rows = BasePeer.doSelect(criteria);
0803: } else {
0804: rows = BasePeer.doSelect(criteria, conn);
0805: }
0806:
0807: List results = new ArrayList();
0808:
0809: for (int i = 0; i < rows.size(); i++) {
0810: Record row = (Record) rows.get(i);
0811:
0812: Class omClass = AttributeValuePeer.getOMClass(row, 1);
0813: AttributeValue obj1 = (AttributeValue) AttributeValuePeer
0814: .row2Object(row, 1, omClass);
0815: omClass = IssuePeer.getOMClass();
0816: Issue obj2 = (Issue) IssuePeer.row2Object(row, offset,
0817: omClass);
0818:
0819: boolean newObject = true;
0820: for (int j = 0; j < results.size(); j++) {
0821: AttributeValue temp_obj1 = (AttributeValue) results
0822: .get(j);
0823: Issue temp_obj2 = (Issue) temp_obj1.getIssue();
0824: if (temp_obj2.getPrimaryKey().equals(
0825: obj2.getPrimaryKey())) {
0826: newObject = false;
0827: temp_obj2.addAttributeValue(obj1);
0828: break;
0829: }
0830: }
0831: if (newObject) {
0832: obj2.initAttributeValues();
0833: obj2.addAttributeValue(obj1);
0834: }
0835: results.add(obj1);
0836: }
0837: return results;
0838: }
0839:
0840: /**
0841: * selects a collection of AttributeValue objects pre-filled with their
0842: * Attribute objects.
0843: *
0844: * This method is protected by default in order to keep the public
0845: * api reasonable. You can provide public methods for those you
0846: * actually need in AttributeValuePeer.
0847: *
0848: * @throws TorqueException Any exceptions caught during processing will be
0849: * rethrown wrapped into a TorqueException.
0850: */
0851: protected static List doSelectJoinAttribute(Criteria criteria)
0852: throws TorqueException {
0853: return doSelectJoinAttribute(criteria, null);
0854: }
0855:
0856: /**
0857: * selects a collection of AttributeValue objects pre-filled with their
0858: * Attribute objects.
0859: *
0860: * This method is protected by default in order to keep the public
0861: * api reasonable. You can provide public methods for those you
0862: * actually need in AttributeValuePeer.
0863: *
0864: * @throws TorqueException Any exceptions caught during processing will be
0865: * rethrown wrapped into a TorqueException.
0866: */
0867: protected static List doSelectJoinAttribute(Criteria criteria,
0868: Connection conn) throws TorqueException {
0869: setDbName(criteria);
0870:
0871: AttributeValuePeer.addSelectColumns(criteria);
0872: int offset = numColumns + 1;
0873: AttributePeer.addSelectColumns(criteria);
0874:
0875: criteria.addJoin(AttributeValuePeer.ATTRIBUTE_ID,
0876: AttributePeer.ATTRIBUTE_ID);
0877:
0878: correctBooleans(criteria);
0879:
0880: List rows;
0881: if (conn == null) {
0882: rows = BasePeer.doSelect(criteria);
0883: } else {
0884: rows = BasePeer.doSelect(criteria, conn);
0885: }
0886:
0887: List results = new ArrayList();
0888:
0889: for (int i = 0; i < rows.size(); i++) {
0890: Record row = (Record) rows.get(i);
0891:
0892: Class omClass = AttributeValuePeer.getOMClass(row, 1);
0893: AttributeValue obj1 = (AttributeValue) AttributeValuePeer
0894: .row2Object(row, 1, omClass);
0895: omClass = AttributePeer.getOMClass();
0896: Attribute obj2 = (Attribute) AttributePeer.row2Object(row,
0897: offset, omClass);
0898:
0899: boolean newObject = true;
0900: for (int j = 0; j < results.size(); j++) {
0901: AttributeValue temp_obj1 = (AttributeValue) results
0902: .get(j);
0903: Attribute temp_obj2 = (Attribute) temp_obj1
0904: .getAttribute();
0905: if (temp_obj2.getPrimaryKey().equals(
0906: obj2.getPrimaryKey())) {
0907: newObject = false;
0908: temp_obj2.addAttributeValue(obj1);
0909: break;
0910: }
0911: }
0912: if (newObject) {
0913: obj2.initAttributeValues();
0914: obj2.addAttributeValue(obj1);
0915: }
0916: results.add(obj1);
0917: }
0918: return results;
0919: }
0920:
0921: /**
0922: * selects a collection of AttributeValue objects pre-filled with their
0923: * AttributeOption objects.
0924: *
0925: * This method is protected by default in order to keep the public
0926: * api reasonable. You can provide public methods for those you
0927: * actually need in AttributeValuePeer.
0928: *
0929: * @throws TorqueException Any exceptions caught during processing will be
0930: * rethrown wrapped into a TorqueException.
0931: */
0932: protected static List doSelectJoinAttributeOption(Criteria criteria)
0933: throws TorqueException {
0934: return doSelectJoinAttributeOption(criteria, null);
0935: }
0936:
0937: /**
0938: * selects a collection of AttributeValue objects pre-filled with their
0939: * AttributeOption objects.
0940: *
0941: * This method is protected by default in order to keep the public
0942: * api reasonable. You can provide public methods for those you
0943: * actually need in AttributeValuePeer.
0944: *
0945: * @throws TorqueException Any exceptions caught during processing will be
0946: * rethrown wrapped into a TorqueException.
0947: */
0948: protected static List doSelectJoinAttributeOption(
0949: Criteria criteria, Connection conn) throws TorqueException {
0950: setDbName(criteria);
0951:
0952: AttributeValuePeer.addSelectColumns(criteria);
0953: int offset = numColumns + 1;
0954: AttributeOptionPeer.addSelectColumns(criteria);
0955:
0956: criteria.addJoin(AttributeValuePeer.OPTION_ID,
0957: AttributeOptionPeer.OPTION_ID);
0958:
0959: correctBooleans(criteria);
0960:
0961: List rows;
0962: if (conn == null) {
0963: rows = BasePeer.doSelect(criteria);
0964: } else {
0965: rows = BasePeer.doSelect(criteria, conn);
0966: }
0967:
0968: List results = new ArrayList();
0969:
0970: for (int i = 0; i < rows.size(); i++) {
0971: Record row = (Record) rows.get(i);
0972:
0973: Class omClass = AttributeValuePeer.getOMClass(row, 1);
0974: AttributeValue obj1 = (AttributeValue) AttributeValuePeer
0975: .row2Object(row, 1, omClass);
0976: omClass = AttributeOptionPeer.getOMClass();
0977: AttributeOption obj2 = (AttributeOption) AttributeOptionPeer
0978: .row2Object(row, offset, omClass);
0979:
0980: boolean newObject = true;
0981: for (int j = 0; j < results.size(); j++) {
0982: AttributeValue temp_obj1 = (AttributeValue) results
0983: .get(j);
0984: AttributeOption temp_obj2 = (AttributeOption) temp_obj1
0985: .getAttributeOption();
0986: if (temp_obj2.getPrimaryKey().equals(
0987: obj2.getPrimaryKey())) {
0988: newObject = false;
0989: temp_obj2.addAttributeValue(obj1);
0990: break;
0991: }
0992: }
0993: if (newObject) {
0994: obj2.initAttributeValues();
0995: obj2.addAttributeValue(obj1);
0996: }
0997: results.add(obj1);
0998: }
0999: return results;
1000: }
1001:
1002: /**
1003: * selects a collection of AttributeValue objects pre-filled with their
1004: * ScarabUserImpl objects.
1005: *
1006: * This method is protected by default in order to keep the public
1007: * api reasonable. You can provide public methods for those you
1008: * actually need in AttributeValuePeer.
1009: *
1010: * @throws TorqueException Any exceptions caught during processing will be
1011: * rethrown wrapped into a TorqueException.
1012: */
1013: protected static List doSelectJoinScarabUserImpl(Criteria criteria)
1014: throws TorqueException {
1015: return doSelectJoinScarabUserImpl(criteria, null);
1016: }
1017:
1018: /**
1019: * selects a collection of AttributeValue objects pre-filled with their
1020: * ScarabUserImpl objects.
1021: *
1022: * This method is protected by default in order to keep the public
1023: * api reasonable. You can provide public methods for those you
1024: * actually need in AttributeValuePeer.
1025: *
1026: * @throws TorqueException Any exceptions caught during processing will be
1027: * rethrown wrapped into a TorqueException.
1028: */
1029: protected static List doSelectJoinScarabUserImpl(Criteria criteria,
1030: Connection conn) throws TorqueException {
1031: setDbName(criteria);
1032:
1033: AttributeValuePeer.addSelectColumns(criteria);
1034: int offset = numColumns + 1;
1035: ScarabUserImplPeer.addSelectColumns(criteria);
1036:
1037: criteria.addJoin(AttributeValuePeer.USER_ID,
1038: ScarabUserImplPeer.USER_ID);
1039:
1040: correctBooleans(criteria);
1041:
1042: List rows;
1043: if (conn == null) {
1044: rows = BasePeer.doSelect(criteria);
1045: } else {
1046: rows = BasePeer.doSelect(criteria, conn);
1047: }
1048:
1049: List results = new ArrayList();
1050:
1051: for (int i = 0; i < rows.size(); i++) {
1052: Record row = (Record) rows.get(i);
1053:
1054: Class omClass = AttributeValuePeer.getOMClass(row, 1);
1055: AttributeValue obj1 = (AttributeValue) AttributeValuePeer
1056: .row2Object(row, 1, omClass);
1057: omClass = ScarabUserImplPeer.getOMClass();
1058: ScarabUserImpl obj2 = (ScarabUserImpl) ScarabUserImplPeer
1059: .row2Object(row, offset, omClass);
1060:
1061: boolean newObject = true;
1062: for (int j = 0; j < results.size(); j++) {
1063: AttributeValue temp_obj1 = (AttributeValue) results
1064: .get(j);
1065: ScarabUserImpl temp_obj2 = (ScarabUserImpl) temp_obj1
1066: .getScarabUser();
1067: if (temp_obj2.getPrimaryKey().equals(
1068: obj2.getPrimaryKey())) {
1069: newObject = false;
1070: temp_obj2.addAttributeValue(obj1);
1071: break;
1072: }
1073: }
1074: if (newObject) {
1075: obj2.initAttributeValues();
1076: obj2.addAttributeValue(obj1);
1077: }
1078: results.add(obj1);
1079: }
1080: return results;
1081: }
1082:
1083: /**
1084: * selects a collection of AttributeValue objects pre-filled with
1085: * all related objects.
1086: *
1087: * This method is protected by default in order to keep the public
1088: * api reasonable. You can provide public methods for those you
1089: * actually need in AttributeValuePeer.
1090: *
1091: * @throws TorqueException Any exceptions caught during processing will be
1092: * rethrown wrapped into a TorqueException.
1093: */
1094: protected static List doSelectJoinAllExceptIssue(Criteria criteria)
1095: throws TorqueException {
1096: return doSelectJoinAllExceptIssue(criteria, null);
1097: }
1098:
1099: /**
1100: * selects a collection of AttributeValue objects pre-filled with
1101: * all related objects.
1102: *
1103: * This method is protected by default in order to keep the public
1104: * api reasonable. You can provide public methods for those you
1105: * actually need in AttributeValuePeer.
1106: *
1107: * @throws TorqueException Any exceptions caught during processing will be
1108: * rethrown wrapped into a TorqueException.
1109: */
1110: protected static List doSelectJoinAllExceptIssue(Criteria criteria,
1111: Connection conn) throws TorqueException {
1112: setDbName(criteria);
1113:
1114: addSelectColumns(criteria);
1115: int offset2 = numColumns + 1;
1116:
1117: AttributePeer.addSelectColumns(criteria);
1118: criteria.addJoin(AttributeValuePeer.ATTRIBUTE_ID,
1119: AttributePeer.ATTRIBUTE_ID);
1120: int offset3 = offset2 + AttributePeer.numColumns;
1121:
1122: AttributeOptionPeer.addSelectColumns(criteria);
1123: criteria.addJoin(AttributeValuePeer.OPTION_ID,
1124: AttributeOptionPeer.OPTION_ID);
1125: int offset4 = offset3 + AttributeOptionPeer.numColumns;
1126:
1127: ScarabUserImplPeer.addSelectColumns(criteria);
1128: criteria.addJoin(AttributeValuePeer.USER_ID,
1129: ScarabUserImplPeer.USER_ID);
1130:
1131: correctBooleans(criteria);
1132:
1133: List rows;
1134: if (conn == null) {
1135: rows = BasePeer.doSelect(criteria);
1136: } else {
1137: rows = BasePeer.doSelect(criteria, conn);
1138: }
1139:
1140: List results = new ArrayList();
1141:
1142: for (int i = 0; i < rows.size(); i++) {
1143: Record row = (Record) rows.get(i);
1144:
1145: Class omClass = AttributeValuePeer.getOMClass(row, 1);
1146: AttributeValue obj1 = (AttributeValue) AttributeValuePeer
1147: .row2Object(row, 1, omClass);
1148:
1149: omClass = AttributePeer.getOMClass();
1150: Attribute obj2 = (Attribute) AttributePeer.row2Object(row,
1151: offset2, omClass);
1152:
1153: boolean newObject = true;
1154: for (int j = 0; j < results.size(); j++) {
1155: AttributeValue temp_obj1 = (AttributeValue) results
1156: .get(j);
1157: Attribute temp_obj2 = (Attribute) temp_obj1
1158: .getAttribute();
1159: if (temp_obj2.getPrimaryKey().equals(
1160: obj2.getPrimaryKey())) {
1161: newObject = false;
1162: temp_obj2.addAttributeValue(obj1);
1163: break;
1164: }
1165: }
1166: if (newObject) {
1167: obj2.initAttributeValues();
1168: obj2.addAttributeValue(obj1);
1169: }
1170:
1171: omClass = AttributeOptionPeer.getOMClass();
1172: AttributeOption obj3 = (AttributeOption) AttributeOptionPeer
1173: .row2Object(row, offset3, omClass);
1174:
1175: newObject = true;
1176: for (int j = 0; j < results.size(); j++) {
1177: AttributeValue temp_obj1 = (AttributeValue) results
1178: .get(j);
1179: AttributeOption temp_obj3 = (AttributeOption) temp_obj1
1180: .getAttributeOption();
1181: if (temp_obj3.getPrimaryKey().equals(
1182: obj3.getPrimaryKey())) {
1183: newObject = false;
1184: temp_obj3.addAttributeValue(obj1);
1185: break;
1186: }
1187: }
1188: if (newObject) {
1189: obj3.initAttributeValues();
1190: obj3.addAttributeValue(obj1);
1191: }
1192:
1193: omClass = ScarabUserImplPeer.getOMClass();
1194: ScarabUserImpl obj4 = (ScarabUserImpl) ScarabUserImplPeer
1195: .row2Object(row, offset4, omClass);
1196:
1197: newObject = true;
1198: for (int j = 0; j < results.size(); j++) {
1199: AttributeValue temp_obj1 = (AttributeValue) results
1200: .get(j);
1201: ScarabUserImpl temp_obj4 = (ScarabUserImpl) temp_obj1
1202: .getScarabUser();
1203: if (temp_obj4.getPrimaryKey().equals(
1204: obj4.getPrimaryKey())) {
1205: newObject = false;
1206: temp_obj4.addAttributeValue(obj1);
1207: break;
1208: }
1209: }
1210: if (newObject) {
1211: obj4.initAttributeValues();
1212: obj4.addAttributeValue(obj1);
1213: }
1214: results.add(obj1);
1215: }
1216: return results;
1217: }
1218:
1219: /**
1220: * selects a collection of AttributeValue objects pre-filled with
1221: * all related objects.
1222: *
1223: * This method is protected by default in order to keep the public
1224: * api reasonable. You can provide public methods for those you
1225: * actually need in AttributeValuePeer.
1226: *
1227: * @throws TorqueException Any exceptions caught during processing will be
1228: * rethrown wrapped into a TorqueException.
1229: */
1230: protected static List doSelectJoinAllExceptAttribute(
1231: Criteria criteria) throws TorqueException {
1232: return doSelectJoinAllExceptAttribute(criteria, null);
1233: }
1234:
1235: /**
1236: * selects a collection of AttributeValue objects pre-filled with
1237: * all related objects.
1238: *
1239: * This method is protected by default in order to keep the public
1240: * api reasonable. You can provide public methods for those you
1241: * actually need in AttributeValuePeer.
1242: *
1243: * @throws TorqueException Any exceptions caught during processing will be
1244: * rethrown wrapped into a TorqueException.
1245: */
1246: protected static List doSelectJoinAllExceptAttribute(
1247: Criteria criteria, Connection conn) throws TorqueException {
1248: setDbName(criteria);
1249:
1250: addSelectColumns(criteria);
1251: int offset2 = numColumns + 1;
1252:
1253: IssuePeer.addSelectColumns(criteria);
1254: criteria.addJoin(AttributeValuePeer.ISSUE_ID,
1255: IssuePeer.ISSUE_ID);
1256: int offset3 = offset2 + IssuePeer.numColumns;
1257:
1258: AttributeOptionPeer.addSelectColumns(criteria);
1259: criteria.addJoin(AttributeValuePeer.OPTION_ID,
1260: AttributeOptionPeer.OPTION_ID);
1261: int offset4 = offset3 + AttributeOptionPeer.numColumns;
1262:
1263: ScarabUserImplPeer.addSelectColumns(criteria);
1264: criteria.addJoin(AttributeValuePeer.USER_ID,
1265: ScarabUserImplPeer.USER_ID);
1266:
1267: correctBooleans(criteria);
1268:
1269: List rows;
1270: if (conn == null) {
1271: rows = BasePeer.doSelect(criteria);
1272: } else {
1273: rows = BasePeer.doSelect(criteria, conn);
1274: }
1275:
1276: List results = new ArrayList();
1277:
1278: for (int i = 0; i < rows.size(); i++) {
1279: Record row = (Record) rows.get(i);
1280:
1281: Class omClass = AttributeValuePeer.getOMClass(row, 1);
1282: AttributeValue obj1 = (AttributeValue) AttributeValuePeer
1283: .row2Object(row, 1, omClass);
1284:
1285: omClass = IssuePeer.getOMClass();
1286: Issue obj2 = (Issue) IssuePeer.row2Object(row, offset2,
1287: omClass);
1288:
1289: boolean newObject = true;
1290: for (int j = 0; j < results.size(); j++) {
1291: AttributeValue temp_obj1 = (AttributeValue) results
1292: .get(j);
1293: Issue temp_obj2 = (Issue) temp_obj1.getIssue();
1294: if (temp_obj2.getPrimaryKey().equals(
1295: obj2.getPrimaryKey())) {
1296: newObject = false;
1297: temp_obj2.addAttributeValue(obj1);
1298: break;
1299: }
1300: }
1301: if (newObject) {
1302: obj2.initAttributeValues();
1303: obj2.addAttributeValue(obj1);
1304: }
1305:
1306: omClass = AttributeOptionPeer.getOMClass();
1307: AttributeOption obj3 = (AttributeOption) AttributeOptionPeer
1308: .row2Object(row, offset3, omClass);
1309:
1310: newObject = true;
1311: for (int j = 0; j < results.size(); j++) {
1312: AttributeValue temp_obj1 = (AttributeValue) results
1313: .get(j);
1314: AttributeOption temp_obj3 = (AttributeOption) temp_obj1
1315: .getAttributeOption();
1316: if (temp_obj3.getPrimaryKey().equals(
1317: obj3.getPrimaryKey())) {
1318: newObject = false;
1319: temp_obj3.addAttributeValue(obj1);
1320: break;
1321: }
1322: }
1323: if (newObject) {
1324: obj3.initAttributeValues();
1325: obj3.addAttributeValue(obj1);
1326: }
1327:
1328: omClass = ScarabUserImplPeer.getOMClass();
1329: ScarabUserImpl obj4 = (ScarabUserImpl) ScarabUserImplPeer
1330: .row2Object(row, offset4, omClass);
1331:
1332: newObject = true;
1333: for (int j = 0; j < results.size(); j++) {
1334: AttributeValue temp_obj1 = (AttributeValue) results
1335: .get(j);
1336: ScarabUserImpl temp_obj4 = (ScarabUserImpl) temp_obj1
1337: .getScarabUser();
1338: if (temp_obj4.getPrimaryKey().equals(
1339: obj4.getPrimaryKey())) {
1340: newObject = false;
1341: temp_obj4.addAttributeValue(obj1);
1342: break;
1343: }
1344: }
1345: if (newObject) {
1346: obj4.initAttributeValues();
1347: obj4.addAttributeValue(obj1);
1348: }
1349: results.add(obj1);
1350: }
1351: return results;
1352: }
1353:
1354: /**
1355: * selects a collection of AttributeValue objects pre-filled with
1356: * all related objects.
1357: *
1358: * This method is protected by default in order to keep the public
1359: * api reasonable. You can provide public methods for those you
1360: * actually need in AttributeValuePeer.
1361: *
1362: * @throws TorqueException Any exceptions caught during processing will be
1363: * rethrown wrapped into a TorqueException.
1364: */
1365: protected static List doSelectJoinAllExceptAttributeOption(
1366: Criteria criteria) throws TorqueException {
1367: return doSelectJoinAllExceptAttributeOption(criteria, null);
1368: }
1369:
1370: /**
1371: * selects a collection of AttributeValue objects pre-filled with
1372: * all related objects.
1373: *
1374: * This method is protected by default in order to keep the public
1375: * api reasonable. You can provide public methods for those you
1376: * actually need in AttributeValuePeer.
1377: *
1378: * @throws TorqueException Any exceptions caught during processing will be
1379: * rethrown wrapped into a TorqueException.
1380: */
1381: protected static List doSelectJoinAllExceptAttributeOption(
1382: Criteria criteria, Connection conn) throws TorqueException {
1383: setDbName(criteria);
1384:
1385: addSelectColumns(criteria);
1386: int offset2 = numColumns + 1;
1387:
1388: IssuePeer.addSelectColumns(criteria);
1389: criteria.addJoin(AttributeValuePeer.ISSUE_ID,
1390: IssuePeer.ISSUE_ID);
1391: int offset3 = offset2 + IssuePeer.numColumns;
1392:
1393: AttributePeer.addSelectColumns(criteria);
1394: criteria.addJoin(AttributeValuePeer.ATTRIBUTE_ID,
1395: AttributePeer.ATTRIBUTE_ID);
1396: int offset4 = offset3 + AttributePeer.numColumns;
1397:
1398: ScarabUserImplPeer.addSelectColumns(criteria);
1399: criteria.addJoin(AttributeValuePeer.USER_ID,
1400: ScarabUserImplPeer.USER_ID);
1401:
1402: correctBooleans(criteria);
1403:
1404: List rows;
1405: if (conn == null) {
1406: rows = BasePeer.doSelect(criteria);
1407: } else {
1408: rows = BasePeer.doSelect(criteria, conn);
1409: }
1410:
1411: List results = new ArrayList();
1412:
1413: for (int i = 0; i < rows.size(); i++) {
1414: Record row = (Record) rows.get(i);
1415:
1416: Class omClass = AttributeValuePeer.getOMClass(row, 1);
1417: AttributeValue obj1 = (AttributeValue) AttributeValuePeer
1418: .row2Object(row, 1, omClass);
1419:
1420: omClass = IssuePeer.getOMClass();
1421: Issue obj2 = (Issue) IssuePeer.row2Object(row, offset2,
1422: omClass);
1423:
1424: boolean newObject = true;
1425: for (int j = 0; j < results.size(); j++) {
1426: AttributeValue temp_obj1 = (AttributeValue) results
1427: .get(j);
1428: Issue temp_obj2 = (Issue) temp_obj1.getIssue();
1429: if (temp_obj2.getPrimaryKey().equals(
1430: obj2.getPrimaryKey())) {
1431: newObject = false;
1432: temp_obj2.addAttributeValue(obj1);
1433: break;
1434: }
1435: }
1436: if (newObject) {
1437: obj2.initAttributeValues();
1438: obj2.addAttributeValue(obj1);
1439: }
1440:
1441: omClass = AttributePeer.getOMClass();
1442: Attribute obj3 = (Attribute) AttributePeer.row2Object(row,
1443: offset3, omClass);
1444:
1445: newObject = true;
1446: for (int j = 0; j < results.size(); j++) {
1447: AttributeValue temp_obj1 = (AttributeValue) results
1448: .get(j);
1449: Attribute temp_obj3 = (Attribute) temp_obj1
1450: .getAttribute();
1451: if (temp_obj3.getPrimaryKey().equals(
1452: obj3.getPrimaryKey())) {
1453: newObject = false;
1454: temp_obj3.addAttributeValue(obj1);
1455: break;
1456: }
1457: }
1458: if (newObject) {
1459: obj3.initAttributeValues();
1460: obj3.addAttributeValue(obj1);
1461: }
1462:
1463: omClass = ScarabUserImplPeer.getOMClass();
1464: ScarabUserImpl obj4 = (ScarabUserImpl) ScarabUserImplPeer
1465: .row2Object(row, offset4, omClass);
1466:
1467: newObject = true;
1468: for (int j = 0; j < results.size(); j++) {
1469: AttributeValue temp_obj1 = (AttributeValue) results
1470: .get(j);
1471: ScarabUserImpl temp_obj4 = (ScarabUserImpl) temp_obj1
1472: .getScarabUser();
1473: if (temp_obj4.getPrimaryKey().equals(
1474: obj4.getPrimaryKey())) {
1475: newObject = false;
1476: temp_obj4.addAttributeValue(obj1);
1477: break;
1478: }
1479: }
1480: if (newObject) {
1481: obj4.initAttributeValues();
1482: obj4.addAttributeValue(obj1);
1483: }
1484: results.add(obj1);
1485: }
1486: return results;
1487: }
1488:
1489: /**
1490: * selects a collection of AttributeValue objects pre-filled with
1491: * all related objects.
1492: *
1493: * This method is protected by default in order to keep the public
1494: * api reasonable. You can provide public methods for those you
1495: * actually need in AttributeValuePeer.
1496: *
1497: * @throws TorqueException Any exceptions caught during processing will be
1498: * rethrown wrapped into a TorqueException.
1499: */
1500: protected static List doSelectJoinAllExceptScarabUserImpl(
1501: Criteria criteria) throws TorqueException {
1502: return doSelectJoinAllExceptScarabUserImpl(criteria, null);
1503: }
1504:
1505: /**
1506: * selects a collection of AttributeValue objects pre-filled with
1507: * all related objects.
1508: *
1509: * This method is protected by default in order to keep the public
1510: * api reasonable. You can provide public methods for those you
1511: * actually need in AttributeValuePeer.
1512: *
1513: * @throws TorqueException Any exceptions caught during processing will be
1514: * rethrown wrapped into a TorqueException.
1515: */
1516: protected static List doSelectJoinAllExceptScarabUserImpl(
1517: Criteria criteria, Connection conn) throws TorqueException {
1518: setDbName(criteria);
1519:
1520: addSelectColumns(criteria);
1521: int offset2 = numColumns + 1;
1522:
1523: IssuePeer.addSelectColumns(criteria);
1524: criteria.addJoin(AttributeValuePeer.ISSUE_ID,
1525: IssuePeer.ISSUE_ID);
1526: int offset3 = offset2 + IssuePeer.numColumns;
1527:
1528: AttributePeer.addSelectColumns(criteria);
1529: criteria.addJoin(AttributeValuePeer.ATTRIBUTE_ID,
1530: AttributePeer.ATTRIBUTE_ID);
1531: int offset4 = offset3 + AttributePeer.numColumns;
1532:
1533: AttributeOptionPeer.addSelectColumns(criteria);
1534: criteria.addJoin(AttributeValuePeer.OPTION_ID,
1535: AttributeOptionPeer.OPTION_ID);
1536:
1537: correctBooleans(criteria);
1538:
1539: List rows;
1540: if (conn == null) {
1541: rows = BasePeer.doSelect(criteria);
1542: } else {
1543: rows = BasePeer.doSelect(criteria, conn);
1544: }
1545:
1546: List results = new ArrayList();
1547:
1548: for (int i = 0; i < rows.size(); i++) {
1549: Record row = (Record) rows.get(i);
1550:
1551: Class omClass = AttributeValuePeer.getOMClass(row, 1);
1552: AttributeValue obj1 = (AttributeValue) AttributeValuePeer
1553: .row2Object(row, 1, omClass);
1554:
1555: omClass = IssuePeer.getOMClass();
1556: Issue obj2 = (Issue) IssuePeer.row2Object(row, offset2,
1557: omClass);
1558:
1559: boolean newObject = true;
1560: for (int j = 0; j < results.size(); j++) {
1561: AttributeValue temp_obj1 = (AttributeValue) results
1562: .get(j);
1563: Issue temp_obj2 = (Issue) temp_obj1.getIssue();
1564: if (temp_obj2.getPrimaryKey().equals(
1565: obj2.getPrimaryKey())) {
1566: newObject = false;
1567: temp_obj2.addAttributeValue(obj1);
1568: break;
1569: }
1570: }
1571: if (newObject) {
1572: obj2.initAttributeValues();
1573: obj2.addAttributeValue(obj1);
1574: }
1575:
1576: omClass = AttributePeer.getOMClass();
1577: Attribute obj3 = (Attribute) AttributePeer.row2Object(row,
1578: offset3, omClass);
1579:
1580: newObject = true;
1581: for (int j = 0; j < results.size(); j++) {
1582: AttributeValue temp_obj1 = (AttributeValue) results
1583: .get(j);
1584: Attribute temp_obj3 = (Attribute) temp_obj1
1585: .getAttribute();
1586: if (temp_obj3.getPrimaryKey().equals(
1587: obj3.getPrimaryKey())) {
1588: newObject = false;
1589: temp_obj3.addAttributeValue(obj1);
1590: break;
1591: }
1592: }
1593: if (newObject) {
1594: obj3.initAttributeValues();
1595: obj3.addAttributeValue(obj1);
1596: }
1597:
1598: omClass = AttributeOptionPeer.getOMClass();
1599: AttributeOption obj4 = (AttributeOption) AttributeOptionPeer
1600: .row2Object(row, offset4, omClass);
1601:
1602: newObject = true;
1603: for (int j = 0; j < results.size(); j++) {
1604: AttributeValue temp_obj1 = (AttributeValue) results
1605: .get(j);
1606: AttributeOption temp_obj4 = (AttributeOption) temp_obj1
1607: .getAttributeOption();
1608: if (temp_obj4.getPrimaryKey().equals(
1609: obj4.getPrimaryKey())) {
1610: newObject = false;
1611: temp_obj4.addAttributeValue(obj1);
1612: break;
1613: }
1614: }
1615: if (newObject) {
1616: obj4.initAttributeValues();
1617: obj4.addAttributeValue(obj1);
1618: }
1619:
1620: results.add(obj1);
1621: }
1622: return results;
1623: }
1624:
1625: /**
1626: * Returns the TableMap related to this peer. This method is not
1627: * needed for general use but a specific application could have a need.
1628: *
1629: * @throws TorqueException Any exceptions caught during processing will be
1630: * rethrown wrapped into a TorqueException.
1631: */
1632: protected static TableMap getTableMap() throws TorqueException {
1633: return Torque.getDatabaseMap(DATABASE_NAME)
1634: .getTable(TABLE_NAME);
1635: }
1636:
1637: private static void setDbName(Criteria crit) {
1638: // Set the correct dbName if it has not been overridden
1639: // crit.getDbName will return the same object if not set to
1640: // another value so == check is okay and faster
1641: if (crit.getDbName() == Torque.getDefaultDB()) {
1642: crit.setDbName(DATABASE_NAME);
1643: }
1644: }
1645: }
|