001
014
015 package com.liferay.portlet.messageboards.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.CalendarUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.BatchSessionUtil;
039 import com.liferay.portal.service.persistence.LockPersistence;
040 import com.liferay.portal.service.persistence.ResourcePersistence;
041 import com.liferay.portal.service.persistence.UserPersistence;
042 import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
046 import com.liferay.portlet.messageboards.NoSuchThreadException;
047 import com.liferay.portlet.messageboards.model.MBThread;
048 import com.liferay.portlet.messageboards.model.impl.MBThreadImpl;
049 import com.liferay.portlet.messageboards.model.impl.MBThreadModelImpl;
050 import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
051 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
052
053 import java.io.Serializable;
054
055 import java.util.ArrayList;
056 import java.util.Collections;
057 import java.util.Date;
058 import java.util.List;
059
060
076 public class MBThreadPersistenceImpl extends BasePersistenceImpl<MBThread>
077 implements MBThreadPersistence {
078 public static final String FINDER_CLASS_NAME_ENTITY = MBThreadImpl.class.getName();
079 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
080 ".List";
081 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
082 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
083 "findByGroupId",
084 new String[] {
085 Long.class.getName(),
086
087 "java.lang.Integer", "java.lang.Integer",
088 "com.liferay.portal.kernel.util.OrderByComparator"
089 });
090 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
091 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
092 "countByGroupId", new String[] { Long.class.getName() });
093 public static final FinderPath FINDER_PATH_FIND_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
094 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
095 "findByG_C",
096 new String[] {
097 Long.class.getName(), Long.class.getName(),
098
099 "java.lang.Integer", "java.lang.Integer",
100 "com.liferay.portal.kernel.util.OrderByComparator"
101 });
102 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
103 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104 "countByG_C",
105 new String[] { Long.class.getName(), Long.class.getName() });
106 public static final FinderPath FINDER_PATH_FIND_BY_G_NOTC = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
107 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108 "findByG_NotC",
109 new String[] {
110 Long.class.getName(), Long.class.getName(),
111
112 "java.lang.Integer", "java.lang.Integer",
113 "com.liferay.portal.kernel.util.OrderByComparator"
114 });
115 public static final FinderPath FINDER_PATH_COUNT_BY_G_NOTC = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
116 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
117 "countByG_NotC",
118 new String[] { Long.class.getName(), Long.class.getName() });
119 public static final FinderPath FINDER_PATH_FIND_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
120 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
121 "findByG_S",
122 new String[] {
123 Long.class.getName(), Integer.class.getName(),
124
125 "java.lang.Integer", "java.lang.Integer",
126 "com.liferay.portal.kernel.util.OrderByComparator"
127 });
128 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
129 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
130 "countByG_S",
131 new String[] { Long.class.getName(), Integer.class.getName() });
132 public static final FinderPath FINDER_PATH_FIND_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
133 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
134 "findByC_P",
135 new String[] {
136 Long.class.getName(), Double.class.getName(),
137
138 "java.lang.Integer", "java.lang.Integer",
139 "com.liferay.portal.kernel.util.OrderByComparator"
140 });
141 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
142 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
143 "countByC_P",
144 new String[] { Long.class.getName(), Double.class.getName() });
145 public static final FinderPath FINDER_PATH_FIND_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
146 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
147 "findByG_C_L",
148 new String[] {
149 Long.class.getName(), Long.class.getName(), Date.class.getName(),
150
151 "java.lang.Integer", "java.lang.Integer",
152 "com.liferay.portal.kernel.util.OrderByComparator"
153 });
154 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
155 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
156 "countByG_C_L",
157 new String[] {
158 Long.class.getName(), Long.class.getName(), Date.class.getName()
159 });
160 public static final FinderPath FINDER_PATH_FIND_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
161 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
162 "findByG_C_S",
163 new String[] {
164 Long.class.getName(), Long.class.getName(),
165 Integer.class.getName(),
166
167 "java.lang.Integer", "java.lang.Integer",
168 "com.liferay.portal.kernel.util.OrderByComparator"
169 });
170 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
171 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
172 "countByG_C_S",
173 new String[] {
174 Long.class.getName(), Long.class.getName(),
175 Integer.class.getName()
176 });
177 public static final FinderPath FINDER_PATH_FIND_BY_G_NOTC_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
178 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
179 "findByG_NotC_S",
180 new String[] {
181 Long.class.getName(), Long.class.getName(),
182 Integer.class.getName(),
183
184 "java.lang.Integer", "java.lang.Integer",
185 "com.liferay.portal.kernel.util.OrderByComparator"
186 });
187 public static final FinderPath FINDER_PATH_COUNT_BY_G_NOTC_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
188 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
189 "countByG_NotC_S",
190 new String[] {
191 Long.class.getName(), Long.class.getName(),
192 Integer.class.getName()
193 });
194 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
195 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
196 "findAll", new String[0]);
197 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
198 MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
199 "countAll", new String[0]);
200
201
206 public void cacheResult(MBThread mbThread) {
207 EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
208 MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread);
209 }
210
211
216 public void cacheResult(List<MBThread> mbThreads) {
217 for (MBThread mbThread : mbThreads) {
218 if (EntityCacheUtil.getResult(
219 MBThreadModelImpl.ENTITY_CACHE_ENABLED,
220 MBThreadImpl.class, mbThread.getPrimaryKey(), this) == null) {
221 cacheResult(mbThread);
222 }
223 }
224 }
225
226
233 public void clearCache() {
234 CacheRegistryUtil.clear(MBThreadImpl.class.getName());
235 EntityCacheUtil.clearCache(MBThreadImpl.class.getName());
236 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
237 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
238 }
239
240
247 public void clearCache(MBThread mbThread) {
248 EntityCacheUtil.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
249 MBThreadImpl.class, mbThread.getPrimaryKey());
250 }
251
252
258 public MBThread create(long threadId) {
259 MBThread mbThread = new MBThreadImpl();
260
261 mbThread.setNew(true);
262 mbThread.setPrimaryKey(threadId);
263
264 return mbThread;
265 }
266
267
275 public MBThread remove(Serializable primaryKey)
276 throws NoSuchModelException, SystemException {
277 return remove(((Long)primaryKey).longValue());
278 }
279
280
288 public MBThread remove(long threadId)
289 throws NoSuchThreadException, SystemException {
290 Session session = null;
291
292 try {
293 session = openSession();
294
295 MBThread mbThread = (MBThread)session.get(MBThreadImpl.class,
296 new Long(threadId));
297
298 if (mbThread == null) {
299 if (_log.isWarnEnabled()) {
300 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + threadId);
301 }
302
303 throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
304 threadId);
305 }
306
307 return remove(mbThread);
308 }
309 catch (NoSuchThreadException nsee) {
310 throw nsee;
311 }
312 catch (Exception e) {
313 throw processException(e);
314 }
315 finally {
316 closeSession(session);
317 }
318 }
319
320 protected MBThread removeImpl(MBThread mbThread) throws SystemException {
321 mbThread = toUnwrappedModel(mbThread);
322
323 Session session = null;
324
325 try {
326 session = openSession();
327
328 BatchSessionUtil.delete(session, mbThread);
329 }
330 catch (Exception e) {
331 throw processException(e);
332 }
333 finally {
334 closeSession(session);
335 }
336
337 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
338
339 EntityCacheUtil.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
340 MBThreadImpl.class, mbThread.getPrimaryKey());
341
342 return mbThread;
343 }
344
345 public MBThread updateImpl(
346 com.liferay.portlet.messageboards.model.MBThread mbThread, boolean merge)
347 throws SystemException {
348 mbThread = toUnwrappedModel(mbThread);
349
350 Session session = null;
351
352 try {
353 session = openSession();
354
355 BatchSessionUtil.update(session, mbThread, merge);
356
357 mbThread.setNew(false);
358 }
359 catch (Exception e) {
360 throw processException(e);
361 }
362 finally {
363 closeSession(session);
364 }
365
366 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
367
368 EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
369 MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread);
370
371 return mbThread;
372 }
373
374 protected MBThread toUnwrappedModel(MBThread mbThread) {
375 if (mbThread instanceof MBThreadImpl) {
376 return mbThread;
377 }
378
379 MBThreadImpl mbThreadImpl = new MBThreadImpl();
380
381 mbThreadImpl.setNew(mbThread.isNew());
382 mbThreadImpl.setPrimaryKey(mbThread.getPrimaryKey());
383
384 mbThreadImpl.setThreadId(mbThread.getThreadId());
385 mbThreadImpl.setGroupId(mbThread.getGroupId());
386 mbThreadImpl.setCategoryId(mbThread.getCategoryId());
387 mbThreadImpl.setRootMessageId(mbThread.getRootMessageId());
388 mbThreadImpl.setMessageCount(mbThread.getMessageCount());
389 mbThreadImpl.setViewCount(mbThread.getViewCount());
390 mbThreadImpl.setLastPostByUserId(mbThread.getLastPostByUserId());
391 mbThreadImpl.setLastPostDate(mbThread.getLastPostDate());
392 mbThreadImpl.setPriority(mbThread.getPriority());
393 mbThreadImpl.setStatus(mbThread.getStatus());
394 mbThreadImpl.setStatusByUserId(mbThread.getStatusByUserId());
395 mbThreadImpl.setStatusByUserName(mbThread.getStatusByUserName());
396 mbThreadImpl.setStatusDate(mbThread.getStatusDate());
397
398 return mbThreadImpl;
399 }
400
401
409 public MBThread findByPrimaryKey(Serializable primaryKey)
410 throws NoSuchModelException, SystemException {
411 return findByPrimaryKey(((Long)primaryKey).longValue());
412 }
413
414
422 public MBThread findByPrimaryKey(long threadId)
423 throws NoSuchThreadException, SystemException {
424 MBThread mbThread = fetchByPrimaryKey(threadId);
425
426 if (mbThread == null) {
427 if (_log.isWarnEnabled()) {
428 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + threadId);
429 }
430
431 throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
432 threadId);
433 }
434
435 return mbThread;
436 }
437
438
445 public MBThread fetchByPrimaryKey(Serializable primaryKey)
446 throws SystemException {
447 return fetchByPrimaryKey(((Long)primaryKey).longValue());
448 }
449
450
457 public MBThread fetchByPrimaryKey(long threadId) throws SystemException {
458 MBThread mbThread = (MBThread)EntityCacheUtil.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
459 MBThreadImpl.class, threadId, this);
460
461 if (mbThread == null) {
462 Session session = null;
463
464 try {
465 session = openSession();
466
467 mbThread = (MBThread)session.get(MBThreadImpl.class,
468 new Long(threadId));
469 }
470 catch (Exception e) {
471 throw processException(e);
472 }
473 finally {
474 if (mbThread != null) {
475 cacheResult(mbThread);
476 }
477
478 closeSession(session);
479 }
480 }
481
482 return mbThread;
483 }
484
485
492 public List<MBThread> findByGroupId(long groupId) throws SystemException {
493 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
494 }
495
496
509 public List<MBThread> findByGroupId(long groupId, int start, int end)
510 throws SystemException {
511 return findByGroupId(groupId, start, end, null);
512 }
513
514
528 public List<MBThread> findByGroupId(long groupId, int start, int end,
529 OrderByComparator orderByComparator) throws SystemException {
530 Object[] finderArgs = new Object[] {
531 groupId,
532
533 String.valueOf(start), String.valueOf(end),
534 String.valueOf(orderByComparator)
535 };
536
537 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
538 finderArgs, this);
539
540 if (list == null) {
541 StringBundler query = null;
542
543 if (orderByComparator != null) {
544 query = new StringBundler(3 +
545 (orderByComparator.getOrderByFields().length * 3));
546 }
547 else {
548 query = new StringBundler(3);
549 }
550
551 query.append(_SQL_SELECT_MBTHREAD_WHERE);
552
553 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
554
555 if (orderByComparator != null) {
556 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
557 orderByComparator);
558 }
559
560 else {
561 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
562 }
563
564 String sql = query.toString();
565
566 Session session = null;
567
568 try {
569 session = openSession();
570
571 Query q = session.createQuery(sql);
572
573 QueryPos qPos = QueryPos.getInstance(q);
574
575 qPos.add(groupId);
576
577 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
578 end);
579 }
580 catch (Exception e) {
581 throw processException(e);
582 }
583 finally {
584 if (list == null) {
585 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_GROUPID,
586 finderArgs);
587 }
588 else {
589 cacheResult(list);
590
591 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
592 finderArgs, list);
593 }
594
595 closeSession(session);
596 }
597 }
598
599 return list;
600 }
601
602
615 public MBThread findByGroupId_First(long groupId,
616 OrderByComparator orderByComparator)
617 throws NoSuchThreadException, SystemException {
618 List<MBThread> list = findByGroupId(groupId, 0, 1, orderByComparator);
619
620 if (list.isEmpty()) {
621 StringBundler msg = new StringBundler(4);
622
623 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
624
625 msg.append("groupId=");
626 msg.append(groupId);
627
628 msg.append(StringPool.CLOSE_CURLY_BRACE);
629
630 throw new NoSuchThreadException(msg.toString());
631 }
632 else {
633 return list.get(0);
634 }
635 }
636
637
650 public MBThread findByGroupId_Last(long groupId,
651 OrderByComparator orderByComparator)
652 throws NoSuchThreadException, SystemException {
653 int count = countByGroupId(groupId);
654
655 List<MBThread> list = findByGroupId(groupId, count - 1, count,
656 orderByComparator);
657
658 if (list.isEmpty()) {
659 StringBundler msg = new StringBundler(4);
660
661 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
662
663 msg.append("groupId=");
664 msg.append(groupId);
665
666 msg.append(StringPool.CLOSE_CURLY_BRACE);
667
668 throw new NoSuchThreadException(msg.toString());
669 }
670 else {
671 return list.get(0);
672 }
673 }
674
675
689 public MBThread[] findByGroupId_PrevAndNext(long threadId, long groupId,
690 OrderByComparator orderByComparator)
691 throws NoSuchThreadException, SystemException {
692 MBThread mbThread = findByPrimaryKey(threadId);
693
694 Session session = null;
695
696 try {
697 session = openSession();
698
699 MBThread[] array = new MBThreadImpl[3];
700
701 array[0] = getByGroupId_PrevAndNext(session, mbThread, groupId,
702 orderByComparator, true);
703
704 array[1] = mbThread;
705
706 array[2] = getByGroupId_PrevAndNext(session, mbThread, groupId,
707 orderByComparator, false);
708
709 return array;
710 }
711 catch (Exception e) {
712 throw processException(e);
713 }
714 finally {
715 closeSession(session);
716 }
717 }
718
719 protected MBThread getByGroupId_PrevAndNext(Session session,
720 MBThread mbThread, long groupId, OrderByComparator orderByComparator,
721 boolean previous) {
722 StringBundler query = null;
723
724 if (orderByComparator != null) {
725 query = new StringBundler(6 +
726 (orderByComparator.getOrderByFields().length * 6));
727 }
728 else {
729 query = new StringBundler(3);
730 }
731
732 query.append(_SQL_SELECT_MBTHREAD_WHERE);
733
734 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
735
736 if (orderByComparator != null) {
737 String[] orderByFields = orderByComparator.getOrderByFields();
738
739 if (orderByFields.length > 0) {
740 query.append(WHERE_AND);
741 }
742
743 for (int i = 0; i < orderByFields.length; i++) {
744 query.append(_ORDER_BY_ENTITY_ALIAS);
745 query.append(orderByFields[i]);
746
747 if ((i + 1) < orderByFields.length) {
748 if (orderByComparator.isAscending() ^ previous) {
749 query.append(WHERE_GREATER_THAN_HAS_NEXT);
750 }
751 else {
752 query.append(WHERE_LESSER_THAN_HAS_NEXT);
753 }
754 }
755 else {
756 if (orderByComparator.isAscending() ^ previous) {
757 query.append(WHERE_GREATER_THAN);
758 }
759 else {
760 query.append(WHERE_LESSER_THAN);
761 }
762 }
763 }
764
765 query.append(ORDER_BY_CLAUSE);
766
767 for (int i = 0; i < orderByFields.length; i++) {
768 query.append(_ORDER_BY_ENTITY_ALIAS);
769 query.append(orderByFields[i]);
770
771 if ((i + 1) < orderByFields.length) {
772 if (orderByComparator.isAscending() ^ previous) {
773 query.append(ORDER_BY_ASC_HAS_NEXT);
774 }
775 else {
776 query.append(ORDER_BY_DESC_HAS_NEXT);
777 }
778 }
779 else {
780 if (orderByComparator.isAscending() ^ previous) {
781 query.append(ORDER_BY_ASC);
782 }
783 else {
784 query.append(ORDER_BY_DESC);
785 }
786 }
787 }
788 }
789
790 else {
791 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
792 }
793
794 String sql = query.toString();
795
796 Query q = session.createQuery(sql);
797
798 q.setFirstResult(0);
799 q.setMaxResults(2);
800
801 QueryPos qPos = QueryPos.getInstance(q);
802
803 qPos.add(groupId);
804
805 if (orderByComparator != null) {
806 Object[] values = orderByComparator.getOrderByValues(mbThread);
807
808 for (Object value : values) {
809 qPos.add(value);
810 }
811 }
812
813 List<MBThread> list = q.list();
814
815 if (list.size() == 2) {
816 return list.get(1);
817 }
818 else {
819 return null;
820 }
821 }
822
823
831 public List<MBThread> findByG_C(long groupId, long categoryId)
832 throws SystemException {
833 return findByG_C(groupId, categoryId, QueryUtil.ALL_POS,
834 QueryUtil.ALL_POS, null);
835 }
836
837
851 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
852 int end) throws SystemException {
853 return findByG_C(groupId, categoryId, start, end, null);
854 }
855
856
871 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
872 int end, OrderByComparator orderByComparator) throws SystemException {
873 Object[] finderArgs = new Object[] {
874 groupId, categoryId,
875
876 String.valueOf(start), String.valueOf(end),
877 String.valueOf(orderByComparator)
878 };
879
880 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C,
881 finderArgs, this);
882
883 if (list == null) {
884 StringBundler query = null;
885
886 if (orderByComparator != null) {
887 query = new StringBundler(4 +
888 (orderByComparator.getOrderByFields().length * 3));
889 }
890 else {
891 query = new StringBundler(4);
892 }
893
894 query.append(_SQL_SELECT_MBTHREAD_WHERE);
895
896 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
897
898 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
899
900 if (orderByComparator != null) {
901 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
902 orderByComparator);
903 }
904
905 else {
906 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
907 }
908
909 String sql = query.toString();
910
911 Session session = null;
912
913 try {
914 session = openSession();
915
916 Query q = session.createQuery(sql);
917
918 QueryPos qPos = QueryPos.getInstance(q);
919
920 qPos.add(groupId);
921
922 qPos.add(categoryId);
923
924 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
925 end);
926 }
927 catch (Exception e) {
928 throw processException(e);
929 }
930 finally {
931 if (list == null) {
932 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_C,
933 finderArgs);
934 }
935 else {
936 cacheResult(list);
937
938 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C,
939 finderArgs, list);
940 }
941
942 closeSession(session);
943 }
944 }
945
946 return list;
947 }
948
949
963 public MBThread findByG_C_First(long groupId, long categoryId,
964 OrderByComparator orderByComparator)
965 throws NoSuchThreadException, SystemException {
966 List<MBThread> list = findByG_C(groupId, categoryId, 0, 1,
967 orderByComparator);
968
969 if (list.isEmpty()) {
970 StringBundler msg = new StringBundler(6);
971
972 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
973
974 msg.append("groupId=");
975 msg.append(groupId);
976
977 msg.append(", categoryId=");
978 msg.append(categoryId);
979
980 msg.append(StringPool.CLOSE_CURLY_BRACE);
981
982 throw new NoSuchThreadException(msg.toString());
983 }
984 else {
985 return list.get(0);
986 }
987 }
988
989
1003 public MBThread findByG_C_Last(long groupId, long categoryId,
1004 OrderByComparator orderByComparator)
1005 throws NoSuchThreadException, SystemException {
1006 int count = countByG_C(groupId, categoryId);
1007
1008 List<MBThread> list = findByG_C(groupId, categoryId, count - 1, count,
1009 orderByComparator);
1010
1011 if (list.isEmpty()) {
1012 StringBundler msg = new StringBundler(6);
1013
1014 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1015
1016 msg.append("groupId=");
1017 msg.append(groupId);
1018
1019 msg.append(", categoryId=");
1020 msg.append(categoryId);
1021
1022 msg.append(StringPool.CLOSE_CURLY_BRACE);
1023
1024 throw new NoSuchThreadException(msg.toString());
1025 }
1026 else {
1027 return list.get(0);
1028 }
1029 }
1030
1031
1046 public MBThread[] findByG_C_PrevAndNext(long threadId, long groupId,
1047 long categoryId, OrderByComparator orderByComparator)
1048 throws NoSuchThreadException, SystemException {
1049 MBThread mbThread = findByPrimaryKey(threadId);
1050
1051 Session session = null;
1052
1053 try {
1054 session = openSession();
1055
1056 MBThread[] array = new MBThreadImpl[3];
1057
1058 array[0] = getByG_C_PrevAndNext(session, mbThread, groupId,
1059 categoryId, orderByComparator, true);
1060
1061 array[1] = mbThread;
1062
1063 array[2] = getByG_C_PrevAndNext(session, mbThread, groupId,
1064 categoryId, orderByComparator, false);
1065
1066 return array;
1067 }
1068 catch (Exception e) {
1069 throw processException(e);
1070 }
1071 finally {
1072 closeSession(session);
1073 }
1074 }
1075
1076 protected MBThread getByG_C_PrevAndNext(Session session, MBThread mbThread,
1077 long groupId, long categoryId, OrderByComparator orderByComparator,
1078 boolean previous) {
1079 StringBundler query = null;
1080
1081 if (orderByComparator != null) {
1082 query = new StringBundler(6 +
1083 (orderByComparator.getOrderByFields().length * 6));
1084 }
1085 else {
1086 query = new StringBundler(3);
1087 }
1088
1089 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1090
1091 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1092
1093 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1094
1095 if (orderByComparator != null) {
1096 String[] orderByFields = orderByComparator.getOrderByFields();
1097
1098 if (orderByFields.length > 0) {
1099 query.append(WHERE_AND);
1100 }
1101
1102 for (int i = 0; i < orderByFields.length; i++) {
1103 query.append(_ORDER_BY_ENTITY_ALIAS);
1104 query.append(orderByFields[i]);
1105
1106 if ((i + 1) < orderByFields.length) {
1107 if (orderByComparator.isAscending() ^ previous) {
1108 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1109 }
1110 else {
1111 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1112 }
1113 }
1114 else {
1115 if (orderByComparator.isAscending() ^ previous) {
1116 query.append(WHERE_GREATER_THAN);
1117 }
1118 else {
1119 query.append(WHERE_LESSER_THAN);
1120 }
1121 }
1122 }
1123
1124 query.append(ORDER_BY_CLAUSE);
1125
1126 for (int i = 0; i < orderByFields.length; i++) {
1127 query.append(_ORDER_BY_ENTITY_ALIAS);
1128 query.append(orderByFields[i]);
1129
1130 if ((i + 1) < orderByFields.length) {
1131 if (orderByComparator.isAscending() ^ previous) {
1132 query.append(ORDER_BY_ASC_HAS_NEXT);
1133 }
1134 else {
1135 query.append(ORDER_BY_DESC_HAS_NEXT);
1136 }
1137 }
1138 else {
1139 if (orderByComparator.isAscending() ^ previous) {
1140 query.append(ORDER_BY_ASC);
1141 }
1142 else {
1143 query.append(ORDER_BY_DESC);
1144 }
1145 }
1146 }
1147 }
1148
1149 else {
1150 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1151 }
1152
1153 String sql = query.toString();
1154
1155 Query q = session.createQuery(sql);
1156
1157 q.setFirstResult(0);
1158 q.setMaxResults(2);
1159
1160 QueryPos qPos = QueryPos.getInstance(q);
1161
1162 qPos.add(groupId);
1163
1164 qPos.add(categoryId);
1165
1166 if (orderByComparator != null) {
1167 Object[] values = orderByComparator.getOrderByValues(mbThread);
1168
1169 for (Object value : values) {
1170 qPos.add(value);
1171 }
1172 }
1173
1174 List<MBThread> list = q.list();
1175
1176 if (list.size() == 2) {
1177 return list.get(1);
1178 }
1179 else {
1180 return null;
1181 }
1182 }
1183
1184
1196 public List<MBThread> findByG_C(long groupId, long[] categoryIds)
1197 throws SystemException {
1198 return findByG_C(groupId, categoryIds, QueryUtil.ALL_POS,
1199 QueryUtil.ALL_POS, null);
1200 }
1201
1202
1216 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
1217 int start, int end) throws SystemException {
1218 return findByG_C(groupId, categoryIds, start, end, null);
1219 }
1220
1221
1236 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
1237 int start, int end, OrderByComparator orderByComparator)
1238 throws SystemException {
1239 Object[] finderArgs = new Object[] {
1240 groupId, StringUtil.merge(categoryIds),
1241
1242 String.valueOf(start), String.valueOf(end),
1243 String.valueOf(orderByComparator)
1244 };
1245
1246 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C,
1247 finderArgs, this);
1248
1249 if (list == null) {
1250 StringBundler query = new StringBundler();
1251
1252 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1253
1254 boolean conjunctionable = false;
1255
1256 if (conjunctionable) {
1257 query.append(WHERE_AND);
1258 }
1259
1260 query.append(_FINDER_COLUMN_G_C_GROUPID_5);
1261
1262 conjunctionable = true;
1263
1264 if ((categoryIds == null) || (categoryIds.length > 0)) {
1265 if (conjunctionable) {
1266 query.append(WHERE_AND);
1267 }
1268
1269 query.append(StringPool.OPEN_PARENTHESIS);
1270
1271 for (int i = 0; i < categoryIds.length; i++) {
1272 query.append(_FINDER_COLUMN_G_C_CATEGORYID_5);
1273
1274 if ((i + 1) < categoryIds.length) {
1275 query.append(WHERE_OR);
1276 }
1277 }
1278
1279 query.append(StringPool.CLOSE_PARENTHESIS);
1280
1281 conjunctionable = true;
1282 }
1283
1284 if (orderByComparator != null) {
1285 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1286 orderByComparator);
1287 }
1288
1289 else {
1290 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1291 }
1292
1293 String sql = query.toString();
1294
1295 Session session = null;
1296
1297 try {
1298 session = openSession();
1299
1300 Query q = session.createQuery(sql);
1301
1302 QueryPos qPos = QueryPos.getInstance(q);
1303
1304 qPos.add(groupId);
1305
1306 if (categoryIds != null) {
1307 qPos.add(categoryIds);
1308 }
1309
1310 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
1311 end);
1312 }
1313 catch (Exception e) {
1314 throw processException(e);
1315 }
1316 finally {
1317 if (list == null) {
1318 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_C,
1319 finderArgs);
1320 }
1321 else {
1322 cacheResult(list);
1323
1324 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C,
1325 finderArgs, list);
1326 }
1327
1328 closeSession(session);
1329 }
1330 }
1331
1332 return list;
1333 }
1334
1335
1343 public List<MBThread> findByG_NotC(long groupId, long categoryId)
1344 throws SystemException {
1345 return findByG_NotC(groupId, categoryId, QueryUtil.ALL_POS,
1346 QueryUtil.ALL_POS, null);
1347 }
1348
1349
1363 public List<MBThread> findByG_NotC(long groupId, long categoryId,
1364 int start, int end) throws SystemException {
1365 return findByG_NotC(groupId, categoryId, start, end, null);
1366 }
1367
1368
1383 public List<MBThread> findByG_NotC(long groupId, long categoryId,
1384 int start, int end, OrderByComparator orderByComparator)
1385 throws SystemException {
1386 Object[] finderArgs = new Object[] {
1387 groupId, categoryId,
1388
1389 String.valueOf(start), String.valueOf(end),
1390 String.valueOf(orderByComparator)
1391 };
1392
1393 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_NOTC,
1394 finderArgs, this);
1395
1396 if (list == null) {
1397 StringBundler query = null;
1398
1399 if (orderByComparator != null) {
1400 query = new StringBundler(4 +
1401 (orderByComparator.getOrderByFields().length * 3));
1402 }
1403 else {
1404 query = new StringBundler(4);
1405 }
1406
1407 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1408
1409 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
1410
1411 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
1412
1413 if (orderByComparator != null) {
1414 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1415 orderByComparator);
1416 }
1417
1418 else {
1419 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1420 }
1421
1422 String sql = query.toString();
1423
1424 Session session = null;
1425
1426 try {
1427 session = openSession();
1428
1429 Query q = session.createQuery(sql);
1430
1431 QueryPos qPos = QueryPos.getInstance(q);
1432
1433 qPos.add(groupId);
1434
1435 qPos.add(categoryId);
1436
1437 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
1438 end);
1439 }
1440 catch (Exception e) {
1441 throw processException(e);
1442 }
1443 finally {
1444 if (list == null) {
1445 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_NOTC,
1446 finderArgs);
1447 }
1448 else {
1449 cacheResult(list);
1450
1451 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_NOTC,
1452 finderArgs, list);
1453 }
1454
1455 closeSession(session);
1456 }
1457 }
1458
1459 return list;
1460 }
1461
1462
1476 public MBThread findByG_NotC_First(long groupId, long categoryId,
1477 OrderByComparator orderByComparator)
1478 throws NoSuchThreadException, SystemException {
1479 List<MBThread> list = findByG_NotC(groupId, categoryId, 0, 1,
1480 orderByComparator);
1481
1482 if (list.isEmpty()) {
1483 StringBundler msg = new StringBundler(6);
1484
1485 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1486
1487 msg.append("groupId=");
1488 msg.append(groupId);
1489
1490 msg.append(", categoryId=");
1491 msg.append(categoryId);
1492
1493 msg.append(StringPool.CLOSE_CURLY_BRACE);
1494
1495 throw new NoSuchThreadException(msg.toString());
1496 }
1497 else {
1498 return list.get(0);
1499 }
1500 }
1501
1502
1516 public MBThread findByG_NotC_Last(long groupId, long categoryId,
1517 OrderByComparator orderByComparator)
1518 throws NoSuchThreadException, SystemException {
1519 int count = countByG_NotC(groupId, categoryId);
1520
1521 List<MBThread> list = findByG_NotC(groupId, categoryId, count - 1,
1522 count, orderByComparator);
1523
1524 if (list.isEmpty()) {
1525 StringBundler msg = new StringBundler(6);
1526
1527 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1528
1529 msg.append("groupId=");
1530 msg.append(groupId);
1531
1532 msg.append(", categoryId=");
1533 msg.append(categoryId);
1534
1535 msg.append(StringPool.CLOSE_CURLY_BRACE);
1536
1537 throw new NoSuchThreadException(msg.toString());
1538 }
1539 else {
1540 return list.get(0);
1541 }
1542 }
1543
1544
1559 public MBThread[] findByG_NotC_PrevAndNext(long threadId, long groupId,
1560 long categoryId, OrderByComparator orderByComparator)
1561 throws NoSuchThreadException, SystemException {
1562 MBThread mbThread = findByPrimaryKey(threadId);
1563
1564 Session session = null;
1565
1566 try {
1567 session = openSession();
1568
1569 MBThread[] array = new MBThreadImpl[3];
1570
1571 array[0] = getByG_NotC_PrevAndNext(session, mbThread, groupId,
1572 categoryId, orderByComparator, true);
1573
1574 array[1] = mbThread;
1575
1576 array[2] = getByG_NotC_PrevAndNext(session, mbThread, groupId,
1577 categoryId, orderByComparator, false);
1578
1579 return array;
1580 }
1581 catch (Exception e) {
1582 throw processException(e);
1583 }
1584 finally {
1585 closeSession(session);
1586 }
1587 }
1588
1589 protected MBThread getByG_NotC_PrevAndNext(Session session,
1590 MBThread mbThread, long groupId, long categoryId,
1591 OrderByComparator orderByComparator, boolean previous) {
1592 StringBundler query = null;
1593
1594 if (orderByComparator != null) {
1595 query = new StringBundler(6 +
1596 (orderByComparator.getOrderByFields().length * 6));
1597 }
1598 else {
1599 query = new StringBundler(3);
1600 }
1601
1602 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1603
1604 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
1605
1606 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
1607
1608 if (orderByComparator != null) {
1609 String[] orderByFields = orderByComparator.getOrderByFields();
1610
1611 if (orderByFields.length > 0) {
1612 query.append(WHERE_AND);
1613 }
1614
1615 for (int i = 0; i < orderByFields.length; i++) {
1616 query.append(_ORDER_BY_ENTITY_ALIAS);
1617 query.append(orderByFields[i]);
1618
1619 if ((i + 1) < orderByFields.length) {
1620 if (orderByComparator.isAscending() ^ previous) {
1621 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1622 }
1623 else {
1624 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1625 }
1626 }
1627 else {
1628 if (orderByComparator.isAscending() ^ previous) {
1629 query.append(WHERE_GREATER_THAN);
1630 }
1631 else {
1632 query.append(WHERE_LESSER_THAN);
1633 }
1634 }
1635 }
1636
1637 query.append(ORDER_BY_CLAUSE);
1638
1639 for (int i = 0; i < orderByFields.length; i++) {
1640 query.append(_ORDER_BY_ENTITY_ALIAS);
1641 query.append(orderByFields[i]);
1642
1643 if ((i + 1) < orderByFields.length) {
1644 if (orderByComparator.isAscending() ^ previous) {
1645 query.append(ORDER_BY_ASC_HAS_NEXT);
1646 }
1647 else {
1648 query.append(ORDER_BY_DESC_HAS_NEXT);
1649 }
1650 }
1651 else {
1652 if (orderByComparator.isAscending() ^ previous) {
1653 query.append(ORDER_BY_ASC);
1654 }
1655 else {
1656 query.append(ORDER_BY_DESC);
1657 }
1658 }
1659 }
1660 }
1661
1662 else {
1663 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1664 }
1665
1666 String sql = query.toString();
1667
1668 Query q = session.createQuery(sql);
1669
1670 q.setFirstResult(0);
1671 q.setMaxResults(2);
1672
1673 QueryPos qPos = QueryPos.getInstance(q);
1674
1675 qPos.add(groupId);
1676
1677 qPos.add(categoryId);
1678
1679 if (orderByComparator != null) {
1680 Object[] values = orderByComparator.getOrderByValues(mbThread);
1681
1682 for (Object value : values) {
1683 qPos.add(value);
1684 }
1685 }
1686
1687 List<MBThread> list = q.list();
1688
1689 if (list.size() == 2) {
1690 return list.get(1);
1691 }
1692 else {
1693 return null;
1694 }
1695 }
1696
1697
1705 public List<MBThread> findByG_S(long groupId, int status)
1706 throws SystemException {
1707 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1708 null);
1709 }
1710
1711
1725 public List<MBThread> findByG_S(long groupId, int status, int start, int end)
1726 throws SystemException {
1727 return findByG_S(groupId, status, start, end, null);
1728 }
1729
1730
1745 public List<MBThread> findByG_S(long groupId, int status, int start,
1746 int end, OrderByComparator orderByComparator) throws SystemException {
1747 Object[] finderArgs = new Object[] {
1748 groupId, status,
1749
1750 String.valueOf(start), String.valueOf(end),
1751 String.valueOf(orderByComparator)
1752 };
1753
1754 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_S,
1755 finderArgs, this);
1756
1757 if (list == null) {
1758 StringBundler query = null;
1759
1760 if (orderByComparator != null) {
1761 query = new StringBundler(4 +
1762 (orderByComparator.getOrderByFields().length * 3));
1763 }
1764 else {
1765 query = new StringBundler(4);
1766 }
1767
1768 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1769
1770 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
1771
1772 query.append(_FINDER_COLUMN_G_S_STATUS_2);
1773
1774 if (orderByComparator != null) {
1775 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1776 orderByComparator);
1777 }
1778
1779 else {
1780 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1781 }
1782
1783 String sql = query.toString();
1784
1785 Session session = null;
1786
1787 try {
1788 session = openSession();
1789
1790 Query q = session.createQuery(sql);
1791
1792 QueryPos qPos = QueryPos.getInstance(q);
1793
1794 qPos.add(groupId);
1795
1796 qPos.add(status);
1797
1798 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
1799 end);
1800 }
1801 catch (Exception e) {
1802 throw processException(e);
1803 }
1804 finally {
1805 if (list == null) {
1806 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_S,
1807 finderArgs);
1808 }
1809 else {
1810 cacheResult(list);
1811
1812 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_S,
1813 finderArgs, list);
1814 }
1815
1816 closeSession(session);
1817 }
1818 }
1819
1820 return list;
1821 }
1822
1823
1837 public MBThread findByG_S_First(long groupId, int status,
1838 OrderByComparator orderByComparator)
1839 throws NoSuchThreadException, SystemException {
1840 List<MBThread> list = findByG_S(groupId, status, 0, 1, orderByComparator);
1841
1842 if (list.isEmpty()) {
1843 StringBundler msg = new StringBundler(6);
1844
1845 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1846
1847 msg.append("groupId=");
1848 msg.append(groupId);
1849
1850 msg.append(", status=");
1851 msg.append(status);
1852
1853 msg.append(StringPool.CLOSE_CURLY_BRACE);
1854
1855 throw new NoSuchThreadException(msg.toString());
1856 }
1857 else {
1858 return list.get(0);
1859 }
1860 }
1861
1862
1876 public MBThread findByG_S_Last(long groupId, int status,
1877 OrderByComparator orderByComparator)
1878 throws NoSuchThreadException, SystemException {
1879 int count = countByG_S(groupId, status);
1880
1881 List<MBThread> list = findByG_S(groupId, status, count - 1, count,
1882 orderByComparator);
1883
1884 if (list.isEmpty()) {
1885 StringBundler msg = new StringBundler(6);
1886
1887 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1888
1889 msg.append("groupId=");
1890 msg.append(groupId);
1891
1892 msg.append(", status=");
1893 msg.append(status);
1894
1895 msg.append(StringPool.CLOSE_CURLY_BRACE);
1896
1897 throw new NoSuchThreadException(msg.toString());
1898 }
1899 else {
1900 return list.get(0);
1901 }
1902 }
1903
1904
1919 public MBThread[] findByG_S_PrevAndNext(long threadId, long groupId,
1920 int status, OrderByComparator orderByComparator)
1921 throws NoSuchThreadException, SystemException {
1922 MBThread mbThread = findByPrimaryKey(threadId);
1923
1924 Session session = null;
1925
1926 try {
1927 session = openSession();
1928
1929 MBThread[] array = new MBThreadImpl[3];
1930
1931 array[0] = getByG_S_PrevAndNext(session, mbThread, groupId, status,
1932 orderByComparator, true);
1933
1934 array[1] = mbThread;
1935
1936 array[2] = getByG_S_PrevAndNext(session, mbThread, groupId, status,
1937 orderByComparator, false);
1938
1939 return array;
1940 }
1941 catch (Exception e) {
1942 throw processException(e);
1943 }
1944 finally {
1945 closeSession(session);
1946 }
1947 }
1948
1949 protected MBThread getByG_S_PrevAndNext(Session session, MBThread mbThread,
1950 long groupId, int status, OrderByComparator orderByComparator,
1951 boolean previous) {
1952 StringBundler query = null;
1953
1954 if (orderByComparator != null) {
1955 query = new StringBundler(6 +
1956 (orderByComparator.getOrderByFields().length * 6));
1957 }
1958 else {
1959 query = new StringBundler(3);
1960 }
1961
1962 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1963
1964 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
1965
1966 query.append(_FINDER_COLUMN_G_S_STATUS_2);
1967
1968 if (orderByComparator != null) {
1969 String[] orderByFields = orderByComparator.getOrderByFields();
1970
1971 if (orderByFields.length > 0) {
1972 query.append(WHERE_AND);
1973 }
1974
1975 for (int i = 0; i < orderByFields.length; i++) {
1976 query.append(_ORDER_BY_ENTITY_ALIAS);
1977 query.append(orderByFields[i]);
1978
1979 if ((i + 1) < orderByFields.length) {
1980 if (orderByComparator.isAscending() ^ previous) {
1981 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1982 }
1983 else {
1984 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1985 }
1986 }
1987 else {
1988 if (orderByComparator.isAscending() ^ previous) {
1989 query.append(WHERE_GREATER_THAN);
1990 }
1991 else {
1992 query.append(WHERE_LESSER_THAN);
1993 }
1994 }
1995 }
1996
1997 query.append(ORDER_BY_CLAUSE);
1998
1999 for (int i = 0; i < orderByFields.length; i++) {
2000 query.append(_ORDER_BY_ENTITY_ALIAS);
2001 query.append(orderByFields[i]);
2002
2003 if ((i + 1) < orderByFields.length) {
2004 if (orderByComparator.isAscending() ^ previous) {
2005 query.append(ORDER_BY_ASC_HAS_NEXT);
2006 }
2007 else {
2008 query.append(ORDER_BY_DESC_HAS_NEXT);
2009 }
2010 }
2011 else {
2012 if (orderByComparator.isAscending() ^ previous) {
2013 query.append(ORDER_BY_ASC);
2014 }
2015 else {
2016 query.append(ORDER_BY_DESC);
2017 }
2018 }
2019 }
2020 }
2021
2022 else {
2023 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2024 }
2025
2026 String sql = query.toString();
2027
2028 Query q = session.createQuery(sql);
2029
2030 q.setFirstResult(0);
2031 q.setMaxResults(2);
2032
2033 QueryPos qPos = QueryPos.getInstance(q);
2034
2035 qPos.add(groupId);
2036
2037 qPos.add(status);
2038
2039 if (orderByComparator != null) {
2040 Object[] values = orderByComparator.getOrderByValues(mbThread);
2041
2042 for (Object value : values) {
2043 qPos.add(value);
2044 }
2045 }
2046
2047 List<MBThread> list = q.list();
2048
2049 if (list.size() == 2) {
2050 return list.get(1);
2051 }
2052 else {
2053 return null;
2054 }
2055 }
2056
2057
2065 public List<MBThread> findByC_P(long categoryId, double priority)
2066 throws SystemException {
2067 return findByC_P(categoryId, priority, QueryUtil.ALL_POS,
2068 QueryUtil.ALL_POS, null);
2069 }
2070
2071
2085 public List<MBThread> findByC_P(long categoryId, double priority,
2086 int start, int end) throws SystemException {
2087 return findByC_P(categoryId, priority, start, end, null);
2088 }
2089
2090
2105 public List<MBThread> findByC_P(long categoryId, double priority,
2106 int start, int end, OrderByComparator orderByComparator)
2107 throws SystemException {
2108 Object[] finderArgs = new Object[] {
2109 categoryId, priority,
2110
2111 String.valueOf(start), String.valueOf(end),
2112 String.valueOf(orderByComparator)
2113 };
2114
2115 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_P,
2116 finderArgs, this);
2117
2118 if (list == null) {
2119 StringBundler query = null;
2120
2121 if (orderByComparator != null) {
2122 query = new StringBundler(4 +
2123 (orderByComparator.getOrderByFields().length * 3));
2124 }
2125 else {
2126 query = new StringBundler(4);
2127 }
2128
2129 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2130
2131 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
2132
2133 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
2134
2135 if (orderByComparator != null) {
2136 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2137 orderByComparator);
2138 }
2139
2140 else {
2141 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2142 }
2143
2144 String sql = query.toString();
2145
2146 Session session = null;
2147
2148 try {
2149 session = openSession();
2150
2151 Query q = session.createQuery(sql);
2152
2153 QueryPos qPos = QueryPos.getInstance(q);
2154
2155 qPos.add(categoryId);
2156
2157 qPos.add(priority);
2158
2159 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
2160 end);
2161 }
2162 catch (Exception e) {
2163 throw processException(e);
2164 }
2165 finally {
2166 if (list == null) {
2167 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_C_P,
2168 finderArgs);
2169 }
2170 else {
2171 cacheResult(list);
2172
2173 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_P,
2174 finderArgs, list);
2175 }
2176
2177 closeSession(session);
2178 }
2179 }
2180
2181 return list;
2182 }
2183
2184
2198 public MBThread findByC_P_First(long categoryId, double priority,
2199 OrderByComparator orderByComparator)
2200 throws NoSuchThreadException, SystemException {
2201 List<MBThread> list = findByC_P(categoryId, priority, 0, 1,
2202 orderByComparator);
2203
2204 if (list.isEmpty()) {
2205 StringBundler msg = new StringBundler(6);
2206
2207 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2208
2209 msg.append("categoryId=");
2210 msg.append(categoryId);
2211
2212 msg.append(", priority=");
2213 msg.append(priority);
2214
2215 msg.append(StringPool.CLOSE_CURLY_BRACE);
2216
2217 throw new NoSuchThreadException(msg.toString());
2218 }
2219 else {
2220 return list.get(0);
2221 }
2222 }
2223
2224
2238 public MBThread findByC_P_Last(long categoryId, double priority,
2239 OrderByComparator orderByComparator)
2240 throws NoSuchThreadException, SystemException {
2241 int count = countByC_P(categoryId, priority);
2242
2243 List<MBThread> list = findByC_P(categoryId, priority, count - 1, count,
2244 orderByComparator);
2245
2246 if (list.isEmpty()) {
2247 StringBundler msg = new StringBundler(6);
2248
2249 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2250
2251 msg.append("categoryId=");
2252 msg.append(categoryId);
2253
2254 msg.append(", priority=");
2255 msg.append(priority);
2256
2257 msg.append(StringPool.CLOSE_CURLY_BRACE);
2258
2259 throw new NoSuchThreadException(msg.toString());
2260 }
2261 else {
2262 return list.get(0);
2263 }
2264 }
2265
2266
2281 public MBThread[] findByC_P_PrevAndNext(long threadId, long categoryId,
2282 double priority, OrderByComparator orderByComparator)
2283 throws NoSuchThreadException, SystemException {
2284 MBThread mbThread = findByPrimaryKey(threadId);
2285
2286 Session session = null;
2287
2288 try {
2289 session = openSession();
2290
2291 MBThread[] array = new MBThreadImpl[3];
2292
2293 array[0] = getByC_P_PrevAndNext(session, mbThread, categoryId,
2294 priority, orderByComparator, true);
2295
2296 array[1] = mbThread;
2297
2298 array[2] = getByC_P_PrevAndNext(session, mbThread, categoryId,
2299 priority, orderByComparator, false);
2300
2301 return array;
2302 }
2303 catch (Exception e) {
2304 throw processException(e);
2305 }
2306 finally {
2307 closeSession(session);
2308 }
2309 }
2310
2311 protected MBThread getByC_P_PrevAndNext(Session session, MBThread mbThread,
2312 long categoryId, double priority, OrderByComparator orderByComparator,
2313 boolean previous) {
2314 StringBundler query = null;
2315
2316 if (orderByComparator != null) {
2317 query = new StringBundler(6 +
2318 (orderByComparator.getOrderByFields().length * 6));
2319 }
2320 else {
2321 query = new StringBundler(3);
2322 }
2323
2324 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2325
2326 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
2327
2328 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
2329
2330 if (orderByComparator != null) {
2331 String[] orderByFields = orderByComparator.getOrderByFields();
2332
2333 if (orderByFields.length > 0) {
2334 query.append(WHERE_AND);
2335 }
2336
2337 for (int i = 0; i < orderByFields.length; i++) {
2338 query.append(_ORDER_BY_ENTITY_ALIAS);
2339 query.append(orderByFields[i]);
2340
2341 if ((i + 1) < orderByFields.length) {
2342 if (orderByComparator.isAscending() ^ previous) {
2343 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2344 }
2345 else {
2346 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2347 }
2348 }
2349 else {
2350 if (orderByComparator.isAscending() ^ previous) {
2351 query.append(WHERE_GREATER_THAN);
2352 }
2353 else {
2354 query.append(WHERE_LESSER_THAN);
2355 }
2356 }
2357 }
2358
2359 query.append(ORDER_BY_CLAUSE);
2360
2361 for (int i = 0; i < orderByFields.length; i++) {
2362 query.append(_ORDER_BY_ENTITY_ALIAS);
2363 query.append(orderByFields[i]);
2364
2365 if ((i + 1) < orderByFields.length) {
2366 if (orderByComparator.isAscending() ^ previous) {
2367 query.append(ORDER_BY_ASC_HAS_NEXT);
2368 }
2369 else {
2370 query.append(ORDER_BY_DESC_HAS_NEXT);
2371 }
2372 }
2373 else {
2374 if (orderByComparator.isAscending() ^ previous) {
2375 query.append(ORDER_BY_ASC);
2376 }
2377 else {
2378 query.append(ORDER_BY_DESC);
2379 }
2380 }
2381 }
2382 }
2383
2384 else {
2385 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2386 }
2387
2388 String sql = query.toString();
2389
2390 Query q = session.createQuery(sql);
2391
2392 q.setFirstResult(0);
2393 q.setMaxResults(2);
2394
2395 QueryPos qPos = QueryPos.getInstance(q);
2396
2397 qPos.add(categoryId);
2398
2399 qPos.add(priority);
2400
2401 if (orderByComparator != null) {
2402 Object[] values = orderByComparator.getOrderByValues(mbThread);
2403
2404 for (Object value : values) {
2405 qPos.add(value);
2406 }
2407 }
2408
2409 List<MBThread> list = q.list();
2410
2411 if (list.size() == 2) {
2412 return list.get(1);
2413 }
2414 else {
2415 return null;
2416 }
2417 }
2418
2419
2428 public List<MBThread> findByG_C_L(long groupId, long categoryId,
2429 Date lastPostDate) throws SystemException {
2430 return findByG_C_L(groupId, categoryId, lastPostDate,
2431 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2432 }
2433
2434
2449 public List<MBThread> findByG_C_L(long groupId, long categoryId,
2450 Date lastPostDate, int start, int end) throws SystemException {
2451 return findByG_C_L(groupId, categoryId, lastPostDate, start, end, null);
2452 }
2453
2454
2470 public List<MBThread> findByG_C_L(long groupId, long categoryId,
2471 Date lastPostDate, int start, int end,
2472 OrderByComparator orderByComparator) throws SystemException {
2473 Object[] finderArgs = new Object[] {
2474 groupId, categoryId, lastPostDate,
2475
2476 String.valueOf(start), String.valueOf(end),
2477 String.valueOf(orderByComparator)
2478 };
2479
2480 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_L,
2481 finderArgs, this);
2482
2483 if (list == null) {
2484 StringBundler query = null;
2485
2486 if (orderByComparator != null) {
2487 query = new StringBundler(5 +
2488 (orderByComparator.getOrderByFields().length * 3));
2489 }
2490 else {
2491 query = new StringBundler(5);
2492 }
2493
2494 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2495
2496 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
2497
2498 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
2499
2500 if (lastPostDate == null) {
2501 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
2502 }
2503 else {
2504 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
2505 }
2506
2507 if (orderByComparator != null) {
2508 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2509 orderByComparator);
2510 }
2511
2512 else {
2513 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2514 }
2515
2516 String sql = query.toString();
2517
2518 Session session = null;
2519
2520 try {
2521 session = openSession();
2522
2523 Query q = session.createQuery(sql);
2524
2525 QueryPos qPos = QueryPos.getInstance(q);
2526
2527 qPos.add(groupId);
2528
2529 qPos.add(categoryId);
2530
2531 if (lastPostDate != null) {
2532 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
2533 }
2534
2535 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
2536 end);
2537 }
2538 catch (Exception e) {
2539 throw processException(e);
2540 }
2541 finally {
2542 if (list == null) {
2543 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_C_L,
2544 finderArgs);
2545 }
2546 else {
2547 cacheResult(list);
2548
2549 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_L,
2550 finderArgs, list);
2551 }
2552
2553 closeSession(session);
2554 }
2555 }
2556
2557 return list;
2558 }
2559
2560
2575 public MBThread findByG_C_L_First(long groupId, long categoryId,
2576 Date lastPostDate, OrderByComparator orderByComparator)
2577 throws NoSuchThreadException, SystemException {
2578 List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate, 0,
2579 1, orderByComparator);
2580
2581 if (list.isEmpty()) {
2582 StringBundler msg = new StringBundler(8);
2583
2584 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2585
2586 msg.append("groupId=");
2587 msg.append(groupId);
2588
2589 msg.append(", categoryId=");
2590 msg.append(categoryId);
2591
2592 msg.append(", lastPostDate=");
2593 msg.append(lastPostDate);
2594
2595 msg.append(StringPool.CLOSE_CURLY_BRACE);
2596
2597 throw new NoSuchThreadException(msg.toString());
2598 }
2599 else {
2600 return list.get(0);
2601 }
2602 }
2603
2604
2619 public MBThread findByG_C_L_Last(long groupId, long categoryId,
2620 Date lastPostDate, OrderByComparator orderByComparator)
2621 throws NoSuchThreadException, SystemException {
2622 int count = countByG_C_L(groupId, categoryId, lastPostDate);
2623
2624 List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate,
2625 count - 1, count, orderByComparator);
2626
2627 if (list.isEmpty()) {
2628 StringBundler msg = new StringBundler(8);
2629
2630 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2631
2632 msg.append("groupId=");
2633 msg.append(groupId);
2634
2635 msg.append(", categoryId=");
2636 msg.append(categoryId);
2637
2638 msg.append(", lastPostDate=");
2639 msg.append(lastPostDate);
2640
2641 msg.append(StringPool.CLOSE_CURLY_BRACE);
2642
2643 throw new NoSuchThreadException(msg.toString());
2644 }
2645 else {
2646 return list.get(0);
2647 }
2648 }
2649
2650
2666 public MBThread[] findByG_C_L_PrevAndNext(long threadId, long groupId,
2667 long categoryId, Date lastPostDate, OrderByComparator orderByComparator)
2668 throws NoSuchThreadException, SystemException {
2669 MBThread mbThread = findByPrimaryKey(threadId);
2670
2671 Session session = null;
2672
2673 try {
2674 session = openSession();
2675
2676 MBThread[] array = new MBThreadImpl[3];
2677
2678 array[0] = getByG_C_L_PrevAndNext(session, mbThread, groupId,
2679 categoryId, lastPostDate, orderByComparator, true);
2680
2681 array[1] = mbThread;
2682
2683 array[2] = getByG_C_L_PrevAndNext(session, mbThread, groupId,
2684 categoryId, lastPostDate, orderByComparator, false);
2685
2686 return array;
2687 }
2688 catch (Exception e) {
2689 throw processException(e);
2690 }
2691 finally {
2692 closeSession(session);
2693 }
2694 }
2695
2696 protected MBThread getByG_C_L_PrevAndNext(Session session,
2697 MBThread mbThread, long groupId, long categoryId, Date lastPostDate,
2698 OrderByComparator orderByComparator, boolean previous) {
2699 StringBundler query = null;
2700
2701 if (orderByComparator != null) {
2702 query = new StringBundler(6 +
2703 (orderByComparator.getOrderByFields().length * 6));
2704 }
2705 else {
2706 query = new StringBundler(3);
2707 }
2708
2709 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2710
2711 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
2712
2713 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
2714
2715 if (lastPostDate == null) {
2716 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
2717 }
2718 else {
2719 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
2720 }
2721
2722 if (orderByComparator != null) {
2723 String[] orderByFields = orderByComparator.getOrderByFields();
2724
2725 if (orderByFields.length > 0) {
2726 query.append(WHERE_AND);
2727 }
2728
2729 for (int i = 0; i < orderByFields.length; i++) {
2730 query.append(_ORDER_BY_ENTITY_ALIAS);
2731 query.append(orderByFields[i]);
2732
2733 if ((i + 1) < orderByFields.length) {
2734 if (orderByComparator.isAscending() ^ previous) {
2735 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2736 }
2737 else {
2738 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2739 }
2740 }
2741 else {
2742 if (orderByComparator.isAscending() ^ previous) {
2743 query.append(WHERE_GREATER_THAN);
2744 }
2745 else {
2746 query.append(WHERE_LESSER_THAN);
2747 }
2748 }
2749 }
2750
2751 query.append(ORDER_BY_CLAUSE);
2752
2753 for (int i = 0; i < orderByFields.length; i++) {
2754 query.append(_ORDER_BY_ENTITY_ALIAS);
2755 query.append(orderByFields[i]);
2756
2757 if ((i + 1) < orderByFields.length) {
2758 if (orderByComparator.isAscending() ^ previous) {
2759 query.append(ORDER_BY_ASC_HAS_NEXT);
2760 }
2761 else {
2762 query.append(ORDER_BY_DESC_HAS_NEXT);
2763 }
2764 }
2765 else {
2766 if (orderByComparator.isAscending() ^ previous) {
2767 query.append(ORDER_BY_ASC);
2768 }
2769 else {
2770 query.append(ORDER_BY_DESC);
2771 }
2772 }
2773 }
2774 }
2775
2776 else {
2777 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2778 }
2779
2780 String sql = query.toString();
2781
2782 Query q = session.createQuery(sql);
2783
2784 q.setFirstResult(0);
2785 q.setMaxResults(2);
2786
2787 QueryPos qPos = QueryPos.getInstance(q);
2788
2789 qPos.add(groupId);
2790
2791 qPos.add(categoryId);
2792
2793 if (lastPostDate != null) {
2794 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
2795 }
2796
2797 if (orderByComparator != null) {
2798 Object[] values = orderByComparator.getOrderByValues(mbThread);
2799
2800 for (Object value : values) {
2801 qPos.add(value);
2802 }
2803 }
2804
2805 List<MBThread> list = q.list();
2806
2807 if (list.size() == 2) {
2808 return list.get(1);
2809 }
2810 else {
2811 return null;
2812 }
2813 }
2814
2815
2824 public List<MBThread> findByG_C_S(long groupId, long categoryId, int status)
2825 throws SystemException {
2826 return findByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS,
2827 QueryUtil.ALL_POS, null);
2828 }
2829
2830
2845 public List<MBThread> findByG_C_S(long groupId, long categoryId,
2846 int status, int start, int end) throws SystemException {
2847 return findByG_C_S(groupId, categoryId, status, start, end, null);
2848 }
2849
2850
2866 public List<MBThread> findByG_C_S(long groupId, long categoryId,
2867 int status, int start, int end, OrderByComparator orderByComparator)
2868 throws SystemException {
2869 Object[] finderArgs = new Object[] {
2870 groupId, categoryId, status,
2871
2872 String.valueOf(start), String.valueOf(end),
2873 String.valueOf(orderByComparator)
2874 };
2875
2876 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_S,
2877 finderArgs, this);
2878
2879 if (list == null) {
2880 StringBundler query = null;
2881
2882 if (orderByComparator != null) {
2883 query = new StringBundler(5 +
2884 (orderByComparator.getOrderByFields().length * 3));
2885 }
2886 else {
2887 query = new StringBundler(5);
2888 }
2889
2890 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2891
2892 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
2893
2894 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
2895
2896 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
2897
2898 if (orderByComparator != null) {
2899 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2900 orderByComparator);
2901 }
2902
2903 else {
2904 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2905 }
2906
2907 String sql = query.toString();
2908
2909 Session session = null;
2910
2911 try {
2912 session = openSession();
2913
2914 Query q = session.createQuery(sql);
2915
2916 QueryPos qPos = QueryPos.getInstance(q);
2917
2918 qPos.add(groupId);
2919
2920 qPos.add(categoryId);
2921
2922 qPos.add(status);
2923
2924 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
2925 end);
2926 }
2927 catch (Exception e) {
2928 throw processException(e);
2929 }
2930 finally {
2931 if (list == null) {
2932 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_C_S,
2933 finderArgs);
2934 }
2935 else {
2936 cacheResult(list);
2937
2938 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_S,
2939 finderArgs, list);
2940 }
2941
2942 closeSession(session);
2943 }
2944 }
2945
2946 return list;
2947 }
2948
2949
2964 public MBThread findByG_C_S_First(long groupId, long categoryId,
2965 int status, OrderByComparator orderByComparator)
2966 throws NoSuchThreadException, SystemException {
2967 List<MBThread> list = findByG_C_S(groupId, categoryId, status, 0, 1,
2968 orderByComparator);
2969
2970 if (list.isEmpty()) {
2971 StringBundler msg = new StringBundler(8);
2972
2973 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2974
2975 msg.append("groupId=");
2976 msg.append(groupId);
2977
2978 msg.append(", categoryId=");
2979 msg.append(categoryId);
2980
2981 msg.append(", status=");
2982 msg.append(status);
2983
2984 msg.append(StringPool.CLOSE_CURLY_BRACE);
2985
2986 throw new NoSuchThreadException(msg.toString());
2987 }
2988 else {
2989 return list.get(0);
2990 }
2991 }
2992
2993
3008 public MBThread findByG_C_S_Last(long groupId, long categoryId, int status,
3009 OrderByComparator orderByComparator)
3010 throws NoSuchThreadException, SystemException {
3011 int count = countByG_C_S(groupId, categoryId, status);
3012
3013 List<MBThread> list = findByG_C_S(groupId, categoryId, status,
3014 count - 1, count, orderByComparator);
3015
3016 if (list.isEmpty()) {
3017 StringBundler msg = new StringBundler(8);
3018
3019 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3020
3021 msg.append("groupId=");
3022 msg.append(groupId);
3023
3024 msg.append(", categoryId=");
3025 msg.append(categoryId);
3026
3027 msg.append(", status=");
3028 msg.append(status);
3029
3030 msg.append(StringPool.CLOSE_CURLY_BRACE);
3031
3032 throw new NoSuchThreadException(msg.toString());
3033 }
3034 else {
3035 return list.get(0);
3036 }
3037 }
3038
3039
3055 public MBThread[] findByG_C_S_PrevAndNext(long threadId, long groupId,
3056 long categoryId, int status, OrderByComparator orderByComparator)
3057 throws NoSuchThreadException, SystemException {
3058 MBThread mbThread = findByPrimaryKey(threadId);
3059
3060 Session session = null;
3061
3062 try {
3063 session = openSession();
3064
3065 MBThread[] array = new MBThreadImpl[3];
3066
3067 array[0] = getByG_C_S_PrevAndNext(session, mbThread, groupId,
3068 categoryId, status, orderByComparator, true);
3069
3070 array[1] = mbThread;
3071
3072 array[2] = getByG_C_S_PrevAndNext(session, mbThread, groupId,
3073 categoryId, status, orderByComparator, false);
3074
3075 return array;
3076 }
3077 catch (Exception e) {
3078 throw processException(e);
3079 }
3080 finally {
3081 closeSession(session);
3082 }
3083 }
3084
3085 protected MBThread getByG_C_S_PrevAndNext(Session session,
3086 MBThread mbThread, long groupId, long categoryId, int status,
3087 OrderByComparator orderByComparator, boolean previous) {
3088 StringBundler query = null;
3089
3090 if (orderByComparator != null) {
3091 query = new StringBundler(6 +
3092 (orderByComparator.getOrderByFields().length * 6));
3093 }
3094 else {
3095 query = new StringBundler(3);
3096 }
3097
3098 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3099
3100 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
3101
3102 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
3103
3104 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
3105
3106 if (orderByComparator != null) {
3107 String[] orderByFields = orderByComparator.getOrderByFields();
3108
3109 if (orderByFields.length > 0) {
3110 query.append(WHERE_AND);
3111 }
3112
3113 for (int i = 0; i < orderByFields.length; i++) {
3114 query.append(_ORDER_BY_ENTITY_ALIAS);
3115 query.append(orderByFields[i]);
3116
3117 if ((i + 1) < orderByFields.length) {
3118 if (orderByComparator.isAscending() ^ previous) {
3119 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3120 }
3121 else {
3122 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3123 }
3124 }
3125 else {
3126 if (orderByComparator.isAscending() ^ previous) {
3127 query.append(WHERE_GREATER_THAN);
3128 }
3129 else {
3130 query.append(WHERE_LESSER_THAN);
3131 }
3132 }
3133 }
3134
3135 query.append(ORDER_BY_CLAUSE);
3136
3137 for (int i = 0; i < orderByFields.length; i++) {
3138 query.append(_ORDER_BY_ENTITY_ALIAS);
3139 query.append(orderByFields[i]);
3140
3141 if ((i + 1) < orderByFields.length) {
3142 if (orderByComparator.isAscending() ^ previous) {
3143 query.append(ORDER_BY_ASC_HAS_NEXT);
3144 }
3145 else {
3146 query.append(ORDER_BY_DESC_HAS_NEXT);
3147 }
3148 }
3149 else {
3150 if (orderByComparator.isAscending() ^ previous) {
3151 query.append(ORDER_BY_ASC);
3152 }
3153 else {
3154 query.append(ORDER_BY_DESC);
3155 }
3156 }
3157 }
3158 }
3159
3160 else {
3161 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3162 }
3163
3164 String sql = query.toString();
3165
3166 Query q = session.createQuery(sql);
3167
3168 q.setFirstResult(0);
3169 q.setMaxResults(2);
3170
3171 QueryPos qPos = QueryPos.getInstance(q);
3172
3173 qPos.add(groupId);
3174
3175 qPos.add(categoryId);
3176
3177 qPos.add(status);
3178
3179 if (orderByComparator != null) {
3180 Object[] values = orderByComparator.getOrderByValues(mbThread);
3181
3182 for (Object value : values) {
3183 qPos.add(value);
3184 }
3185 }
3186
3187 List<MBThread> list = q.list();
3188
3189 if (list.size() == 2) {
3190 return list.get(1);
3191 }
3192 else {
3193 return null;
3194 }
3195 }
3196
3197
3210 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
3211 int status) throws SystemException {
3212 return findByG_C_S(groupId, categoryIds, status, QueryUtil.ALL_POS,
3213 QueryUtil.ALL_POS, null);
3214 }
3215
3216
3231 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
3232 int status, int start, int end) throws SystemException {
3233 return findByG_C_S(groupId, categoryIds, status, start, end, null);
3234 }
3235
3236
3252 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
3253 int status, int start, int end, OrderByComparator orderByComparator)
3254 throws SystemException {
3255 Object[] finderArgs = new Object[] {
3256 groupId, StringUtil.merge(categoryIds), status,
3257
3258 String.valueOf(start), String.valueOf(end),
3259 String.valueOf(orderByComparator)
3260 };
3261
3262 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_S,
3263 finderArgs, this);
3264
3265 if (list == null) {
3266 StringBundler query = new StringBundler();
3267
3268 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3269
3270 boolean conjunctionable = false;
3271
3272 if (conjunctionable) {
3273 query.append(WHERE_AND);
3274 }
3275
3276 query.append(_FINDER_COLUMN_G_C_S_GROUPID_5);
3277
3278 conjunctionable = true;
3279
3280 if ((categoryIds == null) || (categoryIds.length > 0)) {
3281 if (conjunctionable) {
3282 query.append(WHERE_AND);
3283 }
3284
3285 query.append(StringPool.OPEN_PARENTHESIS);
3286
3287 for (int i = 0; i < categoryIds.length; i++) {
3288 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5);
3289
3290 if ((i + 1) < categoryIds.length) {
3291 query.append(WHERE_OR);
3292 }
3293 }
3294
3295 query.append(StringPool.CLOSE_PARENTHESIS);
3296
3297 conjunctionable = true;
3298 }
3299
3300 if (conjunctionable) {
3301 query.append(WHERE_AND);
3302 }
3303
3304 query.append(_FINDER_COLUMN_G_C_S_STATUS_5);
3305
3306 conjunctionable = true;
3307
3308 if (orderByComparator != null) {
3309 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3310 orderByComparator);
3311 }
3312
3313 else {
3314 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3315 }
3316
3317 String sql = query.toString();
3318
3319 Session session = null;
3320
3321 try {
3322 session = openSession();
3323
3324 Query q = session.createQuery(sql);
3325
3326 QueryPos qPos = QueryPos.getInstance(q);
3327
3328 qPos.add(groupId);
3329
3330 if (categoryIds != null) {
3331 qPos.add(categoryIds);
3332 }
3333
3334 qPos.add(status);
3335
3336 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
3337 end);
3338 }
3339 catch (Exception e) {
3340 throw processException(e);
3341 }
3342 finally {
3343 if (list == null) {
3344 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_C_S,
3345 finderArgs);
3346 }
3347 else {
3348 cacheResult(list);
3349
3350 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_S,
3351 finderArgs, list);
3352 }
3353
3354 closeSession(session);
3355 }
3356 }
3357
3358 return list;
3359 }
3360
3361
3370 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
3371 int status) throws SystemException {
3372 return findByG_NotC_S(groupId, categoryId, status, QueryUtil.ALL_POS,
3373 QueryUtil.ALL_POS, null);
3374 }
3375
3376
3391 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
3392 int status, int start, int end) throws SystemException {
3393 return findByG_NotC_S(groupId, categoryId, status, start, end, null);
3394 }
3395
3396
3412 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
3413 int status, int start, int end, OrderByComparator orderByComparator)
3414 throws SystemException {
3415 Object[] finderArgs = new Object[] {
3416 groupId, categoryId, status,
3417
3418 String.valueOf(start), String.valueOf(end),
3419 String.valueOf(orderByComparator)
3420 };
3421
3422 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_NOTC_S,
3423 finderArgs, this);
3424
3425 if (list == null) {
3426 StringBundler query = null;
3427
3428 if (orderByComparator != null) {
3429 query = new StringBundler(5 +
3430 (orderByComparator.getOrderByFields().length * 3));
3431 }
3432 else {
3433 query = new StringBundler(5);
3434 }
3435
3436 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3437
3438 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
3439
3440 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
3441
3442 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
3443
3444 if (orderByComparator != null) {
3445 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3446 orderByComparator);
3447 }
3448
3449 else {
3450 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3451 }
3452
3453 String sql = query.toString();
3454
3455 Session session = null;
3456
3457 try {
3458 session = openSession();
3459
3460 Query q = session.createQuery(sql);
3461
3462 QueryPos qPos = QueryPos.getInstance(q);
3463
3464 qPos.add(groupId);
3465
3466 qPos.add(categoryId);
3467
3468 qPos.add(status);
3469
3470 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
3471 end);
3472 }
3473 catch (Exception e) {
3474 throw processException(e);
3475 }
3476 finally {
3477 if (list == null) {
3478 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_NOTC_S,
3479 finderArgs);
3480 }
3481 else {
3482 cacheResult(list);
3483
3484 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_NOTC_S,
3485 finderArgs, list);
3486 }
3487
3488 closeSession(session);
3489 }
3490 }
3491
3492 return list;
3493 }
3494
3495
3510 public MBThread findByG_NotC_S_First(long groupId, long categoryId,
3511 int status, OrderByComparator orderByComparator)
3512 throws NoSuchThreadException, SystemException {
3513 List<MBThread> list = findByG_NotC_S(groupId, categoryId, status, 0, 1,
3514 orderByComparator);
3515
3516 if (list.isEmpty()) {
3517 StringBundler msg = new StringBundler(8);
3518
3519 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3520
3521 msg.append("groupId=");
3522 msg.append(groupId);
3523
3524 msg.append(", categoryId=");
3525 msg.append(categoryId);
3526
3527 msg.append(", status=");
3528 msg.append(status);
3529
3530 msg.append(StringPool.CLOSE_CURLY_BRACE);
3531
3532 throw new NoSuchThreadException(msg.toString());
3533 }
3534 else {
3535 return list.get(0);
3536 }
3537 }
3538
3539
3554 public MBThread findByG_NotC_S_Last(long groupId, long categoryId,
3555 int status, OrderByComparator orderByComparator)
3556 throws NoSuchThreadException, SystemException {
3557 int count = countByG_NotC_S(groupId, categoryId, status);
3558
3559 List<MBThread> list = findByG_NotC_S(groupId, categoryId, status,
3560 count - 1, count, orderByComparator);
3561
3562 if (list.isEmpty()) {
3563 StringBundler msg = new StringBundler(8);
3564
3565 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3566
3567 msg.append("groupId=");
3568 msg.append(groupId);
3569
3570 msg.append(", categoryId=");
3571 msg.append(categoryId);
3572
3573 msg.append(", status=");
3574 msg.append(status);
3575
3576 msg.append(StringPool.CLOSE_CURLY_BRACE);
3577
3578 throw new NoSuchThreadException(msg.toString());
3579 }
3580 else {
3581 return list.get(0);
3582 }
3583 }
3584
3585
3601 public MBThread[] findByG_NotC_S_PrevAndNext(long threadId, long groupId,
3602 long categoryId, int status, OrderByComparator orderByComparator)
3603 throws NoSuchThreadException, SystemException {
3604 MBThread mbThread = findByPrimaryKey(threadId);
3605
3606 Session session = null;
3607
3608 try {
3609 session = openSession();
3610
3611 MBThread[] array = new MBThreadImpl[3];
3612
3613 array[0] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId,
3614 categoryId, status, orderByComparator, true);
3615
3616 array[1] = mbThread;
3617
3618 array[2] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId,
3619 categoryId, status, orderByComparator, false);
3620
3621 return array;
3622 }
3623 catch (Exception e) {
3624 throw processException(e);
3625 }
3626 finally {
3627 closeSession(session);
3628 }
3629 }
3630
3631 protected MBThread getByG_NotC_S_PrevAndNext(Session session,
3632 MBThread mbThread, long groupId, long categoryId, int status,
3633 OrderByComparator orderByComparator, boolean previous) {
3634 StringBundler query = null;
3635
3636 if (orderByComparator != null) {
3637 query = new StringBundler(6 +
3638 (orderByComparator.getOrderByFields().length * 6));
3639 }
3640 else {
3641 query = new StringBundler(3);
3642 }
3643
3644 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3645
3646 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
3647
3648 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
3649
3650 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
3651
3652 if (orderByComparator != null) {
3653 String[] orderByFields = orderByComparator.getOrderByFields();
3654
3655 if (orderByFields.length > 0) {
3656 query.append(WHERE_AND);
3657 }
3658
3659 for (int i = 0; i < orderByFields.length; i++) {
3660 query.append(_ORDER_BY_ENTITY_ALIAS);
3661 query.append(orderByFields[i]);
3662
3663 if ((i + 1) < orderByFields.length) {
3664 if (orderByComparator.isAscending() ^ previous) {
3665 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3666 }
3667 else {
3668 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3669 }
3670 }
3671 else {
3672 if (orderByComparator.isAscending() ^ previous) {
3673 query.append(WHERE_GREATER_THAN);
3674 }
3675 else {
3676 query.append(WHERE_LESSER_THAN);
3677 }
3678 }
3679 }
3680
3681 query.append(ORDER_BY_CLAUSE);
3682
3683 for (int i = 0; i < orderByFields.length; i++) {
3684 query.append(_ORDER_BY_ENTITY_ALIAS);
3685 query.append(orderByFields[i]);
3686
3687 if ((i + 1) < orderByFields.length) {
3688 if (orderByComparator.isAscending() ^ previous) {
3689 query.append(ORDER_BY_ASC_HAS_NEXT);
3690 }
3691 else {
3692 query.append(ORDER_BY_DESC_HAS_NEXT);
3693 }
3694 }
3695 else {
3696 if (orderByComparator.isAscending() ^ previous) {
3697 query.append(ORDER_BY_ASC);
3698 }
3699 else {
3700 query.append(ORDER_BY_DESC);
3701 }
3702 }
3703 }
3704 }
3705
3706 else {
3707 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3708 }
3709
3710 String sql = query.toString();
3711
3712 Query q = session.createQuery(sql);
3713
3714 q.setFirstResult(0);
3715 q.setMaxResults(2);
3716
3717 QueryPos qPos = QueryPos.getInstance(q);
3718
3719 qPos.add(groupId);
3720
3721 qPos.add(categoryId);
3722
3723 qPos.add(status);
3724
3725 if (orderByComparator != null) {
3726 Object[] values = orderByComparator.getOrderByValues(mbThread);
3727
3728 for (Object value : values) {
3729 qPos.add(value);
3730 }
3731 }
3732
3733 List<MBThread> list = q.list();
3734
3735 if (list.size() == 2) {
3736 return list.get(1);
3737 }
3738 else {
3739 return null;
3740 }
3741 }
3742
3743
3749 public List<MBThread> findAll() throws SystemException {
3750 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3751 }
3752
3753
3765 public List<MBThread> findAll(int start, int end) throws SystemException {
3766 return findAll(start, end, null);
3767 }
3768
3769
3782 public List<MBThread> findAll(int start, int end,
3783 OrderByComparator orderByComparator) throws SystemException {
3784 Object[] finderArgs = new Object[] {
3785 String.valueOf(start), String.valueOf(end),
3786 String.valueOf(orderByComparator)
3787 };
3788
3789 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3790 finderArgs, this);
3791
3792 if (list == null) {
3793 StringBundler query = null;
3794 String sql = null;
3795
3796 if (orderByComparator != null) {
3797 query = new StringBundler(2 +
3798 (orderByComparator.getOrderByFields().length * 3));
3799
3800 query.append(_SQL_SELECT_MBTHREAD);
3801
3802 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3803 orderByComparator);
3804
3805 sql = query.toString();
3806 }
3807 else {
3808 sql = _SQL_SELECT_MBTHREAD.concat(MBThreadModelImpl.ORDER_BY_JPQL);
3809 }
3810
3811 Session session = null;
3812
3813 try {
3814 session = openSession();
3815
3816 Query q = session.createQuery(sql);
3817
3818 if (orderByComparator == null) {
3819 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
3820 start, end, false);
3821
3822 Collections.sort(list);
3823 }
3824 else {
3825 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
3826 start, end);
3827 }
3828 }
3829 catch (Exception e) {
3830 throw processException(e);
3831 }
3832 finally {
3833 if (list == null) {
3834 FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
3835 finderArgs);
3836 }
3837 else {
3838 cacheResult(list);
3839
3840 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
3841 list);
3842 }
3843
3844 closeSession(session);
3845 }
3846 }
3847
3848 return list;
3849 }
3850
3851
3857 public void removeByGroupId(long groupId) throws SystemException {
3858 for (MBThread mbThread : findByGroupId(groupId)) {
3859 remove(mbThread);
3860 }
3861 }
3862
3863
3870 public void removeByG_C(long groupId, long categoryId)
3871 throws SystemException {
3872 for (MBThread mbThread : findByG_C(groupId, categoryId)) {
3873 remove(mbThread);
3874 }
3875 }
3876
3877
3884 public void removeByG_NotC(long groupId, long categoryId)
3885 throws SystemException {
3886 for (MBThread mbThread : findByG_NotC(groupId, categoryId)) {
3887 remove(mbThread);
3888 }
3889 }
3890
3891
3898 public void removeByG_S(long groupId, int status) throws SystemException {
3899 for (MBThread mbThread : findByG_S(groupId, status)) {
3900 remove(mbThread);
3901 }
3902 }
3903
3904
3911 public void removeByC_P(long categoryId, double priority)
3912 throws SystemException {
3913 for (MBThread mbThread : findByC_P(categoryId, priority)) {
3914 remove(mbThread);
3915 }
3916 }
3917
3918
3926 public void removeByG_C_L(long groupId, long categoryId, Date lastPostDate)
3927 throws SystemException {
3928 for (MBThread mbThread : findByG_C_L(groupId, categoryId, lastPostDate)) {
3929 remove(mbThread);
3930 }
3931 }
3932
3933
3941 public void removeByG_C_S(long groupId, long categoryId, int status)
3942 throws SystemException {
3943 for (MBThread mbThread : findByG_C_S(groupId, categoryId, status)) {
3944 remove(mbThread);
3945 }
3946 }
3947
3948
3956 public void removeByG_NotC_S(long groupId, long categoryId, int status)
3957 throws SystemException {
3958 for (MBThread mbThread : findByG_NotC_S(groupId, categoryId, status)) {
3959 remove(mbThread);
3960 }
3961 }
3962
3963
3968 public void removeAll() throws SystemException {
3969 for (MBThread mbThread : findAll()) {
3970 remove(mbThread);
3971 }
3972 }
3973
3974
3981 public int countByGroupId(long groupId) throws SystemException {
3982 Object[] finderArgs = new Object[] { groupId };
3983
3984 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
3985 finderArgs, this);
3986
3987 if (count == null) {
3988 StringBundler query = new StringBundler(2);
3989
3990 query.append(_SQL_COUNT_MBTHREAD_WHERE);
3991
3992 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3993
3994 String sql = query.toString();
3995
3996 Session session = null;
3997
3998 try {
3999 session = openSession();
4000
4001 Query q = session.createQuery(sql);
4002
4003 QueryPos qPos = QueryPos.getInstance(q);
4004
4005 qPos.add(groupId);
4006
4007 count = (Long)q.uniqueResult();
4008 }
4009 catch (Exception e) {
4010 throw processException(e);
4011 }
4012 finally {
4013 if (count == null) {
4014 count = Long.valueOf(0);
4015 }
4016
4017 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4018 finderArgs, count);
4019
4020 closeSession(session);
4021 }
4022 }
4023
4024 return count.intValue();
4025 }
4026
4027
4035 public int countByG_C(long groupId, long categoryId)
4036 throws SystemException {
4037 Object[] finderArgs = new Object[] { groupId, categoryId };
4038
4039 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
4040 finderArgs, this);
4041
4042 if (count == null) {
4043 StringBundler query = new StringBundler(3);
4044
4045 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4046
4047 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
4048
4049 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
4050
4051 String sql = query.toString();
4052
4053 Session session = null;
4054
4055 try {
4056 session = openSession();
4057
4058 Query q = session.createQuery(sql);
4059
4060 QueryPos qPos = QueryPos.getInstance(q);
4061
4062 qPos.add(groupId);
4063
4064 qPos.add(categoryId);
4065
4066 count = (Long)q.uniqueResult();
4067 }
4068 catch (Exception e) {
4069 throw processException(e);
4070 }
4071 finally {
4072 if (count == null) {
4073 count = Long.valueOf(0);
4074 }
4075
4076 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
4077 count);
4078
4079 closeSession(session);
4080 }
4081 }
4082
4083 return count.intValue();
4084 }
4085
4086
4094 public int countByG_C(long groupId, long[] categoryIds)
4095 throws SystemException {
4096 Object[] finderArgs = new Object[] {
4097 groupId, StringUtil.merge(categoryIds)
4098 };
4099
4100 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
4101 finderArgs, this);
4102
4103 if (count == null) {
4104 StringBundler query = new StringBundler();
4105
4106 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4107
4108 boolean conjunctionable = false;
4109
4110 if (conjunctionable) {
4111 query.append(WHERE_AND);
4112 }
4113
4114 query.append(_FINDER_COLUMN_G_C_GROUPID_5);
4115
4116 conjunctionable = true;
4117
4118 if ((categoryIds == null) || (categoryIds.length > 0)) {
4119 if (conjunctionable) {
4120 query.append(WHERE_AND);
4121 }
4122
4123 query.append(StringPool.OPEN_PARENTHESIS);
4124
4125 for (int i = 0; i < categoryIds.length; i++) {
4126 query.append(_FINDER_COLUMN_G_C_CATEGORYID_5);
4127
4128 if ((i + 1) < categoryIds.length) {
4129 query.append(WHERE_OR);
4130 }
4131 }
4132
4133 query.append(StringPool.CLOSE_PARENTHESIS);
4134
4135 conjunctionable = true;
4136 }
4137
4138 String sql = query.toString();
4139
4140 Session session = null;
4141
4142 try {
4143 session = openSession();
4144
4145 Query q = session.createQuery(sql);
4146
4147 QueryPos qPos = QueryPos.getInstance(q);
4148
4149 qPos.add(groupId);
4150
4151 if (categoryIds != null) {
4152 qPos.add(categoryIds);
4153 }
4154
4155 count = (Long)q.uniqueResult();
4156 }
4157 catch (Exception e) {
4158 throw processException(e);
4159 }
4160 finally {
4161 if (count == null) {
4162 count = Long.valueOf(0);
4163 }
4164
4165 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
4166 count);
4167
4168 closeSession(session);
4169 }
4170 }
4171
4172 return count.intValue();
4173 }
4174
4175
4183 public int countByG_NotC(long groupId, long categoryId)
4184 throws SystemException {
4185 Object[] finderArgs = new Object[] { groupId, categoryId };
4186
4187 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_NOTC,
4188 finderArgs, this);
4189
4190 if (count == null) {
4191 StringBundler query = new StringBundler(3);
4192
4193 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4194
4195 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4196
4197 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4198
4199 String sql = query.toString();
4200
4201 Session session = null;
4202
4203 try {
4204 session = openSession();
4205
4206 Query q = session.createQuery(sql);
4207
4208 QueryPos qPos = QueryPos.getInstance(q);
4209
4210 qPos.add(groupId);
4211
4212 qPos.add(categoryId);
4213
4214 count = (Long)q.uniqueResult();
4215 }
4216 catch (Exception e) {
4217 throw processException(e);
4218 }
4219 finally {
4220 if (count == null) {
4221 count = Long.valueOf(0);
4222 }
4223
4224 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_NOTC,
4225 finderArgs, count);
4226
4227 closeSession(session);
4228 }
4229 }
4230
4231 return count.intValue();
4232 }
4233
4234
4242 public int countByG_S(long groupId, int status) throws SystemException {
4243 Object[] finderArgs = new Object[] { groupId, status };
4244
4245 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
4246 finderArgs, this);
4247
4248 if (count == null) {
4249 StringBundler query = new StringBundler(3);
4250
4251 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4252
4253 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4254
4255 query.append(_FINDER_COLUMN_G_S_STATUS_2);
4256
4257 String sql = query.toString();
4258
4259 Session session = null;
4260
4261 try {
4262 session = openSession();
4263
4264 Query q = session.createQuery(sql);
4265
4266 QueryPos qPos = QueryPos.getInstance(q);
4267
4268 qPos.add(groupId);
4269
4270 qPos.add(status);
4271
4272 count = (Long)q.uniqueResult();
4273 }
4274 catch (Exception e) {
4275 throw processException(e);
4276 }
4277 finally {
4278 if (count == null) {
4279 count = Long.valueOf(0);
4280 }
4281
4282 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
4283 count);
4284
4285 closeSession(session);
4286 }
4287 }
4288
4289 return count.intValue();
4290 }
4291
4292
4300 public int countByC_P(long categoryId, double priority)
4301 throws SystemException {
4302 Object[] finderArgs = new Object[] { categoryId, priority };
4303
4304 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
4305 finderArgs, this);
4306
4307 if (count == null) {
4308 StringBundler query = new StringBundler(3);
4309
4310 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4311
4312 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
4313
4314 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
4315
4316 String sql = query.toString();
4317
4318 Session session = null;
4319
4320 try {
4321 session = openSession();
4322
4323 Query q = session.createQuery(sql);
4324
4325 QueryPos qPos = QueryPos.getInstance(q);
4326
4327 qPos.add(categoryId);
4328
4329 qPos.add(priority);
4330
4331 count = (Long)q.uniqueResult();
4332 }
4333 catch (Exception e) {
4334 throw processException(e);
4335 }
4336 finally {
4337 if (count == null) {
4338 count = Long.valueOf(0);
4339 }
4340
4341 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
4342 count);
4343
4344 closeSession(session);
4345 }
4346 }
4347
4348 return count.intValue();
4349 }
4350
4351
4360 public int countByG_C_L(long groupId, long categoryId, Date lastPostDate)
4361 throws SystemException {
4362 Object[] finderArgs = new Object[] { groupId, categoryId, lastPostDate };
4363
4364 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_L,
4365 finderArgs, this);
4366
4367 if (count == null) {
4368 StringBundler query = new StringBundler(4);
4369
4370 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4371
4372 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
4373
4374 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
4375
4376 if (lastPostDate == null) {
4377 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
4378 }
4379 else {
4380 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
4381 }
4382
4383 String sql = query.toString();
4384
4385 Session session = null;
4386
4387 try {
4388 session = openSession();
4389
4390 Query q = session.createQuery(sql);
4391
4392 QueryPos qPos = QueryPos.getInstance(q);
4393
4394 qPos.add(groupId);
4395
4396 qPos.add(categoryId);
4397
4398 if (lastPostDate != null) {
4399 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
4400 }
4401
4402 count = (Long)q.uniqueResult();
4403 }
4404 catch (Exception e) {
4405 throw processException(e);
4406 }
4407 finally {
4408 if (count == null) {
4409 count = Long.valueOf(0);
4410 }
4411
4412 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_L,
4413 finderArgs, count);
4414
4415 closeSession(session);
4416 }
4417 }
4418
4419 return count.intValue();
4420 }
4421
4422
4431 public int countByG_C_S(long groupId, long categoryId, int status)
4432 throws SystemException {
4433 Object[] finderArgs = new Object[] { groupId, categoryId, status };
4434
4435 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
4436 finderArgs, this);
4437
4438 if (count == null) {
4439 StringBundler query = new StringBundler(4);
4440
4441 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4442
4443 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
4444
4445 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
4446
4447 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
4448
4449 String sql = query.toString();
4450
4451 Session session = null;
4452
4453 try {
4454 session = openSession();
4455
4456 Query q = session.createQuery(sql);
4457
4458 QueryPos qPos = QueryPos.getInstance(q);
4459
4460 qPos.add(groupId);
4461
4462 qPos.add(categoryId);
4463
4464 qPos.add(status);
4465
4466 count = (Long)q.uniqueResult();
4467 }
4468 catch (Exception e) {
4469 throw processException(e);
4470 }
4471 finally {
4472 if (count == null) {
4473 count = Long.valueOf(0);
4474 }
4475
4476 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
4477 finderArgs, count);
4478
4479 closeSession(session);
4480 }
4481 }
4482
4483 return count.intValue();
4484 }
4485
4486
4495 public int countByG_C_S(long groupId, long[] categoryIds, int status)
4496 throws SystemException {
4497 Object[] finderArgs = new Object[] {
4498 groupId, StringUtil.merge(categoryIds), status
4499 };
4500
4501 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
4502 finderArgs, this);
4503
4504 if (count == null) {
4505 StringBundler query = new StringBundler();
4506
4507 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4508
4509 boolean conjunctionable = false;
4510
4511 if (conjunctionable) {
4512 query.append(WHERE_AND);
4513 }
4514
4515 query.append(_FINDER_COLUMN_G_C_S_GROUPID_5);
4516
4517 conjunctionable = true;
4518
4519 if ((categoryIds == null) || (categoryIds.length > 0)) {
4520 if (conjunctionable) {
4521 query.append(WHERE_AND);
4522 }
4523
4524 query.append(StringPool.OPEN_PARENTHESIS);
4525
4526 for (int i = 0; i < categoryIds.length; i++) {
4527 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5);
4528
4529 if ((i + 1) < categoryIds.length) {
4530 query.append(WHERE_OR);
4531 }
4532 }
4533
4534 query.append(StringPool.CLOSE_PARENTHESIS);
4535
4536 conjunctionable = true;
4537 }
4538
4539 if (conjunctionable) {
4540 query.append(WHERE_AND);
4541 }
4542
4543 query.append(_FINDER_COLUMN_G_C_S_STATUS_5);
4544
4545 conjunctionable = true;
4546
4547 String sql = query.toString();
4548
4549 Session session = null;
4550
4551 try {
4552 session = openSession();
4553
4554 Query q = session.createQuery(sql);
4555
4556 QueryPos qPos = QueryPos.getInstance(q);
4557
4558 qPos.add(groupId);
4559
4560 if (categoryIds != null) {
4561 qPos.add(categoryIds);
4562 }
4563
4564 qPos.add(status);
4565
4566 count = (Long)q.uniqueResult();
4567 }
4568 catch (Exception e) {
4569 throw processException(e);
4570 }
4571 finally {
4572 if (count == null) {
4573 count = Long.valueOf(0);
4574 }
4575
4576 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
4577 finderArgs, count);
4578
4579 closeSession(session);
4580 }
4581 }
4582
4583 return count.intValue();
4584 }
4585
4586
4595 public int countByG_NotC_S(long groupId, long categoryId, int status)
4596 throws SystemException {
4597 Object[] finderArgs = new Object[] { groupId, categoryId, status };
4598
4599 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_NOTC_S,
4600 finderArgs, this);
4601
4602 if (count == null) {
4603 StringBundler query = new StringBundler(4);
4604
4605 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4606
4607 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
4608
4609 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
4610
4611 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
4612
4613 String sql = query.toString();
4614
4615 Session session = null;
4616
4617 try {
4618 session = openSession();
4619
4620 Query q = session.createQuery(sql);
4621
4622 QueryPos qPos = QueryPos.getInstance(q);
4623
4624 qPos.add(groupId);
4625
4626 qPos.add(categoryId);
4627
4628 qPos.add(status);
4629
4630 count = (Long)q.uniqueResult();
4631 }
4632 catch (Exception e) {
4633 throw processException(e);
4634 }
4635 finally {
4636 if (count == null) {
4637 count = Long.valueOf(0);
4638 }
4639
4640 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_NOTC_S,
4641 finderArgs, count);
4642
4643 closeSession(session);
4644 }
4645 }
4646
4647 return count.intValue();
4648 }
4649
4650
4656 public int countAll() throws SystemException {
4657 Object[] finderArgs = new Object[0];
4658
4659 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4660 finderArgs, this);
4661
4662 if (count == null) {
4663 Session session = null;
4664
4665 try {
4666 session = openSession();
4667
4668 Query q = session.createQuery(_SQL_COUNT_MBTHREAD);
4669
4670 count = (Long)q.uniqueResult();
4671 }
4672 catch (Exception e) {
4673 throw processException(e);
4674 }
4675 finally {
4676 if (count == null) {
4677 count = Long.valueOf(0);
4678 }
4679
4680 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
4681 count);
4682
4683 closeSession(session);
4684 }
4685 }
4686
4687 return count.intValue();
4688 }
4689
4690
4693 public void afterPropertiesSet() {
4694 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4695 com.liferay.portal.util.PropsUtil.get(
4696 "value.object.listener.com.liferay.portlet.messageboards.model.MBThread")));
4697
4698 if (listenerClassNames.length > 0) {
4699 try {
4700 List<ModelListener<MBThread>> listenersList = new ArrayList<ModelListener<MBThread>>();
4701
4702 for (String listenerClassName : listenerClassNames) {
4703 listenersList.add((ModelListener<MBThread>)InstanceFactory.newInstance(
4704 listenerClassName));
4705 }
4706
4707 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4708 }
4709 catch (Exception e) {
4710 _log.error(e);
4711 }
4712 }
4713 }
4714
4715 public void destroy() {
4716 EntityCacheUtil.removeCache(MBThreadImpl.class.getName());
4717 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4718 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
4719 }
4720
4721 @BeanReference(type = MBBanPersistence.class)
4722 protected MBBanPersistence mbBanPersistence;
4723 @BeanReference(type = MBCategoryPersistence.class)
4724 protected MBCategoryPersistence mbCategoryPersistence;
4725 @BeanReference(type = MBDiscussionPersistence.class)
4726 protected MBDiscussionPersistence mbDiscussionPersistence;
4727 @BeanReference(type = MBMailingListPersistence.class)
4728 protected MBMailingListPersistence mbMailingListPersistence;
4729 @BeanReference(type = MBMessagePersistence.class)
4730 protected MBMessagePersistence mbMessagePersistence;
4731 @BeanReference(type = MBMessageFlagPersistence.class)
4732 protected MBMessageFlagPersistence mbMessageFlagPersistence;
4733 @BeanReference(type = MBStatsUserPersistence.class)
4734 protected MBStatsUserPersistence mbStatsUserPersistence;
4735 @BeanReference(type = MBThreadPersistence.class)
4736 protected MBThreadPersistence mbThreadPersistence;
4737 @BeanReference(type = LockPersistence.class)
4738 protected LockPersistence lockPersistence;
4739 @BeanReference(type = ResourcePersistence.class)
4740 protected ResourcePersistence resourcePersistence;
4741 @BeanReference(type = UserPersistence.class)
4742 protected UserPersistence userPersistence;
4743 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
4744 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
4745 @BeanReference(type = AssetEntryPersistence.class)
4746 protected AssetEntryPersistence assetEntryPersistence;
4747 @BeanReference(type = RatingsStatsPersistence.class)
4748 protected RatingsStatsPersistence ratingsStatsPersistence;
4749 @BeanReference(type = SocialActivityPersistence.class)
4750 protected SocialActivityPersistence socialActivityPersistence;
4751 private static final String _SQL_SELECT_MBTHREAD = "SELECT mbThread FROM MBThread mbThread";
4752 private static final String _SQL_SELECT_MBTHREAD_WHERE = "SELECT mbThread FROM MBThread mbThread WHERE ";
4753 private static final String _SQL_COUNT_MBTHREAD = "SELECT COUNT(mbThread) FROM MBThread mbThread";
4754 private static final String _SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(mbThread) FROM MBThread mbThread WHERE ";
4755 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbThread.groupId = ?";
4756 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbThread.groupId = ? AND ";
4757 private static final String _FINDER_COLUMN_G_C_GROUPID_5 = "(" +
4758 _removeConjunction(_FINDER_COLUMN_G_C_GROUPID_2) + ")";
4759 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbThread.categoryId = ?";
4760 private static final String _FINDER_COLUMN_G_C_CATEGORYID_5 = "(" +
4761 _removeConjunction(_FINDER_COLUMN_G_C_CATEGORYID_2) + ")";
4762 private static final String _FINDER_COLUMN_G_NOTC_GROUPID_2 = "mbThread.groupId = ? AND ";
4763 private static final String _FINDER_COLUMN_G_NOTC_CATEGORYID_2 = "mbThread.categoryId != ?";
4764 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "mbThread.groupId = ? AND ";
4765 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbThread.status = ? AND mbThread.categoryId != -1";
4766 private static final String _FINDER_COLUMN_C_P_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
4767 private static final String _FINDER_COLUMN_C_P_PRIORITY_2 = "mbThread.priority = ?";
4768 private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "mbThread.groupId = ? AND ";
4769 private static final String _FINDER_COLUMN_G_C_L_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
4770 private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL";
4771 private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_2 = "mbThread.lastPostDate = ?";
4772 private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "mbThread.groupId = ? AND ";
4773 private static final String _FINDER_COLUMN_G_C_S_GROUPID_5 = "(" +
4774 _removeConjunction(_FINDER_COLUMN_G_C_S_GROUPID_2) + ")";
4775 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
4776 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_5 = "(" +
4777 _removeConjunction(_FINDER_COLUMN_G_C_S_CATEGORYID_2) + ")";
4778 private static final String _FINDER_COLUMN_G_C_S_STATUS_2 = "mbThread.status = ?";
4779 private static final String _FINDER_COLUMN_G_C_S_STATUS_5 = "(" +
4780 _removeConjunction(_FINDER_COLUMN_G_C_S_STATUS_2) + ")";
4781 private static final String _FINDER_COLUMN_G_NOTC_S_GROUPID_2 = "mbThread.groupId = ? AND ";
4782 private static final String _FINDER_COLUMN_G_NOTC_S_CATEGORYID_2 = "mbThread.categoryId != ? AND ";
4783 private static final String _FINDER_COLUMN_G_NOTC_S_STATUS_2 = "mbThread.status = ?";
4784
4785 private static String _removeConjunction(String sql) {
4786 int pos = sql.indexOf(" AND ");
4787
4788 if (pos != -1) {
4789 sql = sql.substring(0, pos);
4790 }
4791
4792 return sql;
4793 }
4794
4795 private static final String _ORDER_BY_ENTITY_ALIAS = "mbThread.";
4796 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBThread exists with the primary key ";
4797 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBThread exists with the key {";
4798 private static Log _log = LogFactoryUtil.getLog(MBThreadPersistenceImpl.class);
4799 }