1packageorg.apache.jetspeed.om.dbregistry;
23import java.math.BigDecimal;
4import java.sql.Connection;
5import java.sql.SQLException;
6import java.util.ArrayList;
7import java.util.Date;
8import java.util.Iterator;
9import java.util.LinkedList;
10import java.util.List;
1112import org.apache.torque.NoRowsException;
13import org.apache.torque.TooManyRowsException;
14import org.apache.torque.Torque;
15import org.apache.torque.TorqueException;
16import org.apache.torque.map.MapBuilder;
17import org.apache.torque.map.TableMap;
18import org.apache.torque.om.DateKey;
19import org.apache.torque.om.NumberKey;
20import org.apache.torque.om.StringKey;
21import org.apache.torque.om.ObjectKey;
22import org.apache.torque.om.SimpleKey;
23import org.apache.torque.util.BasePeer;
24import org.apache.torque.util.Criteria;
2526import com.workingdogs.village.DataSetException;
27import com.workingdogs.village.QueryDataSet;
28import com.workingdogs.village.Record;
2930// Local classes31importorg.apache.jetspeed.om.dbregistry.map.*;
323334/***35 * This class was autogenerated by Torque on:36 *37 * [Thu Apr 22 23:12:36 EDT 2004]38 *39 */40publicabstractclassBasePortletDbEntryPeer41extends BasePeer
42 {
4344/*** the default database name for this class */45publicstaticfinal String DATABASE_NAME = "default";
4647/*** the table name for this class */48publicstaticfinal String TABLE_NAME = "PORTLET";
4950/***51 * @return the map builder for this peer52 * @throws TorqueException Any exceptions caught during processing will be53 * rethrown wrapped into a TorqueException.54 */55publicstatic MapBuilder getMapBuilder()
56 throws TorqueException
57 {
58return getMapBuilder(PortletDbEntryMapBuilder.CLASS_NAME);
59 }
6061/*** the column name for the ID field */62publicstaticfinal String ID;
63/*** the column name for the NAME field */64publicstaticfinal String NAME;
65/*** the column name for the HIDDEN field */66publicstaticfinal String HIDDEN;
67/*** the column name for the CLASSNAME field */68publicstaticfinal String CLASSNAME;
69/*** the column name for the TYPE field */70publicstaticfinal String TYPE;
71/*** the column name for the APPLICATION field */72publicstaticfinal String APPLICATION;
73/*** the column name for the PARENT field */74publicstaticfinal String PARENT;
75/*** the column name for the URL field */76publicstaticfinal String URL;
77/*** the column name for the CACHEDONURL field */78publicstaticfinal String CACHEDONURL;
79/*** the column name for the ROLE field */80publicstaticfinal String ROLE;
81/*** the column name for the TITLE field */82publicstaticfinal String TITLE;
83/*** the column name for the DESCRIPTION field */84publicstaticfinal String DESCRIPTION;
85/*** the column name for the IMAGE field */86publicstaticfinal String IMAGE;
87/*** the column name for the SECURITY field */88publicstaticfinal String SECURITY;
8990static91 {
92 ID = "PORTLET.ID";
93 NAME = "PORTLET.NAME";
94 HIDDEN = "PORTLET.HIDDEN";
95 CLASSNAME = "PORTLET.CLASSNAME";
96 TYPE = "PORTLET.TYPE";
97 APPLICATION = "PORTLET.APPLICATION";
98 PARENT = "PORTLET.PARENT";
99 URL = "PORTLET.URL";
100 CACHEDONURL = "PORTLET.CACHEDONURL";
101 ROLE = "PORTLET.ROLE";
102 TITLE = "PORTLET.TITLE";
103 DESCRIPTION = "PORTLET.DESCRIPTION";
104 IMAGE = "PORTLET.IMAGE";
105 SECURITY = "PORTLET.SECURITY";
106if (Torque.isInit())
107 {
108try109 {
110 getMapBuilder();
111 }
112catch (Exception e)
113 {
114 log.error("Could not initialize Peer", e);
115 }
116 }
117else118 {
119 Torque.registerMapBuilder(PortletDbEntryMapBuilder.CLASS_NAME);
120 }
121 }
122123/*** number of columns for this peer */124publicstaticfinalint numColumns = 14;
125126/*** A class that can be returned by this peer. */127protectedstaticfinal String CLASSNAME_DEFAULT =
128"org.apache.jetspeed.om.dbregistry.PortletDbEntry";
129130/*** A class that can be returned by this peer. */131protectedstaticfinal Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
132133/***134 * Class object initialization method.135 *136 * @param className name of the class to initialize137 * @return the initialized class138 */139privatestatic Class initClass(String className)
140 {
141 Class c = null;
142try143 {
144 c = Class.forName(className);
145 }
146catch (Throwable t)
147 {
148 log.error("A FATAL ERROR has occurred which should not "149 + "have happened under any circumstance. Please notify "150 + "the Torque developers <turbine-torque-dev@jakarta.apache.org> "151 + "and give as many details as possible (including the error "152 + "stack trace).", t);
153154// Error objects should always be propogated.155if (t instanceof Error)
156 {
157throw (Error) t.fillInStackTrace();
158 }
159 }
160return c;
161 }
162163/***164 * Get the list of objects for a ResultSet. Please not that your165 * resultset MUST return columns in the right order. You can use166 * getFieldNames() in BaseObject to get the correct sequence.167 *168 * @param results the ResultSet169 * @return the list of objects170 * @throws TorqueException Any exceptions caught during processing will be171 * rethrown wrapped into a TorqueException.172 */173publicstatic List resultSet2Objects(java.sql.ResultSet results)
174 throws TorqueException
175 {
176try177 {
178 QueryDataSet qds = null;
179 List rows = null;
180try181 {
182 qds = new QueryDataSet(results);
183 rows = getSelectResults(qds);
184 }
185finally186 {
187if (qds != null)
188 {
189 qds.close();
190 }
191 }
192193return populateObjects(rows);
194 }
195catch (SQLException e)
196 {
197thrownew TorqueException(e);
198 }
199catch (DataSetException e)
200 {
201thrownew TorqueException(e);
202 }
203 }
204205206207/***208 * Method to do inserts.209 *210 * @param criteria object used to create the INSERT statement.211 * @throws TorqueException Any exceptions caught during processing will be212 * rethrown wrapped into a TorqueException.213 */214publicstatic ObjectKey doInsert(Criteria criteria)
215 throws TorqueException
216 {
217returnBasePortletDbEntryPeer218 .doInsert(criteria, (Connection) null);
219 }
220221/***222 * Method to do inserts. This method is to be used during a transaction,223 * otherwise use the doInsert(Criteria) method. It will take care of224 * the connection details internally.225 *226 * @param criteria object used to create the INSERT statement.227 * @param con the connection to use228 * @throws TorqueException Any exceptions caught during processing will be229 * rethrown wrapped into a TorqueException.230 */231publicstatic ObjectKey doInsert(Criteria criteria, Connection con)
232 throws TorqueException
233 {
234// check for conversion from boolean to int235if (criteria.containsKey(HIDDEN))
236 {
237 Object possibleBoolean = criteria.get(HIDDEN);
238if (possibleBoolean instanceof Boolean)
239 {
240if (((Boolean) possibleBoolean).booleanValue())
241 {
242 criteria.add(HIDDEN, 1);
243 }
244else245 {
246 criteria.add(HIDDEN, 0);
247 }
248 }
249 }
250// check for conversion from boolean to int251if (criteria.containsKey(APPLICATION))
252 {
253 Object possibleBoolean = criteria.get(APPLICATION);
254if (possibleBoolean instanceof Boolean)
255 {
256if (((Boolean) possibleBoolean).booleanValue())
257 {
258 criteria.add(APPLICATION, 1);
259 }
260else261 {
262 criteria.add(APPLICATION, 0);
263 }
264 }
265 }
266// check for conversion from boolean to int267if (criteria.containsKey(CACHEDONURL))
268 {
269 Object possibleBoolean = criteria.get(CACHEDONURL);
270if (possibleBoolean instanceof Boolean)
271 {
272if (((Boolean) possibleBoolean).booleanValue())
273 {
274 criteria.add(CACHEDONURL, 1);
275 }
276else277 {
278 criteria.add(CACHEDONURL, 0);
279 }
280 }
281 }
282283// Set the correct dbName if it has not been overridden284// criteria.getDbName will return the same object if not set to285// another value so == check is okay and faster286if (criteria.getDbName() == Torque.getDefaultDB())
287 {
288 criteria.setDbName(DATABASE_NAME);
289 }
290if (con == null)
291 {
292return BasePeer.doInsert(criteria);
293 }
294else295 {
296return BasePeer.doInsert(criteria, con);
297 }
298 }
299300/***301 * Add all the columns needed to create a new object.302 *303 * @param criteria object containing the columns to add.304 * @throws TorqueException Any exceptions caught during processing will be305 * rethrown wrapped into a TorqueException.306 */307publicstaticvoid addSelectColumns(Criteria criteria)
308 throws TorqueException
309 {
310 criteria.addSelectColumn(ID);
311 criteria.addSelectColumn(NAME);
312 criteria.addSelectColumn(HIDDEN);
313 criteria.addSelectColumn(CLASSNAME);
314 criteria.addSelectColumn(TYPE);
315 criteria.addSelectColumn(APPLICATION);
316 criteria.addSelectColumn(PARENT);
317 criteria.addSelectColumn(URL);
318 criteria.addSelectColumn(CACHEDONURL);
319 criteria.addSelectColumn(ROLE);
320 criteria.addSelectColumn(TITLE);
321 criteria.addSelectColumn(DESCRIPTION);
322 criteria.addSelectColumn(IMAGE);
323 criteria.addSelectColumn(SECURITY);
324 }
325326/***327 * Create a new object of type cls from a resultset row starting328 * from a specified offset. This is done so that you can select329 * other rows than just those needed for this object. You may330 * for example want to create two objects from the same row.331 *332 * @throws TorqueException Any exceptions caught during processing will be333 * rethrown wrapped into a TorqueException.334 */335publicstaticPortletDbEntry row2Object(Record row,
336int offset,
337 Class cls)
338 throws TorqueException
339 {
340try341 {
342PortletDbEntry obj = (PortletDbEntry) cls.newInstance();
343 PortletDbEntryPeer.populateObject(row, offset, obj);
344 obj.setModified(false);
345 obj.setNew(false);
346347return obj;
348 }
349catch (InstantiationException e)
350 {
351thrownew TorqueException(e);
352 }
353catch (IllegalAccessException e)
354 {
355thrownew TorqueException(e);
356 }
357 }
358359/***360 * Populates an object from a resultset row starting361 * from a specified offset. This is done so that you can select362 * other rows than just those needed for this object. You may363 * for example want to create two objects from the same row.364 *365 * @throws TorqueException Any exceptions caught during processing will be366 * rethrown wrapped into a TorqueException.367 */368publicstaticvoid populateObject(Record row,
369int offset,
370PortletDbEntry obj)
371 throws TorqueException
372 {
373try374 {
375 obj.setId(row.getValue(offset + 0).asLong());
376 obj.setName(row.getValue(offset + 1).asString());
377 obj.setHidden(row.getValue(offset + 2).asBoolean());
378 obj.setClassname(row.getValue(offset + 3).asString());
379 obj.setType(row.getValue(offset + 4).asString());
380 obj.setApplication(row.getValue(offset + 5).asBoolean());
381 obj.setParentRef(row.getValue(offset + 6).asLong());
382 obj.setURL(row.getValue(offset + 7).asString());
383 obj.setCachedonurl(row.getValue(offset + 8).asBoolean());
384 obj.setRole(row.getValue(offset + 9).asString());
385 obj.setTitle(row.getValue(offset + 10).asString());
386 obj.setDescription(row.getValue(offset + 11).asString());
387 obj.setImage(row.getValue(offset + 12).asString());
388 obj.setSecurityRef(row.getValue(offset + 13).asString());
389 }
390catch (DataSetException e)
391 {
392thrownew TorqueException(e);
393 }
394 }
395396/***397 * Method to do selects.398 *399 * @param criteria object used to create the SELECT statement.400 * @return List of selected Objects401 * @throws TorqueException Any exceptions caught during processing will be402 * rethrown wrapped into a TorqueException.403 */404publicstatic List doSelect(Criteria criteria) throws TorqueException
405 {
406return populateObjects(doSelectVillageRecords(criteria));
407 }
408409/***410 * Method to do selects within a transaction.411 *412 * @param criteria object used to create the SELECT statement.413 * @param con the connection to use414 * @return List of selected Objects415 * @throws TorqueException Any exceptions caught during processing will be416 * rethrown wrapped into a TorqueException.417 */418publicstatic List doSelect(Criteria criteria, Connection con)
419 throws TorqueException
420 {
421return populateObjects(doSelectVillageRecords(criteria, con));
422 }
423424/***425 * Grabs the raw Village records to be formed into objects.426 * This method handles connections internally. The Record objects427 * returned by this method should be considered readonly. Do not428 * alter the data and call save(), your results may vary, but are429 * certainly likely to result in hard to track MT bugs.430 *431 * @throws TorqueException Any exceptions caught during processing will be432 * rethrown wrapped into a TorqueException.433 */434publicstatic List doSelectVillageRecords(Criteria criteria)
435 throws TorqueException
436 {
437returnBasePortletDbEntryPeer438 .doSelectVillageRecords(criteria, (Connection) null);
439 }
440441/***442 * Grabs the raw Village records to be formed into objects.443 * This method should be used for transactions444 *445 * @param con the connection to use446 * @throws TorqueException Any exceptions caught during processing will be447 * rethrown wrapped into a TorqueException.448 */449publicstatic List doSelectVillageRecords(Criteria criteria, Connection con)
450 throws TorqueException
451 {
452if (criteria.getSelectColumns().size() == 0)
453 {
454 addSelectColumns(criteria);
455 }
456457// check for conversion from boolean to int458if (criteria.containsKey(HIDDEN))
459 {
460 Object possibleBoolean = criteria.get(HIDDEN);
461if (possibleBoolean instanceof Boolean)
462 {
463if (((Boolean) possibleBoolean).booleanValue())
464 {
465 criteria.add(HIDDEN, 1);
466 }
467else468 {
469 criteria.add(HIDDEN, 0);
470 }
471 }
472 }
473// check for conversion from boolean to int474if (criteria.containsKey(APPLICATION))
475 {
476 Object possibleBoolean = criteria.get(APPLICATION);
477if (possibleBoolean instanceof Boolean)
478 {
479if (((Boolean) possibleBoolean).booleanValue())
480 {
481 criteria.add(APPLICATION, 1);
482 }
483else484 {
485 criteria.add(APPLICATION, 0);
486 }
487 }
488 }
489// check for conversion from boolean to int490if (criteria.containsKey(CACHEDONURL))
491 {
492 Object possibleBoolean = criteria.get(CACHEDONURL);
493if (possibleBoolean instanceof Boolean)
494 {
495if (((Boolean) possibleBoolean).booleanValue())
496 {
497 criteria.add(CACHEDONURL, 1);
498 }
499else500 {
501 criteria.add(CACHEDONURL, 0);
502 }
503 }
504 }
505506// Set the correct dbName if it has not been overridden507// criteria.getDbName will return the same object if not set to508// another value so == check is okay and faster509if (criteria.getDbName() == Torque.getDefaultDB())
510 {
511 criteria.setDbName(DATABASE_NAME);
512 }
513// BasePeer returns a List of Value (Village) arrays. The array514// order follows the order columns were placed in the Select clause.515if (con == null)
516 {
517return BasePeer.doSelect(criteria);
518 }
519else520 {
521return BasePeer.doSelect(criteria, con);
522 }
523 }
524525/***526 * The returned List will contain objects of the default type or527 * objects that inherit from the default.528 *529 * @throws TorqueException Any exceptions caught during processing will be530 * rethrown wrapped into a TorqueException.531 */532publicstatic List populateObjects(List records)
533 throws TorqueException
534 {
535 List results = new ArrayList(records.size());
536537// populate the object(s)538for (int i = 0; i < records.size(); i++)
539 {
540 Record row = (Record) records.get(i);
541 results.add(PortletDbEntryPeer.row2Object(row, 1,
542 PortletDbEntryPeer.getOMClass()));
543 }
544return results;
545 }
546547548/***549 * The class that the Peer will make instances of.550 * If the BO is abstract then you must implement this method551 * in the BO.552 *553 * @throws TorqueException Any exceptions caught during processing will be554 * rethrown wrapped into a TorqueException.555 */556publicstatic Class getOMClass()
557 throws TorqueException
558 {
559return CLASS_DEFAULT;
560 }
561562/***563 * Method to do updates.564 *565 * @param criteria object containing data that is used to create the UPDATE566 * statement.567 * @throws TorqueException Any exceptions caught during processing will be568 * rethrown wrapped into a TorqueException.569 */570publicstaticvoid doUpdate(Criteria criteria) throws TorqueException
571 {
572BasePortletDbEntryPeer573 .doUpdate(criteria, (Connection) null);
574 }
575576/***577 * Method to do updates. This method is to be used during a transaction,578 * otherwise use the doUpdate(Criteria) method. It will take care of579 * the connection details internally.580 *581 * @param criteria object containing data that is used to create the UPDATE582 * statement.583 * @param con the connection to use584 * @throws TorqueException Any exceptions caught during processing will be585 * rethrown wrapped into a TorqueException.586 */587publicstaticvoid doUpdate(Criteria criteria, Connection con)
588 throws TorqueException
589 {
590 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
591 selectCriteria.put(ID, criteria.remove(ID));
592// check for conversion from boolean to int593if (criteria.containsKey(HIDDEN))
594 {
595 Object possibleBoolean = criteria.get(HIDDEN);
596if (possibleBoolean instanceof Boolean)
597 {
598if (((Boolean) possibleBoolean).booleanValue())
599 {
600 criteria.add(HIDDEN, 1);
601 }
602else603 {
604 criteria.add(HIDDEN, 0);
605 }
606 }
607 }
608// check for conversion from boolean to int609if (criteria.containsKey(APPLICATION))
610 {
611 Object possibleBoolean = criteria.get(APPLICATION);
612if (possibleBoolean instanceof Boolean)
613 {
614if (((Boolean) possibleBoolean).booleanValue())
615 {
616 criteria.add(APPLICATION, 1);
617 }
618else619 {
620 criteria.add(APPLICATION, 0);
621 }
622 }
623 }
624// check for conversion from boolean to int625if (criteria.containsKey(CACHEDONURL))
626 {
627 Object possibleBoolean = criteria.get(CACHEDONURL);
628if (possibleBoolean instanceof Boolean)
629 {
630if (((Boolean) possibleBoolean).booleanValue())
631 {
632 criteria.add(CACHEDONURL, 1);
633 }
634else635 {
636 criteria.add(CACHEDONURL, 0);
637 }
638 }
639 }
640641// Set the correct dbName if it has not been overridden642// criteria.getDbName will return the same object if not set to643// another value so == check is okay and faster644if (criteria.getDbName() == Torque.getDefaultDB())
645 {
646 criteria.setDbName(DATABASE_NAME);
647 }
648if (con == null)
649 {
650 BasePeer.doUpdate(selectCriteria, criteria);
651 }
652else653 {
654 BasePeer.doUpdate(selectCriteria, criteria, con);
655 }
656 }
657658/***659 * Method to do deletes.660 *661 * @param criteria object containing data that is used DELETE from database.662 * @throws TorqueException Any exceptions caught during processing will be663 * rethrown wrapped into a TorqueException.664 */665publicstaticvoid doDelete(Criteria criteria) throws TorqueException
666 {
667BasePortletDbEntryPeer668 .doDelete(criteria, (Connection) null);
669 }
670671/***672 * Method to do deletes. This method is to be used during a transaction,673 * otherwise use the doDelete(Criteria) method. It will take care of674 * the connection details internally.675 *676 * @param criteria object containing data that is used DELETE from database.677 * @param con the connection to use678 * @throws TorqueException Any exceptions caught during processing will be679 * rethrown wrapped into a TorqueException.680 */681publicstaticvoid doDelete(Criteria criteria, Connection con)
682 throws TorqueException
683 {
684// check for conversion from boolean to int685if (criteria.containsKey(HIDDEN))
686 {
687 Object possibleBoolean = criteria.get(HIDDEN);
688if (possibleBoolean instanceof Boolean)
689 {
690if (((Boolean) possibleBoolean).booleanValue())
691 {
692 criteria.add(HIDDEN, 1);
693 }
694else695 {
696 criteria.add(HIDDEN, 0);
697 }
698 }
699 }
700// check for conversion from boolean to int701if (criteria.containsKey(APPLICATION))
702 {
703 Object possibleBoolean = criteria.get(APPLICATION);
704if (possibleBoolean instanceof Boolean)
705 {
706if (((Boolean) possibleBoolean).booleanValue())
707 {
708 criteria.add(APPLICATION, 1);
709 }
710else711 {
712 criteria.add(APPLICATION, 0);
713 }
714 }
715 }
716// check for conversion from boolean to int717if (criteria.containsKey(CACHEDONURL))
718 {
719 Object possibleBoolean = criteria.get(CACHEDONURL);
720if (possibleBoolean instanceof Boolean)
721 {
722if (((Boolean) possibleBoolean).booleanValue())
723 {
724 criteria.add(CACHEDONURL, 1);
725 }
726else727 {
728 criteria.add(CACHEDONURL, 0);
729 }
730 }
731 }
732733// Set the correct dbName if it has not been overridden734// criteria.getDbName will return the same object if not set to735// another value so == check is okay and faster736if (criteria.getDbName() == Torque.getDefaultDB())
737 {
738 criteria.setDbName(DATABASE_NAME);
739 }
740if (con == null)
741 {
742 BasePeer.doDelete(criteria);
743 }
744else745 {
746 BasePeer.doDelete(criteria, con);
747 }
748 }
749750/***751 * Method to do selects752 *753 * @throws TorqueException Any exceptions caught during processing will be754 * rethrown wrapped into a TorqueException.755 */756publicstatic List doSelect(PortletDbEntry obj) throws TorqueException
757 {
758return doSelect(buildCriteria(obj));
759 }
760761/***762 * Method to do inserts763 *764 * @throws TorqueException Any exceptions caught during processing will be765 * rethrown wrapped into a TorqueException.766 */767publicstaticvoid doInsert(PortletDbEntry obj) throws TorqueException
768 {
769 obj.setPrimaryKey(doInsert(buildCriteria(obj)));
770 obj.setNew(false);
771 obj.setModified(false);
772 }
773774/***775 * @param obj the data object to update in the database.776 * @throws TorqueException Any exceptions caught during processing will be777 * rethrown wrapped into a TorqueException.778 */779publicstaticvoid doUpdate(PortletDbEntry obj) throws TorqueException
780 {
781 doUpdate(buildCriteria(obj));
782 obj.setModified(false);
783 }
784785/***786 * @param obj the data object to delete in the database.787 * @throws TorqueException Any exceptions caught during processing will be788 * rethrown wrapped into a TorqueException.789 */790publicstaticvoid doDelete(PortletDbEntry obj) throws TorqueException
791 {
792 doDelete(buildCriteria(obj));
793 }
794795/***796 * Method to do inserts. This method is to be used during a transaction,797 * otherwise use the doInsert(PortletDbEntry) method. It will take798 * care of the connection details internally.799 *800 * @param obj the data object to insert into the database.801 * @param con the connection to use802 * @throws TorqueException Any exceptions caught during processing will be803 * rethrown wrapped into a TorqueException.804 */805publicstaticvoid doInsert(PortletDbEntry obj, Connection con)
806 throws TorqueException
807 {
808 obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
809 obj.setNew(false);
810 obj.setModified(false);
811 }
812813/***814 * Method to do update. This method is to be used during a transaction,815 * otherwise use the doUpdate(PortletDbEntry) method. It will take816 * care of the connection details internally.817 *818 * @param obj the data object to update in the database.819 * @param con the connection to use820 * @throws TorqueException Any exceptions caught during processing will be821 * rethrown wrapped into a TorqueException.822 */823publicstaticvoid doUpdate(PortletDbEntry obj, Connection con)
824 throws TorqueException
825 {
826 doUpdate(buildCriteria(obj), con);
827 obj.setModified(false);
828 }
829830/***831 * Method to delete. This method is to be used during a transaction,832 * otherwise use the doDelete(PortletDbEntry) method. It will take833 * care of the connection details internally.834 *835 * @param obj the data object to delete in the database.836 * @param con the connection to use837 * @throws TorqueException Any exceptions caught during processing will be838 * rethrown wrapped into a TorqueException.839 */840publicstaticvoid doDelete(PortletDbEntry obj, Connection con)
841 throws TorqueException
842 {
843 doDelete(buildCriteria(obj), con);
844 }
845846/***847 * Method to do deletes.848 *849 * @param pk ObjectKey that is used DELETE from database.850 * @throws TorqueException Any exceptions caught during processing will be851 * rethrown wrapped into a TorqueException.852 */853publicstaticvoid doDelete(ObjectKey pk) throws TorqueException
854 {
855BasePortletDbEntryPeer856 .doDelete(pk, (Connection) null);
857 }
858859/***860 * Method to delete. This method is to be used during a transaction,861 * otherwise use the doDelete(ObjectKey) method. It will take862 * care of the connection details internally.863 *864 * @param pk the primary key for the object to delete in the database.865 * @param con the connection to use866 * @throws TorqueException Any exceptions caught during processing will be867 * rethrown wrapped into a TorqueException.868 */869publicstaticvoid doDelete(ObjectKey pk, Connection con)
870 throws TorqueException
871 {
872 doDelete(buildCriteria(pk), con);
873 }
874875/*** Build a Criteria object from an ObjectKey */876publicstatic Criteria buildCriteria( ObjectKey pk )
877 {
878 Criteria criteria = new Criteria();
879 criteria.add(ID, pk);
880return criteria;
881 }
882883/*** Build a Criteria object from the data object for this peer */884publicstatic Criteria buildCriteria( PortletDbEntry obj )
885 {
886 Criteria criteria = new Criteria(DATABASE_NAME);
887if (!obj.isNew())
888 criteria.add(ID, obj.getId());
889 criteria.add(NAME, obj.getName());
890 criteria.add(HIDDEN, obj.getHidden());
891 criteria.add(CLASSNAME, obj.getClassname());
892 criteria.add(TYPE, obj.getType());
893 criteria.add(APPLICATION, obj.getApplication());
894 criteria.add(PARENT, obj.getParentRef());
895 criteria.add(URL, obj.getURL());
896 criteria.add(CACHEDONURL, obj.getCachedonurl());
897 criteria.add(ROLE, obj.getRole());
898 criteria.add(TITLE, obj.getTitle());
899 criteria.add(DESCRIPTION, obj.getDescription());
900 criteria.add(IMAGE, obj.getImage());
901 criteria.add(SECURITY, obj.getSecurityRef());
902return criteria;
903 }
904905906/***907 * Retrieve a single object by pk908 *909 * @param pk the primary key910 * @throws TorqueException Any exceptions caught during processing will be911 * rethrown wrapped into a TorqueException.912 * @throws NoRowsException Primary key was not found in database.913 * @throws TooManyRowsException Primary key was not found in database.914 */915publicstaticPortletDbEntry retrieveByPK(long pk)
916 throws TorqueException, NoRowsException, TooManyRowsException
917 {
918return retrieveByPK(SimpleKey.keyFor(pk));
919 }
920921/***922 * Retrieve a single object by pk923 *924 * @param pk the primary key925 * @throws TorqueException Any exceptions caught during processing will be926 * rethrown wrapped into a TorqueException.927 * @throws NoRowsException Primary key was not found in database.928 * @throws TooManyRowsException Primary key was not found in database.929 */930publicstaticPortletDbEntry retrieveByPK(ObjectKey pk)
931 throws TorqueException, NoRowsException, TooManyRowsException
932 {
933 Connection db = null;
934PortletDbEntry retVal = null;
935try936 {
937 db = Torque.getConnection(DATABASE_NAME);
938 retVal = retrieveByPK(pk, db);
939 }
940finally941 {
942 Torque.closeConnection(db);
943 }
944return(retVal);
945 }
946947/***948 * Retrieve a single object by pk949 *950 * @param pk the primary key951 * @param con the connection to use952 * @throws TorqueException Any exceptions caught during processing will be953 * rethrown wrapped into a TorqueException.954 * @throws NoRowsException Primary key was not found in database.955 * @throws TooManyRowsException Primary key was not found in database.956 */957publicstaticPortletDbEntry retrieveByPK(ObjectKey pk, Connection con)
958 throws TorqueException, NoRowsException, TooManyRowsException
959 {
960 Criteria criteria = buildCriteria(pk);
961 List v = doSelect(criteria, con);
962if (v.size() == 0)
963 {
964thrownew NoRowsException("Failed to select a row.");
965 }
966elseif (v.size() > 1)
967 {
968thrownew TooManyRowsException("Failed to select only one row.");
969 }
970else971 {
972return (PortletDbEntry)v.get(0);
973 }
974 }
975976/***977 * Retrieve a multiple objects by pk978 *979 * @param pks List of primary keys980 * @throws TorqueException Any exceptions caught during processing will be981 * rethrown wrapped into a TorqueException.982 */983publicstatic List retrieveByPKs(List pks)
984 throws TorqueException
985 {
986 Connection db = null;
987 List retVal = null;
988try989 {
990 db = Torque.getConnection(DATABASE_NAME);
991 retVal = retrieveByPKs(pks, db);
992 }
993finally994 {
995 Torque.closeConnection(db);
996 }
997return(retVal);
998 }
9991000/***1001 * Retrieve a multiple objects by pk1002 *1003 * @param pks List of primary keys1004 * @param dbcon the connection to use1005 * @throws TorqueException Any exceptions caught during processing will be1006 * rethrown wrapped into a TorqueException.1007 */1008publicstatic List retrieveByPKs( List pks, Connection dbcon )
1009 throws TorqueException
1010 {
1011 List objs = null;
1012if (pks == null || pks.size() == 0)
1013 {
1014 objs = new LinkedList();
1015 }
1016else1017 {
1018 Criteria criteria = new Criteria();
1019 criteria.addIn( ID, pks );
1020 objs = doSelect(criteria, dbcon);
1021 }
1022return objs;
1023 }
10241025102610271028102910301031103210331034/***1035 * Returns the TableMap related to this peer. This method is not1036 * needed for general use but a specific application could have a need.1037 *1038 * @throws TorqueException Any exceptions caught during processing will be1039 * rethrown wrapped into a TorqueException.1040 */1041protectedstatic TableMap getTableMap()
1042 throws TorqueException
1043 {
1044return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1045 }
1046 }