1
22
23 package com.liferay.portlet.messageboards.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.DynamicQuery;
27 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
28 import com.liferay.portal.kernel.util.OrderByComparator;
29 import com.liferay.portal.kernel.util.StringMaker;
30 import com.liferay.portal.kernel.util.StringPool;
31 import com.liferay.portal.service.persistence.BasePersistence;
32 import com.liferay.portal.spring.hibernate.FinderCache;
33 import com.liferay.portal.spring.hibernate.HibernateUtil;
34
35 import com.liferay.portlet.messageboards.NoSuchBanException;
36 import com.liferay.portlet.messageboards.model.MBBan;
37 import com.liferay.portlet.messageboards.model.impl.MBBanImpl;
38
39 import com.liferay.util.dao.hibernate.QueryUtil;
40
41 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43
44 import org.hibernate.Query;
45 import org.hibernate.Session;
46
47 import java.util.Collections;
48 import java.util.Iterator;
49 import java.util.List;
50
51
57 public class MBBanPersistenceImpl extends BasePersistence
58 implements MBBanPersistence {
59 public MBBan create(long banId) {
60 MBBan mbBan = new MBBanImpl();
61 mbBan.setNew(true);
62 mbBan.setPrimaryKey(banId);
63
64 return mbBan;
65 }
66
67 public MBBan remove(long banId) throws NoSuchBanException, SystemException {
68 Session session = null;
69
70 try {
71 session = openSession();
72
73 MBBan mbBan = (MBBan)session.get(MBBanImpl.class, new Long(banId));
74
75 if (mbBan == null) {
76 if (_log.isWarnEnabled()) {
77 _log.warn("No MBBan exists with the primary key " + banId);
78 }
79
80 throw new NoSuchBanException(
81 "No MBBan exists with the primary key " + banId);
82 }
83
84 return remove(mbBan);
85 }
86 catch (NoSuchBanException nsee) {
87 throw nsee;
88 }
89 catch (Exception e) {
90 throw HibernateUtil.processException(e);
91 }
92 finally {
93 closeSession(session);
94 }
95 }
96
97 public MBBan remove(MBBan mbBan) throws SystemException {
98 Session session = null;
99
100 try {
101 session = openSession();
102 session.delete(mbBan);
103 session.flush();
104
105 return mbBan;
106 }
107 catch (Exception e) {
108 throw HibernateUtil.processException(e);
109 }
110 finally {
111 closeSession(session);
112 FinderCache.clearCache(MBBan.class.getName());
113 }
114 }
115
116 public MBBan update(com.liferay.portlet.messageboards.model.MBBan mbBan)
117 throws SystemException {
118 return update(mbBan, false);
119 }
120
121 public MBBan update(com.liferay.portlet.messageboards.model.MBBan mbBan,
122 boolean merge) throws SystemException {
123 Session session = null;
124
125 try {
126 session = openSession();
127
128 if (merge) {
129 session.merge(mbBan);
130 }
131 else {
132 if (mbBan.isNew()) {
133 session.save(mbBan);
134 }
135 }
136
137 session.flush();
138 mbBan.setNew(false);
139
140 return mbBan;
141 }
142 catch (Exception e) {
143 throw HibernateUtil.processException(e);
144 }
145 finally {
146 closeSession(session);
147 FinderCache.clearCache(MBBan.class.getName());
148 }
149 }
150
151 public MBBan findByPrimaryKey(long banId)
152 throws NoSuchBanException, SystemException {
153 MBBan mbBan = fetchByPrimaryKey(banId);
154
155 if (mbBan == null) {
156 if (_log.isWarnEnabled()) {
157 _log.warn("No MBBan exists with the primary key " + banId);
158 }
159
160 throw new NoSuchBanException(
161 "No MBBan exists with the primary key " + banId);
162 }
163
164 return mbBan;
165 }
166
167 public MBBan fetchByPrimaryKey(long banId) throws SystemException {
168 Session session = null;
169
170 try {
171 session = openSession();
172
173 return (MBBan)session.get(MBBanImpl.class, new Long(banId));
174 }
175 catch (Exception e) {
176 throw HibernateUtil.processException(e);
177 }
178 finally {
179 closeSession(session);
180 }
181 }
182
183 public List findByGroupId(long groupId) throws SystemException {
184 String finderClassName = MBBan.class.getName();
185 String finderMethodName = "findByGroupId";
186 String[] finderParams = new String[] { Long.class.getName() };
187 Object[] finderArgs = new Object[] { new Long(groupId) };
188 Object result = FinderCache.getResult(finderClassName,
189 finderMethodName, finderParams, finderArgs, getSessionFactory());
190
191 if (result == null) {
192 Session session = null;
193
194 try {
195 session = openSession();
196
197 StringMaker query = new StringMaker();
198 query.append(
199 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
200 query.append("groupId = ?");
201 query.append(" ");
202
203 Query q = session.createQuery(query.toString());
204 int queryPos = 0;
205 q.setLong(queryPos++, groupId);
206
207 List list = q.list();
208 FinderCache.putResult(finderClassName, finderMethodName,
209 finderParams, finderArgs, list);
210
211 return list;
212 }
213 catch (Exception e) {
214 throw HibernateUtil.processException(e);
215 }
216 finally {
217 closeSession(session);
218 }
219 }
220 else {
221 return (List)result;
222 }
223 }
224
225 public List findByGroupId(long groupId, int begin, int end)
226 throws SystemException {
227 return findByGroupId(groupId, begin, end, null);
228 }
229
230 public List findByGroupId(long groupId, int begin, int end,
231 OrderByComparator obc) throws SystemException {
232 String finderClassName = MBBan.class.getName();
233 String finderMethodName = "findByGroupId";
234 String[] finderParams = new String[] {
235 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
236 "com.liferay.portal.kernel.util.OrderByComparator"
237 };
238 Object[] finderArgs = new Object[] {
239 new Long(groupId), String.valueOf(begin), String.valueOf(end),
240 String.valueOf(obc)
241 };
242 Object result = FinderCache.getResult(finderClassName,
243 finderMethodName, finderParams, finderArgs, getSessionFactory());
244
245 if (result == null) {
246 Session session = null;
247
248 try {
249 session = openSession();
250
251 StringMaker query = new StringMaker();
252 query.append(
253 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
254 query.append("groupId = ?");
255 query.append(" ");
256
257 if (obc != null) {
258 query.append("ORDER BY ");
259 query.append(obc.getOrderBy());
260 }
261
262 Query q = session.createQuery(query.toString());
263 int queryPos = 0;
264 q.setLong(queryPos++, groupId);
265
266 List list = QueryUtil.list(q, getDialect(), begin, end);
267 FinderCache.putResult(finderClassName, finderMethodName,
268 finderParams, finderArgs, list);
269
270 return list;
271 }
272 catch (Exception e) {
273 throw HibernateUtil.processException(e);
274 }
275 finally {
276 closeSession(session);
277 }
278 }
279 else {
280 return (List)result;
281 }
282 }
283
284 public MBBan findByGroupId_First(long groupId, OrderByComparator obc)
285 throws NoSuchBanException, SystemException {
286 List list = findByGroupId(groupId, 0, 1, obc);
287
288 if (list.size() == 0) {
289 StringMaker msg = new StringMaker();
290 msg.append("No MBBan exists with the key ");
291 msg.append(StringPool.OPEN_CURLY_BRACE);
292 msg.append("groupId=");
293 msg.append(groupId);
294 msg.append(StringPool.CLOSE_CURLY_BRACE);
295 throw new NoSuchBanException(msg.toString());
296 }
297 else {
298 return (MBBan)list.get(0);
299 }
300 }
301
302 public MBBan findByGroupId_Last(long groupId, OrderByComparator obc)
303 throws NoSuchBanException, SystemException {
304 int count = countByGroupId(groupId);
305 List list = findByGroupId(groupId, count - 1, count, obc);
306
307 if (list.size() == 0) {
308 StringMaker msg = new StringMaker();
309 msg.append("No MBBan exists with the key ");
310 msg.append(StringPool.OPEN_CURLY_BRACE);
311 msg.append("groupId=");
312 msg.append(groupId);
313 msg.append(StringPool.CLOSE_CURLY_BRACE);
314 throw new NoSuchBanException(msg.toString());
315 }
316 else {
317 return (MBBan)list.get(0);
318 }
319 }
320
321 public MBBan[] findByGroupId_PrevAndNext(long banId, long groupId,
322 OrderByComparator obc) throws NoSuchBanException, SystemException {
323 MBBan mbBan = findByPrimaryKey(banId);
324 int count = countByGroupId(groupId);
325 Session session = null;
326
327 try {
328 session = openSession();
329
330 StringMaker query = new StringMaker();
331 query.append(
332 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
333 query.append("groupId = ?");
334 query.append(" ");
335
336 if (obc != null) {
337 query.append("ORDER BY ");
338 query.append(obc.getOrderBy());
339 }
340
341 Query q = session.createQuery(query.toString());
342 int queryPos = 0;
343 q.setLong(queryPos++, groupId);
344
345 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, mbBan);
346 MBBan[] array = new MBBanImpl[3];
347 array[0] = (MBBan)objArray[0];
348 array[1] = (MBBan)objArray[1];
349 array[2] = (MBBan)objArray[2];
350
351 return array;
352 }
353 catch (Exception e) {
354 throw HibernateUtil.processException(e);
355 }
356 finally {
357 closeSession(session);
358 }
359 }
360
361 public List findByUserId(long userId) throws SystemException {
362 String finderClassName = MBBan.class.getName();
363 String finderMethodName = "findByUserId";
364 String[] finderParams = new String[] { Long.class.getName() };
365 Object[] finderArgs = new Object[] { new Long(userId) };
366 Object result = FinderCache.getResult(finderClassName,
367 finderMethodName, finderParams, finderArgs, getSessionFactory());
368
369 if (result == null) {
370 Session session = null;
371
372 try {
373 session = openSession();
374
375 StringMaker query = new StringMaker();
376 query.append(
377 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
378 query.append("userId = ?");
379 query.append(" ");
380
381 Query q = session.createQuery(query.toString());
382 int queryPos = 0;
383 q.setLong(queryPos++, userId);
384
385 List list = q.list();
386 FinderCache.putResult(finderClassName, finderMethodName,
387 finderParams, finderArgs, list);
388
389 return list;
390 }
391 catch (Exception e) {
392 throw HibernateUtil.processException(e);
393 }
394 finally {
395 closeSession(session);
396 }
397 }
398 else {
399 return (List)result;
400 }
401 }
402
403 public List findByUserId(long userId, int begin, int end)
404 throws SystemException {
405 return findByUserId(userId, begin, end, null);
406 }
407
408 public List findByUserId(long userId, int begin, int end,
409 OrderByComparator obc) throws SystemException {
410 String finderClassName = MBBan.class.getName();
411 String finderMethodName = "findByUserId";
412 String[] finderParams = new String[] {
413 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
414 "com.liferay.portal.kernel.util.OrderByComparator"
415 };
416 Object[] finderArgs = new Object[] {
417 new Long(userId), String.valueOf(begin), String.valueOf(end),
418 String.valueOf(obc)
419 };
420 Object result = FinderCache.getResult(finderClassName,
421 finderMethodName, finderParams, finderArgs, getSessionFactory());
422
423 if (result == null) {
424 Session session = null;
425
426 try {
427 session = openSession();
428
429 StringMaker query = new StringMaker();
430 query.append(
431 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
432 query.append("userId = ?");
433 query.append(" ");
434
435 if (obc != null) {
436 query.append("ORDER BY ");
437 query.append(obc.getOrderBy());
438 }
439
440 Query q = session.createQuery(query.toString());
441 int queryPos = 0;
442 q.setLong(queryPos++, userId);
443
444 List list = QueryUtil.list(q, getDialect(), begin, end);
445 FinderCache.putResult(finderClassName, finderMethodName,
446 finderParams, finderArgs, list);
447
448 return list;
449 }
450 catch (Exception e) {
451 throw HibernateUtil.processException(e);
452 }
453 finally {
454 closeSession(session);
455 }
456 }
457 else {
458 return (List)result;
459 }
460 }
461
462 public MBBan findByUserId_First(long userId, OrderByComparator obc)
463 throws NoSuchBanException, SystemException {
464 List list = findByUserId(userId, 0, 1, obc);
465
466 if (list.size() == 0) {
467 StringMaker msg = new StringMaker();
468 msg.append("No MBBan exists with the key ");
469 msg.append(StringPool.OPEN_CURLY_BRACE);
470 msg.append("userId=");
471 msg.append(userId);
472 msg.append(StringPool.CLOSE_CURLY_BRACE);
473 throw new NoSuchBanException(msg.toString());
474 }
475 else {
476 return (MBBan)list.get(0);
477 }
478 }
479
480 public MBBan findByUserId_Last(long userId, OrderByComparator obc)
481 throws NoSuchBanException, SystemException {
482 int count = countByUserId(userId);
483 List list = findByUserId(userId, count - 1, count, obc);
484
485 if (list.size() == 0) {
486 StringMaker msg = new StringMaker();
487 msg.append("No MBBan exists with the key ");
488 msg.append(StringPool.OPEN_CURLY_BRACE);
489 msg.append("userId=");
490 msg.append(userId);
491 msg.append(StringPool.CLOSE_CURLY_BRACE);
492 throw new NoSuchBanException(msg.toString());
493 }
494 else {
495 return (MBBan)list.get(0);
496 }
497 }
498
499 public MBBan[] findByUserId_PrevAndNext(long banId, long userId,
500 OrderByComparator obc) throws NoSuchBanException, SystemException {
501 MBBan mbBan = findByPrimaryKey(banId);
502 int count = countByUserId(userId);
503 Session session = null;
504
505 try {
506 session = openSession();
507
508 StringMaker query = new StringMaker();
509 query.append(
510 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
511 query.append("userId = ?");
512 query.append(" ");
513
514 if (obc != null) {
515 query.append("ORDER BY ");
516 query.append(obc.getOrderBy());
517 }
518
519 Query q = session.createQuery(query.toString());
520 int queryPos = 0;
521 q.setLong(queryPos++, userId);
522
523 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, mbBan);
524 MBBan[] array = new MBBanImpl[3];
525 array[0] = (MBBan)objArray[0];
526 array[1] = (MBBan)objArray[1];
527 array[2] = (MBBan)objArray[2];
528
529 return array;
530 }
531 catch (Exception e) {
532 throw HibernateUtil.processException(e);
533 }
534 finally {
535 closeSession(session);
536 }
537 }
538
539 public List findByBanUserId(long banUserId) throws SystemException {
540 String finderClassName = MBBan.class.getName();
541 String finderMethodName = "findByBanUserId";
542 String[] finderParams = new String[] { Long.class.getName() };
543 Object[] finderArgs = new Object[] { new Long(banUserId) };
544 Object result = FinderCache.getResult(finderClassName,
545 finderMethodName, finderParams, finderArgs, getSessionFactory());
546
547 if (result == null) {
548 Session session = null;
549
550 try {
551 session = openSession();
552
553 StringMaker query = new StringMaker();
554 query.append(
555 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
556 query.append("banUserId = ?");
557 query.append(" ");
558
559 Query q = session.createQuery(query.toString());
560 int queryPos = 0;
561 q.setLong(queryPos++, banUserId);
562
563 List list = q.list();
564 FinderCache.putResult(finderClassName, finderMethodName,
565 finderParams, finderArgs, list);
566
567 return list;
568 }
569 catch (Exception e) {
570 throw HibernateUtil.processException(e);
571 }
572 finally {
573 closeSession(session);
574 }
575 }
576 else {
577 return (List)result;
578 }
579 }
580
581 public List findByBanUserId(long banUserId, int begin, int end)
582 throws SystemException {
583 return findByBanUserId(banUserId, begin, end, null);
584 }
585
586 public List findByBanUserId(long banUserId, int begin, int end,
587 OrderByComparator obc) throws SystemException {
588 String finderClassName = MBBan.class.getName();
589 String finderMethodName = "findByBanUserId";
590 String[] finderParams = new String[] {
591 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
592 "com.liferay.portal.kernel.util.OrderByComparator"
593 };
594 Object[] finderArgs = new Object[] {
595 new Long(banUserId), String.valueOf(begin), String.valueOf(end),
596 String.valueOf(obc)
597 };
598 Object result = FinderCache.getResult(finderClassName,
599 finderMethodName, finderParams, finderArgs, getSessionFactory());
600
601 if (result == null) {
602 Session session = null;
603
604 try {
605 session = openSession();
606
607 StringMaker query = new StringMaker();
608 query.append(
609 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
610 query.append("banUserId = ?");
611 query.append(" ");
612
613 if (obc != null) {
614 query.append("ORDER BY ");
615 query.append(obc.getOrderBy());
616 }
617
618 Query q = session.createQuery(query.toString());
619 int queryPos = 0;
620 q.setLong(queryPos++, banUserId);
621
622 List list = QueryUtil.list(q, getDialect(), begin, end);
623 FinderCache.putResult(finderClassName, finderMethodName,
624 finderParams, finderArgs, list);
625
626 return list;
627 }
628 catch (Exception e) {
629 throw HibernateUtil.processException(e);
630 }
631 finally {
632 closeSession(session);
633 }
634 }
635 else {
636 return (List)result;
637 }
638 }
639
640 public MBBan findByBanUserId_First(long banUserId, OrderByComparator obc)
641 throws NoSuchBanException, SystemException {
642 List list = findByBanUserId(banUserId, 0, 1, obc);
643
644 if (list.size() == 0) {
645 StringMaker msg = new StringMaker();
646 msg.append("No MBBan exists with the key ");
647 msg.append(StringPool.OPEN_CURLY_BRACE);
648 msg.append("banUserId=");
649 msg.append(banUserId);
650 msg.append(StringPool.CLOSE_CURLY_BRACE);
651 throw new NoSuchBanException(msg.toString());
652 }
653 else {
654 return (MBBan)list.get(0);
655 }
656 }
657
658 public MBBan findByBanUserId_Last(long banUserId, OrderByComparator obc)
659 throws NoSuchBanException, SystemException {
660 int count = countByBanUserId(banUserId);
661 List list = findByBanUserId(banUserId, count - 1, count, obc);
662
663 if (list.size() == 0) {
664 StringMaker msg = new StringMaker();
665 msg.append("No MBBan exists with the key ");
666 msg.append(StringPool.OPEN_CURLY_BRACE);
667 msg.append("banUserId=");
668 msg.append(banUserId);
669 msg.append(StringPool.CLOSE_CURLY_BRACE);
670 throw new NoSuchBanException(msg.toString());
671 }
672 else {
673 return (MBBan)list.get(0);
674 }
675 }
676
677 public MBBan[] findByBanUserId_PrevAndNext(long banId, long banUserId,
678 OrderByComparator obc) throws NoSuchBanException, SystemException {
679 MBBan mbBan = findByPrimaryKey(banId);
680 int count = countByBanUserId(banUserId);
681 Session session = null;
682
683 try {
684 session = openSession();
685
686 StringMaker query = new StringMaker();
687 query.append(
688 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
689 query.append("banUserId = ?");
690 query.append(" ");
691
692 if (obc != null) {
693 query.append("ORDER BY ");
694 query.append(obc.getOrderBy());
695 }
696
697 Query q = session.createQuery(query.toString());
698 int queryPos = 0;
699 q.setLong(queryPos++, banUserId);
700
701 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, mbBan);
702 MBBan[] array = new MBBanImpl[3];
703 array[0] = (MBBan)objArray[0];
704 array[1] = (MBBan)objArray[1];
705 array[2] = (MBBan)objArray[2];
706
707 return array;
708 }
709 catch (Exception e) {
710 throw HibernateUtil.processException(e);
711 }
712 finally {
713 closeSession(session);
714 }
715 }
716
717 public MBBan findByG_B(long groupId, long banUserId)
718 throws NoSuchBanException, SystemException {
719 MBBan mbBan = fetchByG_B(groupId, banUserId);
720
721 if (mbBan == null) {
722 StringMaker msg = new StringMaker();
723 msg.append("No MBBan exists with the key ");
724 msg.append(StringPool.OPEN_CURLY_BRACE);
725 msg.append("groupId=");
726 msg.append(groupId);
727 msg.append(", ");
728 msg.append("banUserId=");
729 msg.append(banUserId);
730 msg.append(StringPool.CLOSE_CURLY_BRACE);
731
732 if (_log.isWarnEnabled()) {
733 _log.warn(msg.toString());
734 }
735
736 throw new NoSuchBanException(msg.toString());
737 }
738
739 return mbBan;
740 }
741
742 public MBBan fetchByG_B(long groupId, long banUserId)
743 throws SystemException {
744 String finderClassName = MBBan.class.getName();
745 String finderMethodName = "fetchByG_B";
746 String[] finderParams = new String[] {
747 Long.class.getName(), Long.class.getName()
748 };
749 Object[] finderArgs = new Object[] {
750 new Long(groupId), new Long(banUserId)
751 };
752 Object result = FinderCache.getResult(finderClassName,
753 finderMethodName, finderParams, finderArgs, getSessionFactory());
754
755 if (result == null) {
756 Session session = null;
757
758 try {
759 session = openSession();
760
761 StringMaker query = new StringMaker();
762 query.append(
763 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
764 query.append("groupId = ?");
765 query.append(" AND ");
766 query.append("banUserId = ?");
767 query.append(" ");
768
769 Query q = session.createQuery(query.toString());
770 int queryPos = 0;
771 q.setLong(queryPos++, groupId);
772 q.setLong(queryPos++, banUserId);
773
774 List list = q.list();
775 FinderCache.putResult(finderClassName, finderMethodName,
776 finderParams, finderArgs, list);
777
778 if (list.size() == 0) {
779 return null;
780 }
781 else {
782 return (MBBan)list.get(0);
783 }
784 }
785 catch (Exception e) {
786 throw HibernateUtil.processException(e);
787 }
788 finally {
789 closeSession(session);
790 }
791 }
792 else {
793 List list = (List)result;
794
795 if (list.size() == 0) {
796 return null;
797 }
798 else {
799 return (MBBan)list.get(0);
800 }
801 }
802 }
803
804 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
805 throws SystemException {
806 Session session = null;
807
808 try {
809 session = openSession();
810
811 DynamicQuery query = queryInitializer.initialize(session);
812
813 return query.list();
814 }
815 catch (Exception e) {
816 throw HibernateUtil.processException(e);
817 }
818 finally {
819 closeSession(session);
820 }
821 }
822
823 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
824 int begin, int end) throws SystemException {
825 Session session = null;
826
827 try {
828 session = openSession();
829
830 DynamicQuery query = queryInitializer.initialize(session);
831 query.setLimit(begin, end);
832
833 return query.list();
834 }
835 catch (Exception e) {
836 throw HibernateUtil.processException(e);
837 }
838 finally {
839 closeSession(session);
840 }
841 }
842
843 public List findAll() throws SystemException {
844 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
845 }
846
847 public List findAll(int begin, int end) throws SystemException {
848 return findAll(begin, end, null);
849 }
850
851 public List findAll(int begin, int end, OrderByComparator obc)
852 throws SystemException {
853 String finderClassName = MBBan.class.getName();
854 String finderMethodName = "findAll";
855 String[] finderParams = new String[] {
856 "java.lang.Integer", "java.lang.Integer",
857 "com.liferay.portal.kernel.util.OrderByComparator"
858 };
859 Object[] finderArgs = new Object[] {
860 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
861 };
862 Object result = FinderCache.getResult(finderClassName,
863 finderMethodName, finderParams, finderArgs, getSessionFactory());
864
865 if (result == null) {
866 Session session = null;
867
868 try {
869 session = openSession();
870
871 StringMaker query = new StringMaker();
872 query.append(
873 "FROM com.liferay.portlet.messageboards.model.MBBan ");
874
875 if (obc != null) {
876 query.append("ORDER BY ");
877 query.append(obc.getOrderBy());
878 }
879
880 Query q = session.createQuery(query.toString());
881 List list = QueryUtil.list(q, getDialect(), begin, end);
882
883 if (obc == null) {
884 Collections.sort(list);
885 }
886
887 FinderCache.putResult(finderClassName, finderMethodName,
888 finderParams, finderArgs, list);
889
890 return list;
891 }
892 catch (Exception e) {
893 throw HibernateUtil.processException(e);
894 }
895 finally {
896 closeSession(session);
897 }
898 }
899 else {
900 return (List)result;
901 }
902 }
903
904 public void removeByGroupId(long groupId) throws SystemException {
905 Iterator itr = findByGroupId(groupId).iterator();
906
907 while (itr.hasNext()) {
908 MBBan mbBan = (MBBan)itr.next();
909 remove(mbBan);
910 }
911 }
912
913 public void removeByUserId(long userId) throws SystemException {
914 Iterator itr = findByUserId(userId).iterator();
915
916 while (itr.hasNext()) {
917 MBBan mbBan = (MBBan)itr.next();
918 remove(mbBan);
919 }
920 }
921
922 public void removeByBanUserId(long banUserId) throws SystemException {
923 Iterator itr = findByBanUserId(banUserId).iterator();
924
925 while (itr.hasNext()) {
926 MBBan mbBan = (MBBan)itr.next();
927 remove(mbBan);
928 }
929 }
930
931 public void removeByG_B(long groupId, long banUserId)
932 throws NoSuchBanException, SystemException {
933 MBBan mbBan = findByG_B(groupId, banUserId);
934 remove(mbBan);
935 }
936
937 public void removeAll() throws SystemException {
938 Iterator itr = findAll().iterator();
939
940 while (itr.hasNext()) {
941 remove((MBBan)itr.next());
942 }
943 }
944
945 public int countByGroupId(long groupId) throws SystemException {
946 String finderClassName = MBBan.class.getName();
947 String finderMethodName = "countByGroupId";
948 String[] finderParams = new String[] { Long.class.getName() };
949 Object[] finderArgs = new Object[] { new Long(groupId) };
950 Object result = FinderCache.getResult(finderClassName,
951 finderMethodName, finderParams, finderArgs, getSessionFactory());
952
953 if (result == null) {
954 Session session = null;
955
956 try {
957 session = openSession();
958
959 StringMaker query = new StringMaker();
960 query.append("SELECT COUNT(*) ");
961 query.append(
962 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
963 query.append("groupId = ?");
964 query.append(" ");
965
966 Query q = session.createQuery(query.toString());
967 int queryPos = 0;
968 q.setLong(queryPos++, groupId);
969
970 Long count = null;
971 Iterator itr = q.list().iterator();
972
973 if (itr.hasNext()) {
974 count = (Long)itr.next();
975 }
976
977 if (count == null) {
978 count = new Long(0);
979 }
980
981 FinderCache.putResult(finderClassName, finderMethodName,
982 finderParams, finderArgs, count);
983
984 return count.intValue();
985 }
986 catch (Exception e) {
987 throw HibernateUtil.processException(e);
988 }
989 finally {
990 closeSession(session);
991 }
992 }
993 else {
994 return ((Long)result).intValue();
995 }
996 }
997
998 public int countByUserId(long userId) throws SystemException {
999 String finderClassName = MBBan.class.getName();
1000 String finderMethodName = "countByUserId";
1001 String[] finderParams = new String[] { Long.class.getName() };
1002 Object[] finderArgs = new Object[] { new Long(userId) };
1003 Object result = FinderCache.getResult(finderClassName,
1004 finderMethodName, finderParams, finderArgs, getSessionFactory());
1005
1006 if (result == null) {
1007 Session session = null;
1008
1009 try {
1010 session = openSession();
1011
1012 StringMaker query = new StringMaker();
1013 query.append("SELECT COUNT(*) ");
1014 query.append(
1015 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
1016 query.append("userId = ?");
1017 query.append(" ");
1018
1019 Query q = session.createQuery(query.toString());
1020 int queryPos = 0;
1021 q.setLong(queryPos++, userId);
1022
1023 Long count = null;
1024 Iterator itr = q.list().iterator();
1025
1026 if (itr.hasNext()) {
1027 count = (Long)itr.next();
1028 }
1029
1030 if (count == null) {
1031 count = new Long(0);
1032 }
1033
1034 FinderCache.putResult(finderClassName, finderMethodName,
1035 finderParams, finderArgs, count);
1036
1037 return count.intValue();
1038 }
1039 catch (Exception e) {
1040 throw HibernateUtil.processException(e);
1041 }
1042 finally {
1043 closeSession(session);
1044 }
1045 }
1046 else {
1047 return ((Long)result).intValue();
1048 }
1049 }
1050
1051 public int countByBanUserId(long banUserId) throws SystemException {
1052 String finderClassName = MBBan.class.getName();
1053 String finderMethodName = "countByBanUserId";
1054 String[] finderParams = new String[] { Long.class.getName() };
1055 Object[] finderArgs = new Object[] { new Long(banUserId) };
1056 Object result = FinderCache.getResult(finderClassName,
1057 finderMethodName, finderParams, finderArgs, getSessionFactory());
1058
1059 if (result == null) {
1060 Session session = null;
1061
1062 try {
1063 session = openSession();
1064
1065 StringMaker query = new StringMaker();
1066 query.append("SELECT COUNT(*) ");
1067 query.append(
1068 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
1069 query.append("banUserId = ?");
1070 query.append(" ");
1071
1072 Query q = session.createQuery(query.toString());
1073 int queryPos = 0;
1074 q.setLong(queryPos++, banUserId);
1075
1076 Long count = null;
1077 Iterator itr = q.list().iterator();
1078
1079 if (itr.hasNext()) {
1080 count = (Long)itr.next();
1081 }
1082
1083 if (count == null) {
1084 count = new Long(0);
1085 }
1086
1087 FinderCache.putResult(finderClassName, finderMethodName,
1088 finderParams, finderArgs, count);
1089
1090 return count.intValue();
1091 }
1092 catch (Exception e) {
1093 throw HibernateUtil.processException(e);
1094 }
1095 finally {
1096 closeSession(session);
1097 }
1098 }
1099 else {
1100 return ((Long)result).intValue();
1101 }
1102 }
1103
1104 public int countByG_B(long groupId, long banUserId)
1105 throws SystemException {
1106 String finderClassName = MBBan.class.getName();
1107 String finderMethodName = "countByG_B";
1108 String[] finderParams = new String[] {
1109 Long.class.getName(), Long.class.getName()
1110 };
1111 Object[] finderArgs = new Object[] {
1112 new Long(groupId), new Long(banUserId)
1113 };
1114 Object result = FinderCache.getResult(finderClassName,
1115 finderMethodName, finderParams, finderArgs, getSessionFactory());
1116
1117 if (result == null) {
1118 Session session = null;
1119
1120 try {
1121 session = openSession();
1122
1123 StringMaker query = new StringMaker();
1124 query.append("SELECT COUNT(*) ");
1125 query.append(
1126 "FROM com.liferay.portlet.messageboards.model.MBBan WHERE ");
1127 query.append("groupId = ?");
1128 query.append(" AND ");
1129 query.append("banUserId = ?");
1130 query.append(" ");
1131
1132 Query q = session.createQuery(query.toString());
1133 int queryPos = 0;
1134 q.setLong(queryPos++, groupId);
1135 q.setLong(queryPos++, banUserId);
1136
1137 Long count = null;
1138 Iterator itr = q.list().iterator();
1139
1140 if (itr.hasNext()) {
1141 count = (Long)itr.next();
1142 }
1143
1144 if (count == null) {
1145 count = new Long(0);
1146 }
1147
1148 FinderCache.putResult(finderClassName, finderMethodName,
1149 finderParams, finderArgs, count);
1150
1151 return count.intValue();
1152 }
1153 catch (Exception e) {
1154 throw HibernateUtil.processException(e);
1155 }
1156 finally {
1157 closeSession(session);
1158 }
1159 }
1160 else {
1161 return ((Long)result).intValue();
1162 }
1163 }
1164
1165 public int countAll() throws SystemException {
1166 String finderClassName = MBBan.class.getName();
1167 String finderMethodName = "countAll";
1168 String[] finderParams = new String[] { };
1169 Object[] finderArgs = new Object[] { };
1170 Object result = FinderCache.getResult(finderClassName,
1171 finderMethodName, finderParams, finderArgs, getSessionFactory());
1172
1173 if (result == null) {
1174 Session session = null;
1175
1176 try {
1177 session = openSession();
1178
1179 StringMaker query = new StringMaker();
1180 query.append("SELECT COUNT(*) ");
1181 query.append(
1182 "FROM com.liferay.portlet.messageboards.model.MBBan");
1183
1184 Query q = session.createQuery(query.toString());
1185 Long count = null;
1186 Iterator itr = q.list().iterator();
1187
1188 if (itr.hasNext()) {
1189 count = (Long)itr.next();
1190 }
1191
1192 if (count == null) {
1193 count = new Long(0);
1194 }
1195
1196 FinderCache.putResult(finderClassName, finderMethodName,
1197 finderParams, finderArgs, count);
1198
1199 return count.intValue();
1200 }
1201 catch (Exception e) {
1202 throw HibernateUtil.processException(e);
1203 }
1204 finally {
1205 closeSession(session);
1206 }
1207 }
1208 else {
1209 return ((Long)result).intValue();
1210 }
1211 }
1212
1213 protected void initDao() {
1214 }
1215
1216 private static Log _log = LogFactory.getLog(MBBanPersistenceImpl.class);
1217}