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