001
014
015 package com.liferay.portlet.messageboards.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.dao.orm.EntityCache;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCache;
023 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024 import com.liferay.portal.kernel.dao.orm.FinderPath;
025 import com.liferay.portal.kernel.dao.orm.Query;
026 import com.liferay.portal.kernel.dao.orm.QueryPos;
027 import com.liferay.portal.kernel.dao.orm.QueryUtil;
028 import com.liferay.portal.kernel.dao.orm.SQLQuery;
029 import com.liferay.portal.kernel.dao.orm.Session;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
032 import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
033 import com.liferay.portal.kernel.util.ArrayUtil;
034 import com.liferay.portal.kernel.util.OrderByComparator;
035 import com.liferay.portal.kernel.util.SetUtil;
036 import com.liferay.portal.kernel.util.StringBundler;
037 import com.liferay.portal.kernel.util.StringPool;
038 import com.liferay.portal.kernel.util.StringUtil;
039 import com.liferay.portal.kernel.util.Validator;
040 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
041 import com.liferay.portal.model.CacheModel;
042 import com.liferay.portal.service.ServiceContext;
043 import com.liferay.portal.service.ServiceContextThreadLocal;
044 import com.liferay.portal.service.persistence.CompanyProvider;
045 import com.liferay.portal.service.persistence.CompanyProviderWrapper;
046 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
047
048 import com.liferay.portlet.messageboards.exception.NoSuchThreadException;
049 import com.liferay.portlet.messageboards.model.MBThread;
050 import com.liferay.portlet.messageboards.model.impl.MBThreadImpl;
051 import com.liferay.portlet.messageboards.model.impl.MBThreadModelImpl;
052 import com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence;
053
054 import java.io.Serializable;
055
056 import java.sql.Timestamp;
057
058 import java.util.Arrays;
059 import java.util.Collections;
060 import java.util.Date;
061 import java.util.HashMap;
062 import java.util.HashSet;
063 import java.util.Iterator;
064 import java.util.List;
065 import java.util.Map;
066 import java.util.Set;
067
068
080 @ProviderType
081 public class MBThreadPersistenceImpl extends BasePersistenceImpl<MBThread>
082 implements MBThreadPersistence {
083
088 public static final String FINDER_CLASS_NAME_ENTITY = MBThreadImpl.class.getName();
089 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
090 ".List1";
091 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
092 ".List2";
093 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
094 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
095 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
096 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
097 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
099 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
100 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
102 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
103 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
104 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
105 new String[] {
106 String.class.getName(),
107
108 Integer.class.getName(), Integer.class.getName(),
109 OrderByComparator.class.getName()
110 });
111 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
112 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
113 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
114 new String[] { String.class.getName() },
115 MBThreadModelImpl.UUID_COLUMN_BITMASK |
116 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
117 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
118 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
119 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
120 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
121 new String[] { String.class.getName() });
122
123
129 @Override
130 public List<MBThread> findByUuid(String uuid) {
131 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
132 }
133
134
146 @Override
147 public List<MBThread> findByUuid(String uuid, int start, int end) {
148 return findByUuid(uuid, start, end, null);
149 }
150
151
164 @Override
165 public List<MBThread> findByUuid(String uuid, int start, int end,
166 OrderByComparator<MBThread> orderByComparator) {
167 return findByUuid(uuid, start, end, orderByComparator, true);
168 }
169
170
184 @Override
185 public List<MBThread> findByUuid(String uuid, int start, int end,
186 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
187 boolean pagination = true;
188 FinderPath finderPath = null;
189 Object[] finderArgs = null;
190
191 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
192 (orderByComparator == null)) {
193 pagination = false;
194 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
195 finderArgs = new Object[] { uuid };
196 }
197 else {
198 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
199 finderArgs = new Object[] { uuid, start, end, orderByComparator };
200 }
201
202 List<MBThread> list = null;
203
204 if (retrieveFromCache) {
205 list = (List<MBThread>)finderCache.getResult(finderPath,
206 finderArgs, this);
207
208 if ((list != null) && !list.isEmpty()) {
209 for (MBThread mbThread : list) {
210 if (!Validator.equals(uuid, mbThread.getUuid())) {
211 list = null;
212
213 break;
214 }
215 }
216 }
217 }
218
219 if (list == null) {
220 StringBundler query = null;
221
222 if (orderByComparator != null) {
223 query = new StringBundler(3 +
224 (orderByComparator.getOrderByFields().length * 2));
225 }
226 else {
227 query = new StringBundler(3);
228 }
229
230 query.append(_SQL_SELECT_MBTHREAD_WHERE);
231
232 boolean bindUuid = false;
233
234 if (uuid == null) {
235 query.append(_FINDER_COLUMN_UUID_UUID_1);
236 }
237 else if (uuid.equals(StringPool.BLANK)) {
238 query.append(_FINDER_COLUMN_UUID_UUID_3);
239 }
240 else {
241 bindUuid = true;
242
243 query.append(_FINDER_COLUMN_UUID_UUID_2);
244 }
245
246 if (orderByComparator != null) {
247 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
248 orderByComparator);
249 }
250 else
251 if (pagination) {
252 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
253 }
254
255 String sql = query.toString();
256
257 Session session = null;
258
259 try {
260 session = openSession();
261
262 Query q = session.createQuery(sql);
263
264 QueryPos qPos = QueryPos.getInstance(q);
265
266 if (bindUuid) {
267 qPos.add(uuid);
268 }
269
270 if (!pagination) {
271 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
272 start, end, false);
273
274 Collections.sort(list);
275
276 list = Collections.unmodifiableList(list);
277 }
278 else {
279 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
280 start, end);
281 }
282
283 cacheResult(list);
284
285 finderCache.putResult(finderPath, finderArgs, list);
286 }
287 catch (Exception e) {
288 finderCache.removeResult(finderPath, finderArgs);
289
290 throw processException(e);
291 }
292 finally {
293 closeSession(session);
294 }
295 }
296
297 return list;
298 }
299
300
308 @Override
309 public MBThread findByUuid_First(String uuid,
310 OrderByComparator<MBThread> orderByComparator)
311 throws NoSuchThreadException {
312 MBThread mbThread = fetchByUuid_First(uuid, orderByComparator);
313
314 if (mbThread != null) {
315 return mbThread;
316 }
317
318 StringBundler msg = new StringBundler(4);
319
320 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
321
322 msg.append("uuid=");
323 msg.append(uuid);
324
325 msg.append(StringPool.CLOSE_CURLY_BRACE);
326
327 throw new NoSuchThreadException(msg.toString());
328 }
329
330
337 @Override
338 public MBThread fetchByUuid_First(String uuid,
339 OrderByComparator<MBThread> orderByComparator) {
340 List<MBThread> list = findByUuid(uuid, 0, 1, orderByComparator);
341
342 if (!list.isEmpty()) {
343 return list.get(0);
344 }
345
346 return null;
347 }
348
349
357 @Override
358 public MBThread findByUuid_Last(String uuid,
359 OrderByComparator<MBThread> orderByComparator)
360 throws NoSuchThreadException {
361 MBThread mbThread = fetchByUuid_Last(uuid, orderByComparator);
362
363 if (mbThread != null) {
364 return mbThread;
365 }
366
367 StringBundler msg = new StringBundler(4);
368
369 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
370
371 msg.append("uuid=");
372 msg.append(uuid);
373
374 msg.append(StringPool.CLOSE_CURLY_BRACE);
375
376 throw new NoSuchThreadException(msg.toString());
377 }
378
379
386 @Override
387 public MBThread fetchByUuid_Last(String uuid,
388 OrderByComparator<MBThread> orderByComparator) {
389 int count = countByUuid(uuid);
390
391 if (count == 0) {
392 return null;
393 }
394
395 List<MBThread> list = findByUuid(uuid, count - 1, count,
396 orderByComparator);
397
398 if (!list.isEmpty()) {
399 return list.get(0);
400 }
401
402 return null;
403 }
404
405
414 @Override
415 public MBThread[] findByUuid_PrevAndNext(long threadId, String uuid,
416 OrderByComparator<MBThread> orderByComparator)
417 throws NoSuchThreadException {
418 MBThread mbThread = findByPrimaryKey(threadId);
419
420 Session session = null;
421
422 try {
423 session = openSession();
424
425 MBThread[] array = new MBThreadImpl[3];
426
427 array[0] = getByUuid_PrevAndNext(session, mbThread, uuid,
428 orderByComparator, true);
429
430 array[1] = mbThread;
431
432 array[2] = getByUuid_PrevAndNext(session, mbThread, uuid,
433 orderByComparator, false);
434
435 return array;
436 }
437 catch (Exception e) {
438 throw processException(e);
439 }
440 finally {
441 closeSession(session);
442 }
443 }
444
445 protected MBThread getByUuid_PrevAndNext(Session session,
446 MBThread mbThread, String uuid,
447 OrderByComparator<MBThread> orderByComparator, boolean previous) {
448 StringBundler query = null;
449
450 if (orderByComparator != null) {
451 query = new StringBundler(4 +
452 (orderByComparator.getOrderByConditionFields().length * 3) +
453 (orderByComparator.getOrderByFields().length * 3));
454 }
455 else {
456 query = new StringBundler(3);
457 }
458
459 query.append(_SQL_SELECT_MBTHREAD_WHERE);
460
461 boolean bindUuid = false;
462
463 if (uuid == null) {
464 query.append(_FINDER_COLUMN_UUID_UUID_1);
465 }
466 else if (uuid.equals(StringPool.BLANK)) {
467 query.append(_FINDER_COLUMN_UUID_UUID_3);
468 }
469 else {
470 bindUuid = true;
471
472 query.append(_FINDER_COLUMN_UUID_UUID_2);
473 }
474
475 if (orderByComparator != null) {
476 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
477
478 if (orderByConditionFields.length > 0) {
479 query.append(WHERE_AND);
480 }
481
482 for (int i = 0; i < orderByConditionFields.length; i++) {
483 query.append(_ORDER_BY_ENTITY_ALIAS);
484 query.append(orderByConditionFields[i]);
485
486 if ((i + 1) < orderByConditionFields.length) {
487 if (orderByComparator.isAscending() ^ previous) {
488 query.append(WHERE_GREATER_THAN_HAS_NEXT);
489 }
490 else {
491 query.append(WHERE_LESSER_THAN_HAS_NEXT);
492 }
493 }
494 else {
495 if (orderByComparator.isAscending() ^ previous) {
496 query.append(WHERE_GREATER_THAN);
497 }
498 else {
499 query.append(WHERE_LESSER_THAN);
500 }
501 }
502 }
503
504 query.append(ORDER_BY_CLAUSE);
505
506 String[] orderByFields = orderByComparator.getOrderByFields();
507
508 for (int i = 0; i < orderByFields.length; i++) {
509 query.append(_ORDER_BY_ENTITY_ALIAS);
510 query.append(orderByFields[i]);
511
512 if ((i + 1) < orderByFields.length) {
513 if (orderByComparator.isAscending() ^ previous) {
514 query.append(ORDER_BY_ASC_HAS_NEXT);
515 }
516 else {
517 query.append(ORDER_BY_DESC_HAS_NEXT);
518 }
519 }
520 else {
521 if (orderByComparator.isAscending() ^ previous) {
522 query.append(ORDER_BY_ASC);
523 }
524 else {
525 query.append(ORDER_BY_DESC);
526 }
527 }
528 }
529 }
530 else {
531 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
532 }
533
534 String sql = query.toString();
535
536 Query q = session.createQuery(sql);
537
538 q.setFirstResult(0);
539 q.setMaxResults(2);
540
541 QueryPos qPos = QueryPos.getInstance(q);
542
543 if (bindUuid) {
544 qPos.add(uuid);
545 }
546
547 if (orderByComparator != null) {
548 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
549
550 for (Object value : values) {
551 qPos.add(value);
552 }
553 }
554
555 List<MBThread> list = q.list();
556
557 if (list.size() == 2) {
558 return list.get(1);
559 }
560 else {
561 return null;
562 }
563 }
564
565
570 @Override
571 public void removeByUuid(String uuid) {
572 for (MBThread mbThread : findByUuid(uuid, QueryUtil.ALL_POS,
573 QueryUtil.ALL_POS, null)) {
574 remove(mbThread);
575 }
576 }
577
578
584 @Override
585 public int countByUuid(String uuid) {
586 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
587
588 Object[] finderArgs = new Object[] { uuid };
589
590 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
591
592 if (count == null) {
593 StringBundler query = new StringBundler(2);
594
595 query.append(_SQL_COUNT_MBTHREAD_WHERE);
596
597 boolean bindUuid = false;
598
599 if (uuid == null) {
600 query.append(_FINDER_COLUMN_UUID_UUID_1);
601 }
602 else if (uuid.equals(StringPool.BLANK)) {
603 query.append(_FINDER_COLUMN_UUID_UUID_3);
604 }
605 else {
606 bindUuid = true;
607
608 query.append(_FINDER_COLUMN_UUID_UUID_2);
609 }
610
611 String sql = query.toString();
612
613 Session session = null;
614
615 try {
616 session = openSession();
617
618 Query q = session.createQuery(sql);
619
620 QueryPos qPos = QueryPos.getInstance(q);
621
622 if (bindUuid) {
623 qPos.add(uuid);
624 }
625
626 count = (Long)q.uniqueResult();
627
628 finderCache.putResult(finderPath, finderArgs, count);
629 }
630 catch (Exception e) {
631 finderCache.removeResult(finderPath, finderArgs);
632
633 throw processException(e);
634 }
635 finally {
636 closeSession(session);
637 }
638 }
639
640 return count.intValue();
641 }
642
643 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbThread.uuid IS NULL";
644 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbThread.uuid = ?";
645 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbThread.uuid IS NULL OR mbThread.uuid = '')";
646 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
647 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
648 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
649 new String[] { String.class.getName(), Long.class.getName() },
650 MBThreadModelImpl.UUID_COLUMN_BITMASK |
651 MBThreadModelImpl.GROUPID_COLUMN_BITMASK);
652 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
653 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
654 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
655 new String[] { String.class.getName(), Long.class.getName() });
656
657
665 @Override
666 public MBThread findByUUID_G(String uuid, long groupId)
667 throws NoSuchThreadException {
668 MBThread mbThread = fetchByUUID_G(uuid, groupId);
669
670 if (mbThread == null) {
671 StringBundler msg = new StringBundler(6);
672
673 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
674
675 msg.append("uuid=");
676 msg.append(uuid);
677
678 msg.append(", groupId=");
679 msg.append(groupId);
680
681 msg.append(StringPool.CLOSE_CURLY_BRACE);
682
683 if (_log.isWarnEnabled()) {
684 _log.warn(msg.toString());
685 }
686
687 throw new NoSuchThreadException(msg.toString());
688 }
689
690 return mbThread;
691 }
692
693
700 @Override
701 public MBThread fetchByUUID_G(String uuid, long groupId) {
702 return fetchByUUID_G(uuid, groupId, true);
703 }
704
705
713 @Override
714 public MBThread fetchByUUID_G(String uuid, long groupId,
715 boolean retrieveFromCache) {
716 Object[] finderArgs = new Object[] { uuid, groupId };
717
718 Object result = null;
719
720 if (retrieveFromCache) {
721 result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
722 finderArgs, this);
723 }
724
725 if (result instanceof MBThread) {
726 MBThread mbThread = (MBThread)result;
727
728 if (!Validator.equals(uuid, mbThread.getUuid()) ||
729 (groupId != mbThread.getGroupId())) {
730 result = null;
731 }
732 }
733
734 if (result == null) {
735 StringBundler query = new StringBundler(4);
736
737 query.append(_SQL_SELECT_MBTHREAD_WHERE);
738
739 boolean bindUuid = false;
740
741 if (uuid == null) {
742 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
743 }
744 else if (uuid.equals(StringPool.BLANK)) {
745 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
746 }
747 else {
748 bindUuid = true;
749
750 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
751 }
752
753 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
754
755 String sql = query.toString();
756
757 Session session = null;
758
759 try {
760 session = openSession();
761
762 Query q = session.createQuery(sql);
763
764 QueryPos qPos = QueryPos.getInstance(q);
765
766 if (bindUuid) {
767 qPos.add(uuid);
768 }
769
770 qPos.add(groupId);
771
772 List<MBThread> list = q.list();
773
774 if (list.isEmpty()) {
775 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
776 finderArgs, list);
777 }
778 else {
779 MBThread mbThread = list.get(0);
780
781 result = mbThread;
782
783 cacheResult(mbThread);
784
785 if ((mbThread.getUuid() == null) ||
786 !mbThread.getUuid().equals(uuid) ||
787 (mbThread.getGroupId() != groupId)) {
788 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
789 finderArgs, mbThread);
790 }
791 }
792 }
793 catch (Exception e) {
794 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
795
796 throw processException(e);
797 }
798 finally {
799 closeSession(session);
800 }
801 }
802
803 if (result instanceof List<?>) {
804 return null;
805 }
806 else {
807 return (MBThread)result;
808 }
809 }
810
811
818 @Override
819 public MBThread removeByUUID_G(String uuid, long groupId)
820 throws NoSuchThreadException {
821 MBThread mbThread = findByUUID_G(uuid, groupId);
822
823 return remove(mbThread);
824 }
825
826
833 @Override
834 public int countByUUID_G(String uuid, long groupId) {
835 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
836
837 Object[] finderArgs = new Object[] { uuid, groupId };
838
839 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
840
841 if (count == null) {
842 StringBundler query = new StringBundler(3);
843
844 query.append(_SQL_COUNT_MBTHREAD_WHERE);
845
846 boolean bindUuid = false;
847
848 if (uuid == null) {
849 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
850 }
851 else if (uuid.equals(StringPool.BLANK)) {
852 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
853 }
854 else {
855 bindUuid = true;
856
857 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
858 }
859
860 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
861
862 String sql = query.toString();
863
864 Session session = null;
865
866 try {
867 session = openSession();
868
869 Query q = session.createQuery(sql);
870
871 QueryPos qPos = QueryPos.getInstance(q);
872
873 if (bindUuid) {
874 qPos.add(uuid);
875 }
876
877 qPos.add(groupId);
878
879 count = (Long)q.uniqueResult();
880
881 finderCache.putResult(finderPath, finderArgs, count);
882 }
883 catch (Exception e) {
884 finderCache.removeResult(finderPath, finderArgs);
885
886 throw processException(e);
887 }
888 finally {
889 closeSession(session);
890 }
891 }
892
893 return count.intValue();
894 }
895
896 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbThread.uuid IS NULL AND ";
897 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbThread.uuid = ? AND ";
898 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbThread.uuid IS NULL OR mbThread.uuid = '') AND ";
899 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbThread.groupId = ?";
900 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
901 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
902 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
903 new String[] {
904 String.class.getName(), Long.class.getName(),
905
906 Integer.class.getName(), Integer.class.getName(),
907 OrderByComparator.class.getName()
908 });
909 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
910 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
911 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
912 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
913 new String[] { String.class.getName(), Long.class.getName() },
914 MBThreadModelImpl.UUID_COLUMN_BITMASK |
915 MBThreadModelImpl.COMPANYID_COLUMN_BITMASK |
916 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
917 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
918 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
919 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
920 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
921 new String[] { String.class.getName(), Long.class.getName() });
922
923
930 @Override
931 public List<MBThread> findByUuid_C(String uuid, long companyId) {
932 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
933 QueryUtil.ALL_POS, null);
934 }
935
936
949 @Override
950 public List<MBThread> findByUuid_C(String uuid, long companyId, int start,
951 int end) {
952 return findByUuid_C(uuid, companyId, start, end, null);
953 }
954
955
969 @Override
970 public List<MBThread> findByUuid_C(String uuid, long companyId, int start,
971 int end, OrderByComparator<MBThread> orderByComparator) {
972 return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
973 }
974
975
990 @Override
991 public List<MBThread> findByUuid_C(String uuid, long companyId, int start,
992 int end, OrderByComparator<MBThread> orderByComparator,
993 boolean retrieveFromCache) {
994 boolean pagination = true;
995 FinderPath finderPath = null;
996 Object[] finderArgs = null;
997
998 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
999 (orderByComparator == null)) {
1000 pagination = false;
1001 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1002 finderArgs = new Object[] { uuid, companyId };
1003 }
1004 else {
1005 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1006 finderArgs = new Object[] {
1007 uuid, companyId,
1008
1009 start, end, orderByComparator
1010 };
1011 }
1012
1013 List<MBThread> list = null;
1014
1015 if (retrieveFromCache) {
1016 list = (List<MBThread>)finderCache.getResult(finderPath,
1017 finderArgs, this);
1018
1019 if ((list != null) && !list.isEmpty()) {
1020 for (MBThread mbThread : list) {
1021 if (!Validator.equals(uuid, mbThread.getUuid()) ||
1022 (companyId != mbThread.getCompanyId())) {
1023 list = null;
1024
1025 break;
1026 }
1027 }
1028 }
1029 }
1030
1031 if (list == null) {
1032 StringBundler query = null;
1033
1034 if (orderByComparator != null) {
1035 query = new StringBundler(4 +
1036 (orderByComparator.getOrderByFields().length * 2));
1037 }
1038 else {
1039 query = new StringBundler(4);
1040 }
1041
1042 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1043
1044 boolean bindUuid = false;
1045
1046 if (uuid == null) {
1047 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1048 }
1049 else if (uuid.equals(StringPool.BLANK)) {
1050 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1051 }
1052 else {
1053 bindUuid = true;
1054
1055 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1056 }
1057
1058 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1059
1060 if (orderByComparator != null) {
1061 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1062 orderByComparator);
1063 }
1064 else
1065 if (pagination) {
1066 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1067 }
1068
1069 String sql = query.toString();
1070
1071 Session session = null;
1072
1073 try {
1074 session = openSession();
1075
1076 Query q = session.createQuery(sql);
1077
1078 QueryPos qPos = QueryPos.getInstance(q);
1079
1080 if (bindUuid) {
1081 qPos.add(uuid);
1082 }
1083
1084 qPos.add(companyId);
1085
1086 if (!pagination) {
1087 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
1088 start, end, false);
1089
1090 Collections.sort(list);
1091
1092 list = Collections.unmodifiableList(list);
1093 }
1094 else {
1095 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
1096 start, end);
1097 }
1098
1099 cacheResult(list);
1100
1101 finderCache.putResult(finderPath, finderArgs, list);
1102 }
1103 catch (Exception e) {
1104 finderCache.removeResult(finderPath, finderArgs);
1105
1106 throw processException(e);
1107 }
1108 finally {
1109 closeSession(session);
1110 }
1111 }
1112
1113 return list;
1114 }
1115
1116
1125 @Override
1126 public MBThread findByUuid_C_First(String uuid, long companyId,
1127 OrderByComparator<MBThread> orderByComparator)
1128 throws NoSuchThreadException {
1129 MBThread mbThread = fetchByUuid_C_First(uuid, companyId,
1130 orderByComparator);
1131
1132 if (mbThread != null) {
1133 return mbThread;
1134 }
1135
1136 StringBundler msg = new StringBundler(6);
1137
1138 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1139
1140 msg.append("uuid=");
1141 msg.append(uuid);
1142
1143 msg.append(", companyId=");
1144 msg.append(companyId);
1145
1146 msg.append(StringPool.CLOSE_CURLY_BRACE);
1147
1148 throw new NoSuchThreadException(msg.toString());
1149 }
1150
1151
1159 @Override
1160 public MBThread fetchByUuid_C_First(String uuid, long companyId,
1161 OrderByComparator<MBThread> orderByComparator) {
1162 List<MBThread> list = findByUuid_C(uuid, companyId, 0, 1,
1163 orderByComparator);
1164
1165 if (!list.isEmpty()) {
1166 return list.get(0);
1167 }
1168
1169 return null;
1170 }
1171
1172
1181 @Override
1182 public MBThread findByUuid_C_Last(String uuid, long companyId,
1183 OrderByComparator<MBThread> orderByComparator)
1184 throws NoSuchThreadException {
1185 MBThread mbThread = fetchByUuid_C_Last(uuid, companyId,
1186 orderByComparator);
1187
1188 if (mbThread != null) {
1189 return mbThread;
1190 }
1191
1192 StringBundler msg = new StringBundler(6);
1193
1194 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1195
1196 msg.append("uuid=");
1197 msg.append(uuid);
1198
1199 msg.append(", companyId=");
1200 msg.append(companyId);
1201
1202 msg.append(StringPool.CLOSE_CURLY_BRACE);
1203
1204 throw new NoSuchThreadException(msg.toString());
1205 }
1206
1207
1215 @Override
1216 public MBThread fetchByUuid_C_Last(String uuid, long companyId,
1217 OrderByComparator<MBThread> orderByComparator) {
1218 int count = countByUuid_C(uuid, companyId);
1219
1220 if (count == 0) {
1221 return null;
1222 }
1223
1224 List<MBThread> list = findByUuid_C(uuid, companyId, count - 1, count,
1225 orderByComparator);
1226
1227 if (!list.isEmpty()) {
1228 return list.get(0);
1229 }
1230
1231 return null;
1232 }
1233
1234
1244 @Override
1245 public MBThread[] findByUuid_C_PrevAndNext(long threadId, String uuid,
1246 long companyId, OrderByComparator<MBThread> orderByComparator)
1247 throws NoSuchThreadException {
1248 MBThread mbThread = findByPrimaryKey(threadId);
1249
1250 Session session = null;
1251
1252 try {
1253 session = openSession();
1254
1255 MBThread[] array = new MBThreadImpl[3];
1256
1257 array[0] = getByUuid_C_PrevAndNext(session, mbThread, uuid,
1258 companyId, orderByComparator, true);
1259
1260 array[1] = mbThread;
1261
1262 array[2] = getByUuid_C_PrevAndNext(session, mbThread, uuid,
1263 companyId, orderByComparator, false);
1264
1265 return array;
1266 }
1267 catch (Exception e) {
1268 throw processException(e);
1269 }
1270 finally {
1271 closeSession(session);
1272 }
1273 }
1274
1275 protected MBThread getByUuid_C_PrevAndNext(Session session,
1276 MBThread mbThread, String uuid, long companyId,
1277 OrderByComparator<MBThread> orderByComparator, boolean previous) {
1278 StringBundler query = null;
1279
1280 if (orderByComparator != null) {
1281 query = new StringBundler(5 +
1282 (orderByComparator.getOrderByConditionFields().length * 3) +
1283 (orderByComparator.getOrderByFields().length * 3));
1284 }
1285 else {
1286 query = new StringBundler(4);
1287 }
1288
1289 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1290
1291 boolean bindUuid = false;
1292
1293 if (uuid == null) {
1294 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1295 }
1296 else if (uuid.equals(StringPool.BLANK)) {
1297 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1298 }
1299 else {
1300 bindUuid = true;
1301
1302 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1303 }
1304
1305 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1306
1307 if (orderByComparator != null) {
1308 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1309
1310 if (orderByConditionFields.length > 0) {
1311 query.append(WHERE_AND);
1312 }
1313
1314 for (int i = 0; i < orderByConditionFields.length; i++) {
1315 query.append(_ORDER_BY_ENTITY_ALIAS);
1316 query.append(orderByConditionFields[i]);
1317
1318 if ((i + 1) < orderByConditionFields.length) {
1319 if (orderByComparator.isAscending() ^ previous) {
1320 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1321 }
1322 else {
1323 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1324 }
1325 }
1326 else {
1327 if (orderByComparator.isAscending() ^ previous) {
1328 query.append(WHERE_GREATER_THAN);
1329 }
1330 else {
1331 query.append(WHERE_LESSER_THAN);
1332 }
1333 }
1334 }
1335
1336 query.append(ORDER_BY_CLAUSE);
1337
1338 String[] orderByFields = orderByComparator.getOrderByFields();
1339
1340 for (int i = 0; i < orderByFields.length; i++) {
1341 query.append(_ORDER_BY_ENTITY_ALIAS);
1342 query.append(orderByFields[i]);
1343
1344 if ((i + 1) < orderByFields.length) {
1345 if (orderByComparator.isAscending() ^ previous) {
1346 query.append(ORDER_BY_ASC_HAS_NEXT);
1347 }
1348 else {
1349 query.append(ORDER_BY_DESC_HAS_NEXT);
1350 }
1351 }
1352 else {
1353 if (orderByComparator.isAscending() ^ previous) {
1354 query.append(ORDER_BY_ASC);
1355 }
1356 else {
1357 query.append(ORDER_BY_DESC);
1358 }
1359 }
1360 }
1361 }
1362 else {
1363 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1364 }
1365
1366 String sql = query.toString();
1367
1368 Query q = session.createQuery(sql);
1369
1370 q.setFirstResult(0);
1371 q.setMaxResults(2);
1372
1373 QueryPos qPos = QueryPos.getInstance(q);
1374
1375 if (bindUuid) {
1376 qPos.add(uuid);
1377 }
1378
1379 qPos.add(companyId);
1380
1381 if (orderByComparator != null) {
1382 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
1383
1384 for (Object value : values) {
1385 qPos.add(value);
1386 }
1387 }
1388
1389 List<MBThread> list = q.list();
1390
1391 if (list.size() == 2) {
1392 return list.get(1);
1393 }
1394 else {
1395 return null;
1396 }
1397 }
1398
1399
1405 @Override
1406 public void removeByUuid_C(String uuid, long companyId) {
1407 for (MBThread mbThread : findByUuid_C(uuid, companyId,
1408 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1409 remove(mbThread);
1410 }
1411 }
1412
1413
1420 @Override
1421 public int countByUuid_C(String uuid, long companyId) {
1422 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1423
1424 Object[] finderArgs = new Object[] { uuid, companyId };
1425
1426 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1427
1428 if (count == null) {
1429 StringBundler query = new StringBundler(3);
1430
1431 query.append(_SQL_COUNT_MBTHREAD_WHERE);
1432
1433 boolean bindUuid = false;
1434
1435 if (uuid == null) {
1436 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1437 }
1438 else if (uuid.equals(StringPool.BLANK)) {
1439 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1440 }
1441 else {
1442 bindUuid = true;
1443
1444 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1445 }
1446
1447 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1448
1449 String sql = query.toString();
1450
1451 Session session = null;
1452
1453 try {
1454 session = openSession();
1455
1456 Query q = session.createQuery(sql);
1457
1458 QueryPos qPos = QueryPos.getInstance(q);
1459
1460 if (bindUuid) {
1461 qPos.add(uuid);
1462 }
1463
1464 qPos.add(companyId);
1465
1466 count = (Long)q.uniqueResult();
1467
1468 finderCache.putResult(finderPath, finderArgs, count);
1469 }
1470 catch (Exception e) {
1471 finderCache.removeResult(finderPath, finderArgs);
1472
1473 throw processException(e);
1474 }
1475 finally {
1476 closeSession(session);
1477 }
1478 }
1479
1480 return count.intValue();
1481 }
1482
1483 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mbThread.uuid IS NULL AND ";
1484 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mbThread.uuid = ? AND ";
1485 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mbThread.uuid IS NULL OR mbThread.uuid = '') AND ";
1486 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mbThread.companyId = ?";
1487 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
1488 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
1489 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1490 new String[] {
1491 Long.class.getName(),
1492
1493 Integer.class.getName(), Integer.class.getName(),
1494 OrderByComparator.class.getName()
1495 });
1496 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1497 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
1498 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
1499 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1500 new String[] { Long.class.getName() },
1501 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
1502 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
1503 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
1504 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
1505 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
1506 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1507 new String[] { Long.class.getName() });
1508
1509
1515 @Override
1516 public List<MBThread> findByGroupId(long groupId) {
1517 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1518 }
1519
1520
1532 @Override
1533 public List<MBThread> findByGroupId(long groupId, int start, int end) {
1534 return findByGroupId(groupId, start, end, null);
1535 }
1536
1537
1550 @Override
1551 public List<MBThread> findByGroupId(long groupId, int start, int end,
1552 OrderByComparator<MBThread> orderByComparator) {
1553 return findByGroupId(groupId, start, end, orderByComparator, true);
1554 }
1555
1556
1570 @Override
1571 public List<MBThread> findByGroupId(long groupId, int start, int end,
1572 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
1573 boolean pagination = true;
1574 FinderPath finderPath = null;
1575 Object[] finderArgs = null;
1576
1577 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1578 (orderByComparator == null)) {
1579 pagination = false;
1580 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1581 finderArgs = new Object[] { groupId };
1582 }
1583 else {
1584 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1585 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1586 }
1587
1588 List<MBThread> list = null;
1589
1590 if (retrieveFromCache) {
1591 list = (List<MBThread>)finderCache.getResult(finderPath,
1592 finderArgs, this);
1593
1594 if ((list != null) && !list.isEmpty()) {
1595 for (MBThread mbThread : list) {
1596 if ((groupId != mbThread.getGroupId())) {
1597 list = null;
1598
1599 break;
1600 }
1601 }
1602 }
1603 }
1604
1605 if (list == null) {
1606 StringBundler query = null;
1607
1608 if (orderByComparator != null) {
1609 query = new StringBundler(3 +
1610 (orderByComparator.getOrderByFields().length * 2));
1611 }
1612 else {
1613 query = new StringBundler(3);
1614 }
1615
1616 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1617
1618 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1619
1620 if (orderByComparator != null) {
1621 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1622 orderByComparator);
1623 }
1624 else
1625 if (pagination) {
1626 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1627 }
1628
1629 String sql = query.toString();
1630
1631 Session session = null;
1632
1633 try {
1634 session = openSession();
1635
1636 Query q = session.createQuery(sql);
1637
1638 QueryPos qPos = QueryPos.getInstance(q);
1639
1640 qPos.add(groupId);
1641
1642 if (!pagination) {
1643 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
1644 start, end, false);
1645
1646 Collections.sort(list);
1647
1648 list = Collections.unmodifiableList(list);
1649 }
1650 else {
1651 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
1652 start, end);
1653 }
1654
1655 cacheResult(list);
1656
1657 finderCache.putResult(finderPath, finderArgs, list);
1658 }
1659 catch (Exception e) {
1660 finderCache.removeResult(finderPath, finderArgs);
1661
1662 throw processException(e);
1663 }
1664 finally {
1665 closeSession(session);
1666 }
1667 }
1668
1669 return list;
1670 }
1671
1672
1680 @Override
1681 public MBThread findByGroupId_First(long groupId,
1682 OrderByComparator<MBThread> orderByComparator)
1683 throws NoSuchThreadException {
1684 MBThread mbThread = fetchByGroupId_First(groupId, orderByComparator);
1685
1686 if (mbThread != null) {
1687 return mbThread;
1688 }
1689
1690 StringBundler msg = new StringBundler(4);
1691
1692 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1693
1694 msg.append("groupId=");
1695 msg.append(groupId);
1696
1697 msg.append(StringPool.CLOSE_CURLY_BRACE);
1698
1699 throw new NoSuchThreadException(msg.toString());
1700 }
1701
1702
1709 @Override
1710 public MBThread fetchByGroupId_First(long groupId,
1711 OrderByComparator<MBThread> orderByComparator) {
1712 List<MBThread> list = findByGroupId(groupId, 0, 1, orderByComparator);
1713
1714 if (!list.isEmpty()) {
1715 return list.get(0);
1716 }
1717
1718 return null;
1719 }
1720
1721
1729 @Override
1730 public MBThread findByGroupId_Last(long groupId,
1731 OrderByComparator<MBThread> orderByComparator)
1732 throws NoSuchThreadException {
1733 MBThread mbThread = fetchByGroupId_Last(groupId, orderByComparator);
1734
1735 if (mbThread != null) {
1736 return mbThread;
1737 }
1738
1739 StringBundler msg = new StringBundler(4);
1740
1741 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1742
1743 msg.append("groupId=");
1744 msg.append(groupId);
1745
1746 msg.append(StringPool.CLOSE_CURLY_BRACE);
1747
1748 throw new NoSuchThreadException(msg.toString());
1749 }
1750
1751
1758 @Override
1759 public MBThread fetchByGroupId_Last(long groupId,
1760 OrderByComparator<MBThread> orderByComparator) {
1761 int count = countByGroupId(groupId);
1762
1763 if (count == 0) {
1764 return null;
1765 }
1766
1767 List<MBThread> list = findByGroupId(groupId, count - 1, count,
1768 orderByComparator);
1769
1770 if (!list.isEmpty()) {
1771 return list.get(0);
1772 }
1773
1774 return null;
1775 }
1776
1777
1786 @Override
1787 public MBThread[] findByGroupId_PrevAndNext(long threadId, long groupId,
1788 OrderByComparator<MBThread> orderByComparator)
1789 throws NoSuchThreadException {
1790 MBThread mbThread = findByPrimaryKey(threadId);
1791
1792 Session session = null;
1793
1794 try {
1795 session = openSession();
1796
1797 MBThread[] array = new MBThreadImpl[3];
1798
1799 array[0] = getByGroupId_PrevAndNext(session, mbThread, groupId,
1800 orderByComparator, true);
1801
1802 array[1] = mbThread;
1803
1804 array[2] = getByGroupId_PrevAndNext(session, mbThread, groupId,
1805 orderByComparator, false);
1806
1807 return array;
1808 }
1809 catch (Exception e) {
1810 throw processException(e);
1811 }
1812 finally {
1813 closeSession(session);
1814 }
1815 }
1816
1817 protected MBThread getByGroupId_PrevAndNext(Session session,
1818 MBThread mbThread, long groupId,
1819 OrderByComparator<MBThread> orderByComparator, boolean previous) {
1820 StringBundler query = null;
1821
1822 if (orderByComparator != null) {
1823 query = new StringBundler(4 +
1824 (orderByComparator.getOrderByConditionFields().length * 3) +
1825 (orderByComparator.getOrderByFields().length * 3));
1826 }
1827 else {
1828 query = new StringBundler(3);
1829 }
1830
1831 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1832
1833 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1834
1835 if (orderByComparator != null) {
1836 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1837
1838 if (orderByConditionFields.length > 0) {
1839 query.append(WHERE_AND);
1840 }
1841
1842 for (int i = 0; i < orderByConditionFields.length; i++) {
1843 query.append(_ORDER_BY_ENTITY_ALIAS);
1844 query.append(orderByConditionFields[i]);
1845
1846 if ((i + 1) < orderByConditionFields.length) {
1847 if (orderByComparator.isAscending() ^ previous) {
1848 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1849 }
1850 else {
1851 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1852 }
1853 }
1854 else {
1855 if (orderByComparator.isAscending() ^ previous) {
1856 query.append(WHERE_GREATER_THAN);
1857 }
1858 else {
1859 query.append(WHERE_LESSER_THAN);
1860 }
1861 }
1862 }
1863
1864 query.append(ORDER_BY_CLAUSE);
1865
1866 String[] orderByFields = orderByComparator.getOrderByFields();
1867
1868 for (int i = 0; i < orderByFields.length; i++) {
1869 query.append(_ORDER_BY_ENTITY_ALIAS);
1870 query.append(orderByFields[i]);
1871
1872 if ((i + 1) < orderByFields.length) {
1873 if (orderByComparator.isAscending() ^ previous) {
1874 query.append(ORDER_BY_ASC_HAS_NEXT);
1875 }
1876 else {
1877 query.append(ORDER_BY_DESC_HAS_NEXT);
1878 }
1879 }
1880 else {
1881 if (orderByComparator.isAscending() ^ previous) {
1882 query.append(ORDER_BY_ASC);
1883 }
1884 else {
1885 query.append(ORDER_BY_DESC);
1886 }
1887 }
1888 }
1889 }
1890 else {
1891 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1892 }
1893
1894 String sql = query.toString();
1895
1896 Query q = session.createQuery(sql);
1897
1898 q.setFirstResult(0);
1899 q.setMaxResults(2);
1900
1901 QueryPos qPos = QueryPos.getInstance(q);
1902
1903 qPos.add(groupId);
1904
1905 if (orderByComparator != null) {
1906 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
1907
1908 for (Object value : values) {
1909 qPos.add(value);
1910 }
1911 }
1912
1913 List<MBThread> list = q.list();
1914
1915 if (list.size() == 2) {
1916 return list.get(1);
1917 }
1918 else {
1919 return null;
1920 }
1921 }
1922
1923
1929 @Override
1930 public List<MBThread> filterFindByGroupId(long groupId) {
1931 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1932 QueryUtil.ALL_POS, null);
1933 }
1934
1935
1947 @Override
1948 public List<MBThread> filterFindByGroupId(long groupId, int start, int end) {
1949 return filterFindByGroupId(groupId, start, end, null);
1950 }
1951
1952
1965 @Override
1966 public List<MBThread> filterFindByGroupId(long groupId, int start, int end,
1967 OrderByComparator<MBThread> orderByComparator) {
1968 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1969 return findByGroupId(groupId, start, end, orderByComparator);
1970 }
1971
1972 StringBundler query = null;
1973
1974 if (orderByComparator != null) {
1975 query = new StringBundler(3 +
1976 (orderByComparator.getOrderByFields().length * 2));
1977 }
1978 else {
1979 query = new StringBundler(4);
1980 }
1981
1982 if (getDB().isSupportsInlineDistinct()) {
1983 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
1984 }
1985 else {
1986 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
1987 }
1988
1989 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1990
1991 if (!getDB().isSupportsInlineDistinct()) {
1992 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
1993 }
1994
1995 if (orderByComparator != null) {
1996 if (getDB().isSupportsInlineDistinct()) {
1997 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1998 orderByComparator, true);
1999 }
2000 else {
2001 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2002 orderByComparator, true);
2003 }
2004 }
2005 else {
2006 if (getDB().isSupportsInlineDistinct()) {
2007 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2008 }
2009 else {
2010 query.append(MBThreadModelImpl.ORDER_BY_SQL);
2011 }
2012 }
2013
2014 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2015 MBThread.class.getName(),
2016 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2017
2018 Session session = null;
2019
2020 try {
2021 session = openSession();
2022
2023 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2024
2025 if (getDB().isSupportsInlineDistinct()) {
2026 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
2027 }
2028 else {
2029 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
2030 }
2031
2032 QueryPos qPos = QueryPos.getInstance(q);
2033
2034 qPos.add(groupId);
2035
2036 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
2037 }
2038 catch (Exception e) {
2039 throw processException(e);
2040 }
2041 finally {
2042 closeSession(session);
2043 }
2044 }
2045
2046
2055 @Override
2056 public MBThread[] filterFindByGroupId_PrevAndNext(long threadId,
2057 long groupId, OrderByComparator<MBThread> orderByComparator)
2058 throws NoSuchThreadException {
2059 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2060 return findByGroupId_PrevAndNext(threadId, groupId,
2061 orderByComparator);
2062 }
2063
2064 MBThread mbThread = findByPrimaryKey(threadId);
2065
2066 Session session = null;
2067
2068 try {
2069 session = openSession();
2070
2071 MBThread[] array = new MBThreadImpl[3];
2072
2073 array[0] = filterGetByGroupId_PrevAndNext(session, mbThread,
2074 groupId, orderByComparator, true);
2075
2076 array[1] = mbThread;
2077
2078 array[2] = filterGetByGroupId_PrevAndNext(session, mbThread,
2079 groupId, orderByComparator, false);
2080
2081 return array;
2082 }
2083 catch (Exception e) {
2084 throw processException(e);
2085 }
2086 finally {
2087 closeSession(session);
2088 }
2089 }
2090
2091 protected MBThread filterGetByGroupId_PrevAndNext(Session session,
2092 MBThread mbThread, long groupId,
2093 OrderByComparator<MBThread> orderByComparator, boolean previous) {
2094 StringBundler query = null;
2095
2096 if (orderByComparator != null) {
2097 query = new StringBundler(5 +
2098 (orderByComparator.getOrderByConditionFields().length * 3) +
2099 (orderByComparator.getOrderByFields().length * 3));
2100 }
2101 else {
2102 query = new StringBundler(4);
2103 }
2104
2105 if (getDB().isSupportsInlineDistinct()) {
2106 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
2107 }
2108 else {
2109 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
2110 }
2111
2112 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2113
2114 if (!getDB().isSupportsInlineDistinct()) {
2115 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
2116 }
2117
2118 if (orderByComparator != null) {
2119 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2120
2121 if (orderByConditionFields.length > 0) {
2122 query.append(WHERE_AND);
2123 }
2124
2125 for (int i = 0; i < orderByConditionFields.length; i++) {
2126 if (getDB().isSupportsInlineDistinct()) {
2127 query.append(_ORDER_BY_ENTITY_ALIAS);
2128 }
2129 else {
2130 query.append(_ORDER_BY_ENTITY_TABLE);
2131 }
2132
2133 query.append(orderByConditionFields[i]);
2134
2135 if ((i + 1) < orderByConditionFields.length) {
2136 if (orderByComparator.isAscending() ^ previous) {
2137 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2138 }
2139 else {
2140 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2141 }
2142 }
2143 else {
2144 if (orderByComparator.isAscending() ^ previous) {
2145 query.append(WHERE_GREATER_THAN);
2146 }
2147 else {
2148 query.append(WHERE_LESSER_THAN);
2149 }
2150 }
2151 }
2152
2153 query.append(ORDER_BY_CLAUSE);
2154
2155 String[] orderByFields = orderByComparator.getOrderByFields();
2156
2157 for (int i = 0; i < orderByFields.length; i++) {
2158 if (getDB().isSupportsInlineDistinct()) {
2159 query.append(_ORDER_BY_ENTITY_ALIAS);
2160 }
2161 else {
2162 query.append(_ORDER_BY_ENTITY_TABLE);
2163 }
2164
2165 query.append(orderByFields[i]);
2166
2167 if ((i + 1) < orderByFields.length) {
2168 if (orderByComparator.isAscending() ^ previous) {
2169 query.append(ORDER_BY_ASC_HAS_NEXT);
2170 }
2171 else {
2172 query.append(ORDER_BY_DESC_HAS_NEXT);
2173 }
2174 }
2175 else {
2176 if (orderByComparator.isAscending() ^ previous) {
2177 query.append(ORDER_BY_ASC);
2178 }
2179 else {
2180 query.append(ORDER_BY_DESC);
2181 }
2182 }
2183 }
2184 }
2185 else {
2186 if (getDB().isSupportsInlineDistinct()) {
2187 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2188 }
2189 else {
2190 query.append(MBThreadModelImpl.ORDER_BY_SQL);
2191 }
2192 }
2193
2194 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2195 MBThread.class.getName(),
2196 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2197
2198 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2199
2200 q.setFirstResult(0);
2201 q.setMaxResults(2);
2202
2203 if (getDB().isSupportsInlineDistinct()) {
2204 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
2205 }
2206 else {
2207 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
2208 }
2209
2210 QueryPos qPos = QueryPos.getInstance(q);
2211
2212 qPos.add(groupId);
2213
2214 if (orderByComparator != null) {
2215 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
2216
2217 for (Object value : values) {
2218 qPos.add(value);
2219 }
2220 }
2221
2222 List<MBThread> list = q.list();
2223
2224 if (list.size() == 2) {
2225 return list.get(1);
2226 }
2227 else {
2228 return null;
2229 }
2230 }
2231
2232
2237 @Override
2238 public void removeByGroupId(long groupId) {
2239 for (MBThread mbThread : findByGroupId(groupId, QueryUtil.ALL_POS,
2240 QueryUtil.ALL_POS, null)) {
2241 remove(mbThread);
2242 }
2243 }
2244
2245
2251 @Override
2252 public int countByGroupId(long groupId) {
2253 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2254
2255 Object[] finderArgs = new Object[] { groupId };
2256
2257 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2258
2259 if (count == null) {
2260 StringBundler query = new StringBundler(2);
2261
2262 query.append(_SQL_COUNT_MBTHREAD_WHERE);
2263
2264 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2265
2266 String sql = query.toString();
2267
2268 Session session = null;
2269
2270 try {
2271 session = openSession();
2272
2273 Query q = session.createQuery(sql);
2274
2275 QueryPos qPos = QueryPos.getInstance(q);
2276
2277 qPos.add(groupId);
2278
2279 count = (Long)q.uniqueResult();
2280
2281 finderCache.putResult(finderPath, finderArgs, count);
2282 }
2283 catch (Exception e) {
2284 finderCache.removeResult(finderPath, finderArgs);
2285
2286 throw processException(e);
2287 }
2288 finally {
2289 closeSession(session);
2290 }
2291 }
2292
2293 return count.intValue();
2294 }
2295
2296
2302 @Override
2303 public int filterCountByGroupId(long groupId) {
2304 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2305 return countByGroupId(groupId);
2306 }
2307
2308 StringBundler query = new StringBundler(2);
2309
2310 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
2311
2312 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2313
2314 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2315 MBThread.class.getName(),
2316 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2317
2318 Session session = null;
2319
2320 try {
2321 session = openSession();
2322
2323 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2324
2325 q.addScalar(COUNT_COLUMN_NAME,
2326 com.liferay.portal.kernel.dao.orm.Type.LONG);
2327
2328 QueryPos qPos = QueryPos.getInstance(q);
2329
2330 qPos.add(groupId);
2331
2332 Long count = (Long)q.uniqueResult();
2333
2334 return count.intValue();
2335 }
2336 catch (Exception e) {
2337 throw processException(e);
2338 }
2339 finally {
2340 closeSession(session);
2341 }
2342 }
2343
2344 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbThread.groupId = ? AND mbThread.categoryId != -1";
2345 public static final FinderPath FINDER_PATH_FETCH_BY_ROOTMESSAGEID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2346 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
2347 FINDER_CLASS_NAME_ENTITY, "fetchByRootMessageId",
2348 new String[] { Long.class.getName() },
2349 MBThreadModelImpl.ROOTMESSAGEID_COLUMN_BITMASK);
2350 public static final FinderPath FINDER_PATH_COUNT_BY_ROOTMESSAGEID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2351 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
2352 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRootMessageId",
2353 new String[] { Long.class.getName() });
2354
2355
2362 @Override
2363 public MBThread findByRootMessageId(long rootMessageId)
2364 throws NoSuchThreadException {
2365 MBThread mbThread = fetchByRootMessageId(rootMessageId);
2366
2367 if (mbThread == null) {
2368 StringBundler msg = new StringBundler(4);
2369
2370 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2371
2372 msg.append("rootMessageId=");
2373 msg.append(rootMessageId);
2374
2375 msg.append(StringPool.CLOSE_CURLY_BRACE);
2376
2377 if (_log.isWarnEnabled()) {
2378 _log.warn(msg.toString());
2379 }
2380
2381 throw new NoSuchThreadException(msg.toString());
2382 }
2383
2384 return mbThread;
2385 }
2386
2387
2393 @Override
2394 public MBThread fetchByRootMessageId(long rootMessageId) {
2395 return fetchByRootMessageId(rootMessageId, true);
2396 }
2397
2398
2405 @Override
2406 public MBThread fetchByRootMessageId(long rootMessageId,
2407 boolean retrieveFromCache) {
2408 Object[] finderArgs = new Object[] { rootMessageId };
2409
2410 Object result = null;
2411
2412 if (retrieveFromCache) {
2413 result = finderCache.getResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
2414 finderArgs, this);
2415 }
2416
2417 if (result instanceof MBThread) {
2418 MBThread mbThread = (MBThread)result;
2419
2420 if ((rootMessageId != mbThread.getRootMessageId())) {
2421 result = null;
2422 }
2423 }
2424
2425 if (result == null) {
2426 StringBundler query = new StringBundler(3);
2427
2428 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2429
2430 query.append(_FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2);
2431
2432 String sql = query.toString();
2433
2434 Session session = null;
2435
2436 try {
2437 session = openSession();
2438
2439 Query q = session.createQuery(sql);
2440
2441 QueryPos qPos = QueryPos.getInstance(q);
2442
2443 qPos.add(rootMessageId);
2444
2445 List<MBThread> list = q.list();
2446
2447 if (list.isEmpty()) {
2448 finderCache.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
2449 finderArgs, list);
2450 }
2451 else {
2452 if ((list.size() > 1) && _log.isWarnEnabled()) {
2453 _log.warn(
2454 "MBThreadPersistenceImpl.fetchByRootMessageId(long, boolean) with parameters (" +
2455 StringUtil.merge(finderArgs) +
2456 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
2457 }
2458
2459 MBThread mbThread = list.get(0);
2460
2461 result = mbThread;
2462
2463 cacheResult(mbThread);
2464
2465 if ((mbThread.getRootMessageId() != rootMessageId)) {
2466 finderCache.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
2467 finderArgs, mbThread);
2468 }
2469 }
2470 }
2471 catch (Exception e) {
2472 finderCache.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
2473 finderArgs);
2474
2475 throw processException(e);
2476 }
2477 finally {
2478 closeSession(session);
2479 }
2480 }
2481
2482 if (result instanceof List<?>) {
2483 return null;
2484 }
2485 else {
2486 return (MBThread)result;
2487 }
2488 }
2489
2490
2496 @Override
2497 public MBThread removeByRootMessageId(long rootMessageId)
2498 throws NoSuchThreadException {
2499 MBThread mbThread = findByRootMessageId(rootMessageId);
2500
2501 return remove(mbThread);
2502 }
2503
2504
2510 @Override
2511 public int countByRootMessageId(long rootMessageId) {
2512 FinderPath finderPath = FINDER_PATH_COUNT_BY_ROOTMESSAGEID;
2513
2514 Object[] finderArgs = new Object[] { rootMessageId };
2515
2516 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2517
2518 if (count == null) {
2519 StringBundler query = new StringBundler(2);
2520
2521 query.append(_SQL_COUNT_MBTHREAD_WHERE);
2522
2523 query.append(_FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2);
2524
2525 String sql = query.toString();
2526
2527 Session session = null;
2528
2529 try {
2530 session = openSession();
2531
2532 Query q = session.createQuery(sql);
2533
2534 QueryPos qPos = QueryPos.getInstance(q);
2535
2536 qPos.add(rootMessageId);
2537
2538 count = (Long)q.uniqueResult();
2539
2540 finderCache.putResult(finderPath, finderArgs, count);
2541 }
2542 catch (Exception e) {
2543 finderCache.removeResult(finderPath, finderArgs);
2544
2545 throw processException(e);
2546 }
2547 finally {
2548 closeSession(session);
2549 }
2550 }
2551
2552 return count.intValue();
2553 }
2554
2555 private static final String _FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2 = "mbThread.rootMessageId = ?";
2556 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2557 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
2558 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C",
2559 new String[] {
2560 Long.class.getName(), Long.class.getName(),
2561
2562 Integer.class.getName(), Integer.class.getName(),
2563 OrderByComparator.class.getName()
2564 });
2565 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2566 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
2567 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C",
2568 new String[] { Long.class.getName(), Long.class.getName() },
2569 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
2570 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
2571 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
2572 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
2573 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2574 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
2575 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
2576 new String[] { Long.class.getName(), Long.class.getName() });
2577 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2578 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
2579 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_C",
2580 new String[] { Long.class.getName(), Long.class.getName() });
2581
2582
2589 @Override
2590 public List<MBThread> findByG_C(long groupId, long categoryId) {
2591 return findByG_C(groupId, categoryId, QueryUtil.ALL_POS,
2592 QueryUtil.ALL_POS, null);
2593 }
2594
2595
2608 @Override
2609 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
2610 int end) {
2611 return findByG_C(groupId, categoryId, start, end, null);
2612 }
2613
2614
2628 @Override
2629 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
2630 int end, OrderByComparator<MBThread> orderByComparator) {
2631 return findByG_C(groupId, categoryId, start, end, orderByComparator,
2632 true);
2633 }
2634
2635
2650 @Override
2651 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
2652 int end, OrderByComparator<MBThread> orderByComparator,
2653 boolean retrieveFromCache) {
2654 boolean pagination = true;
2655 FinderPath finderPath = null;
2656 Object[] finderArgs = null;
2657
2658 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2659 (orderByComparator == null)) {
2660 pagination = false;
2661 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C;
2662 finderArgs = new Object[] { groupId, categoryId };
2663 }
2664 else {
2665 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C;
2666 finderArgs = new Object[] {
2667 groupId, categoryId,
2668
2669 start, end, orderByComparator
2670 };
2671 }
2672
2673 List<MBThread> list = null;
2674
2675 if (retrieveFromCache) {
2676 list = (List<MBThread>)finderCache.getResult(finderPath,
2677 finderArgs, this);
2678
2679 if ((list != null) && !list.isEmpty()) {
2680 for (MBThread mbThread : list) {
2681 if ((groupId != mbThread.getGroupId()) ||
2682 (categoryId != mbThread.getCategoryId())) {
2683 list = null;
2684
2685 break;
2686 }
2687 }
2688 }
2689 }
2690
2691 if (list == null) {
2692 StringBundler query = null;
2693
2694 if (orderByComparator != null) {
2695 query = new StringBundler(4 +
2696 (orderByComparator.getOrderByFields().length * 2));
2697 }
2698 else {
2699 query = new StringBundler(4);
2700 }
2701
2702 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2703
2704 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2705
2706 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2707
2708 if (orderByComparator != null) {
2709 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2710 orderByComparator);
2711 }
2712 else
2713 if (pagination) {
2714 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2715 }
2716
2717 String sql = query.toString();
2718
2719 Session session = null;
2720
2721 try {
2722 session = openSession();
2723
2724 Query q = session.createQuery(sql);
2725
2726 QueryPos qPos = QueryPos.getInstance(q);
2727
2728 qPos.add(groupId);
2729
2730 qPos.add(categoryId);
2731
2732 if (!pagination) {
2733 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
2734 start, end, false);
2735
2736 Collections.sort(list);
2737
2738 list = Collections.unmodifiableList(list);
2739 }
2740 else {
2741 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
2742 start, end);
2743 }
2744
2745 cacheResult(list);
2746
2747 finderCache.putResult(finderPath, finderArgs, list);
2748 }
2749 catch (Exception e) {
2750 finderCache.removeResult(finderPath, finderArgs);
2751
2752 throw processException(e);
2753 }
2754 finally {
2755 closeSession(session);
2756 }
2757 }
2758
2759 return list;
2760 }
2761
2762
2771 @Override
2772 public MBThread findByG_C_First(long groupId, long categoryId,
2773 OrderByComparator<MBThread> orderByComparator)
2774 throws NoSuchThreadException {
2775 MBThread mbThread = fetchByG_C_First(groupId, categoryId,
2776 orderByComparator);
2777
2778 if (mbThread != null) {
2779 return mbThread;
2780 }
2781
2782 StringBundler msg = new StringBundler(6);
2783
2784 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2785
2786 msg.append("groupId=");
2787 msg.append(groupId);
2788
2789 msg.append(", categoryId=");
2790 msg.append(categoryId);
2791
2792 msg.append(StringPool.CLOSE_CURLY_BRACE);
2793
2794 throw new NoSuchThreadException(msg.toString());
2795 }
2796
2797
2805 @Override
2806 public MBThread fetchByG_C_First(long groupId, long categoryId,
2807 OrderByComparator<MBThread> orderByComparator) {
2808 List<MBThread> list = findByG_C(groupId, categoryId, 0, 1,
2809 orderByComparator);
2810
2811 if (!list.isEmpty()) {
2812 return list.get(0);
2813 }
2814
2815 return null;
2816 }
2817
2818
2827 @Override
2828 public MBThread findByG_C_Last(long groupId, long categoryId,
2829 OrderByComparator<MBThread> orderByComparator)
2830 throws NoSuchThreadException {
2831 MBThread mbThread = fetchByG_C_Last(groupId, categoryId,
2832 orderByComparator);
2833
2834 if (mbThread != null) {
2835 return mbThread;
2836 }
2837
2838 StringBundler msg = new StringBundler(6);
2839
2840 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2841
2842 msg.append("groupId=");
2843 msg.append(groupId);
2844
2845 msg.append(", categoryId=");
2846 msg.append(categoryId);
2847
2848 msg.append(StringPool.CLOSE_CURLY_BRACE);
2849
2850 throw new NoSuchThreadException(msg.toString());
2851 }
2852
2853
2861 @Override
2862 public MBThread fetchByG_C_Last(long groupId, long categoryId,
2863 OrderByComparator<MBThread> orderByComparator) {
2864 int count = countByG_C(groupId, categoryId);
2865
2866 if (count == 0) {
2867 return null;
2868 }
2869
2870 List<MBThread> list = findByG_C(groupId, categoryId, count - 1, count,
2871 orderByComparator);
2872
2873 if (!list.isEmpty()) {
2874 return list.get(0);
2875 }
2876
2877 return null;
2878 }
2879
2880
2890 @Override
2891 public MBThread[] findByG_C_PrevAndNext(long threadId, long groupId,
2892 long categoryId, OrderByComparator<MBThread> orderByComparator)
2893 throws NoSuchThreadException {
2894 MBThread mbThread = findByPrimaryKey(threadId);
2895
2896 Session session = null;
2897
2898 try {
2899 session = openSession();
2900
2901 MBThread[] array = new MBThreadImpl[3];
2902
2903 array[0] = getByG_C_PrevAndNext(session, mbThread, groupId,
2904 categoryId, orderByComparator, true);
2905
2906 array[1] = mbThread;
2907
2908 array[2] = getByG_C_PrevAndNext(session, mbThread, groupId,
2909 categoryId, orderByComparator, false);
2910
2911 return array;
2912 }
2913 catch (Exception e) {
2914 throw processException(e);
2915 }
2916 finally {
2917 closeSession(session);
2918 }
2919 }
2920
2921 protected MBThread getByG_C_PrevAndNext(Session session, MBThread mbThread,
2922 long groupId, long categoryId,
2923 OrderByComparator<MBThread> orderByComparator, boolean previous) {
2924 StringBundler query = null;
2925
2926 if (orderByComparator != null) {
2927 query = new StringBundler(5 +
2928 (orderByComparator.getOrderByConditionFields().length * 3) +
2929 (orderByComparator.getOrderByFields().length * 3));
2930 }
2931 else {
2932 query = new StringBundler(4);
2933 }
2934
2935 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2936
2937 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2938
2939 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2940
2941 if (orderByComparator != null) {
2942 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2943
2944 if (orderByConditionFields.length > 0) {
2945 query.append(WHERE_AND);
2946 }
2947
2948 for (int i = 0; i < orderByConditionFields.length; i++) {
2949 query.append(_ORDER_BY_ENTITY_ALIAS);
2950 query.append(orderByConditionFields[i]);
2951
2952 if ((i + 1) < orderByConditionFields.length) {
2953 if (orderByComparator.isAscending() ^ previous) {
2954 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2955 }
2956 else {
2957 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2958 }
2959 }
2960 else {
2961 if (orderByComparator.isAscending() ^ previous) {
2962 query.append(WHERE_GREATER_THAN);
2963 }
2964 else {
2965 query.append(WHERE_LESSER_THAN);
2966 }
2967 }
2968 }
2969
2970 query.append(ORDER_BY_CLAUSE);
2971
2972 String[] orderByFields = orderByComparator.getOrderByFields();
2973
2974 for (int i = 0; i < orderByFields.length; i++) {
2975 query.append(_ORDER_BY_ENTITY_ALIAS);
2976 query.append(orderByFields[i]);
2977
2978 if ((i + 1) < orderByFields.length) {
2979 if (orderByComparator.isAscending() ^ previous) {
2980 query.append(ORDER_BY_ASC_HAS_NEXT);
2981 }
2982 else {
2983 query.append(ORDER_BY_DESC_HAS_NEXT);
2984 }
2985 }
2986 else {
2987 if (orderByComparator.isAscending() ^ previous) {
2988 query.append(ORDER_BY_ASC);
2989 }
2990 else {
2991 query.append(ORDER_BY_DESC);
2992 }
2993 }
2994 }
2995 }
2996 else {
2997 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2998 }
2999
3000 String sql = query.toString();
3001
3002 Query q = session.createQuery(sql);
3003
3004 q.setFirstResult(0);
3005 q.setMaxResults(2);
3006
3007 QueryPos qPos = QueryPos.getInstance(q);
3008
3009 qPos.add(groupId);
3010
3011 qPos.add(categoryId);
3012
3013 if (orderByComparator != null) {
3014 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
3015
3016 for (Object value : values) {
3017 qPos.add(value);
3018 }
3019 }
3020
3021 List<MBThread> list = q.list();
3022
3023 if (list.size() == 2) {
3024 return list.get(1);
3025 }
3026 else {
3027 return null;
3028 }
3029 }
3030
3031
3038 @Override
3039 public List<MBThread> filterFindByG_C(long groupId, long categoryId) {
3040 return filterFindByG_C(groupId, categoryId, QueryUtil.ALL_POS,
3041 QueryUtil.ALL_POS, null);
3042 }
3043
3044
3057 @Override
3058 public List<MBThread> filterFindByG_C(long groupId, long categoryId,
3059 int start, int end) {
3060 return filterFindByG_C(groupId, categoryId, start, end, null);
3061 }
3062
3063
3077 @Override
3078 public List<MBThread> filterFindByG_C(long groupId, long categoryId,
3079 int start, int end, OrderByComparator<MBThread> orderByComparator) {
3080 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3081 return findByG_C(groupId, categoryId, start, end, orderByComparator);
3082 }
3083
3084 StringBundler query = null;
3085
3086 if (orderByComparator != null) {
3087 query = new StringBundler(4 +
3088 (orderByComparator.getOrderByFields().length * 2));
3089 }
3090 else {
3091 query = new StringBundler(5);
3092 }
3093
3094 if (getDB().isSupportsInlineDistinct()) {
3095 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3096 }
3097 else {
3098 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3099 }
3100
3101 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3102
3103 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
3104
3105 if (!getDB().isSupportsInlineDistinct()) {
3106 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3107 }
3108
3109 if (orderByComparator != null) {
3110 if (getDB().isSupportsInlineDistinct()) {
3111 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3112 orderByComparator, true);
3113 }
3114 else {
3115 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3116 orderByComparator, true);
3117 }
3118 }
3119 else {
3120 if (getDB().isSupportsInlineDistinct()) {
3121 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3122 }
3123 else {
3124 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3125 }
3126 }
3127
3128 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3129 MBThread.class.getName(),
3130 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3131
3132 Session session = null;
3133
3134 try {
3135 session = openSession();
3136
3137 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3138
3139 if (getDB().isSupportsInlineDistinct()) {
3140 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3141 }
3142 else {
3143 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3144 }
3145
3146 QueryPos qPos = QueryPos.getInstance(q);
3147
3148 qPos.add(groupId);
3149
3150 qPos.add(categoryId);
3151
3152 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
3153 }
3154 catch (Exception e) {
3155 throw processException(e);
3156 }
3157 finally {
3158 closeSession(session);
3159 }
3160 }
3161
3162
3172 @Override
3173 public MBThread[] filterFindByG_C_PrevAndNext(long threadId, long groupId,
3174 long categoryId, OrderByComparator<MBThread> orderByComparator)
3175 throws NoSuchThreadException {
3176 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3177 return findByG_C_PrevAndNext(threadId, groupId, categoryId,
3178 orderByComparator);
3179 }
3180
3181 MBThread mbThread = findByPrimaryKey(threadId);
3182
3183 Session session = null;
3184
3185 try {
3186 session = openSession();
3187
3188 MBThread[] array = new MBThreadImpl[3];
3189
3190 array[0] = filterGetByG_C_PrevAndNext(session, mbThread, groupId,
3191 categoryId, orderByComparator, true);
3192
3193 array[1] = mbThread;
3194
3195 array[2] = filterGetByG_C_PrevAndNext(session, mbThread, groupId,
3196 categoryId, orderByComparator, false);
3197
3198 return array;
3199 }
3200 catch (Exception e) {
3201 throw processException(e);
3202 }
3203 finally {
3204 closeSession(session);
3205 }
3206 }
3207
3208 protected MBThread filterGetByG_C_PrevAndNext(Session session,
3209 MBThread mbThread, long groupId, long categoryId,
3210 OrderByComparator<MBThread> orderByComparator, boolean previous) {
3211 StringBundler query = null;
3212
3213 if (orderByComparator != null) {
3214 query = new StringBundler(6 +
3215 (orderByComparator.getOrderByConditionFields().length * 3) +
3216 (orderByComparator.getOrderByFields().length * 3));
3217 }
3218 else {
3219 query = new StringBundler(5);
3220 }
3221
3222 if (getDB().isSupportsInlineDistinct()) {
3223 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3224 }
3225 else {
3226 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3227 }
3228
3229 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3230
3231 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
3232
3233 if (!getDB().isSupportsInlineDistinct()) {
3234 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3235 }
3236
3237 if (orderByComparator != null) {
3238 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3239
3240 if (orderByConditionFields.length > 0) {
3241 query.append(WHERE_AND);
3242 }
3243
3244 for (int i = 0; i < orderByConditionFields.length; i++) {
3245 if (getDB().isSupportsInlineDistinct()) {
3246 query.append(_ORDER_BY_ENTITY_ALIAS);
3247 }
3248 else {
3249 query.append(_ORDER_BY_ENTITY_TABLE);
3250 }
3251
3252 query.append(orderByConditionFields[i]);
3253
3254 if ((i + 1) < orderByConditionFields.length) {
3255 if (orderByComparator.isAscending() ^ previous) {
3256 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3257 }
3258 else {
3259 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3260 }
3261 }
3262 else {
3263 if (orderByComparator.isAscending() ^ previous) {
3264 query.append(WHERE_GREATER_THAN);
3265 }
3266 else {
3267 query.append(WHERE_LESSER_THAN);
3268 }
3269 }
3270 }
3271
3272 query.append(ORDER_BY_CLAUSE);
3273
3274 String[] orderByFields = orderByComparator.getOrderByFields();
3275
3276 for (int i = 0; i < orderByFields.length; i++) {
3277 if (getDB().isSupportsInlineDistinct()) {
3278 query.append(_ORDER_BY_ENTITY_ALIAS);
3279 }
3280 else {
3281 query.append(_ORDER_BY_ENTITY_TABLE);
3282 }
3283
3284 query.append(orderByFields[i]);
3285
3286 if ((i + 1) < orderByFields.length) {
3287 if (orderByComparator.isAscending() ^ previous) {
3288 query.append(ORDER_BY_ASC_HAS_NEXT);
3289 }
3290 else {
3291 query.append(ORDER_BY_DESC_HAS_NEXT);
3292 }
3293 }
3294 else {
3295 if (orderByComparator.isAscending() ^ previous) {
3296 query.append(ORDER_BY_ASC);
3297 }
3298 else {
3299 query.append(ORDER_BY_DESC);
3300 }
3301 }
3302 }
3303 }
3304 else {
3305 if (getDB().isSupportsInlineDistinct()) {
3306 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3307 }
3308 else {
3309 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3310 }
3311 }
3312
3313 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3314 MBThread.class.getName(),
3315 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3316
3317 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3318
3319 q.setFirstResult(0);
3320 q.setMaxResults(2);
3321
3322 if (getDB().isSupportsInlineDistinct()) {
3323 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3324 }
3325 else {
3326 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3327 }
3328
3329 QueryPos qPos = QueryPos.getInstance(q);
3330
3331 qPos.add(groupId);
3332
3333 qPos.add(categoryId);
3334
3335 if (orderByComparator != null) {
3336 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
3337
3338 for (Object value : values) {
3339 qPos.add(value);
3340 }
3341 }
3342
3343 List<MBThread> list = q.list();
3344
3345 if (list.size() == 2) {
3346 return list.get(1);
3347 }
3348 else {
3349 return null;
3350 }
3351 }
3352
3353
3360 @Override
3361 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds) {
3362 return filterFindByG_C(groupId, categoryIds, QueryUtil.ALL_POS,
3363 QueryUtil.ALL_POS, null);
3364 }
3365
3366
3379 @Override
3380 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds,
3381 int start, int end) {
3382 return filterFindByG_C(groupId, categoryIds, start, end, null);
3383 }
3384
3385
3399 @Override
3400 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds,
3401 int start, int end, OrderByComparator<MBThread> orderByComparator) {
3402 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3403 return findByG_C(groupId, categoryIds, start, end, orderByComparator);
3404 }
3405
3406 if (categoryIds == null) {
3407 categoryIds = new long[0];
3408 }
3409 else if (categoryIds.length > 1) {
3410 categoryIds = ArrayUtil.unique(categoryIds);
3411
3412 Arrays.sort(categoryIds);
3413 }
3414
3415 StringBundler query = new StringBundler();
3416
3417 if (getDB().isSupportsInlineDistinct()) {
3418 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3419 }
3420 else {
3421 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3422 }
3423
3424 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3425
3426 if (categoryIds.length > 0) {
3427 query.append(StringPool.OPEN_PARENTHESIS);
3428
3429 query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
3430
3431 query.append(StringUtil.merge(categoryIds));
3432
3433 query.append(StringPool.CLOSE_PARENTHESIS);
3434
3435 query.append(StringPool.CLOSE_PARENTHESIS);
3436 }
3437
3438 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
3439 query.index() - 1);
3440
3441 if (!getDB().isSupportsInlineDistinct()) {
3442 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3443 }
3444
3445 if (orderByComparator != null) {
3446 if (getDB().isSupportsInlineDistinct()) {
3447 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3448 orderByComparator, true);
3449 }
3450 else {
3451 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3452 orderByComparator, true);
3453 }
3454 }
3455 else {
3456 if (getDB().isSupportsInlineDistinct()) {
3457 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3458 }
3459 else {
3460 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3461 }
3462 }
3463
3464 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3465 MBThread.class.getName(),
3466 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3467
3468 Session session = null;
3469
3470 try {
3471 session = openSession();
3472
3473 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3474
3475 if (getDB().isSupportsInlineDistinct()) {
3476 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3477 }
3478 else {
3479 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3480 }
3481
3482 QueryPos qPos = QueryPos.getInstance(q);
3483
3484 qPos.add(groupId);
3485
3486 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
3487 }
3488 catch (Exception e) {
3489 throw processException(e);
3490 }
3491 finally {
3492 closeSession(session);
3493 }
3494 }
3495
3496
3507 @Override
3508 public List<MBThread> findByG_C(long groupId, long[] categoryIds) {
3509 return findByG_C(groupId, categoryIds, QueryUtil.ALL_POS,
3510 QueryUtil.ALL_POS, null);
3511 }
3512
3513
3526 @Override
3527 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
3528 int start, int end) {
3529 return findByG_C(groupId, categoryIds, start, end, null);
3530 }
3531
3532
3546 @Override
3547 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
3548 int start, int end, OrderByComparator<MBThread> orderByComparator) {
3549 return findByG_C(groupId, categoryIds, start, end, orderByComparator,
3550 true);
3551 }
3552
3553
3568 @Override
3569 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
3570 int start, int end, OrderByComparator<MBThread> orderByComparator,
3571 boolean retrieveFromCache) {
3572 if (categoryIds == null) {
3573 categoryIds = new long[0];
3574 }
3575 else if (categoryIds.length > 1) {
3576 categoryIds = ArrayUtil.unique(categoryIds);
3577
3578 Arrays.sort(categoryIds);
3579 }
3580
3581 if (categoryIds.length == 1) {
3582 return findByG_C(groupId, categoryIds[0], start, end,
3583 orderByComparator);
3584 }
3585
3586 boolean pagination = true;
3587 Object[] finderArgs = null;
3588
3589 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3590 (orderByComparator == null)) {
3591 pagination = false;
3592 finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds) };
3593 }
3594 else {
3595 finderArgs = new Object[] {
3596 groupId, StringUtil.merge(categoryIds),
3597
3598 start, end, orderByComparator
3599 };
3600 }
3601
3602 List<MBThread> list = null;
3603
3604 if (retrieveFromCache) {
3605 list = (List<MBThread>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C,
3606 finderArgs, this);
3607
3608 if ((list != null) && !list.isEmpty()) {
3609 for (MBThread mbThread : list) {
3610 if ((groupId != mbThread.getGroupId()) ||
3611 !ArrayUtil.contains(categoryIds,
3612 mbThread.getCategoryId())) {
3613 list = null;
3614
3615 break;
3616 }
3617 }
3618 }
3619 }
3620
3621 if (list == null) {
3622 StringBundler query = new StringBundler();
3623
3624 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3625
3626 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3627
3628 if (categoryIds.length > 0) {
3629 query.append(StringPool.OPEN_PARENTHESIS);
3630
3631 query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
3632
3633 query.append(StringUtil.merge(categoryIds));
3634
3635 query.append(StringPool.CLOSE_PARENTHESIS);
3636
3637 query.append(StringPool.CLOSE_PARENTHESIS);
3638 }
3639
3640 query.setStringAt(removeConjunction(query.stringAt(query.index() -
3641 1)), query.index() - 1);
3642
3643 if (orderByComparator != null) {
3644 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3645 orderByComparator);
3646 }
3647 else
3648 if (pagination) {
3649 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3650 }
3651
3652 String sql = query.toString();
3653
3654 Session session = null;
3655
3656 try {
3657 session = openSession();
3658
3659 Query q = session.createQuery(sql);
3660
3661 QueryPos qPos = QueryPos.getInstance(q);
3662
3663 qPos.add(groupId);
3664
3665 if (!pagination) {
3666 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
3667 start, end, false);
3668
3669 Collections.sort(list);
3670
3671 list = Collections.unmodifiableList(list);
3672 }
3673 else {
3674 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
3675 start, end);
3676 }
3677
3678 cacheResult(list);
3679
3680 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C,
3681 finderArgs, list);
3682 }
3683 catch (Exception e) {
3684 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C,
3685 finderArgs);
3686
3687 throw processException(e);
3688 }
3689 finally {
3690 closeSession(session);
3691 }
3692 }
3693
3694 return list;
3695 }
3696
3697
3703 @Override
3704 public void removeByG_C(long groupId, long categoryId) {
3705 for (MBThread mbThread : findByG_C(groupId, categoryId,
3706 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3707 remove(mbThread);
3708 }
3709 }
3710
3711
3718 @Override
3719 public int countByG_C(long groupId, long categoryId) {
3720 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C;
3721
3722 Object[] finderArgs = new Object[] { groupId, categoryId };
3723
3724 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3725
3726 if (count == null) {
3727 StringBundler query = new StringBundler(3);
3728
3729 query.append(_SQL_COUNT_MBTHREAD_WHERE);
3730
3731 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3732
3733 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
3734
3735 String sql = query.toString();
3736
3737 Session session = null;
3738
3739 try {
3740 session = openSession();
3741
3742 Query q = session.createQuery(sql);
3743
3744 QueryPos qPos = QueryPos.getInstance(q);
3745
3746 qPos.add(groupId);
3747
3748 qPos.add(categoryId);
3749
3750 count = (Long)q.uniqueResult();
3751
3752 finderCache.putResult(finderPath, finderArgs, count);
3753 }
3754 catch (Exception e) {
3755 finderCache.removeResult(finderPath, finderArgs);
3756
3757 throw processException(e);
3758 }
3759 finally {
3760 closeSession(session);
3761 }
3762 }
3763
3764 return count.intValue();
3765 }
3766
3767
3774 @Override
3775 public int countByG_C(long groupId, long[] categoryIds) {
3776 if (categoryIds == null) {
3777 categoryIds = new long[0];
3778 }
3779 else if (categoryIds.length > 1) {
3780 categoryIds = ArrayUtil.unique(categoryIds);
3781
3782 Arrays.sort(categoryIds);
3783 }
3784
3785 Object[] finderArgs = new Object[] {
3786 groupId, StringUtil.merge(categoryIds)
3787 };
3788
3789 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
3790 finderArgs, this);
3791
3792 if (count == null) {
3793 StringBundler query = new StringBundler();
3794
3795 query.append(_SQL_COUNT_MBTHREAD_WHERE);
3796
3797 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3798
3799 if (categoryIds.length > 0) {
3800 query.append(StringPool.OPEN_PARENTHESIS);
3801
3802 query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
3803
3804 query.append(StringUtil.merge(categoryIds));
3805
3806 query.append(StringPool.CLOSE_PARENTHESIS);
3807
3808 query.append(StringPool.CLOSE_PARENTHESIS);
3809 }
3810
3811 query.setStringAt(removeConjunction(query.stringAt(query.index() -
3812 1)), query.index() - 1);
3813
3814 String sql = query.toString();
3815
3816 Session session = null;
3817
3818 try {
3819 session = openSession();
3820
3821 Query q = session.createQuery(sql);
3822
3823 QueryPos qPos = QueryPos.getInstance(q);
3824
3825 qPos.add(groupId);
3826
3827 count = (Long)q.uniqueResult();
3828
3829 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
3830 finderArgs, count);
3831 }
3832 catch (Exception e) {
3833 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
3834 finderArgs);
3835
3836 throw processException(e);
3837 }
3838 finally {
3839 closeSession(session);
3840 }
3841 }
3842
3843 return count.intValue();
3844 }
3845
3846
3853 @Override
3854 public int filterCountByG_C(long groupId, long categoryId) {
3855 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3856 return countByG_C(groupId, categoryId);
3857 }
3858
3859 StringBundler query = new StringBundler(3);
3860
3861 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
3862
3863 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3864
3865 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
3866
3867 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3868 MBThread.class.getName(),
3869 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3870
3871 Session session = null;
3872
3873 try {
3874 session = openSession();
3875
3876 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3877
3878 q.addScalar(COUNT_COLUMN_NAME,
3879 com.liferay.portal.kernel.dao.orm.Type.LONG);
3880
3881 QueryPos qPos = QueryPos.getInstance(q);
3882
3883 qPos.add(groupId);
3884
3885 qPos.add(categoryId);
3886
3887 Long count = (Long)q.uniqueResult();
3888
3889 return count.intValue();
3890 }
3891 catch (Exception e) {
3892 throw processException(e);
3893 }
3894 finally {
3895 closeSession(session);
3896 }
3897 }
3898
3899
3906 @Override
3907 public int filterCountByG_C(long groupId, long[] categoryIds) {
3908 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3909 return countByG_C(groupId, categoryIds);
3910 }
3911
3912 if (categoryIds == null) {
3913 categoryIds = new long[0];
3914 }
3915 else if (categoryIds.length > 1) {
3916 categoryIds = ArrayUtil.unique(categoryIds);
3917
3918 Arrays.sort(categoryIds);
3919 }
3920
3921 StringBundler query = new StringBundler();
3922
3923 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
3924
3925 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3926
3927 if (categoryIds.length > 0) {
3928 query.append(StringPool.OPEN_PARENTHESIS);
3929
3930 query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
3931
3932 query.append(StringUtil.merge(categoryIds));
3933
3934 query.append(StringPool.CLOSE_PARENTHESIS);
3935
3936 query.append(StringPool.CLOSE_PARENTHESIS);
3937 }
3938
3939 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
3940 query.index() - 1);
3941
3942 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3943 MBThread.class.getName(),
3944 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3945
3946 Session session = null;
3947
3948 try {
3949 session = openSession();
3950
3951 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3952
3953 q.addScalar(COUNT_COLUMN_NAME,
3954 com.liferay.portal.kernel.dao.orm.Type.LONG);
3955
3956 QueryPos qPos = QueryPos.getInstance(q);
3957
3958 qPos.add(groupId);
3959
3960 Long count = (Long)q.uniqueResult();
3961
3962 return count.intValue();
3963 }
3964 catch (Exception e) {
3965 throw processException(e);
3966 }
3967 finally {
3968 closeSession(session);
3969 }
3970 }
3971
3972 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbThread.groupId = ? AND ";
3973 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbThread.categoryId = ?";
3974 private static final String _FINDER_COLUMN_G_C_CATEGORYID_7 = "mbThread.categoryId IN (";
3975 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
3976 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
3977 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotC",
3978 new String[] {
3979 Long.class.getName(), Long.class.getName(),
3980
3981 Integer.class.getName(), Integer.class.getName(),
3982 OrderByComparator.class.getName()
3983 });
3984 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
3985 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
3986 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotC",
3987 new String[] { Long.class.getName(), Long.class.getName() });
3988
3989
3996 @Override
3997 public List<MBThread> findByG_NotC(long groupId, long categoryId) {
3998 return findByG_NotC(groupId, categoryId, QueryUtil.ALL_POS,
3999 QueryUtil.ALL_POS, null);
4000 }
4001
4002
4015 @Override
4016 public List<MBThread> findByG_NotC(long groupId, long categoryId,
4017 int start, int end) {
4018 return findByG_NotC(groupId, categoryId, start, end, null);
4019 }
4020
4021
4035 @Override
4036 public List<MBThread> findByG_NotC(long groupId, long categoryId,
4037 int start, int end, OrderByComparator<MBThread> orderByComparator) {
4038 return findByG_NotC(groupId, categoryId, start, end, orderByComparator,
4039 true);
4040 }
4041
4042
4057 @Override
4058 public List<MBThread> findByG_NotC(long groupId, long categoryId,
4059 int start, int end, OrderByComparator<MBThread> orderByComparator,
4060 boolean retrieveFromCache) {
4061 boolean pagination = true;
4062 FinderPath finderPath = null;
4063 Object[] finderArgs = null;
4064
4065 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC;
4066 finderArgs = new Object[] {
4067 groupId, categoryId,
4068
4069 start, end, orderByComparator
4070 };
4071
4072 List<MBThread> list = null;
4073
4074 if (retrieveFromCache) {
4075 list = (List<MBThread>)finderCache.getResult(finderPath,
4076 finderArgs, this);
4077
4078 if ((list != null) && !list.isEmpty()) {
4079 for (MBThread mbThread : list) {
4080 if ((groupId != mbThread.getGroupId()) ||
4081 (categoryId == mbThread.getCategoryId())) {
4082 list = null;
4083
4084 break;
4085 }
4086 }
4087 }
4088 }
4089
4090 if (list == null) {
4091 StringBundler query = null;
4092
4093 if (orderByComparator != null) {
4094 query = new StringBundler(4 +
4095 (orderByComparator.getOrderByFields().length * 2));
4096 }
4097 else {
4098 query = new StringBundler(4);
4099 }
4100
4101 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4102
4103 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4104
4105 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4106
4107 if (orderByComparator != null) {
4108 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4109 orderByComparator);
4110 }
4111 else
4112 if (pagination) {
4113 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4114 }
4115
4116 String sql = query.toString();
4117
4118 Session session = null;
4119
4120 try {
4121 session = openSession();
4122
4123 Query q = session.createQuery(sql);
4124
4125 QueryPos qPos = QueryPos.getInstance(q);
4126
4127 qPos.add(groupId);
4128
4129 qPos.add(categoryId);
4130
4131 if (!pagination) {
4132 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
4133 start, end, false);
4134
4135 Collections.sort(list);
4136
4137 list = Collections.unmodifiableList(list);
4138 }
4139 else {
4140 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
4141 start, end);
4142 }
4143
4144 cacheResult(list);
4145
4146 finderCache.putResult(finderPath, finderArgs, list);
4147 }
4148 catch (Exception e) {
4149 finderCache.removeResult(finderPath, finderArgs);
4150
4151 throw processException(e);
4152 }
4153 finally {
4154 closeSession(session);
4155 }
4156 }
4157
4158 return list;
4159 }
4160
4161
4170 @Override
4171 public MBThread findByG_NotC_First(long groupId, long categoryId,
4172 OrderByComparator<MBThread> orderByComparator)
4173 throws NoSuchThreadException {
4174 MBThread mbThread = fetchByG_NotC_First(groupId, categoryId,
4175 orderByComparator);
4176
4177 if (mbThread != null) {
4178 return mbThread;
4179 }
4180
4181 StringBundler msg = new StringBundler(6);
4182
4183 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4184
4185 msg.append("groupId=");
4186 msg.append(groupId);
4187
4188 msg.append(", categoryId=");
4189 msg.append(categoryId);
4190
4191 msg.append(StringPool.CLOSE_CURLY_BRACE);
4192
4193 throw new NoSuchThreadException(msg.toString());
4194 }
4195
4196
4204 @Override
4205 public MBThread fetchByG_NotC_First(long groupId, long categoryId,
4206 OrderByComparator<MBThread> orderByComparator) {
4207 List<MBThread> list = findByG_NotC(groupId, categoryId, 0, 1,
4208 orderByComparator);
4209
4210 if (!list.isEmpty()) {
4211 return list.get(0);
4212 }
4213
4214 return null;
4215 }
4216
4217
4226 @Override
4227 public MBThread findByG_NotC_Last(long groupId, long categoryId,
4228 OrderByComparator<MBThread> orderByComparator)
4229 throws NoSuchThreadException {
4230 MBThread mbThread = fetchByG_NotC_Last(groupId, categoryId,
4231 orderByComparator);
4232
4233 if (mbThread != null) {
4234 return mbThread;
4235 }
4236
4237 StringBundler msg = new StringBundler(6);
4238
4239 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4240
4241 msg.append("groupId=");
4242 msg.append(groupId);
4243
4244 msg.append(", categoryId=");
4245 msg.append(categoryId);
4246
4247 msg.append(StringPool.CLOSE_CURLY_BRACE);
4248
4249 throw new NoSuchThreadException(msg.toString());
4250 }
4251
4252
4260 @Override
4261 public MBThread fetchByG_NotC_Last(long groupId, long categoryId,
4262 OrderByComparator<MBThread> orderByComparator) {
4263 int count = countByG_NotC(groupId, categoryId);
4264
4265 if (count == 0) {
4266 return null;
4267 }
4268
4269 List<MBThread> list = findByG_NotC(groupId, categoryId, count - 1,
4270 count, orderByComparator);
4271
4272 if (!list.isEmpty()) {
4273 return list.get(0);
4274 }
4275
4276 return null;
4277 }
4278
4279
4289 @Override
4290 public MBThread[] findByG_NotC_PrevAndNext(long threadId, long groupId,
4291 long categoryId, OrderByComparator<MBThread> orderByComparator)
4292 throws NoSuchThreadException {
4293 MBThread mbThread = findByPrimaryKey(threadId);
4294
4295 Session session = null;
4296
4297 try {
4298 session = openSession();
4299
4300 MBThread[] array = new MBThreadImpl[3];
4301
4302 array[0] = getByG_NotC_PrevAndNext(session, mbThread, groupId,
4303 categoryId, orderByComparator, true);
4304
4305 array[1] = mbThread;
4306
4307 array[2] = getByG_NotC_PrevAndNext(session, mbThread, groupId,
4308 categoryId, orderByComparator, false);
4309
4310 return array;
4311 }
4312 catch (Exception e) {
4313 throw processException(e);
4314 }
4315 finally {
4316 closeSession(session);
4317 }
4318 }
4319
4320 protected MBThread getByG_NotC_PrevAndNext(Session session,
4321 MBThread mbThread, long groupId, long categoryId,
4322 OrderByComparator<MBThread> orderByComparator, boolean previous) {
4323 StringBundler query = null;
4324
4325 if (orderByComparator != null) {
4326 query = new StringBundler(5 +
4327 (orderByComparator.getOrderByConditionFields().length * 3) +
4328 (orderByComparator.getOrderByFields().length * 3));
4329 }
4330 else {
4331 query = new StringBundler(4);
4332 }
4333
4334 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4335
4336 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4337
4338 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4339
4340 if (orderByComparator != null) {
4341 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4342
4343 if (orderByConditionFields.length > 0) {
4344 query.append(WHERE_AND);
4345 }
4346
4347 for (int i = 0; i < orderByConditionFields.length; i++) {
4348 query.append(_ORDER_BY_ENTITY_ALIAS);
4349 query.append(orderByConditionFields[i]);
4350
4351 if ((i + 1) < orderByConditionFields.length) {
4352 if (orderByComparator.isAscending() ^ previous) {
4353 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4354 }
4355 else {
4356 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4357 }
4358 }
4359 else {
4360 if (orderByComparator.isAscending() ^ previous) {
4361 query.append(WHERE_GREATER_THAN);
4362 }
4363 else {
4364 query.append(WHERE_LESSER_THAN);
4365 }
4366 }
4367 }
4368
4369 query.append(ORDER_BY_CLAUSE);
4370
4371 String[] orderByFields = orderByComparator.getOrderByFields();
4372
4373 for (int i = 0; i < orderByFields.length; i++) {
4374 query.append(_ORDER_BY_ENTITY_ALIAS);
4375 query.append(orderByFields[i]);
4376
4377 if ((i + 1) < orderByFields.length) {
4378 if (orderByComparator.isAscending() ^ previous) {
4379 query.append(ORDER_BY_ASC_HAS_NEXT);
4380 }
4381 else {
4382 query.append(ORDER_BY_DESC_HAS_NEXT);
4383 }
4384 }
4385 else {
4386 if (orderByComparator.isAscending() ^ previous) {
4387 query.append(ORDER_BY_ASC);
4388 }
4389 else {
4390 query.append(ORDER_BY_DESC);
4391 }
4392 }
4393 }
4394 }
4395 else {
4396 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4397 }
4398
4399 String sql = query.toString();
4400
4401 Query q = session.createQuery(sql);
4402
4403 q.setFirstResult(0);
4404 q.setMaxResults(2);
4405
4406 QueryPos qPos = QueryPos.getInstance(q);
4407
4408 qPos.add(groupId);
4409
4410 qPos.add(categoryId);
4411
4412 if (orderByComparator != null) {
4413 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
4414
4415 for (Object value : values) {
4416 qPos.add(value);
4417 }
4418 }
4419
4420 List<MBThread> list = q.list();
4421
4422 if (list.size() == 2) {
4423 return list.get(1);
4424 }
4425 else {
4426 return null;
4427 }
4428 }
4429
4430
4437 @Override
4438 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId) {
4439 return filterFindByG_NotC(groupId, categoryId, QueryUtil.ALL_POS,
4440 QueryUtil.ALL_POS, null);
4441 }
4442
4443
4456 @Override
4457 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId,
4458 int start, int end) {
4459 return filterFindByG_NotC(groupId, categoryId, start, end, null);
4460 }
4461
4462
4476 @Override
4477 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId,
4478 int start, int end, OrderByComparator<MBThread> orderByComparator) {
4479 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4480 return findByG_NotC(groupId, categoryId, start, end,
4481 orderByComparator);
4482 }
4483
4484 StringBundler query = null;
4485
4486 if (orderByComparator != null) {
4487 query = new StringBundler(4 +
4488 (orderByComparator.getOrderByFields().length * 2));
4489 }
4490 else {
4491 query = new StringBundler(5);
4492 }
4493
4494 if (getDB().isSupportsInlineDistinct()) {
4495 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
4496 }
4497 else {
4498 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
4499 }
4500
4501 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4502
4503 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4504
4505 if (!getDB().isSupportsInlineDistinct()) {
4506 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
4507 }
4508
4509 if (orderByComparator != null) {
4510 if (getDB().isSupportsInlineDistinct()) {
4511 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4512 orderByComparator, true);
4513 }
4514 else {
4515 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4516 orderByComparator, true);
4517 }
4518 }
4519 else {
4520 if (getDB().isSupportsInlineDistinct()) {
4521 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4522 }
4523 else {
4524 query.append(MBThreadModelImpl.ORDER_BY_SQL);
4525 }
4526 }
4527
4528 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4529 MBThread.class.getName(),
4530 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4531
4532 Session session = null;
4533
4534 try {
4535 session = openSession();
4536
4537 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4538
4539 if (getDB().isSupportsInlineDistinct()) {
4540 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
4541 }
4542 else {
4543 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
4544 }
4545
4546 QueryPos qPos = QueryPos.getInstance(q);
4547
4548 qPos.add(groupId);
4549
4550 qPos.add(categoryId);
4551
4552 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
4553 }
4554 catch (Exception e) {
4555 throw processException(e);
4556 }
4557 finally {
4558 closeSession(session);
4559 }
4560 }
4561
4562
4572 @Override
4573 public MBThread[] filterFindByG_NotC_PrevAndNext(long threadId,
4574 long groupId, long categoryId,
4575 OrderByComparator<MBThread> orderByComparator)
4576 throws NoSuchThreadException {
4577 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4578 return findByG_NotC_PrevAndNext(threadId, groupId, categoryId,
4579 orderByComparator);
4580 }
4581
4582 MBThread mbThread = findByPrimaryKey(threadId);
4583
4584 Session session = null;
4585
4586 try {
4587 session = openSession();
4588
4589 MBThread[] array = new MBThreadImpl[3];
4590
4591 array[0] = filterGetByG_NotC_PrevAndNext(session, mbThread,
4592 groupId, categoryId, orderByComparator, true);
4593
4594 array[1] = mbThread;
4595
4596 array[2] = filterGetByG_NotC_PrevAndNext(session, mbThread,
4597 groupId, categoryId, orderByComparator, false);
4598
4599 return array;
4600 }
4601 catch (Exception e) {
4602 throw processException(e);
4603 }
4604 finally {
4605 closeSession(session);
4606 }
4607 }
4608
4609 protected MBThread filterGetByG_NotC_PrevAndNext(Session session,
4610 MBThread mbThread, long groupId, long categoryId,
4611 OrderByComparator<MBThread> orderByComparator, boolean previous) {
4612 StringBundler query = null;
4613
4614 if (orderByComparator != null) {
4615 query = new StringBundler(6 +
4616 (orderByComparator.getOrderByConditionFields().length * 3) +
4617 (orderByComparator.getOrderByFields().length * 3));
4618 }
4619 else {
4620 query = new StringBundler(5);
4621 }
4622
4623 if (getDB().isSupportsInlineDistinct()) {
4624 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
4625 }
4626 else {
4627 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
4628 }
4629
4630 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4631
4632 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4633
4634 if (!getDB().isSupportsInlineDistinct()) {
4635 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
4636 }
4637
4638 if (orderByComparator != null) {
4639 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4640
4641 if (orderByConditionFields.length > 0) {
4642 query.append(WHERE_AND);
4643 }
4644
4645 for (int i = 0; i < orderByConditionFields.length; i++) {
4646 if (getDB().isSupportsInlineDistinct()) {
4647 query.append(_ORDER_BY_ENTITY_ALIAS);
4648 }
4649 else {
4650 query.append(_ORDER_BY_ENTITY_TABLE);
4651 }
4652
4653 query.append(orderByConditionFields[i]);
4654
4655 if ((i + 1) < orderByConditionFields.length) {
4656 if (orderByComparator.isAscending() ^ previous) {
4657 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4658 }
4659 else {
4660 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4661 }
4662 }
4663 else {
4664 if (orderByComparator.isAscending() ^ previous) {
4665 query.append(WHERE_GREATER_THAN);
4666 }
4667 else {
4668 query.append(WHERE_LESSER_THAN);
4669 }
4670 }
4671 }
4672
4673 query.append(ORDER_BY_CLAUSE);
4674
4675 String[] orderByFields = orderByComparator.getOrderByFields();
4676
4677 for (int i = 0; i < orderByFields.length; i++) {
4678 if (getDB().isSupportsInlineDistinct()) {
4679 query.append(_ORDER_BY_ENTITY_ALIAS);
4680 }
4681 else {
4682 query.append(_ORDER_BY_ENTITY_TABLE);
4683 }
4684
4685 query.append(orderByFields[i]);
4686
4687 if ((i + 1) < orderByFields.length) {
4688 if (orderByComparator.isAscending() ^ previous) {
4689 query.append(ORDER_BY_ASC_HAS_NEXT);
4690 }
4691 else {
4692 query.append(ORDER_BY_DESC_HAS_NEXT);
4693 }
4694 }
4695 else {
4696 if (orderByComparator.isAscending() ^ previous) {
4697 query.append(ORDER_BY_ASC);
4698 }
4699 else {
4700 query.append(ORDER_BY_DESC);
4701 }
4702 }
4703 }
4704 }
4705 else {
4706 if (getDB().isSupportsInlineDistinct()) {
4707 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4708 }
4709 else {
4710 query.append(MBThreadModelImpl.ORDER_BY_SQL);
4711 }
4712 }
4713
4714 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4715 MBThread.class.getName(),
4716 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4717
4718 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4719
4720 q.setFirstResult(0);
4721 q.setMaxResults(2);
4722
4723 if (getDB().isSupportsInlineDistinct()) {
4724 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
4725 }
4726 else {
4727 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
4728 }
4729
4730 QueryPos qPos = QueryPos.getInstance(q);
4731
4732 qPos.add(groupId);
4733
4734 qPos.add(categoryId);
4735
4736 if (orderByComparator != null) {
4737 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
4738
4739 for (Object value : values) {
4740 qPos.add(value);
4741 }
4742 }
4743
4744 List<MBThread> list = q.list();
4745
4746 if (list.size() == 2) {
4747 return list.get(1);
4748 }
4749 else {
4750 return null;
4751 }
4752 }
4753
4754
4760 @Override
4761 public void removeByG_NotC(long groupId, long categoryId) {
4762 for (MBThread mbThread : findByG_NotC(groupId, categoryId,
4763 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4764 remove(mbThread);
4765 }
4766 }
4767
4768
4775 @Override
4776 public int countByG_NotC(long groupId, long categoryId) {
4777 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC;
4778
4779 Object[] finderArgs = new Object[] { groupId, categoryId };
4780
4781 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4782
4783 if (count == null) {
4784 StringBundler query = new StringBundler(3);
4785
4786 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4787
4788 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4789
4790 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4791
4792 String sql = query.toString();
4793
4794 Session session = null;
4795
4796 try {
4797 session = openSession();
4798
4799 Query q = session.createQuery(sql);
4800
4801 QueryPos qPos = QueryPos.getInstance(q);
4802
4803 qPos.add(groupId);
4804
4805 qPos.add(categoryId);
4806
4807 count = (Long)q.uniqueResult();
4808
4809 finderCache.putResult(finderPath, finderArgs, count);
4810 }
4811 catch (Exception e) {
4812 finderCache.removeResult(finderPath, finderArgs);
4813
4814 throw processException(e);
4815 }
4816 finally {
4817 closeSession(session);
4818 }
4819 }
4820
4821 return count.intValue();
4822 }
4823
4824
4831 @Override
4832 public int filterCountByG_NotC(long groupId, long categoryId) {
4833 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4834 return countByG_NotC(groupId, categoryId);
4835 }
4836
4837 StringBundler query = new StringBundler(3);
4838
4839 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
4840
4841 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4842
4843 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4844
4845 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4846 MBThread.class.getName(),
4847 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4848
4849 Session session = null;
4850
4851 try {
4852 session = openSession();
4853
4854 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4855
4856 q.addScalar(COUNT_COLUMN_NAME,
4857 com.liferay.portal.kernel.dao.orm.Type.LONG);
4858
4859 QueryPos qPos = QueryPos.getInstance(q);
4860
4861 qPos.add(groupId);
4862
4863 qPos.add(categoryId);
4864
4865 Long count = (Long)q.uniqueResult();
4866
4867 return count.intValue();
4868 }
4869 catch (Exception e) {
4870 throw processException(e);
4871 }
4872 finally {
4873 closeSession(session);
4874 }
4875 }
4876
4877 private static final String _FINDER_COLUMN_G_NOTC_GROUPID_2 = "mbThread.groupId = ? AND ";
4878 private static final String _FINDER_COLUMN_G_NOTC_CATEGORYID_2 = "mbThread.categoryId != ?";
4879 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
4880 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
4881 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
4882 new String[] {
4883 Long.class.getName(), Integer.class.getName(),
4884
4885 Integer.class.getName(), Integer.class.getName(),
4886 OrderByComparator.class.getName()
4887 });
4888 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
4889 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
4890 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
4891 new String[] { Long.class.getName(), Integer.class.getName() },
4892 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
4893 MBThreadModelImpl.STATUS_COLUMN_BITMASK |
4894 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
4895 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
4896 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
4897 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
4898 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
4899 new String[] { Long.class.getName(), Integer.class.getName() });
4900
4901
4908 @Override
4909 public List<MBThread> findByG_S(long groupId, int status) {
4910 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4911 null);
4912 }
4913
4914
4927 @Override
4928 public List<MBThread> findByG_S(long groupId, int status, int start, int end) {
4929 return findByG_S(groupId, status, start, end, null);
4930 }
4931
4932
4946 @Override
4947 public List<MBThread> findByG_S(long groupId, int status, int start,
4948 int end, OrderByComparator<MBThread> orderByComparator) {
4949 return findByG_S(groupId, status, start, end, orderByComparator, true);
4950 }
4951
4952
4967 @Override
4968 public List<MBThread> findByG_S(long groupId, int status, int start,
4969 int end, OrderByComparator<MBThread> orderByComparator,
4970 boolean retrieveFromCache) {
4971 boolean pagination = true;
4972 FinderPath finderPath = null;
4973 Object[] finderArgs = null;
4974
4975 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4976 (orderByComparator == null)) {
4977 pagination = false;
4978 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4979 finderArgs = new Object[] { groupId, status };
4980 }
4981 else {
4982 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4983 finderArgs = new Object[] {
4984 groupId, status,
4985
4986 start, end, orderByComparator
4987 };
4988 }
4989
4990 List<MBThread> list = null;
4991
4992 if (retrieveFromCache) {
4993 list = (List<MBThread>)finderCache.getResult(finderPath,
4994 finderArgs, this);
4995
4996 if ((list != null) && !list.isEmpty()) {
4997 for (MBThread mbThread : list) {
4998 if ((groupId != mbThread.getGroupId()) ||
4999 (status != mbThread.getStatus())) {
5000 list = null;
5001
5002 break;
5003 }
5004 }
5005 }
5006 }
5007
5008 if (list == null) {
5009 StringBundler query = null;
5010
5011 if (orderByComparator != null) {
5012 query = new StringBundler(4 +
5013 (orderByComparator.getOrderByFields().length * 2));
5014 }
5015 else {
5016 query = new StringBundler(4);
5017 }
5018
5019 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5020
5021 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5022
5023 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5024
5025 if (orderByComparator != null) {
5026 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5027 orderByComparator);
5028 }
5029 else
5030 if (pagination) {
5031 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5032 }
5033
5034 String sql = query.toString();
5035
5036 Session session = null;
5037
5038 try {
5039 session = openSession();
5040
5041 Query q = session.createQuery(sql);
5042
5043 QueryPos qPos = QueryPos.getInstance(q);
5044
5045 qPos.add(groupId);
5046
5047 qPos.add(status);
5048
5049 if (!pagination) {
5050 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
5051 start, end, false);
5052
5053 Collections.sort(list);
5054
5055 list = Collections.unmodifiableList(list);
5056 }
5057 else {
5058 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
5059 start, end);
5060 }
5061
5062 cacheResult(list);
5063
5064 finderCache.putResult(finderPath, finderArgs, list);
5065 }
5066 catch (Exception e) {
5067 finderCache.removeResult(finderPath, finderArgs);
5068
5069 throw processException(e);
5070 }
5071 finally {
5072 closeSession(session);
5073 }
5074 }
5075
5076 return list;
5077 }
5078
5079
5088 @Override
5089 public MBThread findByG_S_First(long groupId, int status,
5090 OrderByComparator<MBThread> orderByComparator)
5091 throws NoSuchThreadException {
5092 MBThread mbThread = fetchByG_S_First(groupId, status, orderByComparator);
5093
5094 if (mbThread != null) {
5095 return mbThread;
5096 }
5097
5098 StringBundler msg = new StringBundler(6);
5099
5100 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5101
5102 msg.append("groupId=");
5103 msg.append(groupId);
5104
5105 msg.append(", status=");
5106 msg.append(status);
5107
5108 msg.append(StringPool.CLOSE_CURLY_BRACE);
5109
5110 throw new NoSuchThreadException(msg.toString());
5111 }
5112
5113
5121 @Override
5122 public MBThread fetchByG_S_First(long groupId, int status,
5123 OrderByComparator<MBThread> orderByComparator) {
5124 List<MBThread> list = findByG_S(groupId, status, 0, 1, orderByComparator);
5125
5126 if (!list.isEmpty()) {
5127 return list.get(0);
5128 }
5129
5130 return null;
5131 }
5132
5133
5142 @Override
5143 public MBThread findByG_S_Last(long groupId, int status,
5144 OrderByComparator<MBThread> orderByComparator)
5145 throws NoSuchThreadException {
5146 MBThread mbThread = fetchByG_S_Last(groupId, status, orderByComparator);
5147
5148 if (mbThread != null) {
5149 return mbThread;
5150 }
5151
5152 StringBundler msg = new StringBundler(6);
5153
5154 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5155
5156 msg.append("groupId=");
5157 msg.append(groupId);
5158
5159 msg.append(", status=");
5160 msg.append(status);
5161
5162 msg.append(StringPool.CLOSE_CURLY_BRACE);
5163
5164 throw new NoSuchThreadException(msg.toString());
5165 }
5166
5167
5175 @Override
5176 public MBThread fetchByG_S_Last(long groupId, int status,
5177 OrderByComparator<MBThread> orderByComparator) {
5178 int count = countByG_S(groupId, status);
5179
5180 if (count == 0) {
5181 return null;
5182 }
5183
5184 List<MBThread> list = findByG_S(groupId, status, count - 1, count,
5185 orderByComparator);
5186
5187 if (!list.isEmpty()) {
5188 return list.get(0);
5189 }
5190
5191 return null;
5192 }
5193
5194
5204 @Override
5205 public MBThread[] findByG_S_PrevAndNext(long threadId, long groupId,
5206 int status, OrderByComparator<MBThread> orderByComparator)
5207 throws NoSuchThreadException {
5208 MBThread mbThread = findByPrimaryKey(threadId);
5209
5210 Session session = null;
5211
5212 try {
5213 session = openSession();
5214
5215 MBThread[] array = new MBThreadImpl[3];
5216
5217 array[0] = getByG_S_PrevAndNext(session, mbThread, groupId, status,
5218 orderByComparator, true);
5219
5220 array[1] = mbThread;
5221
5222 array[2] = getByG_S_PrevAndNext(session, mbThread, groupId, status,
5223 orderByComparator, false);
5224
5225 return array;
5226 }
5227 catch (Exception e) {
5228 throw processException(e);
5229 }
5230 finally {
5231 closeSession(session);
5232 }
5233 }
5234
5235 protected MBThread getByG_S_PrevAndNext(Session session, MBThread mbThread,
5236 long groupId, int status,
5237 OrderByComparator<MBThread> orderByComparator, boolean previous) {
5238 StringBundler query = null;
5239
5240 if (orderByComparator != null) {
5241 query = new StringBundler(5 +
5242 (orderByComparator.getOrderByConditionFields().length * 3) +
5243 (orderByComparator.getOrderByFields().length * 3));
5244 }
5245 else {
5246 query = new StringBundler(4);
5247 }
5248
5249 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5250
5251 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5252
5253 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5254
5255 if (orderByComparator != null) {
5256 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5257
5258 if (orderByConditionFields.length > 0) {
5259 query.append(WHERE_AND);
5260 }
5261
5262 for (int i = 0; i < orderByConditionFields.length; i++) {
5263 query.append(_ORDER_BY_ENTITY_ALIAS);
5264 query.append(orderByConditionFields[i]);
5265
5266 if ((i + 1) < orderByConditionFields.length) {
5267 if (orderByComparator.isAscending() ^ previous) {
5268 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5269 }
5270 else {
5271 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5272 }
5273 }
5274 else {
5275 if (orderByComparator.isAscending() ^ previous) {
5276 query.append(WHERE_GREATER_THAN);
5277 }
5278 else {
5279 query.append(WHERE_LESSER_THAN);
5280 }
5281 }
5282 }
5283
5284 query.append(ORDER_BY_CLAUSE);
5285
5286 String[] orderByFields = orderByComparator.getOrderByFields();
5287
5288 for (int i = 0; i < orderByFields.length; i++) {
5289 query.append(_ORDER_BY_ENTITY_ALIAS);
5290 query.append(orderByFields[i]);
5291
5292 if ((i + 1) < orderByFields.length) {
5293 if (orderByComparator.isAscending() ^ previous) {
5294 query.append(ORDER_BY_ASC_HAS_NEXT);
5295 }
5296 else {
5297 query.append(ORDER_BY_DESC_HAS_NEXT);
5298 }
5299 }
5300 else {
5301 if (orderByComparator.isAscending() ^ previous) {
5302 query.append(ORDER_BY_ASC);
5303 }
5304 else {
5305 query.append(ORDER_BY_DESC);
5306 }
5307 }
5308 }
5309 }
5310 else {
5311 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5312 }
5313
5314 String sql = query.toString();
5315
5316 Query q = session.createQuery(sql);
5317
5318 q.setFirstResult(0);
5319 q.setMaxResults(2);
5320
5321 QueryPos qPos = QueryPos.getInstance(q);
5322
5323 qPos.add(groupId);
5324
5325 qPos.add(status);
5326
5327 if (orderByComparator != null) {
5328 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
5329
5330 for (Object value : values) {
5331 qPos.add(value);
5332 }
5333 }
5334
5335 List<MBThread> list = q.list();
5336
5337 if (list.size() == 2) {
5338 return list.get(1);
5339 }
5340 else {
5341 return null;
5342 }
5343 }
5344
5345
5352 @Override
5353 public List<MBThread> filterFindByG_S(long groupId, int status) {
5354 return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
5355 QueryUtil.ALL_POS, null);
5356 }
5357
5358
5371 @Override
5372 public List<MBThread> filterFindByG_S(long groupId, int status, int start,
5373 int end) {
5374 return filterFindByG_S(groupId, status, start, end, null);
5375 }
5376
5377
5391 @Override
5392 public List<MBThread> filterFindByG_S(long groupId, int status, int start,
5393 int end, OrderByComparator<MBThread> orderByComparator) {
5394 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5395 return findByG_S(groupId, status, start, end, orderByComparator);
5396 }
5397
5398 StringBundler query = null;
5399
5400 if (orderByComparator != null) {
5401 query = new StringBundler(4 +
5402 (orderByComparator.getOrderByFields().length * 2));
5403 }
5404 else {
5405 query = new StringBundler(5);
5406 }
5407
5408 if (getDB().isSupportsInlineDistinct()) {
5409 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
5410 }
5411 else {
5412 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
5413 }
5414
5415 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5416
5417 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5418
5419 if (!getDB().isSupportsInlineDistinct()) {
5420 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
5421 }
5422
5423 if (orderByComparator != null) {
5424 if (getDB().isSupportsInlineDistinct()) {
5425 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5426 orderByComparator, true);
5427 }
5428 else {
5429 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5430 orderByComparator, true);
5431 }
5432 }
5433 else {
5434 if (getDB().isSupportsInlineDistinct()) {
5435 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5436 }
5437 else {
5438 query.append(MBThreadModelImpl.ORDER_BY_SQL);
5439 }
5440 }
5441
5442 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5443 MBThread.class.getName(),
5444 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5445
5446 Session session = null;
5447
5448 try {
5449 session = openSession();
5450
5451 SQLQuery q = session.createSynchronizedSQLQuery(sql);
5452
5453 if (getDB().isSupportsInlineDistinct()) {
5454 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
5455 }
5456 else {
5457 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
5458 }
5459
5460 QueryPos qPos = QueryPos.getInstance(q);
5461
5462 qPos.add(groupId);
5463
5464 qPos.add(status);
5465
5466 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
5467 }
5468 catch (Exception e) {
5469 throw processException(e);
5470 }
5471 finally {
5472 closeSession(session);
5473 }
5474 }
5475
5476
5486 @Override
5487 public MBThread[] filterFindByG_S_PrevAndNext(long threadId, long groupId,
5488 int status, OrderByComparator<MBThread> orderByComparator)
5489 throws NoSuchThreadException {
5490 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5491 return findByG_S_PrevAndNext(threadId, groupId, status,
5492 orderByComparator);
5493 }
5494
5495 MBThread mbThread = findByPrimaryKey(threadId);
5496
5497 Session session = null;
5498
5499 try {
5500 session = openSession();
5501
5502 MBThread[] array = new MBThreadImpl[3];
5503
5504 array[0] = filterGetByG_S_PrevAndNext(session, mbThread, groupId,
5505 status, orderByComparator, true);
5506
5507 array[1] = mbThread;
5508
5509 array[2] = filterGetByG_S_PrevAndNext(session, mbThread, groupId,
5510 status, orderByComparator, false);
5511
5512 return array;
5513 }
5514 catch (Exception e) {
5515 throw processException(e);
5516 }
5517 finally {
5518 closeSession(session);
5519 }
5520 }
5521
5522 protected MBThread filterGetByG_S_PrevAndNext(Session session,
5523 MBThread mbThread, long groupId, int status,
5524 OrderByComparator<MBThread> orderByComparator, boolean previous) {
5525 StringBundler query = null;
5526
5527 if (orderByComparator != null) {
5528 query = new StringBundler(6 +
5529 (orderByComparator.getOrderByConditionFields().length * 3) +
5530 (orderByComparator.getOrderByFields().length * 3));
5531 }
5532 else {
5533 query = new StringBundler(5);
5534 }
5535
5536 if (getDB().isSupportsInlineDistinct()) {
5537 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
5538 }
5539 else {
5540 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
5541 }
5542
5543 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5544
5545 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5546
5547 if (!getDB().isSupportsInlineDistinct()) {
5548 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
5549 }
5550
5551 if (orderByComparator != null) {
5552 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5553
5554 if (orderByConditionFields.length > 0) {
5555 query.append(WHERE_AND);
5556 }
5557
5558 for (int i = 0; i < orderByConditionFields.length; i++) {
5559 if (getDB().isSupportsInlineDistinct()) {
5560 query.append(_ORDER_BY_ENTITY_ALIAS);
5561 }
5562 else {
5563 query.append(_ORDER_BY_ENTITY_TABLE);
5564 }
5565
5566 query.append(orderByConditionFields[i]);
5567
5568 if ((i + 1) < orderByConditionFields.length) {
5569 if (orderByComparator.isAscending() ^ previous) {
5570 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5571 }
5572 else {
5573 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5574 }
5575 }
5576 else {
5577 if (orderByComparator.isAscending() ^ previous) {
5578 query.append(WHERE_GREATER_THAN);
5579 }
5580 else {
5581 query.append(WHERE_LESSER_THAN);
5582 }
5583 }
5584 }
5585
5586 query.append(ORDER_BY_CLAUSE);
5587
5588 String[] orderByFields = orderByComparator.getOrderByFields();
5589
5590 for (int i = 0; i < orderByFields.length; i++) {
5591 if (getDB().isSupportsInlineDistinct()) {
5592 query.append(_ORDER_BY_ENTITY_ALIAS);
5593 }
5594 else {
5595 query.append(_ORDER_BY_ENTITY_TABLE);
5596 }
5597
5598 query.append(orderByFields[i]);
5599
5600 if ((i + 1) < orderByFields.length) {
5601 if (orderByComparator.isAscending() ^ previous) {
5602 query.append(ORDER_BY_ASC_HAS_NEXT);
5603 }
5604 else {
5605 query.append(ORDER_BY_DESC_HAS_NEXT);
5606 }
5607 }
5608 else {
5609 if (orderByComparator.isAscending() ^ previous) {
5610 query.append(ORDER_BY_ASC);
5611 }
5612 else {
5613 query.append(ORDER_BY_DESC);
5614 }
5615 }
5616 }
5617 }
5618 else {
5619 if (getDB().isSupportsInlineDistinct()) {
5620 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5621 }
5622 else {
5623 query.append(MBThreadModelImpl.ORDER_BY_SQL);
5624 }
5625 }
5626
5627 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5628 MBThread.class.getName(),
5629 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5630
5631 SQLQuery q = session.createSynchronizedSQLQuery(sql);
5632
5633 q.setFirstResult(0);
5634 q.setMaxResults(2);
5635
5636 if (getDB().isSupportsInlineDistinct()) {
5637 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
5638 }
5639 else {
5640 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
5641 }
5642
5643 QueryPos qPos = QueryPos.getInstance(q);
5644
5645 qPos.add(groupId);
5646
5647 qPos.add(status);
5648
5649 if (orderByComparator != null) {
5650 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
5651
5652 for (Object value : values) {
5653 qPos.add(value);
5654 }
5655 }
5656
5657 List<MBThread> list = q.list();
5658
5659 if (list.size() == 2) {
5660 return list.get(1);
5661 }
5662 else {
5663 return null;
5664 }
5665 }
5666
5667
5673 @Override
5674 public void removeByG_S(long groupId, int status) {
5675 for (MBThread mbThread : findByG_S(groupId, status, QueryUtil.ALL_POS,
5676 QueryUtil.ALL_POS, null)) {
5677 remove(mbThread);
5678 }
5679 }
5680
5681
5688 @Override
5689 public int countByG_S(long groupId, int status) {
5690 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
5691
5692 Object[] finderArgs = new Object[] { groupId, status };
5693
5694 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5695
5696 if (count == null) {
5697 StringBundler query = new StringBundler(3);
5698
5699 query.append(_SQL_COUNT_MBTHREAD_WHERE);
5700
5701 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5702
5703 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5704
5705 String sql = query.toString();
5706
5707 Session session = null;
5708
5709 try {
5710 session = openSession();
5711
5712 Query q = session.createQuery(sql);
5713
5714 QueryPos qPos = QueryPos.getInstance(q);
5715
5716 qPos.add(groupId);
5717
5718 qPos.add(status);
5719
5720 count = (Long)q.uniqueResult();
5721
5722 finderCache.putResult(finderPath, finderArgs, count);
5723 }
5724 catch (Exception e) {
5725 finderCache.removeResult(finderPath, finderArgs);
5726
5727 throw processException(e);
5728 }
5729 finally {
5730 closeSession(session);
5731 }
5732 }
5733
5734 return count.intValue();
5735 }
5736
5737
5744 @Override
5745 public int filterCountByG_S(long groupId, int status) {
5746 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5747 return countByG_S(groupId, status);
5748 }
5749
5750 StringBundler query = new StringBundler(3);
5751
5752 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
5753
5754 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5755
5756 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5757
5758 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5759 MBThread.class.getName(),
5760 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5761
5762 Session session = null;
5763
5764 try {
5765 session = openSession();
5766
5767 SQLQuery q = session.createSynchronizedSQLQuery(sql);
5768
5769 q.addScalar(COUNT_COLUMN_NAME,
5770 com.liferay.portal.kernel.dao.orm.Type.LONG);
5771
5772 QueryPos qPos = QueryPos.getInstance(q);
5773
5774 qPos.add(groupId);
5775
5776 qPos.add(status);
5777
5778 Long count = (Long)q.uniqueResult();
5779
5780 return count.intValue();
5781 }
5782 catch (Exception e) {
5783 throw processException(e);
5784 }
5785 finally {
5786 closeSession(session);
5787 }
5788 }
5789
5790 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "mbThread.groupId = ? AND ";
5791 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbThread.status = ? AND mbThread.categoryId != -1";
5792 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
5793 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
5794 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P",
5795 new String[] {
5796 Long.class.getName(), Double.class.getName(),
5797
5798 Integer.class.getName(), Integer.class.getName(),
5799 OrderByComparator.class.getName()
5800 });
5801 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
5802 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
5803 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P",
5804 new String[] { Long.class.getName(), Double.class.getName() },
5805 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
5806 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
5807 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
5808 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
5809 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
5810 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P",
5811 new String[] { Long.class.getName(), Double.class.getName() });
5812
5813
5820 @Override
5821 public List<MBThread> findByC_P(long categoryId, double priority) {
5822 return findByC_P(categoryId, priority, QueryUtil.ALL_POS,
5823 QueryUtil.ALL_POS, null);
5824 }
5825
5826
5839 @Override
5840 public List<MBThread> findByC_P(long categoryId, double priority,
5841 int start, int end) {
5842 return findByC_P(categoryId, priority, start, end, null);
5843 }
5844
5845
5859 @Override
5860 public List<MBThread> findByC_P(long categoryId, double priority,
5861 int start, int end, OrderByComparator<MBThread> orderByComparator) {
5862 return findByC_P(categoryId, priority, start, end, orderByComparator,
5863 true);
5864 }
5865
5866
5881 @Override
5882 public List<MBThread> findByC_P(long categoryId, double priority,
5883 int start, int end, OrderByComparator<MBThread> orderByComparator,
5884 boolean retrieveFromCache) {
5885 boolean pagination = true;
5886 FinderPath finderPath = null;
5887 Object[] finderArgs = null;
5888
5889 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5890 (orderByComparator == null)) {
5891 pagination = false;
5892 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
5893 finderArgs = new Object[] { categoryId, priority };
5894 }
5895 else {
5896 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
5897 finderArgs = new Object[] {
5898 categoryId, priority,
5899
5900 start, end, orderByComparator
5901 };
5902 }
5903
5904 List<MBThread> list = null;
5905
5906 if (retrieveFromCache) {
5907 list = (List<MBThread>)finderCache.getResult(finderPath,
5908 finderArgs, this);
5909
5910 if ((list != null) && !list.isEmpty()) {
5911 for (MBThread mbThread : list) {
5912 if ((categoryId != mbThread.getCategoryId()) ||
5913 (priority != mbThread.getPriority())) {
5914 list = null;
5915
5916 break;
5917 }
5918 }
5919 }
5920 }
5921
5922 if (list == null) {
5923 StringBundler query = null;
5924
5925 if (orderByComparator != null) {
5926 query = new StringBundler(4 +
5927 (orderByComparator.getOrderByFields().length * 2));
5928 }
5929 else {
5930 query = new StringBundler(4);
5931 }
5932
5933 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5934
5935 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
5936
5937 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
5938
5939 if (orderByComparator != null) {
5940 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5941 orderByComparator);
5942 }
5943 else
5944 if (pagination) {
5945 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5946 }
5947
5948 String sql = query.toString();
5949
5950 Session session = null;
5951
5952 try {
5953 session = openSession();
5954
5955 Query q = session.createQuery(sql);
5956
5957 QueryPos qPos = QueryPos.getInstance(q);
5958
5959 qPos.add(categoryId);
5960
5961 qPos.add(priority);
5962
5963 if (!pagination) {
5964 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
5965 start, end, false);
5966
5967 Collections.sort(list);
5968
5969 list = Collections.unmodifiableList(list);
5970 }
5971 else {
5972 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
5973 start, end);
5974 }
5975
5976 cacheResult(list);
5977
5978 finderCache.putResult(finderPath, finderArgs, list);
5979 }
5980 catch (Exception e) {
5981 finderCache.removeResult(finderPath, finderArgs);
5982
5983 throw processException(e);
5984 }
5985 finally {
5986 closeSession(session);
5987 }
5988 }
5989
5990 return list;
5991 }
5992
5993
6002 @Override
6003 public MBThread findByC_P_First(long categoryId, double priority,
6004 OrderByComparator<MBThread> orderByComparator)
6005 throws NoSuchThreadException {
6006 MBThread mbThread = fetchByC_P_First(categoryId, priority,
6007 orderByComparator);
6008
6009 if (mbThread != null) {
6010 return mbThread;
6011 }
6012
6013 StringBundler msg = new StringBundler(6);
6014
6015 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6016
6017 msg.append("categoryId=");
6018 msg.append(categoryId);
6019
6020 msg.append(", priority=");
6021 msg.append(priority);
6022
6023 msg.append(StringPool.CLOSE_CURLY_BRACE);
6024
6025 throw new NoSuchThreadException(msg.toString());
6026 }
6027
6028
6036 @Override
6037 public MBThread fetchByC_P_First(long categoryId, double priority,
6038 OrderByComparator<MBThread> orderByComparator) {
6039 List<MBThread> list = findByC_P(categoryId, priority, 0, 1,
6040 orderByComparator);
6041
6042 if (!list.isEmpty()) {
6043 return list.get(0);
6044 }
6045
6046 return null;
6047 }
6048
6049
6058 @Override
6059 public MBThread findByC_P_Last(long categoryId, double priority,
6060 OrderByComparator<MBThread> orderByComparator)
6061 throws NoSuchThreadException {
6062 MBThread mbThread = fetchByC_P_Last(categoryId, priority,
6063 orderByComparator);
6064
6065 if (mbThread != null) {
6066 return mbThread;
6067 }
6068
6069 StringBundler msg = new StringBundler(6);
6070
6071 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6072
6073 msg.append("categoryId=");
6074 msg.append(categoryId);
6075
6076 msg.append(", priority=");
6077 msg.append(priority);
6078
6079 msg.append(StringPool.CLOSE_CURLY_BRACE);
6080
6081 throw new NoSuchThreadException(msg.toString());
6082 }
6083
6084
6092 @Override
6093 public MBThread fetchByC_P_Last(long categoryId, double priority,
6094 OrderByComparator<MBThread> orderByComparator) {
6095 int count = countByC_P(categoryId, priority);
6096
6097 if (count == 0) {
6098 return null;
6099 }
6100
6101 List<MBThread> list = findByC_P(categoryId, priority, count - 1, count,
6102 orderByComparator);
6103
6104 if (!list.isEmpty()) {
6105 return list.get(0);
6106 }
6107
6108 return null;
6109 }
6110
6111
6121 @Override
6122 public MBThread[] findByC_P_PrevAndNext(long threadId, long categoryId,
6123 double priority, OrderByComparator<MBThread> orderByComparator)
6124 throws NoSuchThreadException {
6125 MBThread mbThread = findByPrimaryKey(threadId);
6126
6127 Session session = null;
6128
6129 try {
6130 session = openSession();
6131
6132 MBThread[] array = new MBThreadImpl[3];
6133
6134 array[0] = getByC_P_PrevAndNext(session, mbThread, categoryId,
6135 priority, orderByComparator, true);
6136
6137 array[1] = mbThread;
6138
6139 array[2] = getByC_P_PrevAndNext(session, mbThread, categoryId,
6140 priority, orderByComparator, false);
6141
6142 return array;
6143 }
6144 catch (Exception e) {
6145 throw processException(e);
6146 }
6147 finally {
6148 closeSession(session);
6149 }
6150 }
6151
6152 protected MBThread getByC_P_PrevAndNext(Session session, MBThread mbThread,
6153 long categoryId, double priority,
6154 OrderByComparator<MBThread> orderByComparator, boolean previous) {
6155 StringBundler query = null;
6156
6157 if (orderByComparator != null) {
6158 query = new StringBundler(5 +
6159 (orderByComparator.getOrderByConditionFields().length * 3) +
6160 (orderByComparator.getOrderByFields().length * 3));
6161 }
6162 else {
6163 query = new StringBundler(4);
6164 }
6165
6166 query.append(_SQL_SELECT_MBTHREAD_WHERE);
6167
6168 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
6169
6170 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
6171
6172 if (orderByComparator != null) {
6173 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6174
6175 if (orderByConditionFields.length > 0) {
6176 query.append(WHERE_AND);
6177 }
6178
6179 for (int i = 0; i < orderByConditionFields.length; i++) {
6180 query.append(_ORDER_BY_ENTITY_ALIAS);
6181 query.append(orderByConditionFields[i]);
6182
6183 if ((i + 1) < orderByConditionFields.length) {
6184 if (orderByComparator.isAscending() ^ previous) {
6185 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6186 }
6187 else {
6188 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6189 }
6190 }
6191 else {
6192 if (orderByComparator.isAscending() ^ previous) {
6193 query.append(WHERE_GREATER_THAN);
6194 }
6195 else {
6196 query.append(WHERE_LESSER_THAN);
6197 }
6198 }
6199 }
6200
6201 query.append(ORDER_BY_CLAUSE);
6202
6203 String[] orderByFields = orderByComparator.getOrderByFields();
6204
6205 for (int i = 0; i < orderByFields.length; i++) {
6206 query.append(_ORDER_BY_ENTITY_ALIAS);
6207 query.append(orderByFields[i]);
6208
6209 if ((i + 1) < orderByFields.length) {
6210 if (orderByComparator.isAscending() ^ previous) {
6211 query.append(ORDER_BY_ASC_HAS_NEXT);
6212 }
6213 else {
6214 query.append(ORDER_BY_DESC_HAS_NEXT);
6215 }
6216 }
6217 else {
6218 if (orderByComparator.isAscending() ^ previous) {
6219 query.append(ORDER_BY_ASC);
6220 }
6221 else {
6222 query.append(ORDER_BY_DESC);
6223 }
6224 }
6225 }
6226 }
6227 else {
6228 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6229 }
6230
6231 String sql = query.toString();
6232
6233 Query q = session.createQuery(sql);
6234
6235 q.setFirstResult(0);
6236 q.setMaxResults(2);
6237
6238 QueryPos qPos = QueryPos.getInstance(q);
6239
6240 qPos.add(categoryId);
6241
6242 qPos.add(priority);
6243
6244 if (orderByComparator != null) {
6245 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
6246
6247 for (Object value : values) {
6248 qPos.add(value);
6249 }
6250 }
6251
6252 List<MBThread> list = q.list();
6253
6254 if (list.size() == 2) {
6255 return list.get(1);
6256 }
6257 else {
6258 return null;
6259 }
6260 }
6261
6262
6268 @Override
6269 public void removeByC_P(long categoryId, double priority) {
6270 for (MBThread mbThread : findByC_P(categoryId, priority,
6271 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6272 remove(mbThread);
6273 }
6274 }
6275
6276
6283 @Override
6284 public int countByC_P(long categoryId, double priority) {
6285 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_P;
6286
6287 Object[] finderArgs = new Object[] { categoryId, priority };
6288
6289 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6290
6291 if (count == null) {
6292 StringBundler query = new StringBundler(3);
6293
6294 query.append(_SQL_COUNT_MBTHREAD_WHERE);
6295
6296 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
6297
6298 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
6299
6300 String sql = query.toString();
6301
6302 Session session = null;
6303
6304 try {
6305 session = openSession();
6306
6307 Query q = session.createQuery(sql);
6308
6309 QueryPos qPos = QueryPos.getInstance(q);
6310
6311 qPos.add(categoryId);
6312
6313 qPos.add(priority);
6314
6315 count = (Long)q.uniqueResult();
6316
6317 finderCache.putResult(finderPath, finderArgs, count);
6318 }
6319 catch (Exception e) {
6320 finderCache.removeResult(finderPath, finderArgs);
6321
6322 throw processException(e);
6323 }
6324 finally {
6325 closeSession(session);
6326 }
6327 }
6328
6329 return count.intValue();
6330 }
6331
6332 private static final String _FINDER_COLUMN_C_P_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
6333 private static final String _FINDER_COLUMN_C_P_PRIORITY_2 = "mbThread.priority = ?";
6334 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6335 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
6336 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByL_P",
6337 new String[] {
6338 Date.class.getName(), Double.class.getName(),
6339
6340 Integer.class.getName(), Integer.class.getName(),
6341 OrderByComparator.class.getName()
6342 });
6343 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6344 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
6345 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P",
6346 new String[] { Date.class.getName(), Double.class.getName() },
6347 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK |
6348 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK);
6349 public static final FinderPath FINDER_PATH_COUNT_BY_L_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6350 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
6351 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P",
6352 new String[] { Date.class.getName(), Double.class.getName() });
6353
6354
6361 @Override
6362 public List<MBThread> findByL_P(Date lastPostDate, double priority) {
6363 return findByL_P(lastPostDate, priority, QueryUtil.ALL_POS,
6364 QueryUtil.ALL_POS, null);
6365 }
6366
6367
6380 @Override
6381 public List<MBThread> findByL_P(Date lastPostDate, double priority,
6382 int start, int end) {
6383 return findByL_P(lastPostDate, priority, start, end, null);
6384 }
6385
6386
6400 @Override
6401 public List<MBThread> findByL_P(Date lastPostDate, double priority,
6402 int start, int end, OrderByComparator<MBThread> orderByComparator) {
6403 return findByL_P(lastPostDate, priority, start, end, orderByComparator,
6404 true);
6405 }
6406
6407
6422 @Override
6423 public List<MBThread> findByL_P(Date lastPostDate, double priority,
6424 int start, int end, OrderByComparator<MBThread> orderByComparator,
6425 boolean retrieveFromCache) {
6426 boolean pagination = true;
6427 FinderPath finderPath = null;
6428 Object[] finderArgs = null;
6429
6430 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6431 (orderByComparator == null)) {
6432 pagination = false;
6433 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P;
6434 finderArgs = new Object[] { lastPostDate, priority };
6435 }
6436 else {
6437 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P;
6438 finderArgs = new Object[] {
6439 lastPostDate, priority,
6440
6441 start, end, orderByComparator
6442 };
6443 }
6444
6445 List<MBThread> list = null;
6446
6447 if (retrieveFromCache) {
6448 list = (List<MBThread>)finderCache.getResult(finderPath,
6449 finderArgs, this);
6450
6451 if ((list != null) && !list.isEmpty()) {
6452 for (MBThread mbThread : list) {
6453 if (!Validator.equals(lastPostDate,
6454 mbThread.getLastPostDate()) ||
6455 (priority != mbThread.getPriority())) {
6456 list = null;
6457
6458 break;
6459 }
6460 }
6461 }
6462 }
6463
6464 if (list == null) {
6465 StringBundler query = null;
6466
6467 if (orderByComparator != null) {
6468 query = new StringBundler(4 +
6469 (orderByComparator.getOrderByFields().length * 2));
6470 }
6471 else {
6472 query = new StringBundler(4);
6473 }
6474
6475 query.append(_SQL_SELECT_MBTHREAD_WHERE);
6476
6477 boolean bindLastPostDate = false;
6478
6479 if (lastPostDate == null) {
6480 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
6481 }
6482 else {
6483 bindLastPostDate = true;
6484
6485 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
6486 }
6487
6488 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
6489
6490 if (orderByComparator != null) {
6491 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6492 orderByComparator);
6493 }
6494 else
6495 if (pagination) {
6496 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6497 }
6498
6499 String sql = query.toString();
6500
6501 Session session = null;
6502
6503 try {
6504 session = openSession();
6505
6506 Query q = session.createQuery(sql);
6507
6508 QueryPos qPos = QueryPos.getInstance(q);
6509
6510 if (bindLastPostDate) {
6511 qPos.add(new Timestamp(lastPostDate.getTime()));
6512 }
6513
6514 qPos.add(priority);
6515
6516 if (!pagination) {
6517 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
6518 start, end, false);
6519
6520 Collections.sort(list);
6521
6522 list = Collections.unmodifiableList(list);
6523 }
6524 else {
6525 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
6526 start, end);
6527 }
6528
6529 cacheResult(list);
6530
6531 finderCache.putResult(finderPath, finderArgs, list);
6532 }
6533 catch (Exception e) {
6534 finderCache.removeResult(finderPath, finderArgs);
6535
6536 throw processException(e);
6537 }
6538 finally {
6539 closeSession(session);
6540 }
6541 }
6542
6543 return list;
6544 }
6545
6546
6555 @Override
6556 public MBThread findByL_P_First(Date lastPostDate, double priority,
6557 OrderByComparator<MBThread> orderByComparator)
6558 throws NoSuchThreadException {
6559 MBThread mbThread = fetchByL_P_First(lastPostDate, priority,
6560 orderByComparator);
6561
6562 if (mbThread != null) {
6563 return mbThread;
6564 }
6565
6566 StringBundler msg = new StringBundler(6);
6567
6568 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6569
6570 msg.append("lastPostDate=");
6571 msg.append(lastPostDate);
6572
6573 msg.append(", priority=");
6574 msg.append(priority);
6575
6576 msg.append(StringPool.CLOSE_CURLY_BRACE);
6577
6578 throw new NoSuchThreadException(msg.toString());
6579 }
6580
6581
6589 @Override
6590 public MBThread fetchByL_P_First(Date lastPostDate, double priority,
6591 OrderByComparator<MBThread> orderByComparator) {
6592 List<MBThread> list = findByL_P(lastPostDate, priority, 0, 1,
6593 orderByComparator);
6594
6595 if (!list.isEmpty()) {
6596 return list.get(0);
6597 }
6598
6599 return null;
6600 }
6601
6602
6611 @Override
6612 public MBThread findByL_P_Last(Date lastPostDate, double priority,
6613 OrderByComparator<MBThread> orderByComparator)
6614 throws NoSuchThreadException {
6615 MBThread mbThread = fetchByL_P_Last(lastPostDate, priority,
6616 orderByComparator);
6617
6618 if (mbThread != null) {
6619 return mbThread;
6620 }
6621
6622 StringBundler msg = new StringBundler(6);
6623
6624 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6625
6626 msg.append("lastPostDate=");
6627 msg.append(lastPostDate);
6628
6629 msg.append(", priority=");
6630 msg.append(priority);
6631
6632 msg.append(StringPool.CLOSE_CURLY_BRACE);
6633
6634 throw new NoSuchThreadException(msg.toString());
6635 }
6636
6637
6645 @Override
6646 public MBThread fetchByL_P_Last(Date lastPostDate, double priority,
6647 OrderByComparator<MBThread> orderByComparator) {
6648 int count = countByL_P(lastPostDate, priority);
6649
6650 if (count == 0) {
6651 return null;
6652 }
6653
6654 List<MBThread> list = findByL_P(lastPostDate, priority, count - 1,
6655 count, orderByComparator);
6656
6657 if (!list.isEmpty()) {
6658 return list.get(0);
6659 }
6660
6661 return null;
6662 }
6663
6664
6674 @Override
6675 public MBThread[] findByL_P_PrevAndNext(long threadId, Date lastPostDate,
6676 double priority, OrderByComparator<MBThread> orderByComparator)
6677 throws NoSuchThreadException {
6678 MBThread mbThread = findByPrimaryKey(threadId);
6679
6680 Session session = null;
6681
6682 try {
6683 session = openSession();
6684
6685 MBThread[] array = new MBThreadImpl[3];
6686
6687 array[0] = getByL_P_PrevAndNext(session, mbThread, lastPostDate,
6688 priority, orderByComparator, true);
6689
6690 array[1] = mbThread;
6691
6692 array[2] = getByL_P_PrevAndNext(session, mbThread, lastPostDate,
6693 priority, orderByComparator, false);
6694
6695 return array;
6696 }
6697 catch (Exception e) {
6698 throw processException(e);
6699 }
6700 finally {
6701 closeSession(session);
6702 }
6703 }
6704
6705 protected MBThread getByL_P_PrevAndNext(Session session, MBThread mbThread,
6706 Date lastPostDate, double priority,
6707 OrderByComparator<MBThread> orderByComparator, boolean previous) {
6708 StringBundler query = null;
6709
6710 if (orderByComparator != null) {
6711 query = new StringBundler(5 +
6712 (orderByComparator.getOrderByConditionFields().length * 3) +
6713 (orderByComparator.getOrderByFields().length * 3));
6714 }
6715 else {
6716 query = new StringBundler(4);
6717 }
6718
6719 query.append(_SQL_SELECT_MBTHREAD_WHERE);
6720
6721 boolean bindLastPostDate = false;
6722
6723 if (lastPostDate == null) {
6724 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
6725 }
6726 else {
6727 bindLastPostDate = true;
6728
6729 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
6730 }
6731
6732 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
6733
6734 if (orderByComparator != null) {
6735 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6736
6737 if (orderByConditionFields.length > 0) {
6738 query.append(WHERE_AND);
6739 }
6740
6741 for (int i = 0; i < orderByConditionFields.length; i++) {
6742 query.append(_ORDER_BY_ENTITY_ALIAS);
6743 query.append(orderByConditionFields[i]);
6744
6745 if ((i + 1) < orderByConditionFields.length) {
6746 if (orderByComparator.isAscending() ^ previous) {
6747 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6748 }
6749 else {
6750 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6751 }
6752 }
6753 else {
6754 if (orderByComparator.isAscending() ^ previous) {
6755 query.append(WHERE_GREATER_THAN);
6756 }
6757 else {
6758 query.append(WHERE_LESSER_THAN);
6759 }
6760 }
6761 }
6762
6763 query.append(ORDER_BY_CLAUSE);
6764
6765 String[] orderByFields = orderByComparator.getOrderByFields();
6766
6767 for (int i = 0; i < orderByFields.length; i++) {
6768 query.append(_ORDER_BY_ENTITY_ALIAS);
6769 query.append(orderByFields[i]);
6770
6771 if ((i + 1) < orderByFields.length) {
6772 if (orderByComparator.isAscending() ^ previous) {
6773 query.append(ORDER_BY_ASC_HAS_NEXT);
6774 }
6775 else {
6776 query.append(ORDER_BY_DESC_HAS_NEXT);
6777 }
6778 }
6779 else {
6780 if (orderByComparator.isAscending() ^ previous) {
6781 query.append(ORDER_BY_ASC);
6782 }
6783 else {
6784 query.append(ORDER_BY_DESC);
6785 }
6786 }
6787 }
6788 }
6789 else {
6790 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6791 }
6792
6793 String sql = query.toString();
6794
6795 Query q = session.createQuery(sql);
6796
6797 q.setFirstResult(0);
6798 q.setMaxResults(2);
6799
6800 QueryPos qPos = QueryPos.getInstance(q);
6801
6802 if (bindLastPostDate) {
6803 qPos.add(new Timestamp(lastPostDate.getTime()));
6804 }
6805
6806 qPos.add(priority);
6807
6808 if (orderByComparator != null) {
6809 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
6810
6811 for (Object value : values) {
6812 qPos.add(value);
6813 }
6814 }
6815
6816 List<MBThread> list = q.list();
6817
6818 if (list.size() == 2) {
6819 return list.get(1);
6820 }
6821 else {
6822 return null;
6823 }
6824 }
6825
6826
6832 @Override
6833 public void removeByL_P(Date lastPostDate, double priority) {
6834 for (MBThread mbThread : findByL_P(lastPostDate, priority,
6835 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6836 remove(mbThread);
6837 }
6838 }
6839
6840
6847 @Override
6848 public int countByL_P(Date lastPostDate, double priority) {
6849 FinderPath finderPath = FINDER_PATH_COUNT_BY_L_P;
6850
6851 Object[] finderArgs = new Object[] { lastPostDate, priority };
6852
6853 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6854
6855 if (count == null) {
6856 StringBundler query = new StringBundler(3);
6857
6858 query.append(_SQL_COUNT_MBTHREAD_WHERE);
6859
6860 boolean bindLastPostDate = false;
6861
6862 if (lastPostDate == null) {
6863 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
6864 }
6865 else {
6866 bindLastPostDate = true;
6867
6868 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
6869 }
6870
6871 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
6872
6873 String sql = query.toString();
6874
6875 Session session = null;
6876
6877 try {
6878 session = openSession();
6879
6880 Query q = session.createQuery(sql);
6881
6882 QueryPos qPos = QueryPos.getInstance(q);
6883
6884 if (bindLastPostDate) {
6885 qPos.add(new Timestamp(lastPostDate.getTime()));
6886 }
6887
6888 qPos.add(priority);
6889
6890 count = (Long)q.uniqueResult();
6891
6892 finderCache.putResult(finderPath, finderArgs, count);
6893 }
6894 catch (Exception e) {
6895 finderCache.removeResult(finderPath, finderArgs);
6896
6897 throw processException(e);
6898 }
6899 finally {
6900 closeSession(session);
6901 }
6902 }
6903
6904 return count.intValue();
6905 }
6906
6907 private static final String _FINDER_COLUMN_L_P_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL AND ";
6908 private static final String _FINDER_COLUMN_L_P_LASTPOSTDATE_2 = "mbThread.lastPostDate = ? AND ";
6909 private static final String _FINDER_COLUMN_L_P_PRIORITY_2 = "mbThread.priority = ? AND mbThread.categoryId != -1";
6910 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6911 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
6912 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_L",
6913 new String[] {
6914 Long.class.getName(), Long.class.getName(), Date.class.getName(),
6915
6916 Integer.class.getName(), Integer.class.getName(),
6917 OrderByComparator.class.getName()
6918 });
6919 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6920 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
6921 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
6922 new String[] {
6923 Long.class.getName(), Long.class.getName(), Date.class.getName()
6924 },
6925 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
6926 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
6927 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK |
6928 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK);
6929 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6930 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
6931 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
6932 new String[] {
6933 Long.class.getName(), Long.class.getName(), Date.class.getName()
6934 });
6935
6936
6944 @Override
6945 public List<MBThread> findByG_C_L(long groupId, long categoryId,
6946 Date lastPostDate) {
6947 return findByG_C_L(groupId, categoryId, lastPostDate,
6948 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6949 }
6950
6951
6965 @Override
6966 public List<MBThread> findByG_C_L(long groupId, long categoryId,
6967 Date lastPostDate, int start, int end) {
6968 return findByG_C_L(groupId, categoryId, lastPostDate, start, end, null);
6969 }
6970
6971
6986 @Override
6987 public List<MBThread> findByG_C_L(long groupId, long categoryId,
6988 Date lastPostDate, int start, int end,
6989 OrderByComparator<MBThread> orderByComparator) {
6990 return findByG_C_L(groupId, categoryId, lastPostDate, start, end,
6991 orderByComparator, true);
6992 }
6993
6994
7010 @Override
7011 public List<MBThread> findByG_C_L(long groupId, long categoryId,
7012 Date lastPostDate, int start, int end,
7013 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
7014 boolean pagination = true;
7015 FinderPath finderPath = null;
7016 Object[] finderArgs = null;
7017
7018 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7019 (orderByComparator == null)) {
7020 pagination = false;
7021 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
7022 finderArgs = new Object[] { groupId, categoryId, lastPostDate };
7023 }
7024 else {
7025 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
7026 finderArgs = new Object[] {
7027 groupId, categoryId, lastPostDate,
7028
7029 start, end, orderByComparator
7030 };
7031 }
7032
7033 List<MBThread> list = null;
7034
7035 if (retrieveFromCache) {
7036 list = (List<MBThread>)finderCache.getResult(finderPath,
7037 finderArgs, this);
7038
7039 if ((list != null) && !list.isEmpty()) {
7040 for (MBThread mbThread : list) {
7041 if ((groupId != mbThread.getGroupId()) ||
7042 (categoryId != mbThread.getCategoryId()) ||
7043 !Validator.equals(lastPostDate,
7044 mbThread.getLastPostDate())) {
7045 list = null;
7046
7047 break;
7048 }
7049 }
7050 }
7051 }
7052
7053 if (list == null) {
7054 StringBundler query = null;
7055
7056 if (orderByComparator != null) {
7057 query = new StringBundler(5 +
7058 (orderByComparator.getOrderByFields().length * 2));
7059 }
7060 else {
7061 query = new StringBundler(5);
7062 }
7063
7064 query.append(_SQL_SELECT_MBTHREAD_WHERE);
7065
7066 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7067
7068 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7069
7070 boolean bindLastPostDate = false;
7071
7072 if (lastPostDate == null) {
7073 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7074 }
7075 else {
7076 bindLastPostDate = true;
7077
7078 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7079 }
7080
7081 if (orderByComparator != null) {
7082 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7083 orderByComparator);
7084 }
7085 else
7086 if (pagination) {
7087 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7088 }
7089
7090 String sql = query.toString();
7091
7092 Session session = null;
7093
7094 try {
7095 session = openSession();
7096
7097 Query q = session.createQuery(sql);
7098
7099 QueryPos qPos = QueryPos.getInstance(q);
7100
7101 qPos.add(groupId);
7102
7103 qPos.add(categoryId);
7104
7105 if (bindLastPostDate) {
7106 qPos.add(new Timestamp(lastPostDate.getTime()));
7107 }
7108
7109 if (!pagination) {
7110 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
7111 start, end, false);
7112
7113 Collections.sort(list);
7114
7115 list = Collections.unmodifiableList(list);
7116 }
7117 else {
7118 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
7119 start, end);
7120 }
7121
7122 cacheResult(list);
7123
7124 finderCache.putResult(finderPath, finderArgs, list);
7125 }
7126 catch (Exception e) {
7127 finderCache.removeResult(finderPath, finderArgs);
7128
7129 throw processException(e);
7130 }
7131 finally {
7132 closeSession(session);
7133 }
7134 }
7135
7136 return list;
7137 }
7138
7139
7149 @Override
7150 public MBThread findByG_C_L_First(long groupId, long categoryId,
7151 Date lastPostDate, OrderByComparator<MBThread> orderByComparator)
7152 throws NoSuchThreadException {
7153 MBThread mbThread = fetchByG_C_L_First(groupId, categoryId,
7154 lastPostDate, orderByComparator);
7155
7156 if (mbThread != null) {
7157 return mbThread;
7158 }
7159
7160 StringBundler msg = new StringBundler(8);
7161
7162 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7163
7164 msg.append("groupId=");
7165 msg.append(groupId);
7166
7167 msg.append(", categoryId=");
7168 msg.append(categoryId);
7169
7170 msg.append(", lastPostDate=");
7171 msg.append(lastPostDate);
7172
7173 msg.append(StringPool.CLOSE_CURLY_BRACE);
7174
7175 throw new NoSuchThreadException(msg.toString());
7176 }
7177
7178
7187 @Override
7188 public MBThread fetchByG_C_L_First(long groupId, long categoryId,
7189 Date lastPostDate, OrderByComparator<MBThread> orderByComparator) {
7190 List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate, 0,
7191 1, orderByComparator);
7192
7193 if (!list.isEmpty()) {
7194 return list.get(0);
7195 }
7196
7197 return null;
7198 }
7199
7200
7210 @Override
7211 public MBThread findByG_C_L_Last(long groupId, long categoryId,
7212 Date lastPostDate, OrderByComparator<MBThread> orderByComparator)
7213 throws NoSuchThreadException {
7214 MBThread mbThread = fetchByG_C_L_Last(groupId, categoryId,
7215 lastPostDate, orderByComparator);
7216
7217 if (mbThread != null) {
7218 return mbThread;
7219 }
7220
7221 StringBundler msg = new StringBundler(8);
7222
7223 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7224
7225 msg.append("groupId=");
7226 msg.append(groupId);
7227
7228 msg.append(", categoryId=");
7229 msg.append(categoryId);
7230
7231 msg.append(", lastPostDate=");
7232 msg.append(lastPostDate);
7233
7234 msg.append(StringPool.CLOSE_CURLY_BRACE);
7235
7236 throw new NoSuchThreadException(msg.toString());
7237 }
7238
7239
7248 @Override
7249 public MBThread fetchByG_C_L_Last(long groupId, long categoryId,
7250 Date lastPostDate, OrderByComparator<MBThread> orderByComparator) {
7251 int count = countByG_C_L(groupId, categoryId, lastPostDate);
7252
7253 if (count == 0) {
7254 return null;
7255 }
7256
7257 List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate,
7258 count - 1, count, orderByComparator);
7259
7260 if (!list.isEmpty()) {
7261 return list.get(0);
7262 }
7263
7264 return null;
7265 }
7266
7267
7278 @Override
7279 public MBThread[] findByG_C_L_PrevAndNext(long threadId, long groupId,
7280 long categoryId, Date lastPostDate,
7281 OrderByComparator<MBThread> orderByComparator)
7282 throws NoSuchThreadException {
7283 MBThread mbThread = findByPrimaryKey(threadId);
7284
7285 Session session = null;
7286
7287 try {
7288 session = openSession();
7289
7290 MBThread[] array = new MBThreadImpl[3];
7291
7292 array[0] = getByG_C_L_PrevAndNext(session, mbThread, groupId,
7293 categoryId, lastPostDate, orderByComparator, true);
7294
7295 array[1] = mbThread;
7296
7297 array[2] = getByG_C_L_PrevAndNext(session, mbThread, groupId,
7298 categoryId, lastPostDate, orderByComparator, false);
7299
7300 return array;
7301 }
7302 catch (Exception e) {
7303 throw processException(e);
7304 }
7305 finally {
7306 closeSession(session);
7307 }
7308 }
7309
7310 protected MBThread getByG_C_L_PrevAndNext(Session session,
7311 MBThread mbThread, long groupId, long categoryId, Date lastPostDate,
7312 OrderByComparator<MBThread> orderByComparator, boolean previous) {
7313 StringBundler query = null;
7314
7315 if (orderByComparator != null) {
7316 query = new StringBundler(6 +
7317 (orderByComparator.getOrderByConditionFields().length * 3) +
7318 (orderByComparator.getOrderByFields().length * 3));
7319 }
7320 else {
7321 query = new StringBundler(5);
7322 }
7323
7324 query.append(_SQL_SELECT_MBTHREAD_WHERE);
7325
7326 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7327
7328 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7329
7330 boolean bindLastPostDate = false;
7331
7332 if (lastPostDate == null) {
7333 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7334 }
7335 else {
7336 bindLastPostDate = true;
7337
7338 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7339 }
7340
7341 if (orderByComparator != null) {
7342 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7343
7344 if (orderByConditionFields.length > 0) {
7345 query.append(WHERE_AND);
7346 }
7347
7348 for (int i = 0; i < orderByConditionFields.length; i++) {
7349 query.append(_ORDER_BY_ENTITY_ALIAS);
7350 query.append(orderByConditionFields[i]);
7351
7352 if ((i + 1) < orderByConditionFields.length) {
7353 if (orderByComparator.isAscending() ^ previous) {
7354 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7355 }
7356 else {
7357 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7358 }
7359 }
7360 else {
7361 if (orderByComparator.isAscending() ^ previous) {
7362 query.append(WHERE_GREATER_THAN);
7363 }
7364 else {
7365 query.append(WHERE_LESSER_THAN);
7366 }
7367 }
7368 }
7369
7370 query.append(ORDER_BY_CLAUSE);
7371
7372 String[] orderByFields = orderByComparator.getOrderByFields();
7373
7374 for (int i = 0; i < orderByFields.length; i++) {
7375 query.append(_ORDER_BY_ENTITY_ALIAS);
7376 query.append(orderByFields[i]);
7377
7378 if ((i + 1) < orderByFields.length) {
7379 if (orderByComparator.isAscending() ^ previous) {
7380 query.append(ORDER_BY_ASC_HAS_NEXT);
7381 }
7382 else {
7383 query.append(ORDER_BY_DESC_HAS_NEXT);
7384 }
7385 }
7386 else {
7387 if (orderByComparator.isAscending() ^ previous) {
7388 query.append(ORDER_BY_ASC);
7389 }
7390 else {
7391 query.append(ORDER_BY_DESC);
7392 }
7393 }
7394 }
7395 }
7396 else {
7397 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7398 }
7399
7400 String sql = query.toString();
7401
7402 Query q = session.createQuery(sql);
7403
7404 q.setFirstResult(0);
7405 q.setMaxResults(2);
7406
7407 QueryPos qPos = QueryPos.getInstance(q);
7408
7409 qPos.add(groupId);
7410
7411 qPos.add(categoryId);
7412
7413 if (bindLastPostDate) {
7414 qPos.add(new Timestamp(lastPostDate.getTime()));
7415 }
7416
7417 if (orderByComparator != null) {
7418 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
7419
7420 for (Object value : values) {
7421 qPos.add(value);
7422 }
7423 }
7424
7425 List<MBThread> list = q.list();
7426
7427 if (list.size() == 2) {
7428 return list.get(1);
7429 }
7430 else {
7431 return null;
7432 }
7433 }
7434
7435
7443 @Override
7444 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
7445 Date lastPostDate) {
7446 return filterFindByG_C_L(groupId, categoryId, lastPostDate,
7447 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7448 }
7449
7450
7464 @Override
7465 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
7466 Date lastPostDate, int start, int end) {
7467 return filterFindByG_C_L(groupId, categoryId, lastPostDate, start, end,
7468 null);
7469 }
7470
7471
7486 @Override
7487 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
7488 Date lastPostDate, int start, int end,
7489 OrderByComparator<MBThread> orderByComparator) {
7490 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7491 return findByG_C_L(groupId, categoryId, lastPostDate, start, end,
7492 orderByComparator);
7493 }
7494
7495 StringBundler query = null;
7496
7497 if (orderByComparator != null) {
7498 query = new StringBundler(5 +
7499 (orderByComparator.getOrderByFields().length * 2));
7500 }
7501 else {
7502 query = new StringBundler(6);
7503 }
7504
7505 if (getDB().isSupportsInlineDistinct()) {
7506 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
7507 }
7508 else {
7509 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
7510 }
7511
7512 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7513
7514 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7515
7516 boolean bindLastPostDate = false;
7517
7518 if (lastPostDate == null) {
7519 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7520 }
7521 else {
7522 bindLastPostDate = true;
7523
7524 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7525 }
7526
7527 if (!getDB().isSupportsInlineDistinct()) {
7528 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
7529 }
7530
7531 if (orderByComparator != null) {
7532 if (getDB().isSupportsInlineDistinct()) {
7533 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7534 orderByComparator, true);
7535 }
7536 else {
7537 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7538 orderByComparator, true);
7539 }
7540 }
7541 else {
7542 if (getDB().isSupportsInlineDistinct()) {
7543 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7544 }
7545 else {
7546 query.append(MBThreadModelImpl.ORDER_BY_SQL);
7547 }
7548 }
7549
7550 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7551 MBThread.class.getName(),
7552 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7553
7554 Session session = null;
7555
7556 try {
7557 session = openSession();
7558
7559 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7560
7561 if (getDB().isSupportsInlineDistinct()) {
7562 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
7563 }
7564 else {
7565 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
7566 }
7567
7568 QueryPos qPos = QueryPos.getInstance(q);
7569
7570 qPos.add(groupId);
7571
7572 qPos.add(categoryId);
7573
7574 if (bindLastPostDate) {
7575 qPos.add(new Timestamp(lastPostDate.getTime()));
7576 }
7577
7578 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
7579 }
7580 catch (Exception e) {
7581 throw processException(e);
7582 }
7583 finally {
7584 closeSession(session);
7585 }
7586 }
7587
7588
7599 @Override
7600 public MBThread[] filterFindByG_C_L_PrevAndNext(long threadId,
7601 long groupId, long categoryId, Date lastPostDate,
7602 OrderByComparator<MBThread> orderByComparator)
7603 throws NoSuchThreadException {
7604 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7605 return findByG_C_L_PrevAndNext(threadId, groupId, categoryId,
7606 lastPostDate, orderByComparator);
7607 }
7608
7609 MBThread mbThread = findByPrimaryKey(threadId);
7610
7611 Session session = null;
7612
7613 try {
7614 session = openSession();
7615
7616 MBThread[] array = new MBThreadImpl[3];
7617
7618 array[0] = filterGetByG_C_L_PrevAndNext(session, mbThread, groupId,
7619 categoryId, lastPostDate, orderByComparator, true);
7620
7621 array[1] = mbThread;
7622
7623 array[2] = filterGetByG_C_L_PrevAndNext(session, mbThread, groupId,
7624 categoryId, lastPostDate, orderByComparator, false);
7625
7626 return array;
7627 }
7628 catch (Exception e) {
7629 throw processException(e);
7630 }
7631 finally {
7632 closeSession(session);
7633 }
7634 }
7635
7636 protected MBThread filterGetByG_C_L_PrevAndNext(Session session,
7637 MBThread mbThread, long groupId, long categoryId, Date lastPostDate,
7638 OrderByComparator<MBThread> orderByComparator, boolean previous) {
7639 StringBundler query = null;
7640
7641 if (orderByComparator != null) {
7642 query = new StringBundler(7 +
7643 (orderByComparator.getOrderByConditionFields().length * 3) +
7644 (orderByComparator.getOrderByFields().length * 3));
7645 }
7646 else {
7647 query = new StringBundler(6);
7648 }
7649
7650 if (getDB().isSupportsInlineDistinct()) {
7651 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
7652 }
7653 else {
7654 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
7655 }
7656
7657 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7658
7659 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7660
7661 boolean bindLastPostDate = false;
7662
7663 if (lastPostDate == null) {
7664 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7665 }
7666 else {
7667 bindLastPostDate = true;
7668
7669 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7670 }
7671
7672 if (!getDB().isSupportsInlineDistinct()) {
7673 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
7674 }
7675
7676 if (orderByComparator != null) {
7677 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7678
7679 if (orderByConditionFields.length > 0) {
7680 query.append(WHERE_AND);
7681 }
7682
7683 for (int i = 0; i < orderByConditionFields.length; i++) {
7684 if (getDB().isSupportsInlineDistinct()) {
7685 query.append(_ORDER_BY_ENTITY_ALIAS);
7686 }
7687 else {
7688 query.append(_ORDER_BY_ENTITY_TABLE);
7689 }
7690
7691 query.append(orderByConditionFields[i]);
7692
7693 if ((i + 1) < orderByConditionFields.length) {
7694 if (orderByComparator.isAscending() ^ previous) {
7695 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7696 }
7697 else {
7698 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7699 }
7700 }
7701 else {
7702 if (orderByComparator.isAscending() ^ previous) {
7703 query.append(WHERE_GREATER_THAN);
7704 }
7705 else {
7706 query.append(WHERE_LESSER_THAN);
7707 }
7708 }
7709 }
7710
7711 query.append(ORDER_BY_CLAUSE);
7712
7713 String[] orderByFields = orderByComparator.getOrderByFields();
7714
7715 for (int i = 0; i < orderByFields.length; i++) {
7716 if (getDB().isSupportsInlineDistinct()) {
7717 query.append(_ORDER_BY_ENTITY_ALIAS);
7718 }
7719 else {
7720 query.append(_ORDER_BY_ENTITY_TABLE);
7721 }
7722
7723 query.append(orderByFields[i]);
7724
7725 if ((i + 1) < orderByFields.length) {
7726 if (orderByComparator.isAscending() ^ previous) {
7727 query.append(ORDER_BY_ASC_HAS_NEXT);
7728 }
7729 else {
7730 query.append(ORDER_BY_DESC_HAS_NEXT);
7731 }
7732 }
7733 else {
7734 if (orderByComparator.isAscending() ^ previous) {
7735 query.append(ORDER_BY_ASC);
7736 }
7737 else {
7738 query.append(ORDER_BY_DESC);
7739 }
7740 }
7741 }
7742 }
7743 else {
7744 if (getDB().isSupportsInlineDistinct()) {
7745 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7746 }
7747 else {
7748 query.append(MBThreadModelImpl.ORDER_BY_SQL);
7749 }
7750 }
7751
7752 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7753 MBThread.class.getName(),
7754 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7755
7756 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7757
7758 q.setFirstResult(0);
7759 q.setMaxResults(2);
7760
7761 if (getDB().isSupportsInlineDistinct()) {
7762 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
7763 }
7764 else {
7765 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
7766 }
7767
7768 QueryPos qPos = QueryPos.getInstance(q);
7769
7770 qPos.add(groupId);
7771
7772 qPos.add(categoryId);
7773
7774 if (bindLastPostDate) {
7775 qPos.add(new Timestamp(lastPostDate.getTime()));
7776 }
7777
7778 if (orderByComparator != null) {
7779 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
7780
7781 for (Object value : values) {
7782 qPos.add(value);
7783 }
7784 }
7785
7786 List<MBThread> list = q.list();
7787
7788 if (list.size() == 2) {
7789 return list.get(1);
7790 }
7791 else {
7792 return null;
7793 }
7794 }
7795
7796
7803 @Override
7804 public void removeByG_C_L(long groupId, long categoryId, Date lastPostDate) {
7805 for (MBThread mbThread : findByG_C_L(groupId, categoryId, lastPostDate,
7806 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7807 remove(mbThread);
7808 }
7809 }
7810
7811
7819 @Override
7820 public int countByG_C_L(long groupId, long categoryId, Date lastPostDate) {
7821 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
7822
7823 Object[] finderArgs = new Object[] { groupId, categoryId, lastPostDate };
7824
7825 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7826
7827 if (count == null) {
7828 StringBundler query = new StringBundler(4);
7829
7830 query.append(_SQL_COUNT_MBTHREAD_WHERE);
7831
7832 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7833
7834 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7835
7836 boolean bindLastPostDate = false;
7837
7838 if (lastPostDate == null) {
7839 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7840 }
7841 else {
7842 bindLastPostDate = true;
7843
7844 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7845 }
7846
7847 String sql = query.toString();
7848
7849 Session session = null;
7850
7851 try {
7852 session = openSession();
7853
7854 Query q = session.createQuery(sql);
7855
7856 QueryPos qPos = QueryPos.getInstance(q);
7857
7858 qPos.add(groupId);
7859
7860 qPos.add(categoryId);
7861
7862 if (bindLastPostDate) {
7863 qPos.add(new Timestamp(lastPostDate.getTime()));
7864 }
7865
7866 count = (Long)q.uniqueResult();
7867
7868 finderCache.putResult(finderPath, finderArgs, count);
7869 }
7870 catch (Exception e) {
7871 finderCache.removeResult(finderPath, finderArgs);
7872
7873 throw processException(e);
7874 }
7875 finally {
7876 closeSession(session);
7877 }
7878 }
7879
7880 return count.intValue();
7881 }
7882
7883
7891 @Override
7892 public int filterCountByG_C_L(long groupId, long categoryId,
7893 Date lastPostDate) {
7894 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7895 return countByG_C_L(groupId, categoryId, lastPostDate);
7896 }
7897
7898 StringBundler query = new StringBundler(4);
7899
7900 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
7901
7902 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7903
7904 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7905
7906 boolean bindLastPostDate = false;
7907
7908 if (lastPostDate == null) {
7909 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7910 }
7911 else {
7912 bindLastPostDate = true;
7913
7914 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7915 }
7916
7917 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7918 MBThread.class.getName(),
7919 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7920
7921 Session session = null;
7922
7923 try {
7924 session = openSession();
7925
7926 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7927
7928 q.addScalar(COUNT_COLUMN_NAME,
7929 com.liferay.portal.kernel.dao.orm.Type.LONG);
7930
7931 QueryPos qPos = QueryPos.getInstance(q);
7932
7933 qPos.add(groupId);
7934
7935 qPos.add(categoryId);
7936
7937 if (bindLastPostDate) {
7938 qPos.add(new Timestamp(lastPostDate.getTime()));
7939 }
7940
7941 Long count = (Long)q.uniqueResult();
7942
7943 return count.intValue();
7944 }
7945 catch (Exception e) {
7946 throw processException(e);
7947 }
7948 finally {
7949 closeSession(session);
7950 }
7951 }
7952
7953 private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "mbThread.groupId = ? AND ";
7954 private static final String _FINDER_COLUMN_G_C_L_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
7955 private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL";
7956 private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_2 = "mbThread.lastPostDate = ?";
7957 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
7958 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
7959 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_S",
7960 new String[] {
7961 Long.class.getName(), Long.class.getName(),
7962 Integer.class.getName(),
7963
7964 Integer.class.getName(), Integer.class.getName(),
7965 OrderByComparator.class.getName()
7966 });
7967 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
7968 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
7969 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_S",
7970 new String[] {
7971 Long.class.getName(), Long.class.getName(),
7972 Integer.class.getName()
7973 },
7974 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
7975 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
7976 MBThreadModelImpl.STATUS_COLUMN_BITMASK |
7977 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
7978 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
7979 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
7980 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
7981 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
7982 new String[] {
7983 Long.class.getName(), Long.class.getName(),
7984 Integer.class.getName()
7985 });
7986 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
7987 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
7988 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_C_S",
7989 new String[] {
7990 Long.class.getName(), Long.class.getName(),
7991 Integer.class.getName()
7992 });
7993
7994
8002 @Override
8003 public List<MBThread> findByG_C_S(long groupId, long categoryId, int status) {
8004 return findByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS,
8005 QueryUtil.ALL_POS, null);
8006 }
8007
8008
8022 @Override
8023 public List<MBThread> findByG_C_S(long groupId, long categoryId,
8024 int status, int start, int end) {
8025 return findByG_C_S(groupId, categoryId, status, start, end, null);
8026 }
8027
8028
8043 @Override
8044 public List<MBThread> findByG_C_S(long groupId, long categoryId,
8045 int status, int start, int end,
8046 OrderByComparator<MBThread> orderByComparator) {
8047 return findByG_C_S(groupId, categoryId, status, start, end,
8048 orderByComparator, true);
8049 }
8050
8051
8067 @Override
8068 public List<MBThread> findByG_C_S(long groupId, long categoryId,
8069 int status, int start, int end,
8070 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
8071 boolean pagination = true;
8072 FinderPath finderPath = null;
8073 Object[] finderArgs = null;
8074
8075 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8076 (orderByComparator == null)) {
8077 pagination = false;
8078 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S;
8079 finderArgs = new Object[] { groupId, categoryId, status };
8080 }
8081 else {
8082 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S;
8083 finderArgs = new Object[] {
8084 groupId, categoryId, status,
8085
8086 start, end, orderByComparator
8087 };
8088 }
8089
8090 List<MBThread> list = null;
8091
8092 if (retrieveFromCache) {
8093 list = (List<MBThread>)finderCache.getResult(finderPath,
8094 finderArgs, this);
8095
8096 if ((list != null) && !list.isEmpty()) {
8097 for (MBThread mbThread : list) {
8098 if ((groupId != mbThread.getGroupId()) ||
8099 (categoryId != mbThread.getCategoryId()) ||
8100 (status != mbThread.getStatus())) {
8101 list = null;
8102
8103 break;
8104 }
8105 }
8106 }
8107 }
8108
8109 if (list == null) {
8110 StringBundler query = null;
8111
8112 if (orderByComparator != null) {
8113 query = new StringBundler(5 +
8114 (orderByComparator.getOrderByFields().length * 2));
8115 }
8116 else {
8117 query = new StringBundler(5);
8118 }
8119
8120 query.append(_SQL_SELECT_MBTHREAD_WHERE);
8121
8122 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8123
8124 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8125
8126 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8127
8128 if (orderByComparator != null) {
8129 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8130 orderByComparator);
8131 }
8132 else
8133 if (pagination) {
8134 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
8135 }
8136
8137 String sql = query.toString();
8138
8139 Session session = null;
8140
8141 try {
8142 session = openSession();
8143
8144 Query q = session.createQuery(sql);
8145
8146 QueryPos qPos = QueryPos.getInstance(q);
8147
8148 qPos.add(groupId);
8149
8150 qPos.add(categoryId);
8151
8152 qPos.add(status);
8153
8154 if (!pagination) {
8155 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
8156 start, end, false);
8157
8158 Collections.sort(list);
8159
8160 list = Collections.unmodifiableList(list);
8161 }
8162 else {
8163 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
8164 start, end);
8165 }
8166
8167 cacheResult(list);
8168
8169 finderCache.putResult(finderPath, finderArgs, list);
8170 }
8171 catch (Exception e) {
8172 finderCache.removeResult(finderPath, finderArgs);
8173
8174 throw processException(e);
8175 }
8176 finally {
8177 closeSession(session);
8178 }
8179 }
8180
8181 return list;
8182 }
8183
8184
8194 @Override
8195 public MBThread findByG_C_S_First(long groupId, long categoryId,
8196 int status, OrderByComparator<MBThread> orderByComparator)
8197 throws NoSuchThreadException {
8198 MBThread mbThread = fetchByG_C_S_First(groupId, categoryId, status,
8199 orderByComparator);
8200
8201 if (mbThread != null) {
8202 return mbThread;
8203 }
8204
8205 StringBundler msg = new StringBundler(8);
8206
8207 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8208
8209 msg.append("groupId=");
8210 msg.append(groupId);
8211
8212 msg.append(", categoryId=");
8213 msg.append(categoryId);
8214
8215 msg.append(", status=");
8216 msg.append(status);
8217
8218 msg.append(StringPool.CLOSE_CURLY_BRACE);
8219
8220 throw new NoSuchThreadException(msg.toString());
8221 }
8222
8223
8232 @Override
8233 public MBThread fetchByG_C_S_First(long groupId, long categoryId,
8234 int status, OrderByComparator<MBThread> orderByComparator) {
8235 List<MBThread> list = findByG_C_S(groupId, categoryId, status, 0, 1,
8236 orderByComparator);
8237
8238 if (!list.isEmpty()) {
8239 return list.get(0);
8240 }
8241
8242 return null;
8243 }
8244
8245
8255 @Override
8256 public MBThread findByG_C_S_Last(long groupId, long categoryId, int status,
8257 OrderByComparator<MBThread> orderByComparator)
8258 throws NoSuchThreadException {
8259 MBThread mbThread = fetchByG_C_S_Last(groupId, categoryId, status,
8260 orderByComparator);
8261
8262 if (mbThread != null) {
8263 return mbThread;
8264 }
8265
8266 StringBundler msg = new StringBundler(8);
8267
8268 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8269
8270 msg.append("groupId=");
8271 msg.append(groupId);
8272
8273 msg.append(", categoryId=");
8274 msg.append(categoryId);
8275
8276 msg.append(", status=");
8277 msg.append(status);
8278
8279 msg.append(StringPool.CLOSE_CURLY_BRACE);
8280
8281 throw new NoSuchThreadException(msg.toString());
8282 }
8283
8284
8293 @Override
8294 public MBThread fetchByG_C_S_Last(long groupId, long categoryId,
8295 int status, OrderByComparator<MBThread> orderByComparator) {
8296 int count = countByG_C_S(groupId, categoryId, status);
8297
8298 if (count == 0) {
8299 return null;
8300 }
8301
8302 List<MBThread> list = findByG_C_S(groupId, categoryId, status,
8303 count - 1, count, orderByComparator);
8304
8305 if (!list.isEmpty()) {
8306 return list.get(0);
8307 }
8308
8309 return null;
8310 }
8311
8312
8323 @Override
8324 public MBThread[] findByG_C_S_PrevAndNext(long threadId, long groupId,
8325 long categoryId, int status,
8326 OrderByComparator<MBThread> orderByComparator)
8327 throws NoSuchThreadException {
8328 MBThread mbThread = findByPrimaryKey(threadId);
8329
8330 Session session = null;
8331
8332 try {
8333 session = openSession();
8334
8335 MBThread[] array = new MBThreadImpl[3];
8336
8337 array[0] = getByG_C_S_PrevAndNext(session, mbThread, groupId,
8338 categoryId, status, orderByComparator, true);
8339
8340 array[1] = mbThread;
8341
8342 array[2] = getByG_C_S_PrevAndNext(session, mbThread, groupId,
8343 categoryId, status, orderByComparator, false);
8344
8345 return array;
8346 }
8347 catch (Exception e) {
8348 throw processException(e);
8349 }
8350 finally {
8351 closeSession(session);
8352 }
8353 }
8354
8355 protected MBThread getByG_C_S_PrevAndNext(Session session,
8356 MBThread mbThread, long groupId, long categoryId, int status,
8357 OrderByComparator<MBThread> orderByComparator, boolean previous) {
8358 StringBundler query = null;
8359
8360 if (orderByComparator != null) {
8361 query = new StringBundler(6 +
8362 (orderByComparator.getOrderByConditionFields().length * 3) +
8363 (orderByComparator.getOrderByFields().length * 3));
8364 }
8365 else {
8366 query = new StringBundler(5);
8367 }
8368
8369 query.append(_SQL_SELECT_MBTHREAD_WHERE);
8370
8371 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8372
8373 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8374
8375 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8376
8377 if (orderByComparator != null) {
8378 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8379
8380 if (orderByConditionFields.length > 0) {
8381 query.append(WHERE_AND);
8382 }
8383
8384 for (int i = 0; i < orderByConditionFields.length; i++) {
8385 query.append(_ORDER_BY_ENTITY_ALIAS);
8386 query.append(orderByConditionFields[i]);
8387
8388 if ((i + 1) < orderByConditionFields.length) {
8389 if (orderByComparator.isAscending() ^ previous) {
8390 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8391 }
8392 else {
8393 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8394 }
8395 }
8396 else {
8397 if (orderByComparator.isAscending() ^ previous) {
8398 query.append(WHERE_GREATER_THAN);
8399 }
8400 else {
8401 query.append(WHERE_LESSER_THAN);
8402 }
8403 }
8404 }
8405
8406 query.append(ORDER_BY_CLAUSE);
8407
8408 String[] orderByFields = orderByComparator.getOrderByFields();
8409
8410 for (int i = 0; i < orderByFields.length; i++) {
8411 query.append(_ORDER_BY_ENTITY_ALIAS);
8412 query.append(orderByFields[i]);
8413
8414 if ((i + 1) < orderByFields.length) {
8415 if (orderByComparator.isAscending() ^ previous) {
8416 query.append(ORDER_BY_ASC_HAS_NEXT);
8417 }
8418 else {
8419 query.append(ORDER_BY_DESC_HAS_NEXT);
8420 }
8421 }
8422 else {
8423 if (orderByComparator.isAscending() ^ previous) {
8424 query.append(ORDER_BY_ASC);
8425 }
8426 else {
8427 query.append(ORDER_BY_DESC);
8428 }
8429 }
8430 }
8431 }
8432 else {
8433 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
8434 }
8435
8436 String sql = query.toString();
8437
8438 Query q = session.createQuery(sql);
8439
8440 q.setFirstResult(0);
8441 q.setMaxResults(2);
8442
8443 QueryPos qPos = QueryPos.getInstance(q);
8444
8445 qPos.add(groupId);
8446
8447 qPos.add(categoryId);
8448
8449 qPos.add(status);
8450
8451 if (orderByComparator != null) {
8452 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
8453
8454 for (Object value : values) {
8455 qPos.add(value);
8456 }
8457 }
8458
8459 List<MBThread> list = q.list();
8460
8461 if (list.size() == 2) {
8462 return list.get(1);
8463 }
8464 else {
8465 return null;
8466 }
8467 }
8468
8469
8477 @Override
8478 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
8479 int status) {
8480 return filterFindByG_C_S(groupId, categoryId, status,
8481 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8482 }
8483
8484
8498 @Override
8499 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
8500 int status, int start, int end) {
8501 return filterFindByG_C_S(groupId, categoryId, status, start, end, null);
8502 }
8503
8504
8519 @Override
8520 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
8521 int status, int start, int end,
8522 OrderByComparator<MBThread> orderByComparator) {
8523 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8524 return findByG_C_S(groupId, categoryId, status, start, end,
8525 orderByComparator);
8526 }
8527
8528 StringBundler query = null;
8529
8530 if (orderByComparator != null) {
8531 query = new StringBundler(5 +
8532 (orderByComparator.getOrderByFields().length * 2));
8533 }
8534 else {
8535 query = new StringBundler(6);
8536 }
8537
8538 if (getDB().isSupportsInlineDistinct()) {
8539 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
8540 }
8541 else {
8542 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
8543 }
8544
8545 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8546
8547 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8548
8549 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8550
8551 if (!getDB().isSupportsInlineDistinct()) {
8552 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
8553 }
8554
8555 if (orderByComparator != null) {
8556 if (getDB().isSupportsInlineDistinct()) {
8557 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8558 orderByComparator, true);
8559 }
8560 else {
8561 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8562 orderByComparator, true);
8563 }
8564 }
8565 else {
8566 if (getDB().isSupportsInlineDistinct()) {
8567 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
8568 }
8569 else {
8570 query.append(MBThreadModelImpl.ORDER_BY_SQL);
8571 }
8572 }
8573
8574 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8575 MBThread.class.getName(),
8576 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8577
8578 Session session = null;
8579
8580 try {
8581 session = openSession();
8582
8583 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8584
8585 if (getDB().isSupportsInlineDistinct()) {
8586 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
8587 }
8588 else {
8589 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
8590 }
8591
8592 QueryPos qPos = QueryPos.getInstance(q);
8593
8594 qPos.add(groupId);
8595
8596 qPos.add(categoryId);
8597
8598 qPos.add(status);
8599
8600 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
8601 }
8602 catch (Exception e) {
8603 throw processException(e);
8604 }
8605 finally {
8606 closeSession(session);
8607 }
8608 }
8609
8610
8621 @Override
8622 public MBThread[] filterFindByG_C_S_PrevAndNext(long threadId,
8623 long groupId, long categoryId, int status,
8624 OrderByComparator<MBThread> orderByComparator)
8625 throws NoSuchThreadException {
8626 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8627 return findByG_C_S_PrevAndNext(threadId, groupId, categoryId,
8628 status, orderByComparator);
8629 }
8630
8631 MBThread mbThread = findByPrimaryKey(threadId);
8632
8633 Session session = null;
8634
8635 try {
8636 session = openSession();
8637
8638 MBThread[] array = new MBThreadImpl[3];
8639
8640 array[0] = filterGetByG_C_S_PrevAndNext(session, mbThread, groupId,
8641 categoryId, status, orderByComparator, true);
8642
8643 array[1] = mbThread;
8644
8645 array[2] = filterGetByG_C_S_PrevAndNext(session, mbThread, groupId,
8646 categoryId, status, orderByComparator, false);
8647
8648 return array;
8649 }
8650 catch (Exception e) {
8651 throw processException(e);
8652 }
8653 finally {
8654 closeSession(session);
8655 }
8656 }
8657
8658 protected MBThread filterGetByG_C_S_PrevAndNext(Session session,
8659 MBThread mbThread, long groupId, long categoryId, int status,
8660 OrderByComparator<MBThread> orderByComparator, boolean previous) {
8661 StringBundler query = null;
8662
8663 if (orderByComparator != null) {
8664 query = new StringBundler(7 +
8665 (orderByComparator.getOrderByConditionFields().length * 3) +
8666 (orderByComparator.getOrderByFields().length * 3));
8667 }
8668 else {
8669 query = new StringBundler(6);
8670 }
8671
8672 if (getDB().isSupportsInlineDistinct()) {
8673 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
8674 }
8675 else {
8676 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
8677 }
8678
8679 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8680
8681 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8682
8683 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8684
8685 if (!getDB().isSupportsInlineDistinct()) {
8686 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
8687 }
8688
8689 if (orderByComparator != null) {
8690 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8691
8692 if (orderByConditionFields.length > 0) {
8693 query.append(WHERE_AND);
8694 }
8695
8696 for (int i = 0; i < orderByConditionFields.length; i++) {
8697 if (getDB().isSupportsInlineDistinct()) {
8698 query.append(_ORDER_BY_ENTITY_ALIAS);
8699 }
8700 else {
8701 query.append(_ORDER_BY_ENTITY_TABLE);
8702 }
8703
8704 query.append(orderByConditionFields[i]);
8705
8706 if ((i + 1) < orderByConditionFields.length) {
8707 if (orderByComparator.isAscending() ^ previous) {
8708 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8709 }
8710 else {
8711 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8712 }
8713 }
8714 else {
8715 if (orderByComparator.isAscending() ^ previous) {
8716 query.append(WHERE_GREATER_THAN);
8717 }
8718 else {
8719 query.append(WHERE_LESSER_THAN);
8720 }
8721 }
8722 }
8723
8724 query.append(ORDER_BY_CLAUSE);
8725
8726 String[] orderByFields = orderByComparator.getOrderByFields();
8727
8728 for (int i = 0; i < orderByFields.length; i++) {
8729 if (getDB().isSupportsInlineDistinct()) {
8730 query.append(_ORDER_BY_ENTITY_ALIAS);
8731 }
8732 else {
8733 query.append(_ORDER_BY_ENTITY_TABLE);
8734 }
8735
8736 query.append(orderByFields[i]);
8737
8738 if ((i + 1) < orderByFields.length) {
8739 if (orderByComparator.isAscending() ^ previous) {
8740 query.append(ORDER_BY_ASC_HAS_NEXT);
8741 }
8742 else {
8743 query.append(ORDER_BY_DESC_HAS_NEXT);
8744 }
8745 }
8746 else {
8747 if (orderByComparator.isAscending() ^ previous) {
8748 query.append(ORDER_BY_ASC);
8749 }
8750 else {
8751 query.append(ORDER_BY_DESC);
8752 }
8753 }
8754 }
8755 }
8756 else {
8757 if (getDB().isSupportsInlineDistinct()) {
8758 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
8759 }
8760 else {
8761 query.append(MBThreadModelImpl.ORDER_BY_SQL);
8762 }
8763 }
8764
8765 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8766 MBThread.class.getName(),
8767 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8768
8769 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8770
8771 q.setFirstResult(0);
8772 q.setMaxResults(2);
8773
8774 if (getDB().isSupportsInlineDistinct()) {
8775 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
8776 }
8777 else {
8778 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
8779 }
8780
8781 QueryPos qPos = QueryPos.getInstance(q);
8782
8783 qPos.add(groupId);
8784
8785 qPos.add(categoryId);
8786
8787 qPos.add(status);
8788
8789 if (orderByComparator != null) {
8790 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
8791
8792 for (Object value : values) {
8793 qPos.add(value);
8794 }
8795 }
8796
8797 List<MBThread> list = q.list();
8798
8799 if (list.size() == 2) {
8800 return list.get(1);
8801 }
8802 else {
8803 return null;
8804 }
8805 }
8806
8807
8815 @Override
8816 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
8817 int status) {
8818 return filterFindByG_C_S(groupId, categoryIds, status,
8819 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8820 }
8821
8822
8836 @Override
8837 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
8838 int status, int start, int end) {
8839 return filterFindByG_C_S(groupId, categoryIds, status, start, end, null);
8840 }
8841
8842
8857 @Override
8858 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
8859 int status, int start, int end,
8860 OrderByComparator<MBThread> orderByComparator) {
8861 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8862 return findByG_C_S(groupId, categoryIds, status, start, end,
8863 orderByComparator);
8864 }
8865
8866 if (categoryIds == null) {
8867 categoryIds = new long[0];
8868 }
8869 else if (categoryIds.length > 1) {
8870 categoryIds = ArrayUtil.unique(categoryIds);
8871
8872 Arrays.sort(categoryIds);
8873 }
8874
8875 StringBundler query = new StringBundler();
8876
8877 if (getDB().isSupportsInlineDistinct()) {
8878 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
8879 }
8880 else {
8881 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
8882 }
8883
8884 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8885
8886 if (categoryIds.length > 0) {
8887 query.append(StringPool.OPEN_PARENTHESIS);
8888
8889 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_7);
8890
8891 query.append(StringUtil.merge(categoryIds));
8892
8893 query.append(StringPool.CLOSE_PARENTHESIS);
8894
8895 query.append(StringPool.CLOSE_PARENTHESIS);
8896
8897 query.append(WHERE_AND);
8898 }
8899
8900 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8901
8902 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8903 query.index() - 1);
8904
8905 if (!getDB().isSupportsInlineDistinct()) {
8906 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
8907 }
8908
8909 if (orderByComparator != null) {
8910 if (getDB().isSupportsInlineDistinct()) {
8911 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8912 orderByComparator, true);
8913 }
8914 else {
8915 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8916 orderByComparator, true);
8917 }
8918 }
8919 else {
8920 if (getDB().isSupportsInlineDistinct()) {
8921 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
8922 }
8923 else {
8924 query.append(MBThreadModelImpl.ORDER_BY_SQL);
8925 }
8926 }
8927
8928 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8929 MBThread.class.getName(),
8930 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8931
8932 Session session = null;
8933
8934 try {
8935 session = openSession();
8936
8937 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8938
8939 if (getDB().isSupportsInlineDistinct()) {
8940 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
8941 }
8942 else {
8943 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
8944 }
8945
8946 QueryPos qPos = QueryPos.getInstance(q);
8947
8948 qPos.add(groupId);
8949
8950 qPos.add(status);
8951
8952 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
8953 }
8954 catch (Exception e) {
8955 throw processException(e);
8956 }
8957 finally {
8958 closeSession(session);
8959 }
8960 }
8961
8962
8974 @Override
8975 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
8976 int status) {
8977 return findByG_C_S(groupId, categoryIds, status, QueryUtil.ALL_POS,
8978 QueryUtil.ALL_POS, null);
8979 }
8980
8981
8995 @Override
8996 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
8997 int status, int start, int end) {
8998 return findByG_C_S(groupId, categoryIds, status, start, end, null);
8999 }
9000
9001
9016 @Override
9017 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
9018 int status, int start, int end,
9019 OrderByComparator<MBThread> orderByComparator) {
9020 return findByG_C_S(groupId, categoryIds, status, start, end,
9021 orderByComparator, true);
9022 }
9023
9024
9040 @Override
9041 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
9042 int status, int start, int end,
9043 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
9044 if (categoryIds == null) {
9045 categoryIds = new long[0];
9046 }
9047 else if (categoryIds.length > 1) {
9048 categoryIds = ArrayUtil.unique(categoryIds);
9049
9050 Arrays.sort(categoryIds);
9051 }
9052
9053 if (categoryIds.length == 1) {
9054 return findByG_C_S(groupId, categoryIds[0], status, start, end,
9055 orderByComparator);
9056 }
9057
9058 boolean pagination = true;
9059 Object[] finderArgs = null;
9060
9061 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9062 (orderByComparator == null)) {
9063 pagination = false;
9064 finderArgs = new Object[] {
9065 groupId, StringUtil.merge(categoryIds), status
9066 };
9067 }
9068 else {
9069 finderArgs = new Object[] {
9070 groupId, StringUtil.merge(categoryIds), status,
9071
9072 start, end, orderByComparator
9073 };
9074 }
9075
9076 List<MBThread> list = null;
9077
9078 if (retrieveFromCache) {
9079 list = (List<MBThread>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S,
9080 finderArgs, this);
9081
9082 if ((list != null) && !list.isEmpty()) {
9083 for (MBThread mbThread : list) {
9084 if ((groupId != mbThread.getGroupId()) ||
9085 !ArrayUtil.contains(categoryIds,
9086 mbThread.getCategoryId()) ||
9087 (status != mbThread.getStatus())) {
9088 list = null;
9089
9090 break;
9091 }
9092 }
9093 }
9094 }
9095
9096 if (list == null) {
9097 StringBundler query = new StringBundler();
9098
9099 query.append(_SQL_SELECT_MBTHREAD_WHERE);
9100
9101 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9102
9103 if (categoryIds.length > 0) {
9104 query.append(StringPool.OPEN_PARENTHESIS);
9105
9106 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_7);
9107
9108 query.append(StringUtil.merge(categoryIds));
9109
9110 query.append(StringPool.CLOSE_PARENTHESIS);
9111
9112 query.append(StringPool.CLOSE_PARENTHESIS);
9113
9114 query.append(WHERE_AND);
9115 }
9116
9117 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9118
9119 query.setStringAt(removeConjunction(query.stringAt(query.index() -
9120 1)), query.index() - 1);
9121
9122 if (orderByComparator != null) {
9123 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9124 orderByComparator);
9125 }
9126 else
9127 if (pagination) {
9128 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
9129 }
9130
9131 String sql = query.toString();
9132
9133 Session session = null;
9134
9135 try {
9136 session = openSession();
9137
9138 Query q = session.createQuery(sql);
9139
9140 QueryPos qPos = QueryPos.getInstance(q);
9141
9142 qPos.add(groupId);
9143
9144 qPos.add(status);
9145
9146 if (!pagination) {
9147 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
9148 start, end, false);
9149
9150 Collections.sort(list);
9151
9152 list = Collections.unmodifiableList(list);
9153 }
9154 else {
9155 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
9156 start, end);
9157 }
9158
9159 cacheResult(list);
9160
9161 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S,
9162 finderArgs, list);
9163 }
9164 catch (Exception e) {
9165 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S,
9166 finderArgs);
9167
9168 throw processException(e);
9169 }
9170 finally {
9171 closeSession(session);
9172 }
9173 }
9174
9175 return list;
9176 }
9177
9178
9185 @Override
9186 public void removeByG_C_S(long groupId, long categoryId, int status) {
9187 for (MBThread mbThread : findByG_C_S(groupId, categoryId, status,
9188 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9189 remove(mbThread);
9190 }
9191 }
9192
9193
9201 @Override
9202 public int countByG_C_S(long groupId, long categoryId, int status) {
9203 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
9204
9205 Object[] finderArgs = new Object[] { groupId, categoryId, status };
9206
9207 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9208
9209 if (count == null) {
9210 StringBundler query = new StringBundler(4);
9211
9212 query.append(_SQL_COUNT_MBTHREAD_WHERE);
9213
9214 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9215
9216 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
9217
9218 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9219
9220 String sql = query.toString();
9221
9222 Session session = null;
9223
9224 try {
9225 session = openSession();
9226
9227 Query q = session.createQuery(sql);
9228
9229 QueryPos qPos = QueryPos.getInstance(q);
9230
9231 qPos.add(groupId);
9232
9233 qPos.add(categoryId);
9234
9235 qPos.add(status);
9236
9237 count = (Long)q.uniqueResult();
9238
9239 finderCache.putResult(finderPath, finderArgs, count);
9240 }
9241 catch (Exception e) {
9242 finderCache.removeResult(finderPath, finderArgs);
9243
9244 throw processException(e);
9245 }
9246 finally {
9247 closeSession(session);
9248 }
9249 }
9250
9251 return count.intValue();
9252 }
9253
9254
9262 @Override
9263 public int countByG_C_S(long groupId, long[] categoryIds, int status) {
9264 if (categoryIds == null) {
9265 categoryIds = new long[0];
9266 }
9267 else if (categoryIds.length > 1) {
9268 categoryIds = ArrayUtil.unique(categoryIds);
9269
9270 Arrays.sort(categoryIds);
9271 }
9272
9273 Object[] finderArgs = new Object[] {
9274 groupId, StringUtil.merge(categoryIds), status
9275 };
9276
9277 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S,
9278 finderArgs, this);
9279
9280 if (count == null) {
9281 StringBundler query = new StringBundler();
9282
9283 query.append(_SQL_COUNT_MBTHREAD_WHERE);
9284
9285 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9286
9287 if (categoryIds.length > 0) {
9288 query.append(StringPool.OPEN_PARENTHESIS);
9289
9290 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_7);
9291
9292 query.append(StringUtil.merge(categoryIds));
9293
9294 query.append(StringPool.CLOSE_PARENTHESIS);
9295
9296 query.append(StringPool.CLOSE_PARENTHESIS);
9297
9298 query.append(WHERE_AND);
9299 }
9300
9301 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9302
9303 query.setStringAt(removeConjunction(query.stringAt(query.index() -
9304 1)), query.index() - 1);
9305
9306 String sql = query.toString();
9307
9308 Session session = null;
9309
9310 try {
9311 session = openSession();
9312
9313 Query q = session.createQuery(sql);
9314
9315 QueryPos qPos = QueryPos.getInstance(q);
9316
9317 qPos.add(groupId);
9318
9319 qPos.add(status);
9320
9321 count = (Long)q.uniqueResult();
9322
9323 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S,
9324 finderArgs, count);
9325 }
9326 catch (Exception e) {
9327 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S,
9328 finderArgs);
9329
9330 throw processException(e);
9331 }
9332 finally {
9333 closeSession(session);
9334 }
9335 }
9336
9337 return count.intValue();
9338 }
9339
9340
9348 @Override
9349 public int filterCountByG_C_S(long groupId, long categoryId, int status) {
9350 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9351 return countByG_C_S(groupId, categoryId, status);
9352 }
9353
9354 StringBundler query = new StringBundler(4);
9355
9356 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
9357
9358 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9359
9360 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
9361
9362 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9363
9364 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9365 MBThread.class.getName(),
9366 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9367
9368 Session session = null;
9369
9370 try {
9371 session = openSession();
9372
9373 SQLQuery q = session.createSynchronizedSQLQuery(sql);
9374
9375 q.addScalar(COUNT_COLUMN_NAME,
9376 com.liferay.portal.kernel.dao.orm.Type.LONG);
9377
9378 QueryPos qPos = QueryPos.getInstance(q);
9379
9380 qPos.add(groupId);
9381
9382 qPos.add(categoryId);
9383
9384 qPos.add(status);
9385
9386 Long count = (Long)q.uniqueResult();
9387
9388 return count.intValue();
9389 }
9390 catch (Exception e) {
9391 throw processException(e);
9392 }
9393 finally {
9394 closeSession(session);
9395 }
9396 }
9397
9398
9406 @Override
9407 public int filterCountByG_C_S(long groupId, long[] categoryIds, int status) {
9408 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9409 return countByG_C_S(groupId, categoryIds, status);
9410 }
9411
9412 if (categoryIds == null) {
9413 categoryIds = new long[0];
9414 }
9415 else if (categoryIds.length > 1) {
9416 categoryIds = ArrayUtil.unique(categoryIds);
9417
9418 Arrays.sort(categoryIds);
9419 }
9420
9421 StringBundler query = new StringBundler();
9422
9423 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
9424
9425 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9426
9427 if (categoryIds.length > 0) {
9428 query.append(StringPool.OPEN_PARENTHESIS);
9429
9430 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_7);
9431
9432 query.append(StringUtil.merge(categoryIds));
9433
9434 query.append(StringPool.CLOSE_PARENTHESIS);
9435
9436 query.append(StringPool.CLOSE_PARENTHESIS);
9437
9438 query.append(WHERE_AND);
9439 }
9440
9441 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9442
9443 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
9444 query.index() - 1);
9445
9446 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9447 MBThread.class.getName(),
9448 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9449
9450 Session session = null;
9451
9452 try {
9453 session = openSession();
9454
9455 SQLQuery q = session.createSynchronizedSQLQuery(sql);
9456
9457 q.addScalar(COUNT_COLUMN_NAME,
9458 com.liferay.portal.kernel.dao.orm.Type.LONG);
9459
9460 QueryPos qPos = QueryPos.getInstance(q);
9461
9462 qPos.add(groupId);
9463
9464 qPos.add(status);
9465
9466 Long count = (Long)q.uniqueResult();
9467
9468 return count.intValue();
9469 }
9470 catch (Exception e) {
9471 throw processException(e);
9472 }
9473 finally {
9474 closeSession(session);
9475 }
9476 }
9477
9478 private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "mbThread.groupId = ? AND ";
9479 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
9480 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_7 = "mbThread.categoryId IN (";
9481 private static final String _FINDER_COLUMN_G_C_S_STATUS_2 = "mbThread.status = ?";
9482 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_NOTS = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
9483 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
9484 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_NotS",
9485 new String[] {
9486 Long.class.getName(), Long.class.getName(),
9487 Integer.class.getName(),
9488
9489 Integer.class.getName(), Integer.class.getName(),
9490 OrderByComparator.class.getName()
9491 });
9492 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_NOTS =
9493 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
9494 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
9495 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_C_NotS",
9496 new String[] {
9497 Long.class.getName(), Long.class.getName(),
9498 Integer.class.getName()
9499 });
9500
9501
9509 @Override
9510 public List<MBThread> findByG_C_NotS(long groupId, long categoryId,
9511 int status) {
9512 return findByG_C_NotS(groupId, categoryId, status, QueryUtil.ALL_POS,
9513 QueryUtil.ALL_POS, null);
9514 }
9515
9516
9530 @Override
9531 public List<MBThread> findByG_C_NotS(long groupId, long categoryId,
9532 int status, int start, int end) {
9533 return findByG_C_NotS(groupId, categoryId, status, start, end, null);
9534 }
9535
9536
9551 @Override
9552 public List<MBThread> findByG_C_NotS(long groupId, long categoryId,
9553 int status, int start, int end,
9554 OrderByComparator<MBThread> orderByComparator) {
9555 return findByG_C_NotS(groupId, categoryId, status, start, end,
9556 orderByComparator, true);
9557 }
9558
9559
9575 @Override
9576 public List<MBThread> findByG_C_NotS(long groupId, long categoryId,
9577 int status, int start, int end,
9578 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
9579 boolean pagination = true;
9580 FinderPath finderPath = null;
9581 Object[] finderArgs = null;
9582
9583 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_NOTS;
9584 finderArgs = new Object[] {
9585 groupId, categoryId, status,
9586
9587 start, end, orderByComparator
9588 };
9589
9590 List<MBThread> list = null;
9591
9592 if (retrieveFromCache) {
9593 list = (List<MBThread>)finderCache.getResult(finderPath,
9594 finderArgs, this);
9595
9596 if ((list != null) && !list.isEmpty()) {
9597 for (MBThread mbThread : list) {
9598 if ((groupId != mbThread.getGroupId()) ||
9599 (categoryId != mbThread.getCategoryId()) ||
9600 (status == mbThread.getStatus())) {
9601 list = null;
9602
9603 break;
9604 }
9605 }
9606 }
9607 }
9608
9609 if (list == null) {
9610 StringBundler query = null;
9611
9612 if (orderByComparator != null) {
9613 query = new StringBundler(5 +
9614 (orderByComparator.getOrderByFields().length * 2));
9615 }
9616 else {
9617 query = new StringBundler(5);
9618 }
9619
9620 query.append(_SQL_SELECT_MBTHREAD_WHERE);
9621
9622 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
9623
9624 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
9625
9626 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
9627
9628 if (orderByComparator != null) {
9629 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9630 orderByComparator);
9631 }
9632 else
9633 if (pagination) {
9634 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
9635 }
9636
9637 String sql = query.toString();
9638
9639 Session session = null;
9640
9641 try {
9642 session = openSession();
9643
9644 Query q = session.createQuery(sql);
9645
9646 QueryPos qPos = QueryPos.getInstance(q);
9647
9648 qPos.add(groupId);
9649
9650 qPos.add(categoryId);
9651
9652 qPos.add(status);
9653
9654 if (!pagination) {
9655 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
9656 start, end, false);
9657
9658 Collections.sort(list);
9659
9660 list = Collections.unmodifiableList(list);
9661 }
9662 else {
9663 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
9664 start, end);
9665 }
9666
9667 cacheResult(list);
9668
9669 finderCache.putResult(finderPath, finderArgs, list);
9670 }
9671 catch (Exception e) {
9672 finderCache.removeResult(finderPath, finderArgs);
9673
9674 throw processException(e);
9675 }
9676 finally {
9677 closeSession(session);
9678 }
9679 }
9680
9681 return list;
9682 }
9683
9684
9694 @Override
9695 public MBThread findByG_C_NotS_First(long groupId, long categoryId,
9696 int status, OrderByComparator<MBThread> orderByComparator)
9697 throws NoSuchThreadException {
9698 MBThread mbThread = fetchByG_C_NotS_First(groupId, categoryId, status,
9699 orderByComparator);
9700
9701 if (mbThread != null) {
9702 return mbThread;
9703 }
9704
9705 StringBundler msg = new StringBundler(8);
9706
9707 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9708
9709 msg.append("groupId=");
9710 msg.append(groupId);
9711
9712 msg.append(", categoryId=");
9713 msg.append(categoryId);
9714
9715 msg.append(", status=");
9716 msg.append(status);
9717
9718 msg.append(StringPool.CLOSE_CURLY_BRACE);
9719
9720 throw new NoSuchThreadException(msg.toString());
9721 }
9722
9723
9732 @Override
9733 public MBThread fetchByG_C_NotS_First(long groupId, long categoryId,
9734 int status, OrderByComparator<MBThread> orderByComparator) {
9735 List<MBThread> list = findByG_C_NotS(groupId, categoryId, status, 0, 1,
9736 orderByComparator);
9737
9738 if (!list.isEmpty()) {
9739 return list.get(0);
9740 }
9741
9742 return null;
9743 }
9744
9745
9755 @Override
9756 public MBThread findByG_C_NotS_Last(long groupId, long categoryId,
9757 int status, OrderByComparator<MBThread> orderByComparator)
9758 throws NoSuchThreadException {
9759 MBThread mbThread = fetchByG_C_NotS_Last(groupId, categoryId, status,
9760 orderByComparator);
9761
9762 if (mbThread != null) {
9763 return mbThread;
9764 }
9765
9766 StringBundler msg = new StringBundler(8);
9767
9768 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9769
9770 msg.append("groupId=");
9771 msg.append(groupId);
9772
9773 msg.append(", categoryId=");
9774 msg.append(categoryId);
9775
9776 msg.append(", status=");
9777 msg.append(status);
9778
9779 msg.append(StringPool.CLOSE_CURLY_BRACE);
9780
9781 throw new NoSuchThreadException(msg.toString());
9782 }
9783
9784
9793 @Override
9794 public MBThread fetchByG_C_NotS_Last(long groupId, long categoryId,
9795 int status, OrderByComparator<MBThread> orderByComparator) {
9796 int count = countByG_C_NotS(groupId, categoryId, status);
9797
9798 if (count == 0) {
9799 return null;
9800 }
9801
9802 List<MBThread> list = findByG_C_NotS(groupId, categoryId, status,
9803 count - 1, count, orderByComparator);
9804
9805 if (!list.isEmpty()) {
9806 return list.get(0);
9807 }
9808
9809 return null;
9810 }
9811
9812
9823 @Override
9824 public MBThread[] findByG_C_NotS_PrevAndNext(long threadId, long groupId,
9825 long categoryId, int status,
9826 OrderByComparator<MBThread> orderByComparator)
9827 throws NoSuchThreadException {
9828 MBThread mbThread = findByPrimaryKey(threadId);
9829
9830 Session session = null;
9831
9832 try {
9833 session = openSession();
9834
9835 MBThread[] array = new MBThreadImpl[3];
9836
9837 array[0] = getByG_C_NotS_PrevAndNext(session, mbThread, groupId,
9838 categoryId, status, orderByComparator, true);
9839
9840 array[1] = mbThread;
9841
9842 array[2] = getByG_C_NotS_PrevAndNext(session, mbThread, groupId,
9843 categoryId, status, orderByComparator, false);
9844
9845 return array;
9846 }
9847 catch (Exception e) {
9848 throw processException(e);
9849 }
9850 finally {
9851 closeSession(session);
9852 }
9853 }
9854
9855 protected MBThread getByG_C_NotS_PrevAndNext(Session session,
9856 MBThread mbThread, long groupId, long categoryId, int status,
9857 OrderByComparator<MBThread> orderByComparator, boolean previous) {
9858 StringBundler query = null;
9859
9860 if (orderByComparator != null) {
9861 query = new StringBundler(6 +
9862 (orderByComparator.getOrderByConditionFields().length * 3) +
9863 (orderByComparator.getOrderByFields().length * 3));
9864 }
9865 else {
9866 query = new StringBundler(5);
9867 }
9868
9869 query.append(_SQL_SELECT_MBTHREAD_WHERE);
9870
9871 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
9872
9873 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
9874
9875 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
9876
9877 if (orderByComparator != null) {
9878 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9879
9880 if (orderByConditionFields.length > 0) {
9881 query.append(WHERE_AND);
9882 }
9883
9884 for (int i = 0; i < orderByConditionFields.length; i++) {
9885 query.append(_ORDER_BY_ENTITY_ALIAS);
9886 query.append(orderByConditionFields[i]);
9887
9888 if ((i + 1) < orderByConditionFields.length) {
9889 if (orderByComparator.isAscending() ^ previous) {
9890 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9891 }
9892 else {
9893 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9894 }
9895 }
9896 else {
9897 if (orderByComparator.isAscending() ^ previous) {
9898 query.append(WHERE_GREATER_THAN);
9899 }
9900 else {
9901 query.append(WHERE_LESSER_THAN);
9902 }
9903 }
9904 }
9905
9906 query.append(ORDER_BY_CLAUSE);
9907
9908 String[] orderByFields = orderByComparator.getOrderByFields();
9909
9910 for (int i = 0; i < orderByFields.length; i++) {
9911 query.append(_ORDER_BY_ENTITY_ALIAS);
9912 query.append(orderByFields[i]);
9913
9914 if ((i + 1) < orderByFields.length) {
9915 if (orderByComparator.isAscending() ^ previous) {
9916 query.append(ORDER_BY_ASC_HAS_NEXT);
9917 }
9918 else {
9919 query.append(ORDER_BY_DESC_HAS_NEXT);
9920 }
9921 }
9922 else {
9923 if (orderByComparator.isAscending() ^ previous) {
9924 query.append(ORDER_BY_ASC);
9925 }
9926 else {
9927 query.append(ORDER_BY_DESC);
9928 }
9929 }
9930 }
9931 }
9932 else {
9933 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
9934 }
9935
9936 String sql = query.toString();
9937
9938 Query q = session.createQuery(sql);
9939
9940 q.setFirstResult(0);
9941 q.setMaxResults(2);
9942
9943 QueryPos qPos = QueryPos.getInstance(q);
9944
9945 qPos.add(groupId);
9946
9947 qPos.add(categoryId);
9948
9949 qPos.add(status);
9950
9951 if (orderByComparator != null) {
9952 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
9953
9954 for (Object value : values) {
9955 qPos.add(value);
9956 }
9957 }
9958
9959 List<MBThread> list = q.list();
9960
9961 if (list.size() == 2) {
9962 return list.get(1);
9963 }
9964 else {
9965 return null;
9966 }
9967 }
9968
9969
9977 @Override
9978 public List<MBThread> filterFindByG_C_NotS(long groupId, long categoryId,
9979 int status) {
9980 return filterFindByG_C_NotS(groupId, categoryId, status,
9981 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9982 }
9983
9984
9998 @Override
9999 public List<MBThread> filterFindByG_C_NotS(long groupId, long categoryId,
10000 int status, int start, int end) {
10001 return filterFindByG_C_NotS(groupId, categoryId, status, start, end,
10002 null);
10003 }
10004
10005
10020 @Override
10021 public List<MBThread> filterFindByG_C_NotS(long groupId, long categoryId,
10022 int status, int start, int end,
10023 OrderByComparator<MBThread> orderByComparator) {
10024 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10025 return findByG_C_NotS(groupId, categoryId, status, start, end,
10026 orderByComparator);
10027 }
10028
10029 StringBundler query = null;
10030
10031 if (orderByComparator != null) {
10032 query = new StringBundler(5 +
10033 (orderByComparator.getOrderByFields().length * 2));
10034 }
10035 else {
10036 query = new StringBundler(6);
10037 }
10038
10039 if (getDB().isSupportsInlineDistinct()) {
10040 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
10041 }
10042 else {
10043 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
10044 }
10045
10046 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10047
10048 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
10049
10050 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10051
10052 if (!getDB().isSupportsInlineDistinct()) {
10053 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
10054 }
10055
10056 if (orderByComparator != null) {
10057 if (getDB().isSupportsInlineDistinct()) {
10058 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10059 orderByComparator, true);
10060 }
10061 else {
10062 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10063 orderByComparator, true);
10064 }
10065 }
10066 else {
10067 if (getDB().isSupportsInlineDistinct()) {
10068 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
10069 }
10070 else {
10071 query.append(MBThreadModelImpl.ORDER_BY_SQL);
10072 }
10073 }
10074
10075 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10076 MBThread.class.getName(),
10077 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10078
10079 Session session = null;
10080
10081 try {
10082 session = openSession();
10083
10084 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10085
10086 if (getDB().isSupportsInlineDistinct()) {
10087 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
10088 }
10089 else {
10090 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
10091 }
10092
10093 QueryPos qPos = QueryPos.getInstance(q);
10094
10095 qPos.add(groupId);
10096
10097 qPos.add(categoryId);
10098
10099 qPos.add(status);
10100
10101 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
10102 }
10103 catch (Exception e) {
10104 throw processException(e);
10105 }
10106 finally {
10107 closeSession(session);
10108 }
10109 }
10110
10111
10122 @Override
10123 public MBThread[] filterFindByG_C_NotS_PrevAndNext(long threadId,
10124 long groupId, long categoryId, int status,
10125 OrderByComparator<MBThread> orderByComparator)
10126 throws NoSuchThreadException {
10127 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10128 return findByG_C_NotS_PrevAndNext(threadId, groupId, categoryId,
10129 status, orderByComparator);
10130 }
10131
10132 MBThread mbThread = findByPrimaryKey(threadId);
10133
10134 Session session = null;
10135
10136 try {
10137 session = openSession();
10138
10139 MBThread[] array = new MBThreadImpl[3];
10140
10141 array[0] = filterGetByG_C_NotS_PrevAndNext(session, mbThread,
10142 groupId, categoryId, status, orderByComparator, true);
10143
10144 array[1] = mbThread;
10145
10146 array[2] = filterGetByG_C_NotS_PrevAndNext(session, mbThread,
10147 groupId, categoryId, status, orderByComparator, false);
10148
10149 return array;
10150 }
10151 catch (Exception e) {
10152 throw processException(e);
10153 }
10154 finally {
10155 closeSession(session);
10156 }
10157 }
10158
10159 protected MBThread filterGetByG_C_NotS_PrevAndNext(Session session,
10160 MBThread mbThread, long groupId, long categoryId, int status,
10161 OrderByComparator<MBThread> orderByComparator, boolean previous) {
10162 StringBundler query = null;
10163
10164 if (orderByComparator != null) {
10165 query = new StringBundler(7 +
10166 (orderByComparator.getOrderByConditionFields().length * 3) +
10167 (orderByComparator.getOrderByFields().length * 3));
10168 }
10169 else {
10170 query = new StringBundler(6);
10171 }
10172
10173 if (getDB().isSupportsInlineDistinct()) {
10174 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
10175 }
10176 else {
10177 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
10178 }
10179
10180 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10181
10182 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
10183
10184 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10185
10186 if (!getDB().isSupportsInlineDistinct()) {
10187 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
10188 }
10189
10190 if (orderByComparator != null) {
10191 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10192
10193 if (orderByConditionFields.length > 0) {
10194 query.append(WHERE_AND);
10195 }
10196
10197 for (int i = 0; i < orderByConditionFields.length; i++) {
10198 if (getDB().isSupportsInlineDistinct()) {
10199 query.append(_ORDER_BY_ENTITY_ALIAS);
10200 }
10201 else {
10202 query.append(_ORDER_BY_ENTITY_TABLE);
10203 }
10204
10205 query.append(orderByConditionFields[i]);
10206
10207 if ((i + 1) < orderByConditionFields.length) {
10208 if (orderByComparator.isAscending() ^ previous) {
10209 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10210 }
10211 else {
10212 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10213 }
10214 }
10215 else {
10216 if (orderByComparator.isAscending() ^ previous) {
10217 query.append(WHERE_GREATER_THAN);
10218 }
10219 else {
10220 query.append(WHERE_LESSER_THAN);
10221 }
10222 }
10223 }
10224
10225 query.append(ORDER_BY_CLAUSE);
10226
10227 String[] orderByFields = orderByComparator.getOrderByFields();
10228
10229 for (int i = 0; i < orderByFields.length; i++) {
10230 if (getDB().isSupportsInlineDistinct()) {
10231 query.append(_ORDER_BY_ENTITY_ALIAS);
10232 }
10233 else {
10234 query.append(_ORDER_BY_ENTITY_TABLE);
10235 }
10236
10237 query.append(orderByFields[i]);
10238
10239 if ((i + 1) < orderByFields.length) {
10240 if (orderByComparator.isAscending() ^ previous) {
10241 query.append(ORDER_BY_ASC_HAS_NEXT);
10242 }
10243 else {
10244 query.append(ORDER_BY_DESC_HAS_NEXT);
10245 }
10246 }
10247 else {
10248 if (orderByComparator.isAscending() ^ previous) {
10249 query.append(ORDER_BY_ASC);
10250 }
10251 else {
10252 query.append(ORDER_BY_DESC);
10253 }
10254 }
10255 }
10256 }
10257 else {
10258 if (getDB().isSupportsInlineDistinct()) {
10259 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
10260 }
10261 else {
10262 query.append(MBThreadModelImpl.ORDER_BY_SQL);
10263 }
10264 }
10265
10266 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10267 MBThread.class.getName(),
10268 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10269
10270 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10271
10272 q.setFirstResult(0);
10273 q.setMaxResults(2);
10274
10275 if (getDB().isSupportsInlineDistinct()) {
10276 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
10277 }
10278 else {
10279 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
10280 }
10281
10282 QueryPos qPos = QueryPos.getInstance(q);
10283
10284 qPos.add(groupId);
10285
10286 qPos.add(categoryId);
10287
10288 qPos.add(status);
10289
10290 if (orderByComparator != null) {
10291 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
10292
10293 for (Object value : values) {
10294 qPos.add(value);
10295 }
10296 }
10297
10298 List<MBThread> list = q.list();
10299
10300 if (list.size() == 2) {
10301 return list.get(1);
10302 }
10303 else {
10304 return null;
10305 }
10306 }
10307
10308
10316 @Override
10317 public List<MBThread> filterFindByG_C_NotS(long groupId,
10318 long[] categoryIds, int status) {
10319 return filterFindByG_C_NotS(groupId, categoryIds, status,
10320 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10321 }
10322
10323
10337 @Override
10338 public List<MBThread> filterFindByG_C_NotS(long groupId,
10339 long[] categoryIds, int status, int start, int end) {
10340 return filterFindByG_C_NotS(groupId, categoryIds, status, start, end,
10341 null);
10342 }
10343
10344
10359 @Override
10360 public List<MBThread> filterFindByG_C_NotS(long groupId,
10361 long[] categoryIds, int status, int start, int end,
10362 OrderByComparator<MBThread> orderByComparator) {
10363 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10364 return findByG_C_NotS(groupId, categoryIds, status, start, end,
10365 orderByComparator);
10366 }
10367
10368 if (categoryIds == null) {
10369 categoryIds = new long[0];
10370 }
10371 else if (categoryIds.length > 1) {
10372 categoryIds = ArrayUtil.unique(categoryIds);
10373
10374 Arrays.sort(categoryIds);
10375 }
10376
10377 StringBundler query = new StringBundler();
10378
10379 if (getDB().isSupportsInlineDistinct()) {
10380 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
10381 }
10382 else {
10383 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
10384 }
10385
10386 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10387
10388 if (categoryIds.length > 0) {
10389 query.append(StringPool.OPEN_PARENTHESIS);
10390
10391 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_7);
10392
10393 query.append(StringUtil.merge(categoryIds));
10394
10395 query.append(StringPool.CLOSE_PARENTHESIS);
10396
10397 query.append(StringPool.CLOSE_PARENTHESIS);
10398
10399 query.append(WHERE_AND);
10400 }
10401
10402 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10403
10404 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
10405 query.index() - 1);
10406
10407 if (!getDB().isSupportsInlineDistinct()) {
10408 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
10409 }
10410
10411 if (orderByComparator != null) {
10412 if (getDB().isSupportsInlineDistinct()) {
10413 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10414 orderByComparator, true);
10415 }
10416 else {
10417 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10418 orderByComparator, true);
10419 }
10420 }
10421 else {
10422 if (getDB().isSupportsInlineDistinct()) {
10423 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
10424 }
10425 else {
10426 query.append(MBThreadModelImpl.ORDER_BY_SQL);
10427 }
10428 }
10429
10430 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10431 MBThread.class.getName(),
10432 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10433
10434 Session session = null;
10435
10436 try {
10437 session = openSession();
10438
10439 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10440
10441 if (getDB().isSupportsInlineDistinct()) {
10442 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
10443 }
10444 else {
10445 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
10446 }
10447
10448 QueryPos qPos = QueryPos.getInstance(q);
10449
10450 qPos.add(groupId);
10451
10452 qPos.add(status);
10453
10454 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
10455 }
10456 catch (Exception e) {
10457 throw processException(e);
10458 }
10459 finally {
10460 closeSession(session);
10461 }
10462 }
10463
10464
10476 @Override
10477 public List<MBThread> findByG_C_NotS(long groupId, long[] categoryIds,
10478 int status) {
10479 return findByG_C_NotS(groupId, categoryIds, status, QueryUtil.ALL_POS,
10480 QueryUtil.ALL_POS, null);
10481 }
10482
10483
10497 @Override
10498 public List<MBThread> findByG_C_NotS(long groupId, long[] categoryIds,
10499 int status, int start, int end) {
10500 return findByG_C_NotS(groupId, categoryIds, status, start, end, null);
10501 }
10502
10503
10518 @Override
10519 public List<MBThread> findByG_C_NotS(long groupId, long[] categoryIds,
10520 int status, int start, int end,
10521 OrderByComparator<MBThread> orderByComparator) {
10522 return findByG_C_NotS(groupId, categoryIds, status, start, end,
10523 orderByComparator, true);
10524 }
10525
10526
10542 @Override
10543 public List<MBThread> findByG_C_NotS(long groupId, long[] categoryIds,
10544 int status, int start, int end,
10545 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
10546 if (categoryIds == null) {
10547 categoryIds = new long[0];
10548 }
10549 else if (categoryIds.length > 1) {
10550 categoryIds = ArrayUtil.unique(categoryIds);
10551
10552 Arrays.sort(categoryIds);
10553 }
10554
10555 if (categoryIds.length == 1) {
10556 return findByG_C_NotS(groupId, categoryIds[0], status, start, end,
10557 orderByComparator);
10558 }
10559
10560 boolean pagination = true;
10561 Object[] finderArgs = null;
10562
10563 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10564 (orderByComparator == null)) {
10565 pagination = false;
10566 finderArgs = new Object[] {
10567 groupId, StringUtil.merge(categoryIds), status
10568 };
10569 }
10570 else {
10571 finderArgs = new Object[] {
10572 groupId, StringUtil.merge(categoryIds), status,
10573
10574 start, end, orderByComparator
10575 };
10576 }
10577
10578 List<MBThread> list = null;
10579
10580 if (retrieveFromCache) {
10581 list = (List<MBThread>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_NOTS,
10582 finderArgs, this);
10583
10584 if ((list != null) && !list.isEmpty()) {
10585 for (MBThread mbThread : list) {
10586 if ((groupId != mbThread.getGroupId()) ||
10587 !ArrayUtil.contains(categoryIds,
10588 mbThread.getCategoryId()) ||
10589 (status == mbThread.getStatus())) {
10590 list = null;
10591
10592 break;
10593 }
10594 }
10595 }
10596 }
10597
10598 if (list == null) {
10599 StringBundler query = new StringBundler();
10600
10601 query.append(_SQL_SELECT_MBTHREAD_WHERE);
10602
10603 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10604
10605 if (categoryIds.length > 0) {
10606 query.append(StringPool.OPEN_PARENTHESIS);
10607
10608 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_7);
10609
10610 query.append(StringUtil.merge(categoryIds));
10611
10612 query.append(StringPool.CLOSE_PARENTHESIS);
10613
10614 query.append(StringPool.CLOSE_PARENTHESIS);
10615
10616 query.append(WHERE_AND);
10617 }
10618
10619 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10620
10621 query.setStringAt(removeConjunction(query.stringAt(query.index() -
10622 1)), query.index() - 1);
10623
10624 if (orderByComparator != null) {
10625 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10626 orderByComparator);
10627 }
10628 else
10629 if (pagination) {
10630 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
10631 }
10632
10633 String sql = query.toString();
10634
10635 Session session = null;
10636
10637 try {
10638 session = openSession();
10639
10640 Query q = session.createQuery(sql);
10641
10642 QueryPos qPos = QueryPos.getInstance(q);
10643
10644 qPos.add(groupId);
10645
10646 qPos.add(status);
10647
10648 if (!pagination) {
10649 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
10650 start, end, false);
10651
10652 Collections.sort(list);
10653
10654 list = Collections.unmodifiableList(list);
10655 }
10656 else {
10657 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
10658 start, end);
10659 }
10660
10661 cacheResult(list);
10662
10663 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_NOTS,
10664 finderArgs, list);
10665 }
10666 catch (Exception e) {
10667 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_NOTS,
10668 finderArgs);
10669
10670 throw processException(e);
10671 }
10672 finally {
10673 closeSession(session);
10674 }
10675 }
10676
10677 return list;
10678 }
10679
10680
10687 @Override
10688 public void removeByG_C_NotS(long groupId, long categoryId, int status) {
10689 for (MBThread mbThread : findByG_C_NotS(groupId, categoryId, status,
10690 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10691 remove(mbThread);
10692 }
10693 }
10694
10695
10703 @Override
10704 public int countByG_C_NotS(long groupId, long categoryId, int status) {
10705 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_NOTS;
10706
10707 Object[] finderArgs = new Object[] { groupId, categoryId, status };
10708
10709 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10710
10711 if (count == null) {
10712 StringBundler query = new StringBundler(4);
10713
10714 query.append(_SQL_COUNT_MBTHREAD_WHERE);
10715
10716 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10717
10718 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
10719
10720 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10721
10722 String sql = query.toString();
10723
10724 Session session = null;
10725
10726 try {
10727 session = openSession();
10728
10729 Query q = session.createQuery(sql);
10730
10731 QueryPos qPos = QueryPos.getInstance(q);
10732
10733 qPos.add(groupId);
10734
10735 qPos.add(categoryId);
10736
10737 qPos.add(status);
10738
10739 count = (Long)q.uniqueResult();
10740
10741 finderCache.putResult(finderPath, finderArgs, count);
10742 }
10743 catch (Exception e) {
10744 finderCache.removeResult(finderPath, finderArgs);
10745
10746 throw processException(e);
10747 }
10748 finally {
10749 closeSession(session);
10750 }
10751 }
10752
10753 return count.intValue();
10754 }
10755
10756
10764 @Override
10765 public int countByG_C_NotS(long groupId, long[] categoryIds, int status) {
10766 if (categoryIds == null) {
10767 categoryIds = new long[0];
10768 }
10769 else if (categoryIds.length > 1) {
10770 categoryIds = ArrayUtil.unique(categoryIds);
10771
10772 Arrays.sort(categoryIds);
10773 }
10774
10775 Object[] finderArgs = new Object[] {
10776 groupId, StringUtil.merge(categoryIds), status
10777 };
10778
10779 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_NOTS,
10780 finderArgs, this);
10781
10782 if (count == null) {
10783 StringBundler query = new StringBundler();
10784
10785 query.append(_SQL_COUNT_MBTHREAD_WHERE);
10786
10787 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10788
10789 if (categoryIds.length > 0) {
10790 query.append(StringPool.OPEN_PARENTHESIS);
10791
10792 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_7);
10793
10794 query.append(StringUtil.merge(categoryIds));
10795
10796 query.append(StringPool.CLOSE_PARENTHESIS);
10797
10798 query.append(StringPool.CLOSE_PARENTHESIS);
10799
10800 query.append(WHERE_AND);
10801 }
10802
10803 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10804
10805 query.setStringAt(removeConjunction(query.stringAt(query.index() -
10806 1)), query.index() - 1);
10807
10808 String sql = query.toString();
10809
10810 Session session = null;
10811
10812 try {
10813 session = openSession();
10814
10815 Query q = session.createQuery(sql);
10816
10817 QueryPos qPos = QueryPos.getInstance(q);
10818
10819 qPos.add(groupId);
10820
10821 qPos.add(status);
10822
10823 count = (Long)q.uniqueResult();
10824
10825 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_NOTS,
10826 finderArgs, count);
10827 }
10828 catch (Exception e) {
10829 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_NOTS,
10830 finderArgs);
10831
10832 throw processException(e);
10833 }
10834 finally {
10835 closeSession(session);
10836 }
10837 }
10838
10839 return count.intValue();
10840 }
10841
10842
10850 @Override
10851 public int filterCountByG_C_NotS(long groupId, long categoryId, int status) {
10852 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10853 return countByG_C_NotS(groupId, categoryId, status);
10854 }
10855
10856 StringBundler query = new StringBundler(4);
10857
10858 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
10859
10860 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10861
10862 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
10863
10864 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10865
10866 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10867 MBThread.class.getName(),
10868 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10869
10870 Session session = null;
10871
10872 try {
10873 session = openSession();
10874
10875 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10876
10877 q.addScalar(COUNT_COLUMN_NAME,
10878 com.liferay.portal.kernel.dao.orm.Type.LONG);
10879
10880 QueryPos qPos = QueryPos.getInstance(q);
10881
10882 qPos.add(groupId);
10883
10884 qPos.add(categoryId);
10885
10886 qPos.add(status);
10887
10888 Long count = (Long)q.uniqueResult();
10889
10890 return count.intValue();
10891 }
10892 catch (Exception e) {
10893 throw processException(e);
10894 }
10895 finally {
10896 closeSession(session);
10897 }
10898 }
10899
10900
10908 @Override
10909 public int filterCountByG_C_NotS(long groupId, long[] categoryIds,
10910 int status) {
10911 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10912 return countByG_C_NotS(groupId, categoryIds, status);
10913 }
10914
10915 if (categoryIds == null) {
10916 categoryIds = new long[0];
10917 }
10918 else if (categoryIds.length > 1) {
10919 categoryIds = ArrayUtil.unique(categoryIds);
10920
10921 Arrays.sort(categoryIds);
10922 }
10923
10924 StringBundler query = new StringBundler();
10925
10926 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
10927
10928 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10929
10930 if (categoryIds.length > 0) {
10931 query.append(StringPool.OPEN_PARENTHESIS);
10932
10933 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_7);
10934
10935 query.append(StringUtil.merge(categoryIds));
10936
10937 query.append(StringPool.CLOSE_PARENTHESIS);
10938
10939 query.append(StringPool.CLOSE_PARENTHESIS);
10940
10941 query.append(WHERE_AND);
10942 }
10943
10944 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10945
10946 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
10947 query.index() - 1);
10948
10949 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10950 MBThread.class.getName(),
10951 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10952
10953 Session session = null;
10954
10955 try {
10956 session = openSession();
10957
10958 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10959
10960 q.addScalar(COUNT_COLUMN_NAME,
10961 com.liferay.portal.kernel.dao.orm.Type.LONG);
10962
10963 QueryPos qPos = QueryPos.getInstance(q);
10964
10965 qPos.add(groupId);
10966
10967 qPos.add(status);
10968
10969 Long count = (Long)q.uniqueResult();
10970
10971 return count.intValue();
10972 }
10973 catch (Exception e) {
10974 throw processException(e);
10975 }
10976 finally {
10977 closeSession(session);
10978 }
10979 }
10980
10981 private static final String _FINDER_COLUMN_G_C_NOTS_GROUPID_2 = "mbThread.groupId = ? AND ";
10982 private static final String _FINDER_COLUMN_G_C_NOTS_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
10983 private static final String _FINDER_COLUMN_G_C_NOTS_CATEGORYID_7 = "mbThread.categoryId IN (";
10984 private static final String _FINDER_COLUMN_G_C_NOTS_STATUS_2 = "mbThread.status != ?";
10985 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
10986 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
10987 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotC_S",
10988 new String[] {
10989 Long.class.getName(), Long.class.getName(),
10990 Integer.class.getName(),
10991
10992 Integer.class.getName(), Integer.class.getName(),
10993 OrderByComparator.class.getName()
10994 });
10995 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_S =
10996 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
10997 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
10998 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotC_S",
10999 new String[] {
11000 Long.class.getName(), Long.class.getName(),
11001 Integer.class.getName()
11002 });
11003
11004
11012 @Override
11013 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
11014 int status) {
11015 return findByG_NotC_S(groupId, categoryId, status, QueryUtil.ALL_POS,
11016 QueryUtil.ALL_POS, null);
11017 }
11018
11019
11033 @Override
11034 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
11035 int status, int start, int end) {
11036 return findByG_NotC_S(groupId, categoryId, status, start, end, null);
11037 }
11038
11039
11054 @Override
11055 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
11056 int status, int start, int end,
11057 OrderByComparator<MBThread> orderByComparator) {
11058 return findByG_NotC_S(groupId, categoryId, status, start, end,
11059 orderByComparator, true);
11060 }
11061
11062
11078 @Override
11079 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
11080 int status, int start, int end,
11081 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
11082 boolean pagination = true;
11083 FinderPath finderPath = null;
11084 Object[] finderArgs = null;
11085
11086 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_S;
11087 finderArgs = new Object[] {
11088 groupId, categoryId, status,
11089
11090 start, end, orderByComparator
11091 };
11092
11093 List<MBThread> list = null;
11094
11095 if (retrieveFromCache) {
11096 list = (List<MBThread>)finderCache.getResult(finderPath,
11097 finderArgs, this);
11098
11099 if ((list != null) && !list.isEmpty()) {
11100 for (MBThread mbThread : list) {
11101 if ((groupId != mbThread.getGroupId()) ||
11102 (categoryId == mbThread.getCategoryId()) ||
11103 (status != mbThread.getStatus())) {
11104 list = null;
11105
11106 break;
11107 }
11108 }
11109 }
11110 }
11111
11112 if (list == null) {
11113 StringBundler query = null;
11114
11115 if (orderByComparator != null) {
11116 query = new StringBundler(5 +
11117 (orderByComparator.getOrderByFields().length * 2));
11118 }
11119 else {
11120 query = new StringBundler(5);
11121 }
11122
11123 query.append(_SQL_SELECT_MBTHREAD_WHERE);
11124
11125 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11126
11127 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11128
11129 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11130
11131 if (orderByComparator != null) {
11132 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11133 orderByComparator);
11134 }
11135 else
11136 if (pagination) {
11137 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
11138 }
11139
11140 String sql = query.toString();
11141
11142 Session session = null;
11143
11144 try {
11145 session = openSession();
11146
11147 Query q = session.createQuery(sql);
11148
11149 QueryPos qPos = QueryPos.getInstance(q);
11150
11151 qPos.add(groupId);
11152
11153 qPos.add(categoryId);
11154
11155 qPos.add(status);
11156
11157 if (!pagination) {
11158 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
11159 start, end, false);
11160
11161 Collections.sort(list);
11162
11163 list = Collections.unmodifiableList(list);
11164 }
11165 else {
11166 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
11167 start, end);
11168 }
11169
11170 cacheResult(list);
11171
11172 finderCache.putResult(finderPath, finderArgs, list);
11173 }
11174 catch (Exception e) {
11175 finderCache.removeResult(finderPath, finderArgs);
11176
11177 throw processException(e);
11178 }
11179 finally {
11180 closeSession(session);
11181 }
11182 }
11183
11184 return list;
11185 }
11186
11187
11197 @Override
11198 public MBThread findByG_NotC_S_First(long groupId, long categoryId,
11199 int status, OrderByComparator<MBThread> orderByComparator)
11200 throws NoSuchThreadException {
11201 MBThread mbThread = fetchByG_NotC_S_First(groupId, categoryId, status,
11202 orderByComparator);
11203
11204 if (mbThread != null) {
11205 return mbThread;
11206 }
11207
11208 StringBundler msg = new StringBundler(8);
11209
11210 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11211
11212 msg.append("groupId=");
11213 msg.append(groupId);
11214
11215 msg.append(", categoryId=");
11216 msg.append(categoryId);
11217
11218 msg.append(", status=");
11219 msg.append(status);
11220
11221 msg.append(StringPool.CLOSE_CURLY_BRACE);
11222
11223 throw new NoSuchThreadException(msg.toString());
11224 }
11225
11226
11235 @Override
11236 public MBThread fetchByG_NotC_S_First(long groupId, long categoryId,
11237 int status, OrderByComparator<MBThread> orderByComparator) {
11238 List<MBThread> list = findByG_NotC_S(groupId, categoryId, status, 0, 1,
11239 orderByComparator);
11240
11241 if (!list.isEmpty()) {
11242 return list.get(0);
11243 }
11244
11245 return null;
11246 }
11247
11248
11258 @Override
11259 public MBThread findByG_NotC_S_Last(long groupId, long categoryId,
11260 int status, OrderByComparator<MBThread> orderByComparator)
11261 throws NoSuchThreadException {
11262 MBThread mbThread = fetchByG_NotC_S_Last(groupId, categoryId, status,
11263 orderByComparator);
11264
11265 if (mbThread != null) {
11266 return mbThread;
11267 }
11268
11269 StringBundler msg = new StringBundler(8);
11270
11271 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11272
11273 msg.append("groupId=");
11274 msg.append(groupId);
11275
11276 msg.append(", categoryId=");
11277 msg.append(categoryId);
11278
11279 msg.append(", status=");
11280 msg.append(status);
11281
11282 msg.append(StringPool.CLOSE_CURLY_BRACE);
11283
11284 throw new NoSuchThreadException(msg.toString());
11285 }
11286
11287
11296 @Override
11297 public MBThread fetchByG_NotC_S_Last(long groupId, long categoryId,
11298 int status, OrderByComparator<MBThread> orderByComparator) {
11299 int count = countByG_NotC_S(groupId, categoryId, status);
11300
11301 if (count == 0) {
11302 return null;
11303 }
11304
11305 List<MBThread> list = findByG_NotC_S(groupId, categoryId, status,
11306 count - 1, count, orderByComparator);
11307
11308 if (!list.isEmpty()) {
11309 return list.get(0);
11310 }
11311
11312 return null;
11313 }
11314
11315
11326 @Override
11327 public MBThread[] findByG_NotC_S_PrevAndNext(long threadId, long groupId,
11328 long categoryId, int status,
11329 OrderByComparator<MBThread> orderByComparator)
11330 throws NoSuchThreadException {
11331 MBThread mbThread = findByPrimaryKey(threadId);
11332
11333 Session session = null;
11334
11335 try {
11336 session = openSession();
11337
11338 MBThread[] array = new MBThreadImpl[3];
11339
11340 array[0] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId,
11341 categoryId, status, orderByComparator, true);
11342
11343 array[1] = mbThread;
11344
11345 array[2] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId,
11346 categoryId, status, orderByComparator, false);
11347
11348 return array;
11349 }
11350 catch (Exception e) {
11351 throw processException(e);
11352 }
11353 finally {
11354 closeSession(session);
11355 }
11356 }
11357
11358 protected MBThread getByG_NotC_S_PrevAndNext(Session session,
11359 MBThread mbThread, long groupId, long categoryId, int status,
11360 OrderByComparator<MBThread> orderByComparator, boolean previous) {
11361 StringBundler query = null;
11362
11363 if (orderByComparator != null) {
11364 query = new StringBundler(6 +
11365 (orderByComparator.getOrderByConditionFields().length * 3) +
11366 (orderByComparator.getOrderByFields().length * 3));
11367 }
11368 else {
11369 query = new StringBundler(5);
11370 }
11371
11372 query.append(_SQL_SELECT_MBTHREAD_WHERE);
11373
11374 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11375
11376 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11377
11378 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11379
11380 if (orderByComparator != null) {
11381 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11382
11383 if (orderByConditionFields.length > 0) {
11384 query.append(WHERE_AND);
11385 }
11386
11387 for (int i = 0; i < orderByConditionFields.length; i++) {
11388 query.append(_ORDER_BY_ENTITY_ALIAS);
11389 query.append(orderByConditionFields[i]);
11390
11391 if ((i + 1) < orderByConditionFields.length) {
11392 if (orderByComparator.isAscending() ^ previous) {
11393 query.append(WHERE_GREATER_THAN_HAS_NEXT);
11394 }
11395 else {
11396 query.append(WHERE_LESSER_THAN_HAS_NEXT);
11397 }
11398 }
11399 else {
11400 if (orderByComparator.isAscending() ^ previous) {
11401 query.append(WHERE_GREATER_THAN);
11402 }
11403 else {
11404 query.append(WHERE_LESSER_THAN);
11405 }
11406 }
11407 }
11408
11409 query.append(ORDER_BY_CLAUSE);
11410
11411 String[] orderByFields = orderByComparator.getOrderByFields();
11412
11413 for (int i = 0; i < orderByFields.length; i++) {
11414 query.append(_ORDER_BY_ENTITY_ALIAS);
11415 query.append(orderByFields[i]);
11416
11417 if ((i + 1) < orderByFields.length) {
11418 if (orderByComparator.isAscending() ^ previous) {
11419 query.append(ORDER_BY_ASC_HAS_NEXT);
11420 }
11421 else {
11422 query.append(ORDER_BY_DESC_HAS_NEXT);
11423 }
11424 }
11425 else {
11426 if (orderByComparator.isAscending() ^ previous) {
11427 query.append(ORDER_BY_ASC);
11428 }
11429 else {
11430 query.append(ORDER_BY_DESC);
11431 }
11432 }
11433 }
11434 }
11435 else {
11436 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
11437 }
11438
11439 String sql = query.toString();
11440
11441 Query q = session.createQuery(sql);
11442
11443 q.setFirstResult(0);
11444 q.setMaxResults(2);
11445
11446 QueryPos qPos = QueryPos.getInstance(q);
11447
11448 qPos.add(groupId);
11449
11450 qPos.add(categoryId);
11451
11452 qPos.add(status);
11453
11454 if (orderByComparator != null) {
11455 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
11456
11457 for (Object value : values) {
11458 qPos.add(value);
11459 }
11460 }
11461
11462 List<MBThread> list = q.list();
11463
11464 if (list.size() == 2) {
11465 return list.get(1);
11466 }
11467 else {
11468 return null;
11469 }
11470 }
11471
11472
11480 @Override
11481 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
11482 int status) {
11483 return filterFindByG_NotC_S(groupId, categoryId, status,
11484 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11485 }
11486
11487
11501 @Override
11502 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
11503 int status, int start, int end) {
11504 return filterFindByG_NotC_S(groupId, categoryId, status, start, end,
11505 null);
11506 }
11507
11508
11523 @Override
11524 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
11525 int status, int start, int end,
11526 OrderByComparator<MBThread> orderByComparator) {
11527 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11528 return findByG_NotC_S(groupId, categoryId, status, start, end,
11529 orderByComparator);
11530 }
11531
11532 StringBundler query = null;
11533
11534 if (orderByComparator != null) {
11535 query = new StringBundler(5 +
11536 (orderByComparator.getOrderByFields().length * 2));
11537 }
11538 else {
11539 query = new StringBundler(6);
11540 }
11541
11542 if (getDB().isSupportsInlineDistinct()) {
11543 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
11544 }
11545 else {
11546 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
11547 }
11548
11549 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11550
11551 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11552
11553 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11554
11555 if (!getDB().isSupportsInlineDistinct()) {
11556 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
11557 }
11558
11559 if (orderByComparator != null) {
11560 if (getDB().isSupportsInlineDistinct()) {
11561 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11562 orderByComparator, true);
11563 }
11564 else {
11565 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11566 orderByComparator, true);
11567 }
11568 }
11569 else {
11570 if (getDB().isSupportsInlineDistinct()) {
11571 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
11572 }
11573 else {
11574 query.append(MBThreadModelImpl.ORDER_BY_SQL);
11575 }
11576 }
11577
11578 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11579 MBThread.class.getName(),
11580 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11581
11582 Session session = null;
11583
11584 try {
11585 session = openSession();
11586
11587 SQLQuery q = session.createSynchronizedSQLQuery(sql);
11588
11589 if (getDB().isSupportsInlineDistinct()) {
11590 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
11591 }
11592 else {
11593 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
11594 }
11595
11596 QueryPos qPos = QueryPos.getInstance(q);
11597
11598 qPos.add(groupId);
11599
11600 qPos.add(categoryId);
11601
11602 qPos.add(status);
11603
11604 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
11605 }
11606 catch (Exception e) {
11607 throw processException(e);
11608 }
11609 finally {
11610 closeSession(session);
11611 }
11612 }
11613
11614
11625 @Override
11626 public MBThread[] filterFindByG_NotC_S_PrevAndNext(long threadId,
11627 long groupId, long categoryId, int status,
11628 OrderByComparator<MBThread> orderByComparator)
11629 throws NoSuchThreadException {
11630 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11631 return findByG_NotC_S_PrevAndNext(threadId, groupId, categoryId,
11632 status, orderByComparator);
11633 }
11634
11635 MBThread mbThread = findByPrimaryKey(threadId);
11636
11637 Session session = null;
11638
11639 try {
11640 session = openSession();
11641
11642 MBThread[] array = new MBThreadImpl[3];
11643
11644 array[0] = filterGetByG_NotC_S_PrevAndNext(session, mbThread,
11645 groupId, categoryId, status, orderByComparator, true);
11646
11647 array[1] = mbThread;
11648
11649 array[2] = filterGetByG_NotC_S_PrevAndNext(session, mbThread,
11650 groupId, categoryId, status, orderByComparator, false);
11651
11652 return array;
11653 }
11654 catch (Exception e) {
11655 throw processException(e);
11656 }
11657 finally {
11658 closeSession(session);
11659 }
11660 }
11661
11662 protected MBThread filterGetByG_NotC_S_PrevAndNext(Session session,
11663 MBThread mbThread, long groupId, long categoryId, int status,
11664 OrderByComparator<MBThread> orderByComparator, boolean previous) {
11665 StringBundler query = null;
11666
11667 if (orderByComparator != null) {
11668 query = new StringBundler(7 +
11669 (orderByComparator.getOrderByConditionFields().length * 3) +
11670 (orderByComparator.getOrderByFields().length * 3));
11671 }
11672 else {
11673 query = new StringBundler(6);
11674 }
11675
11676 if (getDB().isSupportsInlineDistinct()) {
11677 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
11678 }
11679 else {
11680 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
11681 }
11682
11683 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11684
11685 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11686
11687 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11688
11689 if (!getDB().isSupportsInlineDistinct()) {
11690 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
11691 }
11692
11693 if (orderByComparator != null) {
11694 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11695
11696 if (orderByConditionFields.length > 0) {
11697 query.append(WHERE_AND);
11698 }
11699
11700 for (int i = 0; i < orderByConditionFields.length; i++) {
11701 if (getDB().isSupportsInlineDistinct()) {
11702 query.append(_ORDER_BY_ENTITY_ALIAS);
11703 }
11704 else {
11705 query.append(_ORDER_BY_ENTITY_TABLE);
11706 }
11707
11708 query.append(orderByConditionFields[i]);
11709
11710 if ((i + 1) < orderByConditionFields.length) {
11711 if (orderByComparator.isAscending() ^ previous) {
11712 query.append(WHERE_GREATER_THAN_HAS_NEXT);
11713 }
11714 else {
11715 query.append(WHERE_LESSER_THAN_HAS_NEXT);
11716 }
11717 }
11718 else {
11719 if (orderByComparator.isAscending() ^ previous) {
11720 query.append(WHERE_GREATER_THAN);
11721 }
11722 else {
11723 query.append(WHERE_LESSER_THAN);
11724 }
11725 }
11726 }
11727
11728 query.append(ORDER_BY_CLAUSE);
11729
11730 String[] orderByFields = orderByComparator.getOrderByFields();
11731
11732 for (int i = 0; i < orderByFields.length; i++) {
11733 if (getDB().isSupportsInlineDistinct()) {
11734 query.append(_ORDER_BY_ENTITY_ALIAS);
11735 }
11736 else {
11737 query.append(_ORDER_BY_ENTITY_TABLE);
11738 }
11739
11740 query.append(orderByFields[i]);
11741
11742 if ((i + 1) < orderByFields.length) {
11743 if (orderByComparator.isAscending() ^ previous) {
11744 query.append(ORDER_BY_ASC_HAS_NEXT);
11745 }
11746 else {
11747 query.append(ORDER_BY_DESC_HAS_NEXT);
11748 }
11749 }
11750 else {
11751 if (orderByComparator.isAscending() ^ previous) {
11752 query.append(ORDER_BY_ASC);
11753 }
11754 else {
11755 query.append(ORDER_BY_DESC);
11756 }
11757 }
11758 }
11759 }
11760 else {
11761 if (getDB().isSupportsInlineDistinct()) {
11762 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
11763 }
11764 else {
11765 query.append(MBThreadModelImpl.ORDER_BY_SQL);
11766 }
11767 }
11768
11769 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11770 MBThread.class.getName(),
11771 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11772
11773 SQLQuery q = session.createSynchronizedSQLQuery(sql);
11774
11775 q.setFirstResult(0);
11776 q.setMaxResults(2);
11777
11778 if (getDB().isSupportsInlineDistinct()) {
11779 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
11780 }
11781 else {
11782 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
11783 }
11784
11785 QueryPos qPos = QueryPos.getInstance(q);
11786
11787 qPos.add(groupId);
11788
11789 qPos.add(categoryId);
11790
11791 qPos.add(status);
11792
11793 if (orderByComparator != null) {
11794 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
11795
11796 for (Object value : values) {
11797 qPos.add(value);
11798 }
11799 }
11800
11801 List<MBThread> list = q.list();
11802
11803 if (list.size() == 2) {
11804 return list.get(1);
11805 }
11806 else {
11807 return null;
11808 }
11809 }
11810
11811
11818 @Override
11819 public void removeByG_NotC_S(long groupId, long categoryId, int status) {
11820 for (MBThread mbThread : findByG_NotC_S(groupId, categoryId, status,
11821 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11822 remove(mbThread);
11823 }
11824 }
11825
11826
11834 @Override
11835 public int countByG_NotC_S(long groupId, long categoryId, int status) {
11836 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_S;
11837
11838 Object[] finderArgs = new Object[] { groupId, categoryId, status };
11839
11840 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
11841
11842 if (count == null) {
11843 StringBundler query = new StringBundler(4);
11844
11845 query.append(_SQL_COUNT_MBTHREAD_WHERE);
11846
11847 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11848
11849 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11850
11851 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11852
11853 String sql = query.toString();
11854
11855 Session session = null;
11856
11857 try {
11858 session = openSession();
11859
11860 Query q = session.createQuery(sql);
11861
11862 QueryPos qPos = QueryPos.getInstance(q);
11863
11864 qPos.add(groupId);
11865
11866 qPos.add(categoryId);
11867
11868 qPos.add(status);
11869
11870 count = (Long)q.uniqueResult();
11871
11872 finderCache.putResult(finderPath, finderArgs, count);
11873 }
11874 catch (Exception e) {
11875 finderCache.removeResult(finderPath, finderArgs);
11876
11877 throw processException(e);
11878 }
11879 finally {
11880 closeSession(session);
11881 }
11882 }
11883
11884 return count.intValue();
11885 }
11886
11887
11895 @Override
11896 public int filterCountByG_NotC_S(long groupId, long categoryId, int status) {
11897 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11898 return countByG_NotC_S(groupId, categoryId, status);
11899 }
11900
11901 StringBundler query = new StringBundler(4);
11902
11903 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
11904
11905 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11906
11907 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11908
11909 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11910
11911 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11912 MBThread.class.getName(),
11913 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11914
11915 Session session = null;
11916
11917 try {
11918 session = openSession();
11919
11920 SQLQuery q = session.createSynchronizedSQLQuery(sql);
11921
11922 q.addScalar(COUNT_COLUMN_NAME,
11923 com.liferay.portal.kernel.dao.orm.Type.LONG);
11924
11925 QueryPos qPos = QueryPos.getInstance(q);
11926
11927 qPos.add(groupId);
11928
11929 qPos.add(categoryId);
11930
11931 qPos.add(status);
11932
11933 Long count = (Long)q.uniqueResult();
11934
11935 return count.intValue();
11936 }
11937 catch (Exception e) {
11938 throw processException(e);
11939 }
11940 finally {
11941 closeSession(session);
11942 }
11943 }
11944
11945 private static final String _FINDER_COLUMN_G_NOTC_S_GROUPID_2 = "mbThread.groupId = ? AND ";
11946 private static final String _FINDER_COLUMN_G_NOTC_S_CATEGORYID_2 = "mbThread.categoryId != ? AND ";
11947 private static final String _FINDER_COLUMN_G_NOTC_S_STATUS_2 = "mbThread.status = ?";
11948 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_NOTS =
11949 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
11950 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
11951 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotC_NotS",
11952 new String[] {
11953 Long.class.getName(), Long.class.getName(),
11954 Integer.class.getName(),
11955
11956 Integer.class.getName(), Integer.class.getName(),
11957 OrderByComparator.class.getName()
11958 });
11959 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_NOTS =
11960 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
11961 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
11962 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotC_NotS",
11963 new String[] {
11964 Long.class.getName(), Long.class.getName(),
11965 Integer.class.getName()
11966 });
11967
11968
11976 @Override
11977 public List<MBThread> findByG_NotC_NotS(long groupId, long categoryId,
11978 int status) {
11979 return findByG_NotC_NotS(groupId, categoryId, status,
11980 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11981 }
11982
11983
11997 @Override
11998 public List<MBThread> findByG_NotC_NotS(long groupId, long categoryId,
11999 int status, int start, int end) {
12000 return findByG_NotC_NotS(groupId, categoryId, status, start, end, null);
12001 }
12002
12003
12018 @Override
12019 public List<MBThread> findByG_NotC_NotS(long groupId, long categoryId,
12020 int status, int start, int end,
12021 OrderByComparator<MBThread> orderByComparator) {
12022 return findByG_NotC_NotS(groupId, categoryId, status, start, end,
12023 orderByComparator, true);
12024 }
12025
12026
12042 @Override
12043 public List<MBThread> findByG_NotC_NotS(long groupId, long categoryId,
12044 int status, int start, int end,
12045 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
12046 boolean pagination = true;
12047 FinderPath finderPath = null;
12048 Object[] finderArgs = null;
12049
12050 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_NOTS;
12051 finderArgs = new Object[] {
12052 groupId, categoryId, status,
12053
12054 start, end, orderByComparator
12055 };
12056
12057 List<MBThread> list = null;
12058
12059 if (retrieveFromCache) {
12060 list = (List<MBThread>)finderCache.getResult(finderPath,
12061 finderArgs, this);
12062
12063 if ((list != null) && !list.isEmpty()) {
12064 for (MBThread mbThread : list) {
12065 if ((groupId != mbThread.getGroupId()) ||
12066 (categoryId == mbThread.getCategoryId()) ||
12067 (status == mbThread.getStatus())) {
12068 list = null;
12069
12070 break;
12071 }
12072 }
12073 }
12074 }
12075
12076 if (list == null) {
12077 StringBundler query = null;
12078
12079 if (orderByComparator != null) {
12080 query = new StringBundler(5 +
12081 (orderByComparator.getOrderByFields().length * 2));
12082 }
12083 else {
12084 query = new StringBundler(5);
12085 }
12086
12087 query.append(_SQL_SELECT_MBTHREAD_WHERE);
12088
12089 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12090
12091 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12092
12093 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12094
12095 if (orderByComparator != null) {
12096 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12097 orderByComparator);
12098 }
12099 else
12100 if (pagination) {
12101 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
12102 }
12103
12104 String sql = query.toString();
12105
12106 Session session = null;
12107
12108 try {
12109 session = openSession();
12110
12111 Query q = session.createQuery(sql);
12112
12113 QueryPos qPos = QueryPos.getInstance(q);
12114
12115 qPos.add(groupId);
12116
12117 qPos.add(categoryId);
12118
12119 qPos.add(status);
12120
12121 if (!pagination) {
12122 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
12123 start, end, false);
12124
12125 Collections.sort(list);
12126
12127 list = Collections.unmodifiableList(list);
12128 }
12129 else {
12130 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
12131 start, end);
12132 }
12133
12134 cacheResult(list);
12135
12136 finderCache.putResult(finderPath, finderArgs, list);
12137 }
12138 catch (Exception e) {
12139 finderCache.removeResult(finderPath, finderArgs);
12140
12141 throw processException(e);
12142 }
12143 finally {
12144 closeSession(session);
12145 }
12146 }
12147
12148 return list;
12149 }
12150
12151
12161 @Override
12162 public MBThread findByG_NotC_NotS_First(long groupId, long categoryId,
12163 int status, OrderByComparator<MBThread> orderByComparator)
12164 throws NoSuchThreadException {
12165 MBThread mbThread = fetchByG_NotC_NotS_First(groupId, categoryId,
12166 status, orderByComparator);
12167
12168 if (mbThread != null) {
12169 return mbThread;
12170 }
12171
12172 StringBundler msg = new StringBundler(8);
12173
12174 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12175
12176 msg.append("groupId=");
12177 msg.append(groupId);
12178
12179 msg.append(", categoryId=");
12180 msg.append(categoryId);
12181
12182 msg.append(", status=");
12183 msg.append(status);
12184
12185 msg.append(StringPool.CLOSE_CURLY_BRACE);
12186
12187 throw new NoSuchThreadException(msg.toString());
12188 }
12189
12190
12199 @Override
12200 public MBThread fetchByG_NotC_NotS_First(long groupId, long categoryId,
12201 int status, OrderByComparator<MBThread> orderByComparator) {
12202 List<MBThread> list = findByG_NotC_NotS(groupId, categoryId, status, 0,
12203 1, orderByComparator);
12204
12205 if (!list.isEmpty()) {
12206 return list.get(0);
12207 }
12208
12209 return null;
12210 }
12211
12212
12222 @Override
12223 public MBThread findByG_NotC_NotS_Last(long groupId, long categoryId,
12224 int status, OrderByComparator<MBThread> orderByComparator)
12225 throws NoSuchThreadException {
12226 MBThread mbThread = fetchByG_NotC_NotS_Last(groupId, categoryId,
12227 status, orderByComparator);
12228
12229 if (mbThread != null) {
12230 return mbThread;
12231 }
12232
12233 StringBundler msg = new StringBundler(8);
12234
12235 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12236
12237 msg.append("groupId=");
12238 msg.append(groupId);
12239
12240 msg.append(", categoryId=");
12241 msg.append(categoryId);
12242
12243 msg.append(", status=");
12244 msg.append(status);
12245
12246 msg.append(StringPool.CLOSE_CURLY_BRACE);
12247
12248 throw new NoSuchThreadException(msg.toString());
12249 }
12250
12251
12260 @Override
12261 public MBThread fetchByG_NotC_NotS_Last(long groupId, long categoryId,
12262 int status, OrderByComparator<MBThread> orderByComparator) {
12263 int count = countByG_NotC_NotS(groupId, categoryId, status);
12264
12265 if (count == 0) {
12266 return null;
12267 }
12268
12269 List<MBThread> list = findByG_NotC_NotS(groupId, categoryId, status,
12270 count - 1, count, orderByComparator);
12271
12272 if (!list.isEmpty()) {
12273 return list.get(0);
12274 }
12275
12276 return null;
12277 }
12278
12279
12290 @Override
12291 public MBThread[] findByG_NotC_NotS_PrevAndNext(long threadId,
12292 long groupId, long categoryId, int status,
12293 OrderByComparator<MBThread> orderByComparator)
12294 throws NoSuchThreadException {
12295 MBThread mbThread = findByPrimaryKey(threadId);
12296
12297 Session session = null;
12298
12299 try {
12300 session = openSession();
12301
12302 MBThread[] array = new MBThreadImpl[3];
12303
12304 array[0] = getByG_NotC_NotS_PrevAndNext(session, mbThread, groupId,
12305 categoryId, status, orderByComparator, true);
12306
12307 array[1] = mbThread;
12308
12309 array[2] = getByG_NotC_NotS_PrevAndNext(session, mbThread, groupId,
12310 categoryId, status, orderByComparator, false);
12311
12312 return array;
12313 }
12314 catch (Exception e) {
12315 throw processException(e);
12316 }
12317 finally {
12318 closeSession(session);
12319 }
12320 }
12321
12322 protected MBThread getByG_NotC_NotS_PrevAndNext(Session session,
12323 MBThread mbThread, long groupId, long categoryId, int status,
12324 OrderByComparator<MBThread> orderByComparator, boolean previous) {
12325 StringBundler query = null;
12326
12327 if (orderByComparator != null) {
12328 query = new StringBundler(6 +
12329 (orderByComparator.getOrderByConditionFields().length * 3) +
12330 (orderByComparator.getOrderByFields().length * 3));
12331 }
12332 else {
12333 query = new StringBundler(5);
12334 }
12335
12336 query.append(_SQL_SELECT_MBTHREAD_WHERE);
12337
12338 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12339
12340 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12341
12342 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12343
12344 if (orderByComparator != null) {
12345 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12346
12347 if (orderByConditionFields.length > 0) {
12348 query.append(WHERE_AND);
12349 }
12350
12351 for (int i = 0; i < orderByConditionFields.length; i++) {
12352 query.append(_ORDER_BY_ENTITY_ALIAS);
12353 query.append(orderByConditionFields[i]);
12354
12355 if ((i + 1) < orderByConditionFields.length) {
12356 if (orderByComparator.isAscending() ^ previous) {
12357 query.append(WHERE_GREATER_THAN_HAS_NEXT);
12358 }
12359 else {
12360 query.append(WHERE_LESSER_THAN_HAS_NEXT);
12361 }
12362 }
12363 else {
12364 if (orderByComparator.isAscending() ^ previous) {
12365 query.append(WHERE_GREATER_THAN);
12366 }
12367 else {
12368 query.append(WHERE_LESSER_THAN);
12369 }
12370 }
12371 }
12372
12373 query.append(ORDER_BY_CLAUSE);
12374
12375 String[] orderByFields = orderByComparator.getOrderByFields();
12376
12377 for (int i = 0; i < orderByFields.length; i++) {
12378 query.append(_ORDER_BY_ENTITY_ALIAS);
12379 query.append(orderByFields[i]);
12380
12381 if ((i + 1) < orderByFields.length) {
12382 if (orderByComparator.isAscending() ^ previous) {
12383 query.append(ORDER_BY_ASC_HAS_NEXT);
12384 }
12385 else {
12386 query.append(ORDER_BY_DESC_HAS_NEXT);
12387 }
12388 }
12389 else {
12390 if (orderByComparator.isAscending() ^ previous) {
12391 query.append(ORDER_BY_ASC);
12392 }
12393 else {
12394 query.append(ORDER_BY_DESC);
12395 }
12396 }
12397 }
12398 }
12399 else {
12400 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
12401 }
12402
12403 String sql = query.toString();
12404
12405 Query q = session.createQuery(sql);
12406
12407 q.setFirstResult(0);
12408 q.setMaxResults(2);
12409
12410 QueryPos qPos = QueryPos.getInstance(q);
12411
12412 qPos.add(groupId);
12413
12414 qPos.add(categoryId);
12415
12416 qPos.add(status);
12417
12418 if (orderByComparator != null) {
12419 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
12420
12421 for (Object value : values) {
12422 qPos.add(value);
12423 }
12424 }
12425
12426 List<MBThread> list = q.list();
12427
12428 if (list.size() == 2) {
12429 return list.get(1);
12430 }
12431 else {
12432 return null;
12433 }
12434 }
12435
12436
12444 @Override
12445 public List<MBThread> filterFindByG_NotC_NotS(long groupId,
12446 long categoryId, int status) {
12447 return filterFindByG_NotC_NotS(groupId, categoryId, status,
12448 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12449 }
12450
12451
12465 @Override
12466 public List<MBThread> filterFindByG_NotC_NotS(long groupId,
12467 long categoryId, int status, int start, int end) {
12468 return filterFindByG_NotC_NotS(groupId, categoryId, status, start, end,
12469 null);
12470 }
12471
12472
12487 @Override
12488 public List<MBThread> filterFindByG_NotC_NotS(long groupId,
12489 long categoryId, int status, int start, int end,
12490 OrderByComparator<MBThread> orderByComparator) {
12491 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12492 return findByG_NotC_NotS(groupId, categoryId, status, start, end,
12493 orderByComparator);
12494 }
12495
12496 StringBundler query = null;
12497
12498 if (orderByComparator != null) {
12499 query = new StringBundler(5 +
12500 (orderByComparator.getOrderByFields().length * 2));
12501 }
12502 else {
12503 query = new StringBundler(6);
12504 }
12505
12506 if (getDB().isSupportsInlineDistinct()) {
12507 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
12508 }
12509 else {
12510 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
12511 }
12512
12513 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12514
12515 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12516
12517 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12518
12519 if (!getDB().isSupportsInlineDistinct()) {
12520 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
12521 }
12522
12523 if (orderByComparator != null) {
12524 if (getDB().isSupportsInlineDistinct()) {
12525 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12526 orderByComparator, true);
12527 }
12528 else {
12529 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12530 orderByComparator, true);
12531 }
12532 }
12533 else {
12534 if (getDB().isSupportsInlineDistinct()) {
12535 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
12536 }
12537 else {
12538 query.append(MBThreadModelImpl.ORDER_BY_SQL);
12539 }
12540 }
12541
12542 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12543 MBThread.class.getName(),
12544 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12545
12546 Session session = null;
12547
12548 try {
12549 session = openSession();
12550
12551 SQLQuery q = session.createSynchronizedSQLQuery(sql);
12552
12553 if (getDB().isSupportsInlineDistinct()) {
12554 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
12555 }
12556 else {
12557 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
12558 }
12559
12560 QueryPos qPos = QueryPos.getInstance(q);
12561
12562 qPos.add(groupId);
12563
12564 qPos.add(categoryId);
12565
12566 qPos.add(status);
12567
12568 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
12569 }
12570 catch (Exception e) {
12571 throw processException(e);
12572 }
12573 finally {
12574 closeSession(session);
12575 }
12576 }
12577
12578
12589 @Override
12590 public MBThread[] filterFindByG_NotC_NotS_PrevAndNext(long threadId,
12591 long groupId, long categoryId, int status,
12592 OrderByComparator<MBThread> orderByComparator)
12593 throws NoSuchThreadException {
12594 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12595 return findByG_NotC_NotS_PrevAndNext(threadId, groupId, categoryId,
12596 status, orderByComparator);
12597 }
12598
12599 MBThread mbThread = findByPrimaryKey(threadId);
12600
12601 Session session = null;
12602
12603 try {
12604 session = openSession();
12605
12606 MBThread[] array = new MBThreadImpl[3];
12607
12608 array[0] = filterGetByG_NotC_NotS_PrevAndNext(session, mbThread,
12609 groupId, categoryId, status, orderByComparator, true);
12610
12611 array[1] = mbThread;
12612
12613 array[2] = filterGetByG_NotC_NotS_PrevAndNext(session, mbThread,
12614 groupId, categoryId, status, orderByComparator, false);
12615
12616 return array;
12617 }
12618 catch (Exception e) {
12619 throw processException(e);
12620 }
12621 finally {
12622 closeSession(session);
12623 }
12624 }
12625
12626 protected MBThread filterGetByG_NotC_NotS_PrevAndNext(Session session,
12627 MBThread mbThread, long groupId, long categoryId, int status,
12628 OrderByComparator<MBThread> orderByComparator, boolean previous) {
12629 StringBundler query = null;
12630
12631 if (orderByComparator != null) {
12632 query = new StringBundler(7 +
12633 (orderByComparator.getOrderByConditionFields().length * 3) +
12634 (orderByComparator.getOrderByFields().length * 3));
12635 }
12636 else {
12637 query = new StringBundler(6);
12638 }
12639
12640 if (getDB().isSupportsInlineDistinct()) {
12641 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
12642 }
12643 else {
12644 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
12645 }
12646
12647 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12648
12649 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12650
12651 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12652
12653 if (!getDB().isSupportsInlineDistinct()) {
12654 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
12655 }
12656
12657 if (orderByComparator != null) {
12658 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12659
12660 if (orderByConditionFields.length > 0) {
12661 query.append(WHERE_AND);
12662 }
12663
12664 for (int i = 0; i < orderByConditionFields.length; i++) {
12665 if (getDB().isSupportsInlineDistinct()) {
12666 query.append(_ORDER_BY_ENTITY_ALIAS);
12667 }
12668 else {
12669 query.append(_ORDER_BY_ENTITY_TABLE);
12670 }
12671
12672 query.append(orderByConditionFields[i]);
12673
12674 if ((i + 1) < orderByConditionFields.length) {
12675 if (orderByComparator.isAscending() ^ previous) {
12676 query.append(WHERE_GREATER_THAN_HAS_NEXT);
12677 }
12678 else {
12679 query.append(WHERE_LESSER_THAN_HAS_NEXT);
12680 }
12681 }
12682 else {
12683 if (orderByComparator.isAscending() ^ previous) {
12684 query.append(WHERE_GREATER_THAN);
12685 }
12686 else {
12687 query.append(WHERE_LESSER_THAN);
12688 }
12689 }
12690 }
12691
12692 query.append(ORDER_BY_CLAUSE);
12693
12694 String[] orderByFields = orderByComparator.getOrderByFields();
12695
12696 for (int i = 0; i < orderByFields.length; i++) {
12697 if (getDB().isSupportsInlineDistinct()) {
12698 query.append(_ORDER_BY_ENTITY_ALIAS);
12699 }
12700 else {
12701 query.append(_ORDER_BY_ENTITY_TABLE);
12702 }
12703
12704 query.append(orderByFields[i]);
12705
12706 if ((i + 1) < orderByFields.length) {
12707 if (orderByComparator.isAscending() ^ previous) {
12708 query.append(ORDER_BY_ASC_HAS_NEXT);
12709 }
12710 else {
12711 query.append(ORDER_BY_DESC_HAS_NEXT);
12712 }
12713 }
12714 else {
12715 if (orderByComparator.isAscending() ^ previous) {
12716 query.append(ORDER_BY_ASC);
12717 }
12718 else {
12719 query.append(ORDER_BY_DESC);
12720 }
12721 }
12722 }
12723 }
12724 else {
12725 if (getDB().isSupportsInlineDistinct()) {
12726 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
12727 }
12728 else {
12729 query.append(MBThreadModelImpl.ORDER_BY_SQL);
12730 }
12731 }
12732
12733 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12734 MBThread.class.getName(),
12735 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12736
12737 SQLQuery q = session.createSynchronizedSQLQuery(sql);
12738
12739 q.setFirstResult(0);
12740 q.setMaxResults(2);
12741
12742 if (getDB().isSupportsInlineDistinct()) {
12743 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
12744 }
12745 else {
12746 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
12747 }
12748
12749 QueryPos qPos = QueryPos.getInstance(q);
12750
12751 qPos.add(groupId);
12752
12753 qPos.add(categoryId);
12754
12755 qPos.add(status);
12756
12757 if (orderByComparator != null) {
12758 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
12759
12760 for (Object value : values) {
12761 qPos.add(value);
12762 }
12763 }
12764
12765 List<MBThread> list = q.list();
12766
12767 if (list.size() == 2) {
12768 return list.get(1);
12769 }
12770 else {
12771 return null;
12772 }
12773 }
12774
12775
12782 @Override
12783 public void removeByG_NotC_NotS(long groupId, long categoryId, int status) {
12784 for (MBThread mbThread : findByG_NotC_NotS(groupId, categoryId, status,
12785 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12786 remove(mbThread);
12787 }
12788 }
12789
12790
12798 @Override
12799 public int countByG_NotC_NotS(long groupId, long categoryId, int status) {
12800 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_NOTS;
12801
12802 Object[] finderArgs = new Object[] { groupId, categoryId, status };
12803
12804 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
12805
12806 if (count == null) {
12807 StringBundler query = new StringBundler(4);
12808
12809 query.append(_SQL_COUNT_MBTHREAD_WHERE);
12810
12811 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12812
12813 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12814
12815 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12816
12817 String sql = query.toString();
12818
12819 Session session = null;
12820
12821 try {
12822 session = openSession();
12823
12824 Query q = session.createQuery(sql);
12825
12826 QueryPos qPos = QueryPos.getInstance(q);
12827
12828 qPos.add(groupId);
12829
12830 qPos.add(categoryId);
12831
12832 qPos.add(status);
12833
12834 count = (Long)q.uniqueResult();
12835
12836 finderCache.putResult(finderPath, finderArgs, count);
12837 }
12838 catch (Exception e) {
12839 finderCache.removeResult(finderPath, finderArgs);
12840
12841 throw processException(e);
12842 }
12843 finally {
12844 closeSession(session);
12845 }
12846 }
12847
12848 return count.intValue();
12849 }
12850
12851
12859 @Override
12860 public int filterCountByG_NotC_NotS(long groupId, long categoryId,
12861 int status) {
12862 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12863 return countByG_NotC_NotS(groupId, categoryId, status);
12864 }
12865
12866 StringBundler query = new StringBundler(4);
12867
12868 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
12869
12870 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12871
12872 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12873
12874 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12875
12876 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12877 MBThread.class.getName(),
12878 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12879
12880 Session session = null;
12881
12882 try {
12883 session = openSession();
12884
12885 SQLQuery q = session.createSynchronizedSQLQuery(sql);
12886
12887 q.addScalar(COUNT_COLUMN_NAME,
12888 com.liferay.portal.kernel.dao.orm.Type.LONG);
12889
12890 QueryPos qPos = QueryPos.getInstance(q);
12891
12892 qPos.add(groupId);
12893
12894 qPos.add(categoryId);
12895
12896 qPos.add(status);
12897
12898 Long count = (Long)q.uniqueResult();
12899
12900 return count.intValue();
12901 }
12902 catch (Exception e) {
12903 throw processException(e);
12904 }
12905 finally {
12906 closeSession(session);
12907 }
12908 }
12909
12910 private static final String _FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2 = "mbThread.groupId = ? AND ";
12911 private static final String _FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2 = "mbThread.categoryId != ? AND ";
12912 private static final String _FINDER_COLUMN_G_NOTC_NOTS_STATUS_2 = "mbThread.status != ?";
12913
12914 public MBThreadPersistenceImpl() {
12915 setModelClass(MBThread.class);
12916 }
12917
12918
12923 @Override
12924 public void cacheResult(MBThread mbThread) {
12925 entityCache.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
12926 MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread);
12927
12928 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
12929 new Object[] { mbThread.getUuid(), mbThread.getGroupId() }, mbThread);
12930
12931 finderCache.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
12932 new Object[] { mbThread.getRootMessageId() }, mbThread);
12933
12934 mbThread.resetOriginalValues();
12935 }
12936
12937
12942 @Override
12943 public void cacheResult(List<MBThread> mbThreads) {
12944 for (MBThread mbThread : mbThreads) {
12945 if (entityCache.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
12946 MBThreadImpl.class, mbThread.getPrimaryKey()) == null) {
12947 cacheResult(mbThread);
12948 }
12949 else {
12950 mbThread.resetOriginalValues();
12951 }
12952 }
12953 }
12954
12955
12962 @Override
12963 public void clearCache() {
12964 entityCache.clearCache(MBThreadImpl.class);
12965
12966 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
12967 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12968 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12969 }
12970
12971
12978 @Override
12979 public void clearCache(MBThread mbThread) {
12980 entityCache.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
12981 MBThreadImpl.class, mbThread.getPrimaryKey());
12982
12983 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12984 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12985
12986 clearUniqueFindersCache((MBThreadModelImpl)mbThread);
12987 }
12988
12989 @Override
12990 public void clearCache(List<MBThread> mbThreads) {
12991 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12992 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12993
12994 for (MBThread mbThread : mbThreads) {
12995 entityCache.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
12996 MBThreadImpl.class, mbThread.getPrimaryKey());
12997
12998 clearUniqueFindersCache((MBThreadModelImpl)mbThread);
12999 }
13000 }
13001
13002 protected void cacheUniqueFindersCache(
13003 MBThreadModelImpl mbThreadModelImpl, boolean isNew) {
13004 if (isNew) {
13005 Object[] args = new Object[] {
13006 mbThreadModelImpl.getUuid(), mbThreadModelImpl.getGroupId()
13007 };
13008
13009 finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
13010 Long.valueOf(1));
13011 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
13012 mbThreadModelImpl);
13013
13014 args = new Object[] { mbThreadModelImpl.getRootMessageId() };
13015
13016 finderCache.putResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args,
13017 Long.valueOf(1));
13018 finderCache.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args,
13019 mbThreadModelImpl);
13020 }
13021 else {
13022 if ((mbThreadModelImpl.getColumnBitmask() &
13023 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
13024 Object[] args = new Object[] {
13025 mbThreadModelImpl.getUuid(),
13026 mbThreadModelImpl.getGroupId()
13027 };
13028
13029 finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
13030 Long.valueOf(1));
13031 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
13032 mbThreadModelImpl);
13033 }
13034
13035 if ((mbThreadModelImpl.getColumnBitmask() &
13036 FINDER_PATH_FETCH_BY_ROOTMESSAGEID.getColumnBitmask()) != 0) {
13037 Object[] args = new Object[] {
13038 mbThreadModelImpl.getRootMessageId()
13039 };
13040
13041 finderCache.putResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args,
13042 Long.valueOf(1));
13043 finderCache.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args,
13044 mbThreadModelImpl);
13045 }
13046 }
13047 }
13048
13049 protected void clearUniqueFindersCache(MBThreadModelImpl mbThreadModelImpl) {
13050 Object[] args = new Object[] {
13051 mbThreadModelImpl.getUuid(), mbThreadModelImpl.getGroupId()
13052 };
13053
13054 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
13055 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
13056
13057 if ((mbThreadModelImpl.getColumnBitmask() &
13058 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
13059 args = new Object[] {
13060 mbThreadModelImpl.getOriginalUuid(),
13061 mbThreadModelImpl.getOriginalGroupId()
13062 };
13063
13064 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
13065 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
13066 }
13067
13068 args = new Object[] { mbThreadModelImpl.getRootMessageId() };
13069
13070 finderCache.removeResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args);
13071 finderCache.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args);
13072
13073 if ((mbThreadModelImpl.getColumnBitmask() &
13074 FINDER_PATH_FETCH_BY_ROOTMESSAGEID.getColumnBitmask()) != 0) {
13075 args = new Object[] { mbThreadModelImpl.getOriginalRootMessageId() };
13076
13077 finderCache.removeResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args);
13078 finderCache.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args);
13079 }
13080 }
13081
13082
13088 @Override
13089 public MBThread create(long threadId) {
13090 MBThread mbThread = new MBThreadImpl();
13091
13092 mbThread.setNew(true);
13093 mbThread.setPrimaryKey(threadId);
13094
13095 String uuid = PortalUUIDUtil.generate();
13096
13097 mbThread.setUuid(uuid);
13098
13099 mbThread.setCompanyId(companyProvider.getCompanyId());
13100
13101 return mbThread;
13102 }
13103
13104
13111 @Override
13112 public MBThread remove(long threadId) throws NoSuchThreadException {
13113 return remove((Serializable)threadId);
13114 }
13115
13116
13123 @Override
13124 public MBThread remove(Serializable primaryKey)
13125 throws NoSuchThreadException {
13126 Session session = null;
13127
13128 try {
13129 session = openSession();
13130
13131 MBThread mbThread = (MBThread)session.get(MBThreadImpl.class,
13132 primaryKey);
13133
13134 if (mbThread == null) {
13135 if (_log.isWarnEnabled()) {
13136 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
13137 }
13138
13139 throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
13140 primaryKey);
13141 }
13142
13143 return remove(mbThread);
13144 }
13145 catch (NoSuchThreadException nsee) {
13146 throw nsee;
13147 }
13148 catch (Exception e) {
13149 throw processException(e);
13150 }
13151 finally {
13152 closeSession(session);
13153 }
13154 }
13155
13156 @Override
13157 protected MBThread removeImpl(MBThread mbThread) {
13158 mbThread = toUnwrappedModel(mbThread);
13159
13160 Session session = null;
13161
13162 try {
13163 session = openSession();
13164
13165 if (!session.contains(mbThread)) {
13166 mbThread = (MBThread)session.get(MBThreadImpl.class,
13167 mbThread.getPrimaryKeyObj());
13168 }
13169
13170 if (mbThread != null) {
13171 session.delete(mbThread);
13172 }
13173 }
13174 catch (Exception e) {
13175 throw processException(e);
13176 }
13177 finally {
13178 closeSession(session);
13179 }
13180
13181 if (mbThread != null) {
13182 clearCache(mbThread);
13183 }
13184
13185 return mbThread;
13186 }
13187
13188 @Override
13189 public MBThread updateImpl(MBThread mbThread) {
13190 mbThread = toUnwrappedModel(mbThread);
13191
13192 boolean isNew = mbThread.isNew();
13193
13194 MBThreadModelImpl mbThreadModelImpl = (MBThreadModelImpl)mbThread;
13195
13196 if (Validator.isNull(mbThread.getUuid())) {
13197 String uuid = PortalUUIDUtil.generate();
13198
13199 mbThread.setUuid(uuid);
13200 }
13201
13202 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
13203
13204 Date now = new Date();
13205
13206 if (isNew && (mbThread.getCreateDate() == null)) {
13207 if (serviceContext == null) {
13208 mbThread.setCreateDate(now);
13209 }
13210 else {
13211 mbThread.setCreateDate(serviceContext.getCreateDate(now));
13212 }
13213 }
13214
13215 if (!mbThreadModelImpl.hasSetModifiedDate()) {
13216 if (serviceContext == null) {
13217 mbThread.setModifiedDate(now);
13218 }
13219 else {
13220 mbThread.setModifiedDate(serviceContext.getModifiedDate(now));
13221 }
13222 }
13223
13224 Session session = null;
13225
13226 try {
13227 session = openSession();
13228
13229 if (mbThread.isNew()) {
13230 session.save(mbThread);
13231
13232 mbThread.setNew(false);
13233 }
13234 else {
13235 mbThread = (MBThread)session.merge(mbThread);
13236 }
13237 }
13238 catch (Exception e) {
13239 throw processException(e);
13240 }
13241 finally {
13242 closeSession(session);
13243 }
13244
13245 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
13246
13247 if (isNew || !MBThreadModelImpl.COLUMN_BITMASK_ENABLED) {
13248 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
13249 }
13250
13251 else {
13252 if ((mbThreadModelImpl.getColumnBitmask() &
13253 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
13254 Object[] args = new Object[] { mbThreadModelImpl.getOriginalUuid() };
13255
13256 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
13257 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
13258 args);
13259
13260 args = new Object[] { mbThreadModelImpl.getUuid() };
13261
13262 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
13263 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
13264 args);
13265 }
13266
13267 if ((mbThreadModelImpl.getColumnBitmask() &
13268 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
13269 Object[] args = new Object[] {
13270 mbThreadModelImpl.getOriginalUuid(),
13271 mbThreadModelImpl.getOriginalCompanyId()
13272 };
13273
13274 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
13275 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
13276 args);
13277
13278 args = new Object[] {
13279 mbThreadModelImpl.getUuid(),
13280 mbThreadModelImpl.getCompanyId()
13281 };
13282
13283 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
13284 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
13285 args);
13286 }
13287
13288 if ((mbThreadModelImpl.getColumnBitmask() &
13289 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
13290 Object[] args = new Object[] {
13291 mbThreadModelImpl.getOriginalGroupId()
13292 };
13293
13294 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
13295 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
13296 args);
13297
13298 args = new Object[] { mbThreadModelImpl.getGroupId() };
13299
13300 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
13301 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
13302 args);
13303 }
13304
13305 if ((mbThreadModelImpl.getColumnBitmask() &
13306 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C.getColumnBitmask()) != 0) {
13307 Object[] args = new Object[] {
13308 mbThreadModelImpl.getOriginalGroupId(),
13309 mbThreadModelImpl.getOriginalCategoryId()
13310 };
13311
13312 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
13313 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
13314 args);
13315
13316 args = new Object[] {
13317 mbThreadModelImpl.getGroupId(),
13318 mbThreadModelImpl.getCategoryId()
13319 };
13320
13321 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
13322 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
13323 args);
13324 }
13325
13326 if ((mbThreadModelImpl.getColumnBitmask() &
13327 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
13328 Object[] args = new Object[] {
13329 mbThreadModelImpl.getOriginalGroupId(),
13330 mbThreadModelImpl.getOriginalStatus()
13331 };
13332
13333 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
13334 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
13335 args);
13336
13337 args = new Object[] {
13338 mbThreadModelImpl.getGroupId(),
13339 mbThreadModelImpl.getStatus()
13340 };
13341
13342 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
13343 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
13344 args);
13345 }
13346
13347 if ((mbThreadModelImpl.getColumnBitmask() &
13348 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
13349 Object[] args = new Object[] {
13350 mbThreadModelImpl.getOriginalCategoryId(),
13351 mbThreadModelImpl.getOriginalPriority()
13352 };
13353
13354 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
13355 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
13356 args);
13357
13358 args = new Object[] {
13359 mbThreadModelImpl.getCategoryId(),
13360 mbThreadModelImpl.getPriority()
13361 };
13362
13363 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
13364 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
13365 args);
13366 }
13367
13368 if ((mbThreadModelImpl.getColumnBitmask() &
13369 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P.getColumnBitmask()) != 0) {
13370 Object[] args = new Object[] {
13371 mbThreadModelImpl.getOriginalLastPostDate(),
13372 mbThreadModelImpl.getOriginalPriority()
13373 };
13374
13375 finderCache.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
13376 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
13377 args);
13378
13379 args = new Object[] {
13380 mbThreadModelImpl.getLastPostDate(),
13381 mbThreadModelImpl.getPriority()
13382 };
13383
13384 finderCache.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
13385 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
13386 args);
13387 }
13388
13389 if ((mbThreadModelImpl.getColumnBitmask() &
13390 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
13391 Object[] args = new Object[] {
13392 mbThreadModelImpl.getOriginalGroupId(),
13393 mbThreadModelImpl.getOriginalCategoryId(),
13394 mbThreadModelImpl.getOriginalLastPostDate()
13395 };
13396
13397 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
13398 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
13399 args);
13400
13401 args = new Object[] {
13402 mbThreadModelImpl.getGroupId(),
13403 mbThreadModelImpl.getCategoryId(),
13404 mbThreadModelImpl.getLastPostDate()
13405 };
13406
13407 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
13408 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
13409 args);
13410 }
13411
13412 if ((mbThreadModelImpl.getColumnBitmask() &
13413 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S.getColumnBitmask()) != 0) {
13414 Object[] args = new Object[] {
13415 mbThreadModelImpl.getOriginalGroupId(),
13416 mbThreadModelImpl.getOriginalCategoryId(),
13417 mbThreadModelImpl.getOriginalStatus()
13418 };
13419
13420 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
13421 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S,
13422 args);
13423
13424 args = new Object[] {
13425 mbThreadModelImpl.getGroupId(),
13426 mbThreadModelImpl.getCategoryId(),
13427 mbThreadModelImpl.getStatus()
13428 };
13429
13430 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
13431 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S,
13432 args);
13433 }
13434 }
13435
13436 entityCache.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13437 MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread, false);
13438
13439 clearUniqueFindersCache(mbThreadModelImpl);
13440 cacheUniqueFindersCache(mbThreadModelImpl, isNew);
13441
13442 mbThread.resetOriginalValues();
13443
13444 return mbThread;
13445 }
13446
13447 protected MBThread toUnwrappedModel(MBThread mbThread) {
13448 if (mbThread instanceof MBThreadImpl) {
13449 return mbThread;
13450 }
13451
13452 MBThreadImpl mbThreadImpl = new MBThreadImpl();
13453
13454 mbThreadImpl.setNew(mbThread.isNew());
13455 mbThreadImpl.setPrimaryKey(mbThread.getPrimaryKey());
13456
13457 mbThreadImpl.setUuid(mbThread.getUuid());
13458 mbThreadImpl.setThreadId(mbThread.getThreadId());
13459 mbThreadImpl.setGroupId(mbThread.getGroupId());
13460 mbThreadImpl.setCompanyId(mbThread.getCompanyId());
13461 mbThreadImpl.setUserId(mbThread.getUserId());
13462 mbThreadImpl.setUserName(mbThread.getUserName());
13463 mbThreadImpl.setCreateDate(mbThread.getCreateDate());
13464 mbThreadImpl.setModifiedDate(mbThread.getModifiedDate());
13465 mbThreadImpl.setCategoryId(mbThread.getCategoryId());
13466 mbThreadImpl.setRootMessageId(mbThread.getRootMessageId());
13467 mbThreadImpl.setRootMessageUserId(mbThread.getRootMessageUserId());
13468 mbThreadImpl.setMessageCount(mbThread.getMessageCount());
13469 mbThreadImpl.setViewCount(mbThread.getViewCount());
13470 mbThreadImpl.setLastPostByUserId(mbThread.getLastPostByUserId());
13471 mbThreadImpl.setLastPostDate(mbThread.getLastPostDate());
13472 mbThreadImpl.setPriority(mbThread.getPriority());
13473 mbThreadImpl.setQuestion(mbThread.isQuestion());
13474 mbThreadImpl.setLastPublishDate(mbThread.getLastPublishDate());
13475 mbThreadImpl.setStatus(mbThread.getStatus());
13476 mbThreadImpl.setStatusByUserId(mbThread.getStatusByUserId());
13477 mbThreadImpl.setStatusByUserName(mbThread.getStatusByUserName());
13478 mbThreadImpl.setStatusDate(mbThread.getStatusDate());
13479
13480 return mbThreadImpl;
13481 }
13482
13483
13490 @Override
13491 public MBThread findByPrimaryKey(Serializable primaryKey)
13492 throws NoSuchThreadException {
13493 MBThread mbThread = fetchByPrimaryKey(primaryKey);
13494
13495 if (mbThread == null) {
13496 if (_log.isWarnEnabled()) {
13497 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
13498 }
13499
13500 throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
13501 primaryKey);
13502 }
13503
13504 return mbThread;
13505 }
13506
13507
13514 @Override
13515 public MBThread findByPrimaryKey(long threadId)
13516 throws NoSuchThreadException {
13517 return findByPrimaryKey((Serializable)threadId);
13518 }
13519
13520
13526 @Override
13527 public MBThread fetchByPrimaryKey(Serializable primaryKey) {
13528 MBThread mbThread = (MBThread)entityCache.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13529 MBThreadImpl.class, primaryKey);
13530
13531 if (mbThread == _nullMBThread) {
13532 return null;
13533 }
13534
13535 if (mbThread == null) {
13536 Session session = null;
13537
13538 try {
13539 session = openSession();
13540
13541 mbThread = (MBThread)session.get(MBThreadImpl.class, primaryKey);
13542
13543 if (mbThread != null) {
13544 cacheResult(mbThread);
13545 }
13546 else {
13547 entityCache.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13548 MBThreadImpl.class, primaryKey, _nullMBThread);
13549 }
13550 }
13551 catch (Exception e) {
13552 entityCache.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13553 MBThreadImpl.class, primaryKey);
13554
13555 throw processException(e);
13556 }
13557 finally {
13558 closeSession(session);
13559 }
13560 }
13561
13562 return mbThread;
13563 }
13564
13565
13571 @Override
13572 public MBThread fetchByPrimaryKey(long threadId) {
13573 return fetchByPrimaryKey((Serializable)threadId);
13574 }
13575
13576 @Override
13577 public Map<Serializable, MBThread> fetchByPrimaryKeys(
13578 Set<Serializable> primaryKeys) {
13579 if (primaryKeys.isEmpty()) {
13580 return Collections.emptyMap();
13581 }
13582
13583 Map<Serializable, MBThread> map = new HashMap<Serializable, MBThread>();
13584
13585 if (primaryKeys.size() == 1) {
13586 Iterator<Serializable> iterator = primaryKeys.iterator();
13587
13588 Serializable primaryKey = iterator.next();
13589
13590 MBThread mbThread = fetchByPrimaryKey(primaryKey);
13591
13592 if (mbThread != null) {
13593 map.put(primaryKey, mbThread);
13594 }
13595
13596 return map;
13597 }
13598
13599 Set<Serializable> uncachedPrimaryKeys = null;
13600
13601 for (Serializable primaryKey : primaryKeys) {
13602 MBThread mbThread = (MBThread)entityCache.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13603 MBThreadImpl.class, primaryKey);
13604
13605 if (mbThread == null) {
13606 if (uncachedPrimaryKeys == null) {
13607 uncachedPrimaryKeys = new HashSet<Serializable>();
13608 }
13609
13610 uncachedPrimaryKeys.add(primaryKey);
13611 }
13612 else {
13613 map.put(primaryKey, mbThread);
13614 }
13615 }
13616
13617 if (uncachedPrimaryKeys == null) {
13618 return map;
13619 }
13620
13621 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
13622 1);
13623
13624 query.append(_SQL_SELECT_MBTHREAD_WHERE_PKS_IN);
13625
13626 for (Serializable primaryKey : uncachedPrimaryKeys) {
13627 query.append(String.valueOf(primaryKey));
13628
13629 query.append(StringPool.COMMA);
13630 }
13631
13632 query.setIndex(query.index() - 1);
13633
13634 query.append(StringPool.CLOSE_PARENTHESIS);
13635
13636 String sql = query.toString();
13637
13638 Session session = null;
13639
13640 try {
13641 session = openSession();
13642
13643 Query q = session.createQuery(sql);
13644
13645 for (MBThread mbThread : (List<MBThread>)q.list()) {
13646 map.put(mbThread.getPrimaryKeyObj(), mbThread);
13647
13648 cacheResult(mbThread);
13649
13650 uncachedPrimaryKeys.remove(mbThread.getPrimaryKeyObj());
13651 }
13652
13653 for (Serializable primaryKey : uncachedPrimaryKeys) {
13654 entityCache.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13655 MBThreadImpl.class, primaryKey, _nullMBThread);
13656 }
13657 }
13658 catch (Exception e) {
13659 throw processException(e);
13660 }
13661 finally {
13662 closeSession(session);
13663 }
13664
13665 return map;
13666 }
13667
13668
13673 @Override
13674 public List<MBThread> findAll() {
13675 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13676 }
13677
13678
13689 @Override
13690 public List<MBThread> findAll(int start, int end) {
13691 return findAll(start, end, null);
13692 }
13693
13694
13706 @Override
13707 public List<MBThread> findAll(int start, int end,
13708 OrderByComparator<MBThread> orderByComparator) {
13709 return findAll(start, end, orderByComparator, true);
13710 }
13711
13712
13725 @Override
13726 public List<MBThread> findAll(int start, int end,
13727 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
13728 boolean pagination = true;
13729 FinderPath finderPath = null;
13730 Object[] finderArgs = null;
13731
13732 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13733 (orderByComparator == null)) {
13734 pagination = false;
13735 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
13736 finderArgs = FINDER_ARGS_EMPTY;
13737 }
13738 else {
13739 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
13740 finderArgs = new Object[] { start, end, orderByComparator };
13741 }
13742
13743 List<MBThread> list = null;
13744
13745 if (retrieveFromCache) {
13746 list = (List<MBThread>)finderCache.getResult(finderPath,
13747 finderArgs, this);
13748 }
13749
13750 if (list == null) {
13751 StringBundler query = null;
13752 String sql = null;
13753
13754 if (orderByComparator != null) {
13755 query = new StringBundler(2 +
13756 (orderByComparator.getOrderByFields().length * 2));
13757
13758 query.append(_SQL_SELECT_MBTHREAD);
13759
13760 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13761 orderByComparator);
13762
13763 sql = query.toString();
13764 }
13765 else {
13766 sql = _SQL_SELECT_MBTHREAD;
13767
13768 if (pagination) {
13769 sql = sql.concat(MBThreadModelImpl.ORDER_BY_JPQL);
13770 }
13771 }
13772
13773 Session session = null;
13774
13775 try {
13776 session = openSession();
13777
13778 Query q = session.createQuery(sql);
13779
13780 if (!pagination) {
13781 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
13782 start, end, false);
13783
13784 Collections.sort(list);
13785
13786 list = Collections.unmodifiableList(list);
13787 }
13788 else {
13789 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
13790 start, end);
13791 }
13792
13793 cacheResult(list);
13794
13795 finderCache.putResult(finderPath, finderArgs, list);
13796 }
13797 catch (Exception e) {
13798 finderCache.removeResult(finderPath, finderArgs);
13799
13800 throw processException(e);
13801 }
13802 finally {
13803 closeSession(session);
13804 }
13805 }
13806
13807 return list;
13808 }
13809
13810
13814 @Override
13815 public void removeAll() {
13816 for (MBThread mbThread : findAll()) {
13817 remove(mbThread);
13818 }
13819 }
13820
13821
13826 @Override
13827 public int countAll() {
13828 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
13829 FINDER_ARGS_EMPTY, this);
13830
13831 if (count == null) {
13832 Session session = null;
13833
13834 try {
13835 session = openSession();
13836
13837 Query q = session.createQuery(_SQL_COUNT_MBTHREAD);
13838
13839 count = (Long)q.uniqueResult();
13840
13841 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
13842 count);
13843 }
13844 catch (Exception e) {
13845 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
13846 FINDER_ARGS_EMPTY);
13847
13848 throw processException(e);
13849 }
13850 finally {
13851 closeSession(session);
13852 }
13853 }
13854
13855 return count.intValue();
13856 }
13857
13858 @Override
13859 public Set<String> getBadColumnNames() {
13860 return _badColumnNames;
13861 }
13862
13863 @Override
13864 protected Map<String, Integer> getTableColumnsMap() {
13865 return MBThreadModelImpl.TABLE_COLUMNS_MAP;
13866 }
13867
13868
13871 public void afterPropertiesSet() {
13872 }
13873
13874 public void destroy() {
13875 entityCache.removeCache(MBThreadImpl.class.getName());
13876 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
13877 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
13878 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
13879 }
13880
13881 @BeanReference(type = CompanyProviderWrapper.class)
13882 protected CompanyProvider companyProvider;
13883 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
13884 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
13885 private static final String _SQL_SELECT_MBTHREAD = "SELECT mbThread FROM MBThread mbThread";
13886 private static final String _SQL_SELECT_MBTHREAD_WHERE_PKS_IN = "SELECT mbThread FROM MBThread mbThread WHERE threadId IN (";
13887 private static final String _SQL_SELECT_MBTHREAD_WHERE = "SELECT mbThread FROM MBThread mbThread WHERE ";
13888 private static final String _SQL_COUNT_MBTHREAD = "SELECT COUNT(mbThread) FROM MBThread mbThread";
13889 private static final String _SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(mbThread) FROM MBThread mbThread WHERE ";
13890 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mbThread.threadId";
13891 private static final String _FILTER_SQL_SELECT_MBTHREAD_WHERE = "SELECT DISTINCT {mbThread.*} FROM MBThread mbThread WHERE ";
13892 private static final String _FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1 =
13893 "SELECT {MBThread.*} FROM (SELECT DISTINCT mbThread.threadId FROM MBThread mbThread WHERE ";
13894 private static final String _FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2 =
13895 ") TEMP_TABLE INNER JOIN MBThread ON TEMP_TABLE.threadId = MBThread.threadId";
13896 private static final String _FILTER_SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(DISTINCT mbThread.threadId) AS COUNT_VALUE FROM MBThread mbThread WHERE ";
13897 private static final String _FILTER_ENTITY_ALIAS = "mbThread";
13898 private static final String _FILTER_ENTITY_TABLE = "MBThread";
13899 private static final String _ORDER_BY_ENTITY_ALIAS = "mbThread.";
13900 private static final String _ORDER_BY_ENTITY_TABLE = "MBThread.";
13901 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBThread exists with the primary key ";
13902 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBThread exists with the key {";
13903 private static final Log _log = LogFactoryUtil.getLog(MBThreadPersistenceImpl.class);
13904 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
13905 "uuid"
13906 });
13907 private static final MBThread _nullMBThread = new MBThreadImpl() {
13908 @Override
13909 public Object clone() {
13910 return this;
13911 }
13912
13913 @Override
13914 public CacheModel<MBThread> toCacheModel() {
13915 return _nullMBThreadCacheModel;
13916 }
13917 };
13918
13919 private static final CacheModel<MBThread> _nullMBThreadCacheModel = new CacheModel<MBThread>() {
13920 @Override
13921 public MBThread toEntityModel() {
13922 return _nullMBThread;
13923 }
13924 };
13925 }