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