1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchPasswordPolicyRelException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.dao.DynamicQuery;
28 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
29 import com.liferay.portal.kernel.util.OrderByComparator;
30 import com.liferay.portal.kernel.util.StringMaker;
31 import com.liferay.portal.kernel.util.StringPool;
32 import com.liferay.portal.model.PasswordPolicyRel;
33 import com.liferay.portal.model.impl.PasswordPolicyRelImpl;
34 import com.liferay.portal.service.persistence.BasePersistence;
35 import com.liferay.portal.spring.hibernate.FinderCache;
36 import com.liferay.portal.spring.hibernate.HibernateUtil;
37
38 import com.liferay.util.dao.hibernate.QueryUtil;
39
40 import org.apache.commons.logging.Log;
41 import org.apache.commons.logging.LogFactory;
42
43 import org.hibernate.Query;
44 import org.hibernate.Session;
45
46 import java.util.Collections;
47 import java.util.Iterator;
48 import java.util.List;
49
50
56 public class PasswordPolicyRelPersistenceImpl extends BasePersistence
57 implements PasswordPolicyRelPersistence {
58 public PasswordPolicyRel create(long passwordPolicyRelId) {
59 PasswordPolicyRel passwordPolicyRel = new PasswordPolicyRelImpl();
60 passwordPolicyRel.setNew(true);
61 passwordPolicyRel.setPrimaryKey(passwordPolicyRelId);
62
63 return passwordPolicyRel;
64 }
65
66 public PasswordPolicyRel remove(long passwordPolicyRelId)
67 throws NoSuchPasswordPolicyRelException, SystemException {
68 Session session = null;
69
70 try {
71 session = openSession();
72
73 PasswordPolicyRel passwordPolicyRel = (PasswordPolicyRel)session.get(PasswordPolicyRelImpl.class,
74 new Long(passwordPolicyRelId));
75
76 if (passwordPolicyRel == null) {
77 if (_log.isWarnEnabled()) {
78 _log.warn(
79 "No PasswordPolicyRel exists with the primary key " +
80 passwordPolicyRelId);
81 }
82
83 throw new NoSuchPasswordPolicyRelException(
84 "No PasswordPolicyRel exists with the primary key " +
85 passwordPolicyRelId);
86 }
87
88 return remove(passwordPolicyRel);
89 }
90 catch (NoSuchPasswordPolicyRelException nsee) {
91 throw nsee;
92 }
93 catch (Exception e) {
94 throw HibernateUtil.processException(e);
95 }
96 finally {
97 closeSession(session);
98 }
99 }
100
101 public PasswordPolicyRel remove(PasswordPolicyRel passwordPolicyRel)
102 throws SystemException {
103 Session session = null;
104
105 try {
106 session = openSession();
107 session.delete(passwordPolicyRel);
108 session.flush();
109
110 return passwordPolicyRel;
111 }
112 catch (Exception e) {
113 throw HibernateUtil.processException(e);
114 }
115 finally {
116 closeSession(session);
117 FinderCache.clearCache(PasswordPolicyRel.class.getName());
118 }
119 }
120
121 public PasswordPolicyRel update(
122 com.liferay.portal.model.PasswordPolicyRel passwordPolicyRel)
123 throws SystemException {
124 return update(passwordPolicyRel, false);
125 }
126
127 public PasswordPolicyRel update(
128 com.liferay.portal.model.PasswordPolicyRel passwordPolicyRel,
129 boolean merge) throws SystemException {
130 Session session = null;
131
132 try {
133 session = openSession();
134
135 if (merge) {
136 session.merge(passwordPolicyRel);
137 }
138 else {
139 if (passwordPolicyRel.isNew()) {
140 session.save(passwordPolicyRel);
141 }
142 }
143
144 session.flush();
145 passwordPolicyRel.setNew(false);
146
147 return passwordPolicyRel;
148 }
149 catch (Exception e) {
150 throw HibernateUtil.processException(e);
151 }
152 finally {
153 closeSession(session);
154 FinderCache.clearCache(PasswordPolicyRel.class.getName());
155 }
156 }
157
158 public PasswordPolicyRel findByPrimaryKey(long passwordPolicyRelId)
159 throws NoSuchPasswordPolicyRelException, SystemException {
160 PasswordPolicyRel passwordPolicyRel = fetchByPrimaryKey(passwordPolicyRelId);
161
162 if (passwordPolicyRel == null) {
163 if (_log.isWarnEnabled()) {
164 _log.warn("No PasswordPolicyRel exists with the primary key " +
165 passwordPolicyRelId);
166 }
167
168 throw new NoSuchPasswordPolicyRelException(
169 "No PasswordPolicyRel exists with the primary key " +
170 passwordPolicyRelId);
171 }
172
173 return passwordPolicyRel;
174 }
175
176 public PasswordPolicyRel fetchByPrimaryKey(long passwordPolicyRelId)
177 throws SystemException {
178 Session session = null;
179
180 try {
181 session = openSession();
182
183 return (PasswordPolicyRel)session.get(PasswordPolicyRelImpl.class,
184 new Long(passwordPolicyRelId));
185 }
186 catch (Exception e) {
187 throw HibernateUtil.processException(e);
188 }
189 finally {
190 closeSession(session);
191 }
192 }
193
194 public PasswordPolicyRel findByC_C(long classNameId, long classPK)
195 throws NoSuchPasswordPolicyRelException, SystemException {
196 PasswordPolicyRel passwordPolicyRel = fetchByC_C(classNameId, classPK);
197
198 if (passwordPolicyRel == null) {
199 StringMaker msg = new StringMaker();
200 msg.append("No PasswordPolicyRel exists with the key ");
201 msg.append(StringPool.OPEN_CURLY_BRACE);
202 msg.append("classNameId=");
203 msg.append(classNameId);
204 msg.append(", ");
205 msg.append("classPK=");
206 msg.append(classPK);
207 msg.append(StringPool.CLOSE_CURLY_BRACE);
208
209 if (_log.isWarnEnabled()) {
210 _log.warn(msg.toString());
211 }
212
213 throw new NoSuchPasswordPolicyRelException(msg.toString());
214 }
215
216 return passwordPolicyRel;
217 }
218
219 public PasswordPolicyRel fetchByC_C(long classNameId, long classPK)
220 throws SystemException {
221 String finderClassName = PasswordPolicyRel.class.getName();
222 String finderMethodName = "fetchByC_C";
223 String[] finderParams = new String[] {
224 Long.class.getName(), Long.class.getName()
225 };
226 Object[] finderArgs = new Object[] {
227 new Long(classNameId), new Long(classPK)
228 };
229 Object result = FinderCache.getResult(finderClassName,
230 finderMethodName, finderParams, finderArgs, getSessionFactory());
231
232 if (result == null) {
233 Session session = null;
234
235 try {
236 session = openSession();
237
238 StringMaker query = new StringMaker();
239 query.append(
240 "FROM com.liferay.portal.model.PasswordPolicyRel WHERE ");
241 query.append("classNameId = ?");
242 query.append(" AND ");
243 query.append("classPK = ?");
244 query.append(" ");
245
246 Query q = session.createQuery(query.toString());
247 int queryPos = 0;
248 q.setLong(queryPos++, classNameId);
249 q.setLong(queryPos++, classPK);
250
251 List list = q.list();
252 FinderCache.putResult(finderClassName, finderMethodName,
253 finderParams, finderArgs, list);
254
255 if (list.size() == 0) {
256 return null;
257 }
258 else {
259 return (PasswordPolicyRel)list.get(0);
260 }
261 }
262 catch (Exception e) {
263 throw HibernateUtil.processException(e);
264 }
265 finally {
266 closeSession(session);
267 }
268 }
269 else {
270 List list = (List)result;
271
272 if (list.size() == 0) {
273 return null;
274 }
275 else {
276 return (PasswordPolicyRel)list.get(0);
277 }
278 }
279 }
280
281 public PasswordPolicyRel findByP_C_C(long passwordPolicyId,
282 long classNameId, long classPK)
283 throws NoSuchPasswordPolicyRelException, SystemException {
284 PasswordPolicyRel passwordPolicyRel = fetchByP_C_C(passwordPolicyId,
285 classNameId, classPK);
286
287 if (passwordPolicyRel == null) {
288 StringMaker msg = new StringMaker();
289 msg.append("No PasswordPolicyRel exists with the key ");
290 msg.append(StringPool.OPEN_CURLY_BRACE);
291 msg.append("passwordPolicyId=");
292 msg.append(passwordPolicyId);
293 msg.append(", ");
294 msg.append("classNameId=");
295 msg.append(classNameId);
296 msg.append(", ");
297 msg.append("classPK=");
298 msg.append(classPK);
299 msg.append(StringPool.CLOSE_CURLY_BRACE);
300
301 if (_log.isWarnEnabled()) {
302 _log.warn(msg.toString());
303 }
304
305 throw new NoSuchPasswordPolicyRelException(msg.toString());
306 }
307
308 return passwordPolicyRel;
309 }
310
311 public PasswordPolicyRel fetchByP_C_C(long passwordPolicyId,
312 long classNameId, long classPK) throws SystemException {
313 String finderClassName = PasswordPolicyRel.class.getName();
314 String finderMethodName = "fetchByP_C_C";
315 String[] finderParams = new String[] {
316 Long.class.getName(), Long.class.getName(), Long.class.getName()
317 };
318 Object[] finderArgs = new Object[] {
319 new Long(passwordPolicyId), new Long(classNameId),
320 new Long(classPK)
321 };
322 Object result = FinderCache.getResult(finderClassName,
323 finderMethodName, finderParams, finderArgs, getSessionFactory());
324
325 if (result == null) {
326 Session session = null;
327
328 try {
329 session = openSession();
330
331 StringMaker query = new StringMaker();
332 query.append(
333 "FROM com.liferay.portal.model.PasswordPolicyRel WHERE ");
334 query.append("passwordPolicyId = ?");
335 query.append(" AND ");
336 query.append("classNameId = ?");
337 query.append(" AND ");
338 query.append("classPK = ?");
339 query.append(" ");
340
341 Query q = session.createQuery(query.toString());
342 int queryPos = 0;
343 q.setLong(queryPos++, passwordPolicyId);
344 q.setLong(queryPos++, classNameId);
345 q.setLong(queryPos++, classPK);
346
347 List list = q.list();
348 FinderCache.putResult(finderClassName, finderMethodName,
349 finderParams, finderArgs, list);
350
351 if (list.size() == 0) {
352 return null;
353 }
354 else {
355 return (PasswordPolicyRel)list.get(0);
356 }
357 }
358 catch (Exception e) {
359 throw HibernateUtil.processException(e);
360 }
361 finally {
362 closeSession(session);
363 }
364 }
365 else {
366 List list = (List)result;
367
368 if (list.size() == 0) {
369 return null;
370 }
371 else {
372 return (PasswordPolicyRel)list.get(0);
373 }
374 }
375 }
376
377 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
378 throws SystemException {
379 Session session = null;
380
381 try {
382 session = openSession();
383
384 DynamicQuery query = queryInitializer.initialize(session);
385
386 return query.list();
387 }
388 catch (Exception e) {
389 throw HibernateUtil.processException(e);
390 }
391 finally {
392 closeSession(session);
393 }
394 }
395
396 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
397 int begin, int end) throws SystemException {
398 Session session = null;
399
400 try {
401 session = openSession();
402
403 DynamicQuery query = queryInitializer.initialize(session);
404 query.setLimit(begin, end);
405
406 return query.list();
407 }
408 catch (Exception e) {
409 throw HibernateUtil.processException(e);
410 }
411 finally {
412 closeSession(session);
413 }
414 }
415
416 public List findAll() throws SystemException {
417 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
418 }
419
420 public List findAll(int begin, int end) throws SystemException {
421 return findAll(begin, end, null);
422 }
423
424 public List findAll(int begin, int end, OrderByComparator obc)
425 throws SystemException {
426 String finderClassName = PasswordPolicyRel.class.getName();
427 String finderMethodName = "findAll";
428 String[] finderParams = new String[] {
429 "java.lang.Integer", "java.lang.Integer",
430 "com.liferay.portal.kernel.util.OrderByComparator"
431 };
432 Object[] finderArgs = new Object[] {
433 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
434 };
435 Object result = FinderCache.getResult(finderClassName,
436 finderMethodName, finderParams, finderArgs, getSessionFactory());
437
438 if (result == null) {
439 Session session = null;
440
441 try {
442 session = openSession();
443
444 StringMaker query = new StringMaker();
445 query.append("FROM com.liferay.portal.model.PasswordPolicyRel ");
446
447 if (obc != null) {
448 query.append("ORDER BY ");
449 query.append(obc.getOrderBy());
450 }
451
452 Query q = session.createQuery(query.toString());
453 List list = QueryUtil.list(q, getDialect(), begin, end);
454
455 if (obc == null) {
456 Collections.sort(list);
457 }
458
459 FinderCache.putResult(finderClassName, finderMethodName,
460 finderParams, finderArgs, list);
461
462 return list;
463 }
464 catch (Exception e) {
465 throw HibernateUtil.processException(e);
466 }
467 finally {
468 closeSession(session);
469 }
470 }
471 else {
472 return (List)result;
473 }
474 }
475
476 public void removeByC_C(long classNameId, long classPK)
477 throws NoSuchPasswordPolicyRelException, SystemException {
478 PasswordPolicyRel passwordPolicyRel = findByC_C(classNameId, classPK);
479 remove(passwordPolicyRel);
480 }
481
482 public void removeByP_C_C(long passwordPolicyId, long classNameId,
483 long classPK) throws NoSuchPasswordPolicyRelException, SystemException {
484 PasswordPolicyRel passwordPolicyRel = findByP_C_C(passwordPolicyId,
485 classNameId, classPK);
486 remove(passwordPolicyRel);
487 }
488
489 public void removeAll() throws SystemException {
490 Iterator itr = findAll().iterator();
491
492 while (itr.hasNext()) {
493 remove((PasswordPolicyRel)itr.next());
494 }
495 }
496
497 public int countByC_C(long classNameId, long classPK)
498 throws SystemException {
499 String finderClassName = PasswordPolicyRel.class.getName();
500 String finderMethodName = "countByC_C";
501 String[] finderParams = new String[] {
502 Long.class.getName(), Long.class.getName()
503 };
504 Object[] finderArgs = new Object[] {
505 new Long(classNameId), new Long(classPK)
506 };
507 Object result = FinderCache.getResult(finderClassName,
508 finderMethodName, finderParams, finderArgs, getSessionFactory());
509
510 if (result == null) {
511 Session session = null;
512
513 try {
514 session = openSession();
515
516 StringMaker query = new StringMaker();
517 query.append("SELECT COUNT(*) ");
518 query.append(
519 "FROM com.liferay.portal.model.PasswordPolicyRel WHERE ");
520 query.append("classNameId = ?");
521 query.append(" AND ");
522 query.append("classPK = ?");
523 query.append(" ");
524
525 Query q = session.createQuery(query.toString());
526 int queryPos = 0;
527 q.setLong(queryPos++, classNameId);
528 q.setLong(queryPos++, classPK);
529
530 Long count = null;
531 Iterator itr = q.list().iterator();
532
533 if (itr.hasNext()) {
534 count = (Long)itr.next();
535 }
536
537 if (count == null) {
538 count = new Long(0);
539 }
540
541 FinderCache.putResult(finderClassName, finderMethodName,
542 finderParams, finderArgs, count);
543
544 return count.intValue();
545 }
546 catch (Exception e) {
547 throw HibernateUtil.processException(e);
548 }
549 finally {
550 closeSession(session);
551 }
552 }
553 else {
554 return ((Long)result).intValue();
555 }
556 }
557
558 public int countByP_C_C(long passwordPolicyId, long classNameId,
559 long classPK) throws SystemException {
560 String finderClassName = PasswordPolicyRel.class.getName();
561 String finderMethodName = "countByP_C_C";
562 String[] finderParams = new String[] {
563 Long.class.getName(), Long.class.getName(), Long.class.getName()
564 };
565 Object[] finderArgs = new Object[] {
566 new Long(passwordPolicyId), new Long(classNameId),
567 new Long(classPK)
568 };
569 Object result = FinderCache.getResult(finderClassName,
570 finderMethodName, finderParams, finderArgs, getSessionFactory());
571
572 if (result == null) {
573 Session session = null;
574
575 try {
576 session = openSession();
577
578 StringMaker query = new StringMaker();
579 query.append("SELECT COUNT(*) ");
580 query.append(
581 "FROM com.liferay.portal.model.PasswordPolicyRel WHERE ");
582 query.append("passwordPolicyId = ?");
583 query.append(" AND ");
584 query.append("classNameId = ?");
585 query.append(" AND ");
586 query.append("classPK = ?");
587 query.append(" ");
588
589 Query q = session.createQuery(query.toString());
590 int queryPos = 0;
591 q.setLong(queryPos++, passwordPolicyId);
592 q.setLong(queryPos++, classNameId);
593 q.setLong(queryPos++, classPK);
594
595 Long count = null;
596 Iterator itr = q.list().iterator();
597
598 if (itr.hasNext()) {
599 count = (Long)itr.next();
600 }
601
602 if (count == null) {
603 count = new Long(0);
604 }
605
606 FinderCache.putResult(finderClassName, finderMethodName,
607 finderParams, finderArgs, count);
608
609 return count.intValue();
610 }
611 catch (Exception e) {
612 throw HibernateUtil.processException(e);
613 }
614 finally {
615 closeSession(session);
616 }
617 }
618 else {
619 return ((Long)result).intValue();
620 }
621 }
622
623 public int countAll() throws SystemException {
624 String finderClassName = PasswordPolicyRel.class.getName();
625 String finderMethodName = "countAll";
626 String[] finderParams = new String[] { };
627 Object[] finderArgs = new Object[] { };
628 Object result = FinderCache.getResult(finderClassName,
629 finderMethodName, finderParams, finderArgs, getSessionFactory());
630
631 if (result == null) {
632 Session session = null;
633
634 try {
635 session = openSession();
636
637 StringMaker query = new StringMaker();
638 query.append("SELECT COUNT(*) ");
639 query.append("FROM com.liferay.portal.model.PasswordPolicyRel");
640
641 Query q = session.createQuery(query.toString());
642 Long count = null;
643 Iterator itr = q.list().iterator();
644
645 if (itr.hasNext()) {
646 count = (Long)itr.next();
647 }
648
649 if (count == null) {
650 count = new Long(0);
651 }
652
653 FinderCache.putResult(finderClassName, finderMethodName,
654 finderParams, finderArgs, count);
655
656 return count.intValue();
657 }
658 catch (Exception e) {
659 throw HibernateUtil.processException(e);
660 }
661 finally {
662 closeSession(session);
663 }
664 }
665 else {
666 return ((Long)result).intValue();
667 }
668 }
669
670 protected void initDao() {
671 }
672
673 private static Log _log = LogFactory.getLog(PasswordPolicyRelPersistenceImpl.class);
674 }