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