%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.services.security.torque.om.BaseTurbineRolePermissionPeer |
|
|
1 | package org.apache.turbine.services.security.torque.om; |
|
2 | ||
3 | import java.math.BigDecimal; |
|
4 | import java.sql.Connection; |
|
5 | import java.sql.SQLException; |
|
6 | import java.util.ArrayList; |
|
7 | import java.util.Date; |
|
8 | import java.util.Iterator; |
|
9 | import java.util.LinkedList; |
|
10 | import java.util.List; |
|
11 | ||
12 | import org.apache.torque.NoRowsException; |
|
13 | import org.apache.torque.TooManyRowsException; |
|
14 | import org.apache.torque.Torque; |
|
15 | import org.apache.torque.TorqueException; |
|
16 | import org.apache.torque.map.MapBuilder; |
|
17 | import org.apache.torque.map.TableMap; |
|
18 | import org.apache.torque.om.DateKey; |
|
19 | import org.apache.torque.om.NumberKey; |
|
20 | import org.apache.torque.om.StringKey; |
|
21 | import org.apache.torque.om.ObjectKey; |
|
22 | import org.apache.torque.om.SimpleKey; |
|
23 | import org.apache.torque.util.BasePeer; |
|
24 | import org.apache.torque.util.Criteria; |
|
25 | ||
26 | import com.workingdogs.village.DataSetException; |
|
27 | import com.workingdogs.village.QueryDataSet; |
|
28 | import com.workingdogs.village.Record; |
|
29 | ||
30 | // Local classes |
|
31 | import org.apache.turbine.services.security.torque.om.map.*; |
|
32 | ||
33 | ||
34 | ||
35 | ||
36 | /** |
|
37 | * This class was autogenerated by Torque on: |
|
38 | * |
|
39 | * [Mon Oct 03 14:24:58 CEST 2005] |
|
40 | * |
|
41 | */ |
|
42 | 6 | public abstract class BaseTurbineRolePermissionPeer |
43 | extends BasePeer |
|
44 | { |
|
45 | ||
46 | /** the default database name for this class */ |
|
47 | public static final String DATABASE_NAME = "default"; |
|
48 | ||
49 | /** the table name for this class */ |
|
50 | public static final String TABLE_NAME = "TURBINE_ROLE_PERMISSION"; |
|
51 | ||
52 | /** |
|
53 | * @return the map builder for this peer |
|
54 | * @throws TorqueException Any exceptions caught during processing will be |
|
55 | * rethrown wrapped into a TorqueException. |
|
56 | */ |
|
57 | public static MapBuilder getMapBuilder() |
|
58 | throws TorqueException |
|
59 | { |
|
60 | 0 | return getMapBuilder(TurbineRolePermissionMapBuilder.CLASS_NAME); |
61 | } |
|
62 | ||
63 | /** the column name for the ROLE_ID field */ |
|
64 | public static final String ROLE_ID; |
|
65 | /** the column name for the PERMISSION_ID field */ |
|
66 | public static final String PERMISSION_ID; |
|
67 | ||
68 | static |
|
69 | 3 | { |
70 | 6 | ROLE_ID = "TURBINE_ROLE_PERMISSION.ROLE_ID"; |
71 | 6 | PERMISSION_ID = "TURBINE_ROLE_PERMISSION.PERMISSION_ID"; |
72 | 6 | if (Torque.isInit()) |
73 | { |
|
74 | try |
|
75 | { |
|
76 | 6 | getMapBuilder(TurbineRolePermissionMapBuilder.CLASS_NAME); |
77 | 3 | } |
78 | 0 | catch (Exception e) |
79 | { |
|
80 | 0 | log.error("Could not initialize Peer", e); |
81 | 6 | } |
82 | } |
|
83 | else |
|
84 | { |
|
85 | 0 | Torque.registerMapBuilder(TurbineRolePermissionMapBuilder.CLASS_NAME); |
86 | } |
|
87 | } |
|
88 | ||
89 | /** number of columns for this peer */ |
|
90 | public static final int numColumns = 2; |
|
91 | ||
92 | /** A class that can be returned by this peer. */ |
|
93 | protected static final String CLASSNAME_DEFAULT = |
|
94 | "org.apache.turbine.services.security.torque.om.TurbineRolePermission"; |
|
95 | ||
96 | /** A class that can be returned by this peer. */ |
|
97 | 6 | protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); |
98 | ||
99 | /** |
|
100 | * Class object initialization method. |
|
101 | * |
|
102 | * @param className name of the class to initialize |
|
103 | * @return the initialized class |
|
104 | */ |
|
105 | private static Class initClass(String className) |
|
106 | { |
|
107 | 6 | Class c = null; |
108 | try |
|
109 | { |
|
110 | 6 | c = Class.forName(className); |
111 | 3 | } |
112 | 0 | catch (Throwable t) |
113 | { |
|
114 | 0 | log.error("A FATAL ERROR has occurred which should not " |
115 | + "have happened under any circumstance. Please notify " |
|
116 | + "the Torque developers <torque-dev@db.apache.org> " |
|
117 | + "and give as many details as possible (including the error " |
|
118 | + "stack trace).", t); |
|
119 | ||
120 | // Error objects should always be propogated. |
|
121 | 0 | if (t instanceof Error) |
122 | { |
|
123 | 0 | throw (Error) t.fillInStackTrace(); |
124 | } |
|
125 | 3 | } |
126 | 6 | return c; |
127 | } |
|
128 | ||
129 | /** |
|
130 | * Get the list of objects for a ResultSet. Please not that your |
|
131 | * resultset MUST return columns in the right order. You can use |
|
132 | * getFieldNames() in BaseObject to get the correct sequence. |
|
133 | * |
|
134 | * @param results the ResultSet |
|
135 | * @return the list of objects |
|
136 | * @throws TorqueException Any exceptions caught during processing will be |
|
137 | * rethrown wrapped into a TorqueException. |
|
138 | */ |
|
139 | public static List resultSet2Objects(java.sql.ResultSet results) |
|
140 | throws TorqueException |
|
141 | { |
|
142 | try |
|
143 | { |
|
144 | 0 | QueryDataSet qds = null; |
145 | 0 | List rows = null; |
146 | try |
|
147 | { |
|
148 | 0 | qds = new QueryDataSet(results); |
149 | 0 | rows = getSelectResults(qds); |
150 | } |
|
151 | finally |
|
152 | { |
|
153 | 0 | if (qds != null) |
154 | { |
|
155 | 0 | qds.close(); |
156 | } |
|
157 | } |
|
158 | ||
159 | 0 | return populateObjects(rows); |
160 | } |
|
161 | 0 | catch (SQLException e) |
162 | { |
|
163 | 0 | throw new TorqueException(e); |
164 | } |
|
165 | 0 | catch (DataSetException e) |
166 | { |
|
167 | 0 | throw new TorqueException(e); |
168 | } |
|
169 | } |
|
170 | ||
171 | ||
172 | ||
173 | /** |
|
174 | * Method to do inserts. |
|
175 | * |
|
176 | * @param criteria object used to create the INSERT statement. |
|
177 | * @throws TorqueException Any exceptions caught during processing will be |
|
178 | * rethrown wrapped into a TorqueException. |
|
179 | */ |
|
180 | public static ObjectKey doInsert(Criteria criteria) |
|
181 | throws TorqueException |
|
182 | { |
|
183 | 4 | return BaseTurbineRolePermissionPeer |
184 | .doInsert(criteria, (Connection) null); |
|
185 | } |
|
186 | ||
187 | /** |
|
188 | * Method to do inserts. This method is to be used during a transaction, |
|
189 | * otherwise use the doInsert(Criteria) method. It will take care of |
|
190 | * the connection details internally. |
|
191 | * |
|
192 | * @param criteria object used to create the INSERT statement. |
|
193 | * @param con the connection to use |
|
194 | * @throws TorqueException Any exceptions caught during processing will be |
|
195 | * rethrown wrapped into a TorqueException. |
|
196 | */ |
|
197 | public static ObjectKey doInsert(Criteria criteria, Connection con) |
|
198 | throws TorqueException |
|
199 | { |
|
200 | ||
201 | 4 | setDbName(criteria); |
202 | ||
203 | 4 | if (con == null) |
204 | { |
|
205 | 4 | return BasePeer.doInsert(criteria); |
206 | } |
|
207 | else |
|
208 | { |
|
209 | 0 | return BasePeer.doInsert(criteria, con); |
210 | } |
|
211 | } |
|
212 | ||
213 | /** |
|
214 | * Add all the columns needed to create a new object. |
|
215 | * |
|
216 | * @param criteria object containing the columns to add. |
|
217 | * @throws TorqueException Any exceptions caught during processing will be |
|
218 | * rethrown wrapped into a TorqueException. |
|
219 | */ |
|
220 | public static void addSelectColumns(Criteria criteria) |
|
221 | throws TorqueException |
|
222 | { |
|
223 | 0 | criteria.addSelectColumn(ROLE_ID); |
224 | 0 | criteria.addSelectColumn(PERMISSION_ID); |
225 | 0 | } |
226 | ||
227 | /** |
|
228 | * Create a new object of type cls from a resultset row starting |
|
229 | * from a specified offset. This is done so that you can select |
|
230 | * other rows than just those needed for this object. You may |
|
231 | * for example want to create two objects from the same row. |
|
232 | * |
|
233 | * @throws TorqueException Any exceptions caught during processing will be |
|
234 | * rethrown wrapped into a TorqueException. |
|
235 | */ |
|
236 | public static TurbineRolePermission row2Object(Record row, |
|
237 | int offset, |
|
238 | Class cls) |
|
239 | throws TorqueException |
|
240 | { |
|
241 | try |
|
242 | { |
|
243 | 0 | TurbineRolePermission obj = (TurbineRolePermission) cls.newInstance(); |
244 | 0 | TurbineRolePermissionPeer.populateObject(row, offset, obj); |
245 | 0 | obj.setModified(false); |
246 | 0 | obj.setNew(false); |
247 | ||
248 | 0 | return obj; |
249 | } |
|
250 | 0 | catch (InstantiationException e) |
251 | { |
|
252 | 0 | throw new TorqueException(e); |
253 | } |
|
254 | 0 | catch (IllegalAccessException e) |
255 | { |
|
256 | 0 | throw new TorqueException(e); |
257 | } |
|
258 | } |
|
259 | ||
260 | /** |
|
261 | * Populates an object from a resultset row starting |
|
262 | * from a specified offset. This is done so that you can select |
|
263 | * other rows than just those needed for this object. You may |
|
264 | * for example want to create two objects from the same row. |
|
265 | * |
|
266 | * @throws TorqueException Any exceptions caught during processing will be |
|
267 | * rethrown wrapped into a TorqueException. |
|
268 | */ |
|
269 | public static void populateObject(Record row, |
|
270 | int offset, |
|
271 | TurbineRolePermission obj) |
|
272 | throws TorqueException |
|
273 | { |
|
274 | try |
|
275 | { |
|
276 | 0 | obj.setRoleId(row.getValue(offset + 0).asInt()); |
277 | 0 | obj.setPermissionId(row.getValue(offset + 1).asInt()); |
278 | } |
|
279 | 0 | catch (DataSetException e) |
280 | { |
|
281 | 0 | throw new TorqueException(e); |
282 | 0 | } |
283 | 0 | } |
284 | ||
285 | /** |
|
286 | * Method to do selects. |
|
287 | * |
|
288 | * @param criteria object used to create the SELECT statement. |
|
289 | * @return List of selected Objects |
|
290 | * @throws TorqueException Any exceptions caught during processing will be |
|
291 | * rethrown wrapped into a TorqueException. |
|
292 | */ |
|
293 | public static List doSelect(Criteria criteria) throws TorqueException |
|
294 | { |
|
295 | 0 | return populateObjects(doSelectVillageRecords(criteria)); |
296 | } |
|
297 | ||
298 | /** |
|
299 | * Method to do selects within a transaction. |
|
300 | * |
|
301 | * @param criteria object used to create the SELECT statement. |
|
302 | * @param con the connection to use |
|
303 | * @return List of selected Objects |
|
304 | * @throws TorqueException Any exceptions caught during processing will be |
|
305 | * rethrown wrapped into a TorqueException. |
|
306 | */ |
|
307 | public static List doSelect(Criteria criteria, Connection con) |
|
308 | throws TorqueException |
|
309 | { |
|
310 | 0 | return populateObjects(doSelectVillageRecords(criteria, con)); |
311 | } |
|
312 | ||
313 | /** |
|
314 | * Grabs the raw Village records to be formed into objects. |
|
315 | * This method handles connections internally. The Record objects |
|
316 | * returned by this method should be considered readonly. Do not |
|
317 | * alter the data and call save(), your results may vary, but are |
|
318 | * certainly likely to result in hard to track MT bugs. |
|
319 | * |
|
320 | * @throws TorqueException Any exceptions caught during processing will be |
|
321 | * rethrown wrapped into a TorqueException. |
|
322 | */ |
|
323 | public static List doSelectVillageRecords(Criteria criteria) |
|
324 | throws TorqueException |
|
325 | { |
|
326 | 0 | return BaseTurbineRolePermissionPeer |
327 | .doSelectVillageRecords(criteria, (Connection) null); |
|
328 | } |
|
329 | ||
330 | /** |
|
331 | * Grabs the raw Village records to be formed into objects. |
|
332 | * This method should be used for transactions |
|
333 | * |
|
334 | * @param criteria object used to create the SELECT statement. |
|
335 | * @param con the connection to use |
|
336 | * @throws TorqueException Any exceptions caught during processing will be |
|
337 | * rethrown wrapped into a TorqueException. |
|
338 | */ |
|
339 | public static List doSelectVillageRecords(Criteria criteria, Connection con) |
|
340 | throws TorqueException |
|
341 | { |
|
342 | 0 | if (criteria.getSelectColumns().size() == 0) |
343 | { |
|
344 | 0 | addSelectColumns(criteria); |
345 | } |
|
346 | ||
347 | ||
348 | 0 | setDbName(criteria); |
349 | ||
350 | // BasePeer returns a List of Value (Village) arrays. The array |
|
351 | // order follows the order columns were placed in the Select clause. |
|
352 | 0 | if (con == null) |
353 | { |
|
354 | 0 | return BasePeer.doSelect(criteria); |
355 | } |
|
356 | else |
|
357 | { |
|
358 | 0 | return BasePeer.doSelect(criteria, con); |
359 | } |
|
360 | } |
|
361 | ||
362 | /** |
|
363 | * The returned List will contain objects of the default type or |
|
364 | * objects that inherit from the default. |
|
365 | * |
|
366 | * @throws TorqueException Any exceptions caught during processing will be |
|
367 | * rethrown wrapped into a TorqueException. |
|
368 | */ |
|
369 | public static List populateObjects(List records) |
|
370 | throws TorqueException |
|
371 | { |
|
372 | 0 | List results = new ArrayList(records.size()); |
373 | ||
374 | // populate the object(s) |
|
375 | 0 | for (int i = 0; i < records.size(); i++) |
376 | { |
|
377 | 0 | Record row = (Record) records.get(i); |
378 | 0 | results.add(TurbineRolePermissionPeer.row2Object(row, 1, |
379 | TurbineRolePermissionPeer.getOMClass())); |
|
380 | } |
|
381 | 0 | return results; |
382 | } |
|
383 | ||
384 | ||
385 | /** |
|
386 | * The class that the Peer will make instances of. |
|
387 | * If the BO is abstract then you must implement this method |
|
388 | * in the BO. |
|
389 | * |
|
390 | * @throws TorqueException Any exceptions caught during processing will be |
|
391 | * rethrown wrapped into a TorqueException. |
|
392 | */ |
|
393 | public static Class getOMClass() |
|
394 | throws TorqueException |
|
395 | { |
|
396 | 0 | return CLASS_DEFAULT; |
397 | } |
|
398 | ||
399 | /** |
|
400 | * Method to do updates. |
|
401 | * |
|
402 | * @param criteria object containing data that is used to create the UPDATE |
|
403 | * statement. |
|
404 | * @throws TorqueException Any exceptions caught during processing will be |
|
405 | * rethrown wrapped into a TorqueException. |
|
406 | */ |
|
407 | public static void doUpdate(Criteria criteria) throws TorqueException |
|
408 | { |
|
409 | 0 | BaseTurbineRolePermissionPeer |
410 | .doUpdate(criteria, (Connection) null); |
|
411 | 0 | } |
412 | ||
413 | /** |
|
414 | * Method to do updates. This method is to be used during a transaction, |
|
415 | * otherwise use the doUpdate(Criteria) method. It will take care of |
|
416 | * the connection details internally. |
|
417 | * |
|
418 | * @param criteria object containing data that is used to create the UPDATE |
|
419 | * statement. |
|
420 | * @param con the connection to use |
|
421 | * @throws TorqueException Any exceptions caught during processing will be |
|
422 | * rethrown wrapped into a TorqueException. |
|
423 | */ |
|
424 | public static void doUpdate(Criteria criteria, Connection con) |
|
425 | throws TorqueException |
|
426 | { |
|
427 | 0 | Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); |
428 | 0 | selectCriteria.put(ROLE_ID, criteria.remove(ROLE_ID)); |
429 | 0 | selectCriteria.put(PERMISSION_ID, criteria.remove(PERMISSION_ID)); |
430 | ||
431 | 0 | setDbName(criteria); |
432 | ||
433 | 0 | if (con == null) |
434 | { |
|
435 | 0 | BasePeer.doUpdate(selectCriteria, criteria); |
436 | } |
|
437 | else |
|
438 | { |
|
439 | 0 | BasePeer.doUpdate(selectCriteria, criteria, con); |
440 | } |
|
441 | 0 | } |
442 | ||
443 | /** |
|
444 | * Method to do deletes. |
|
445 | * |
|
446 | * @param criteria object containing data that is used DELETE from database. |
|
447 | * @throws TorqueException Any exceptions caught during processing will be |
|
448 | * rethrown wrapped into a TorqueException. |
|
449 | */ |
|
450 | public static void doDelete(Criteria criteria) throws TorqueException |
|
451 | { |
|
452 | 2 | TurbineRolePermissionPeer |
453 | .doDelete(criteria, (Connection) null); |
|
454 | 2 | } |
455 | ||
456 | /** |
|
457 | * Method to do deletes. This method is to be used during a transaction, |
|
458 | * otherwise use the doDelete(Criteria) method. It will take care of |
|
459 | * the connection details internally. |
|
460 | * |
|
461 | * @param criteria object containing data that is used DELETE from database. |
|
462 | * @param con the connection to use |
|
463 | * @throws TorqueException Any exceptions caught during processing will be |
|
464 | * rethrown wrapped into a TorqueException. |
|
465 | */ |
|
466 | public static void doDelete(Criteria criteria, Connection con) |
|
467 | throws TorqueException |
|
468 | { |
|
469 | ||
470 | 2 | setDbName(criteria); |
471 | ||
472 | 2 | if (con == null) |
473 | { |
|
474 | 2 | BasePeer.doDelete(criteria); |
475 | } |
|
476 | else |
|
477 | { |
|
478 | 0 | BasePeer.doDelete(criteria, con); |
479 | } |
|
480 | 2 | } |
481 | ||
482 | /** |
|
483 | * Method to do selects |
|
484 | * |
|
485 | * @throws TorqueException Any exceptions caught during processing will be |
|
486 | * rethrown wrapped into a TorqueException. |
|
487 | */ |
|
488 | public static List doSelect(TurbineRolePermission obj) throws TorqueException |
|
489 | { |
|
490 | 0 | return doSelect(buildSelectCriteria(obj)); |
491 | } |
|
492 | ||
493 | /** |
|
494 | * Method to do inserts |
|
495 | * |
|
496 | * @throws TorqueException Any exceptions caught during processing will be |
|
497 | * rethrown wrapped into a TorqueException. |
|
498 | */ |
|
499 | public static void doInsert(TurbineRolePermission obj) throws TorqueException |
|
500 | { |
|
501 | 0 | doInsert(buildCriteria(obj)); |
502 | 0 | obj.setNew(false); |
503 | 0 | obj.setModified(false); |
504 | 0 | } |
505 | ||
506 | /** |
|
507 | * @param obj the data object to update in the database. |
|
508 | * @throws TorqueException Any exceptions caught during processing will be |
|
509 | * rethrown wrapped into a TorqueException. |
|
510 | */ |
|
511 | public static void doUpdate(TurbineRolePermission obj) throws TorqueException |
|
512 | { |
|
513 | 0 | doUpdate(buildCriteria(obj)); |
514 | 0 | obj.setModified(false); |
515 | 0 | } |
516 | ||
517 | /** |
|
518 | * @param obj the data object to delete in the database. |
|
519 | * @throws TorqueException Any exceptions caught during processing will be |
|
520 | * rethrown wrapped into a TorqueException. |
|
521 | */ |
|
522 | public static void doDelete(TurbineRolePermission obj) throws TorqueException |
|
523 | { |
|
524 | 0 | doDelete(buildSelectCriteria(obj)); |
525 | 0 | } |
526 | ||
527 | /** |
|
528 | * Method to do inserts. This method is to be used during a transaction, |
|
529 | * otherwise use the doInsert(TurbineRolePermission) method. It will take |
|
530 | * care of the connection details internally. |
|
531 | * |
|
532 | * @param obj the data object to insert into the database. |
|
533 | * @param con the connection to use |
|
534 | * @throws TorqueException Any exceptions caught during processing will be |
|
535 | * rethrown wrapped into a TorqueException. |
|
536 | */ |
|
537 | public static void doInsert(TurbineRolePermission obj, Connection con) |
|
538 | throws TorqueException |
|
539 | { |
|
540 | 0 | doInsert(buildCriteria(obj), con); |
541 | 0 | obj.setNew(false); |
542 | 0 | obj.setModified(false); |
543 | 0 | } |
544 | ||
545 | /** |
|
546 | * Method to do update. This method is to be used during a transaction, |
|
547 | * otherwise use the doUpdate(TurbineRolePermission) method. It will take |
|
548 | * care of the connection details internally. |
|
549 | * |
|
550 | * @param obj the data object to update in the database. |
|
551 | * @param con the connection to use |
|
552 | * @throws TorqueException Any exceptions caught during processing will be |
|
553 | * rethrown wrapped into a TorqueException. |
|
554 | */ |
|
555 | public static void doUpdate(TurbineRolePermission obj, Connection con) |
|
556 | throws TorqueException |
|
557 | { |
|
558 | 0 | doUpdate(buildCriteria(obj), con); |
559 | 0 | obj.setModified(false); |
560 | 0 | } |
561 | ||
562 | /** |
|
563 | * Method to delete. This method is to be used during a transaction, |
|
564 | * otherwise use the doDelete(TurbineRolePermission) method. It will take |
|
565 | * care of the connection details internally. |
|
566 | * |
|
567 | * @param obj the data object to delete in the database. |
|
568 | * @param con the connection to use |
|
569 | * @throws TorqueException Any exceptions caught during processing will be |
|
570 | * rethrown wrapped into a TorqueException. |
|
571 | */ |
|
572 | public static void doDelete(TurbineRolePermission obj, Connection con) |
|
573 | throws TorqueException |
|
574 | { |
|
575 | 0 | doDelete(buildSelectCriteria(obj), con); |
576 | 0 | } |
577 | ||
578 | /** |
|
579 | * Method to do deletes. |
|
580 | * |
|
581 | * @param pk ObjectKey that is used DELETE from database. |
|
582 | * @throws TorqueException Any exceptions caught during processing will be |
|
583 | * rethrown wrapped into a TorqueException. |
|
584 | */ |
|
585 | public static void doDelete(ObjectKey pk) throws TorqueException |
|
586 | { |
|
587 | 0 | BaseTurbineRolePermissionPeer |
588 | .doDelete(pk, (Connection) null); |
|
589 | 0 | } |
590 | ||
591 | /** |
|
592 | * Method to delete. This method is to be used during a transaction, |
|
593 | * otherwise use the doDelete(ObjectKey) method. It will take |
|
594 | * care of the connection details internally. |
|
595 | * |
|
596 | * @param pk the primary key for the object to delete in the database. |
|
597 | * @param con the connection to use |
|
598 | * @throws TorqueException Any exceptions caught during processing will be |
|
599 | * rethrown wrapped into a TorqueException. |
|
600 | */ |
|
601 | public static void doDelete(ObjectKey pk, Connection con) |
|
602 | throws TorqueException |
|
603 | { |
|
604 | 0 | doDelete(buildCriteria(pk), con); |
605 | 0 | } |
606 | ||
607 | /** Build a Criteria object from an ObjectKey */ |
|
608 | public static Criteria buildCriteria( ObjectKey pk ) |
|
609 | { |
|
610 | 0 | Criteria criteria = new Criteria(); |
611 | 0 | SimpleKey[] keys = (SimpleKey[])pk.getValue(); |
612 | 0 | criteria.add(ROLE_ID, keys[0]); |
613 | 0 | criteria.add(PERMISSION_ID, keys[1]); |
614 | 0 | return criteria; |
615 | } |
|
616 | ||
617 | /** Build a Criteria object from the data object for this peer */ |
|
618 | public static Criteria buildCriteria( TurbineRolePermission obj ) |
|
619 | { |
|
620 | 0 | Criteria criteria = new Criteria(DATABASE_NAME); |
621 | 0 | criteria.add(ROLE_ID, obj.getRoleId()); |
622 | 0 | criteria.add(PERMISSION_ID, obj.getPermissionId()); |
623 | 0 | return criteria; |
624 | } |
|
625 | ||
626 | /** Build a Criteria object from the data object for this peer, skipping all binary columns */ |
|
627 | public static Criteria buildSelectCriteria( TurbineRolePermission obj ) |
|
628 | { |
|
629 | 0 | Criteria criteria = new Criteria(DATABASE_NAME); |
630 | 0 | criteria.add(ROLE_ID, obj.getRoleId()); |
631 | 0 | criteria.add(PERMISSION_ID, obj.getPermissionId()); |
632 | 0 | return criteria; |
633 | } |
|
634 | ||
635 | ||
636 | ||
637 | /** |
|
638 | * Retrieve a single object by pk |
|
639 | * |
|
640 | * @param pk the primary key |
|
641 | * @throws TorqueException Any exceptions caught during processing will be |
|
642 | * rethrown wrapped into a TorqueException. |
|
643 | * @throws NoRowsException Primary key was not found in database. |
|
644 | * @throws TooManyRowsException Primary key was not found in database. |
|
645 | */ |
|
646 | public static TurbineRolePermission retrieveByPK(ObjectKey pk) |
|
647 | throws TorqueException, NoRowsException, TooManyRowsException |
|
648 | { |
|
649 | 0 | Connection db = null; |
650 | 0 | TurbineRolePermission retVal = null; |
651 | try |
|
652 | { |
|
653 | 0 | db = Torque.getConnection(DATABASE_NAME); |
654 | 0 | retVal = retrieveByPK(pk, db); |
655 | } |
|
656 | finally |
|
657 | { |
|
658 | 0 | Torque.closeConnection(db); |
659 | 0 | } |
660 | 0 | return(retVal); |
661 | } |
|
662 | ||
663 | /** |
|
664 | * Retrieve a single object by pk |
|
665 | * |
|
666 | * @param pk the primary key |
|
667 | * @param con the connection to use |
|
668 | * @throws TorqueException Any exceptions caught during processing will be |
|
669 | * rethrown wrapped into a TorqueException. |
|
670 | * @throws NoRowsException Primary key was not found in database. |
|
671 | * @throws TooManyRowsException Primary key was not found in database. |
|
672 | */ |
|
673 | public static TurbineRolePermission retrieveByPK(ObjectKey pk, Connection con) |
|
674 | throws TorqueException, NoRowsException, TooManyRowsException |
|
675 | { |
|
676 | 0 | Criteria criteria = buildCriteria(pk); |
677 | 0 | List v = doSelect(criteria, con); |
678 | 0 | if (v.size() == 0) |
679 | { |
|
680 | 0 | throw new NoRowsException("Failed to select a row."); |
681 | } |
|
682 | 0 | else if (v.size() > 1) |
683 | { |
|
684 | 0 | throw new TooManyRowsException("Failed to select only one row."); |
685 | } |
|
686 | else |
|
687 | { |
|
688 | 0 | return (TurbineRolePermission)v.get(0); |
689 | } |
|
690 | } |
|
691 | ||
692 | /** |
|
693 | * Retrieve a multiple objects by pk |
|
694 | * |
|
695 | * @param pks List of primary keys |
|
696 | * @throws TorqueException Any exceptions caught during processing will be |
|
697 | * rethrown wrapped into a TorqueException. |
|
698 | */ |
|
699 | public static List retrieveByPKs(List pks) |
|
700 | throws TorqueException |
|
701 | { |
|
702 | 0 | Connection db = null; |
703 | 0 | List retVal = null; |
704 | try |
|
705 | { |
|
706 | 0 | db = Torque.getConnection(DATABASE_NAME); |
707 | 0 | retVal = retrieveByPKs(pks, db); |
708 | } |
|
709 | finally |
|
710 | { |
|
711 | 0 | Torque.closeConnection(db); |
712 | 0 | } |
713 | 0 | return(retVal); |
714 | } |
|
715 | ||
716 | /** |
|
717 | * Retrieve a multiple objects by pk |
|
718 | * |
|
719 | * @param pks List of primary keys |
|
720 | * @param dbcon the connection to use |
|
721 | * @throws TorqueException Any exceptions caught during processing will be |
|
722 | * rethrown wrapped into a TorqueException. |
|
723 | */ |
|
724 | public static List retrieveByPKs( List pks, Connection dbcon ) |
|
725 | throws TorqueException |
|
726 | { |
|
727 | 0 | List objs = null; |
728 | 0 | if (pks == null || pks.size() == 0) |
729 | { |
|
730 | 0 | objs = new LinkedList(); |
731 | } |
|
732 | else |
|
733 | { |
|
734 | 0 | Criteria criteria = new Criteria(); |
735 | 0 | Iterator iter = pks.iterator(); |
736 | 0 | while (iter.hasNext()) |
737 | { |
|
738 | 0 | ObjectKey pk = (ObjectKey)iter.next(); |
739 | 0 | SimpleKey[] keys = (SimpleKey[])pk.getValue(); |
740 | 0 | Criteria.Criterion c0 = criteria.getNewCriterion( |
741 | ROLE_ID, keys[0], Criteria.EQUAL); |
|
742 | 0 | Criteria.Criterion c1 = criteria.getNewCriterion( |
743 | PERMISSION_ID, keys[1], Criteria.EQUAL); |
|
744 | 0 | c0.and(c1); |
745 | 0 | criteria.or(c0); |
746 | } |
|
747 | 0 | objs = doSelect(criteria, dbcon); |
748 | } |
|
749 | 0 | return objs; |
750 | } |
|
751 | ||
752 | ||
753 | /** |
|
754 | * retrieve object using using pk values. |
|
755 | * |
|
756 | * @param role_id int |
|
757 | * @param permission_id int |
|
758 | */ |
|
759 | public static TurbineRolePermission retrieveByPK( |
|
760 | int role_id |
|
761 | , int permission_id |
|
762 | ) throws TorqueException |
|
763 | { |
|
764 | 0 | Connection db = null; |
765 | 0 | TurbineRolePermission retVal = null; |
766 | try |
|
767 | { |
|
768 | 0 | db = Torque.getConnection(DATABASE_NAME); |
769 | 0 | retVal = retrieveByPK( |
770 | role_id |
|
771 | , permission_id |
|
772 | , db); |
|
773 | } |
|
774 | finally |
|
775 | { |
|
776 | 0 | Torque.closeConnection(db); |
777 | 0 | } |
778 | 0 | return(retVal); |
779 | } |
|
780 | ||
781 | /** |
|
782 | * retrieve object using using pk values. |
|
783 | * |
|
784 | * @param role_id int |
|
785 | * @param permission_id int |
|
786 | * @param con Connection |
|
787 | */ |
|
788 | public static TurbineRolePermission retrieveByPK( |
|
789 | int role_id |
|
790 | , int permission_id |
|
791 | ,Connection con) throws TorqueException |
|
792 | { |
|
793 | ||
794 | 0 | Criteria criteria = new Criteria(5); |
795 | 0 | criteria.add(ROLE_ID, role_id); |
796 | 0 | criteria.add(PERMISSION_ID, permission_id); |
797 | 0 | List v = doSelect(criteria, con); |
798 | 0 | if (v.size() != 1) |
799 | { |
|
800 | 0 | throw new TorqueException("Failed to select one and only one row."); |
801 | } |
|
802 | else |
|
803 | { |
|
804 | 0 | return (TurbineRolePermission) v.get(0); |
805 | } |
|
806 | } |
|
807 | ||
808 | ||
809 | ||
810 | ||
811 | ||
812 | ||
813 | ||
814 | ||
815 | /** |
|
816 | * selects a collection of TurbineRolePermission objects pre-filled with their |
|
817 | * TurbineRole objects. |
|
818 | * |
|
819 | * This method is protected by default in order to keep the public |
|
820 | * api reasonable. You can provide public methods for those you |
|
821 | * actually need in TurbineRolePermissionPeer. |
|
822 | * |
|
823 | * @throws TorqueException Any exceptions caught during processing will be |
|
824 | * rethrown wrapped into a TorqueException. |
|
825 | */ |
|
826 | protected static List doSelectJoinTurbineRole(Criteria criteria) |
|
827 | throws TorqueException |
|
828 | { |
|
829 | 0 | setDbName(criteria); |
830 | ||
831 | 0 | TurbineRolePermissionPeer.addSelectColumns(criteria); |
832 | 0 | int offset = numColumns + 1; |
833 | 0 | TurbineRolePeer.addSelectColumns(criteria); |
834 | ||
835 | ||
836 | 0 | criteria.addJoin(TurbineRolePermissionPeer.ROLE_ID, |
837 | TurbineRolePeer.ROLE_ID); |
|
838 | ||
839 | ||
840 | ||
841 | 0 | List rows = BasePeer.doSelect(criteria); |
842 | 0 | List results = new ArrayList(); |
843 | ||
844 | 0 | for (int i = 0; i < rows.size(); i++) |
845 | { |
|
846 | 0 | Record row = (Record) rows.get(i); |
847 | ||
848 | 0 | Class omClass = TurbineRolePermissionPeer.getOMClass(); |
849 | 0 | TurbineRolePermission obj1 = (TurbineRolePermission) TurbineRolePermissionPeer |
850 | .row2Object(row, 1, omClass); |
|
851 | 0 | omClass = TurbineRolePeer.getOMClass(); |
852 | 0 | TurbineRole obj2 = (TurbineRole)TurbineRolePeer |
853 | .row2Object(row, offset, omClass); |
|
854 | ||
855 | 0 | boolean newObject = true; |
856 | 0 | for (int j = 0; j < results.size(); j++) |
857 | { |
|
858 | 0 | TurbineRolePermission temp_obj1 = (TurbineRolePermission)results.get(j); |
859 | 0 | TurbineRole temp_obj2 = (TurbineRole)temp_obj1.getTurbineRole(); |
860 | 0 | if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) |
861 | { |
|
862 | 0 | newObject = false; |
863 | 0 | temp_obj2.addTurbineRolePermission(obj1); |
864 | 0 | break; |
865 | } |
|
866 | } |
|
867 | 0 | if (newObject) |
868 | { |
|
869 | 0 | obj2.initTurbineRolePermissions(); |
870 | 0 | obj2.addTurbineRolePermission(obj1); |
871 | } |
|
872 | 0 | results.add(obj1); |
873 | } |
|
874 | 0 | return results; |
875 | } |
|
876 | ||
877 | ||
878 | ||
879 | ||
880 | /** |
|
881 | * selects a collection of TurbineRolePermission objects pre-filled with their |
|
882 | * TurbinePermission objects. |
|
883 | * |
|
884 | * This method is protected by default in order to keep the public |
|
885 | * api reasonable. You can provide public methods for those you |
|
886 | * actually need in TurbineRolePermissionPeer. |
|
887 | * |
|
888 | * @throws TorqueException Any exceptions caught during processing will be |
|
889 | * rethrown wrapped into a TorqueException. |
|
890 | */ |
|
891 | protected static List doSelectJoinTurbinePermission(Criteria criteria) |
|
892 | throws TorqueException |
|
893 | { |
|
894 | 0 | setDbName(criteria); |
895 | ||
896 | 0 | TurbineRolePermissionPeer.addSelectColumns(criteria); |
897 | 0 | int offset = numColumns + 1; |
898 | 0 | TurbinePermissionPeer.addSelectColumns(criteria); |
899 | ||
900 | ||
901 | 0 | criteria.addJoin(TurbineRolePermissionPeer.PERMISSION_ID, |
902 | TurbinePermissionPeer.PERMISSION_ID); |
|
903 | ||
904 | ||
905 | ||
906 | 0 | List rows = BasePeer.doSelect(criteria); |
907 | 0 | List results = new ArrayList(); |
908 | ||
909 | 0 | for (int i = 0; i < rows.size(); i++) |
910 | { |
|
911 | 0 | Record row = (Record) rows.get(i); |
912 | ||
913 | 0 | Class omClass = TurbineRolePermissionPeer.getOMClass(); |
914 | 0 | TurbineRolePermission obj1 = (TurbineRolePermission) TurbineRolePermissionPeer |
915 | .row2Object(row, 1, omClass); |
|
916 | 0 | omClass = TurbinePermissionPeer.getOMClass(); |
917 | 0 | TurbinePermission obj2 = (TurbinePermission)TurbinePermissionPeer |
918 | .row2Object(row, offset, omClass); |
|
919 | ||
920 | 0 | boolean newObject = true; |
921 | 0 | for (int j = 0; j < results.size(); j++) |
922 | { |
|
923 | 0 | TurbineRolePermission temp_obj1 = (TurbineRolePermission)results.get(j); |
924 | 0 | TurbinePermission temp_obj2 = (TurbinePermission)temp_obj1.getTurbinePermission(); |
925 | 0 | if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) |
926 | { |
|
927 | 0 | newObject = false; |
928 | 0 | temp_obj2.addTurbineRolePermission(obj1); |
929 | 0 | break; |
930 | } |
|
931 | } |
|
932 | 0 | if (newObject) |
933 | { |
|
934 | 0 | obj2.initTurbineRolePermissions(); |
935 | 0 | obj2.addTurbineRolePermission(obj1); |
936 | } |
|
937 | 0 | results.add(obj1); |
938 | } |
|
939 | 0 | return results; |
940 | } |
|
941 | ||
942 | ||
943 | ||
944 | ||
945 | /** |
|
946 | * Returns the TableMap related to this peer. This method is not |
|
947 | * needed for general use but a specific application could have a need. |
|
948 | * |
|
949 | * @throws TorqueException Any exceptions caught during processing will be |
|
950 | * rethrown wrapped into a TorqueException. |
|
951 | */ |
|
952 | protected static TableMap getTableMap() |
|
953 | throws TorqueException |
|
954 | { |
|
955 | 0 | return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); |
956 | } |
|
957 | ||
958 | private static void setDbName(Criteria crit) |
|
959 | { |
|
960 | // Set the correct dbName if it has not been overridden |
|
961 | // crit.getDbName will return the same object if not set to |
|
962 | // another value so == check is okay and faster |
|
963 | 6 | if (crit.getDbName() == Torque.getDefaultDB()) |
964 | { |
|
965 | 6 | crit.setDbName(DATABASE_NAME); |
966 | } |
|
967 | 6 | } |
968 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |