Source Code Cross Referenced for BaseTransitionPeer.java in  » Issue-Tracking » scarab-0.21 » org » tigris » scarab » om » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Issue Tracking » scarab 0.21 » org.tigris.scarab.om 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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