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.util.ArrayUtil;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.SetUtil;
035 import com.liferay.portal.kernel.util.StringBundler;
036 import com.liferay.portal.kernel.util.StringPool;
037 import com.liferay.portal.kernel.util.StringUtil;
038 import com.liferay.portal.kernel.util.Validator;
039 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
040 import com.liferay.portal.model.CacheModel;
041 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
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.impl.BasePersistenceImpl;
046
047 import com.liferay.portlet.messageboards.NoSuchThreadException;
048 import com.liferay.portlet.messageboards.model.MBThread;
049 import com.liferay.portlet.messageboards.model.impl.MBThreadImpl;
050 import com.liferay.portlet.messageboards.model.impl.MBThreadModelImpl;
051 import com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence;
052
053 import java.io.Serializable;
054
055 import java.sql.Timestamp;
056
057 import java.util.Arrays;
058 import java.util.Collections;
059 import java.util.Date;
060 import java.util.HashMap;
061 import java.util.HashSet;
062 import java.util.Iterator;
063 import java.util.List;
064 import java.util.Map;
065 import java.util.Set;
066
067
079 @ProviderType
080 public class MBThreadPersistenceImpl extends BasePersistenceImpl<MBThread>
081 implements MBThreadPersistence {
082
087 public static final String FINDER_CLASS_NAME_ENTITY = MBThreadImpl.class.getName();
088 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089 ".List1";
090 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
091 ".List2";
092 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
093 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
094 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
095 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
096 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
098 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
099 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
101 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
102 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
103 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
104 new String[] {
105 String.class.getName(),
106
107 Integer.class.getName(), Integer.class.getName(),
108 OrderByComparator.class.getName()
109 });
110 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
111 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
113 new String[] { String.class.getName() },
114 MBThreadModelImpl.UUID_COLUMN_BITMASK |
115 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
116 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
117 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
118 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
119 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
120 new String[] { String.class.getName() });
121
122
128 @Override
129 public List<MBThread> findByUuid(String uuid) {
130 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
131 }
132
133
145 @Override
146 public List<MBThread> findByUuid(String uuid, int start, int end) {
147 return findByUuid(uuid, start, end, null);
148 }
149
150
163 @Override
164 public List<MBThread> findByUuid(String uuid, int start, int end,
165 OrderByComparator<MBThread> orderByComparator) {
166 return findByUuid(uuid, start, end, orderByComparator, true);
167 }
168
169
183 @Override
184 public List<MBThread> findByUuid(String uuid, int start, int end,
185 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
186 boolean pagination = true;
187 FinderPath finderPath = null;
188 Object[] finderArgs = null;
189
190 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
191 (orderByComparator == null)) {
192 pagination = false;
193 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
194 finderArgs = new Object[] { uuid };
195 }
196 else {
197 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
198 finderArgs = new Object[] { uuid, start, end, orderByComparator };
199 }
200
201 List<MBThread> list = null;
202
203 if (retrieveFromCache) {
204 list = (List<MBThread>)finderCache.getResult(finderPath,
205 finderArgs, this);
206
207 if ((list != null) && !list.isEmpty()) {
208 for (MBThread mbThread : list) {
209 if (!Validator.equals(uuid, mbThread.getUuid())) {
210 list = null;
211
212 break;
213 }
214 }
215 }
216 }
217
218 if (list == null) {
219 StringBundler query = null;
220
221 if (orderByComparator != null) {
222 query = new StringBundler(3 +
223 (orderByComparator.getOrderByFields().length * 3));
224 }
225 else {
226 query = new StringBundler(3);
227 }
228
229 query.append(_SQL_SELECT_MBTHREAD_WHERE);
230
231 boolean bindUuid = false;
232
233 if (uuid == null) {
234 query.append(_FINDER_COLUMN_UUID_UUID_1);
235 }
236 else if (uuid.equals(StringPool.BLANK)) {
237 query.append(_FINDER_COLUMN_UUID_UUID_3);
238 }
239 else {
240 bindUuid = true;
241
242 query.append(_FINDER_COLUMN_UUID_UUID_2);
243 }
244
245 if (orderByComparator != null) {
246 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
247 orderByComparator);
248 }
249 else
250 if (pagination) {
251 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
252 }
253
254 String sql = query.toString();
255
256 Session session = null;
257
258 try {
259 session = openSession();
260
261 Query q = session.createQuery(sql);
262
263 QueryPos qPos = QueryPos.getInstance(q);
264
265 if (bindUuid) {
266 qPos.add(uuid);
267 }
268
269 if (!pagination) {
270 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
271 start, end, false);
272
273 Collections.sort(list);
274
275 list = Collections.unmodifiableList(list);
276 }
277 else {
278 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
279 start, end);
280 }
281
282 cacheResult(list);
283
284 finderCache.putResult(finderPath, finderArgs, list);
285 }
286 catch (Exception e) {
287 finderCache.removeResult(finderPath, finderArgs);
288
289 throw processException(e);
290 }
291 finally {
292 closeSession(session);
293 }
294 }
295
296 return list;
297 }
298
299
307 @Override
308 public MBThread findByUuid_First(String uuid,
309 OrderByComparator<MBThread> orderByComparator)
310 throws NoSuchThreadException {
311 MBThread mbThread = fetchByUuid_First(uuid, orderByComparator);
312
313 if (mbThread != null) {
314 return mbThread;
315 }
316
317 StringBundler msg = new StringBundler(4);
318
319 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
320
321 msg.append("uuid=");
322 msg.append(uuid);
323
324 msg.append(StringPool.CLOSE_CURLY_BRACE);
325
326 throw new NoSuchThreadException(msg.toString());
327 }
328
329
336 @Override
337 public MBThread fetchByUuid_First(String uuid,
338 OrderByComparator<MBThread> orderByComparator) {
339 List<MBThread> list = findByUuid(uuid, 0, 1, orderByComparator);
340
341 if (!list.isEmpty()) {
342 return list.get(0);
343 }
344
345 return null;
346 }
347
348
356 @Override
357 public MBThread findByUuid_Last(String uuid,
358 OrderByComparator<MBThread> orderByComparator)
359 throws NoSuchThreadException {
360 MBThread mbThread = fetchByUuid_Last(uuid, orderByComparator);
361
362 if (mbThread != null) {
363 return mbThread;
364 }
365
366 StringBundler msg = new StringBundler(4);
367
368 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
369
370 msg.append("uuid=");
371 msg.append(uuid);
372
373 msg.append(StringPool.CLOSE_CURLY_BRACE);
374
375 throw new NoSuchThreadException(msg.toString());
376 }
377
378
385 @Override
386 public MBThread fetchByUuid_Last(String uuid,
387 OrderByComparator<MBThread> orderByComparator) {
388 int count = countByUuid(uuid);
389
390 if (count == 0) {
391 return null;
392 }
393
394 List<MBThread> list = findByUuid(uuid, count - 1, count,
395 orderByComparator);
396
397 if (!list.isEmpty()) {
398 return list.get(0);
399 }
400
401 return null;
402 }
403
404
413 @Override
414 public MBThread[] findByUuid_PrevAndNext(long threadId, String uuid,
415 OrderByComparator<MBThread> orderByComparator)
416 throws NoSuchThreadException {
417 MBThread mbThread = findByPrimaryKey(threadId);
418
419 Session session = null;
420
421 try {
422 session = openSession();
423
424 MBThread[] array = new MBThreadImpl[3];
425
426 array[0] = getByUuid_PrevAndNext(session, mbThread, uuid,
427 orderByComparator, true);
428
429 array[1] = mbThread;
430
431 array[2] = getByUuid_PrevAndNext(session, mbThread, uuid,
432 orderByComparator, false);
433
434 return array;
435 }
436 catch (Exception e) {
437 throw processException(e);
438 }
439 finally {
440 closeSession(session);
441 }
442 }
443
444 protected MBThread getByUuid_PrevAndNext(Session session,
445 MBThread mbThread, String uuid,
446 OrderByComparator<MBThread> orderByComparator, boolean previous) {
447 StringBundler query = null;
448
449 if (orderByComparator != null) {
450 query = new StringBundler(6 +
451 (orderByComparator.getOrderByFields().length * 6));
452 }
453 else {
454 query = new StringBundler(3);
455 }
456
457 query.append(_SQL_SELECT_MBTHREAD_WHERE);
458
459 boolean bindUuid = false;
460
461 if (uuid == null) {
462 query.append(_FINDER_COLUMN_UUID_UUID_1);
463 }
464 else if (uuid.equals(StringPool.BLANK)) {
465 query.append(_FINDER_COLUMN_UUID_UUID_3);
466 }
467 else {
468 bindUuid = true;
469
470 query.append(_FINDER_COLUMN_UUID_UUID_2);
471 }
472
473 if (orderByComparator != null) {
474 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
475
476 if (orderByConditionFields.length > 0) {
477 query.append(WHERE_AND);
478 }
479
480 for (int i = 0; i < orderByConditionFields.length; i++) {
481 query.append(_ORDER_BY_ENTITY_ALIAS);
482 query.append(orderByConditionFields[i]);
483
484 if ((i + 1) < orderByConditionFields.length) {
485 if (orderByComparator.isAscending() ^ previous) {
486 query.append(WHERE_GREATER_THAN_HAS_NEXT);
487 }
488 else {
489 query.append(WHERE_LESSER_THAN_HAS_NEXT);
490 }
491 }
492 else {
493 if (orderByComparator.isAscending() ^ previous) {
494 query.append(WHERE_GREATER_THAN);
495 }
496 else {
497 query.append(WHERE_LESSER_THAN);
498 }
499 }
500 }
501
502 query.append(ORDER_BY_CLAUSE);
503
504 String[] orderByFields = orderByComparator.getOrderByFields();
505
506 for (int i = 0; i < orderByFields.length; i++) {
507 query.append(_ORDER_BY_ENTITY_ALIAS);
508 query.append(orderByFields[i]);
509
510 if ((i + 1) < orderByFields.length) {
511 if (orderByComparator.isAscending() ^ previous) {
512 query.append(ORDER_BY_ASC_HAS_NEXT);
513 }
514 else {
515 query.append(ORDER_BY_DESC_HAS_NEXT);
516 }
517 }
518 else {
519 if (orderByComparator.isAscending() ^ previous) {
520 query.append(ORDER_BY_ASC);
521 }
522 else {
523 query.append(ORDER_BY_DESC);
524 }
525 }
526 }
527 }
528 else {
529 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
530 }
531
532 String sql = query.toString();
533
534 Query q = session.createQuery(sql);
535
536 q.setFirstResult(0);
537 q.setMaxResults(2);
538
539 QueryPos qPos = QueryPos.getInstance(q);
540
541 if (bindUuid) {
542 qPos.add(uuid);
543 }
544
545 if (orderByComparator != null) {
546 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
547
548 for (Object value : values) {
549 qPos.add(value);
550 }
551 }
552
553 List<MBThread> list = q.list();
554
555 if (list.size() == 2) {
556 return list.get(1);
557 }
558 else {
559 return null;
560 }
561 }
562
563
568 @Override
569 public void removeByUuid(String uuid) {
570 for (MBThread mbThread : findByUuid(uuid, QueryUtil.ALL_POS,
571 QueryUtil.ALL_POS, null)) {
572 remove(mbThread);
573 }
574 }
575
576
582 @Override
583 public int countByUuid(String uuid) {
584 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
585
586 Object[] finderArgs = new Object[] { uuid };
587
588 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
589
590 if (count == null) {
591 StringBundler query = new StringBundler(2);
592
593 query.append(_SQL_COUNT_MBTHREAD_WHERE);
594
595 boolean bindUuid = false;
596
597 if (uuid == null) {
598 query.append(_FINDER_COLUMN_UUID_UUID_1);
599 }
600 else if (uuid.equals(StringPool.BLANK)) {
601 query.append(_FINDER_COLUMN_UUID_UUID_3);
602 }
603 else {
604 bindUuid = true;
605
606 query.append(_FINDER_COLUMN_UUID_UUID_2);
607 }
608
609 String sql = query.toString();
610
611 Session session = null;
612
613 try {
614 session = openSession();
615
616 Query q = session.createQuery(sql);
617
618 QueryPos qPos = QueryPos.getInstance(q);
619
620 if (bindUuid) {
621 qPos.add(uuid);
622 }
623
624 count = (Long)q.uniqueResult();
625
626 finderCache.putResult(finderPath, finderArgs, count);
627 }
628 catch (Exception e) {
629 finderCache.removeResult(finderPath, finderArgs);
630
631 throw processException(e);
632 }
633 finally {
634 closeSession(session);
635 }
636 }
637
638 return count.intValue();
639 }
640
641 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbThread.uuid IS NULL";
642 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbThread.uuid = ?";
643 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbThread.uuid IS NULL OR mbThread.uuid = '')";
644 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
645 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
646 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
647 new String[] { String.class.getName(), Long.class.getName() },
648 MBThreadModelImpl.UUID_COLUMN_BITMASK |
649 MBThreadModelImpl.GROUPID_COLUMN_BITMASK);
650 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
651 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
652 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
653 new String[] { String.class.getName(), Long.class.getName() });
654
655
663 @Override
664 public MBThread findByUUID_G(String uuid, long groupId)
665 throws NoSuchThreadException {
666 MBThread mbThread = fetchByUUID_G(uuid, groupId);
667
668 if (mbThread == null) {
669 StringBundler msg = new StringBundler(6);
670
671 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
672
673 msg.append("uuid=");
674 msg.append(uuid);
675
676 msg.append(", groupId=");
677 msg.append(groupId);
678
679 msg.append(StringPool.CLOSE_CURLY_BRACE);
680
681 if (_log.isWarnEnabled()) {
682 _log.warn(msg.toString());
683 }
684
685 throw new NoSuchThreadException(msg.toString());
686 }
687
688 return mbThread;
689 }
690
691
698 @Override
699 public MBThread fetchByUUID_G(String uuid, long groupId) {
700 return fetchByUUID_G(uuid, groupId, true);
701 }
702
703
711 @Override
712 public MBThread fetchByUUID_G(String uuid, long groupId,
713 boolean retrieveFromCache) {
714 Object[] finderArgs = new Object[] { uuid, groupId };
715
716 Object result = null;
717
718 if (retrieveFromCache) {
719 result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
720 finderArgs, this);
721 }
722
723 if (result instanceof MBThread) {
724 MBThread mbThread = (MBThread)result;
725
726 if (!Validator.equals(uuid, mbThread.getUuid()) ||
727 (groupId != mbThread.getGroupId())) {
728 result = null;
729 }
730 }
731
732 if (result == null) {
733 StringBundler query = new StringBundler(4);
734
735 query.append(_SQL_SELECT_MBTHREAD_WHERE);
736
737 boolean bindUuid = false;
738
739 if (uuid == null) {
740 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
741 }
742 else if (uuid.equals(StringPool.BLANK)) {
743 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
744 }
745 else {
746 bindUuid = true;
747
748 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
749 }
750
751 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
752
753 String sql = query.toString();
754
755 Session session = null;
756
757 try {
758 session = openSession();
759
760 Query q = session.createQuery(sql);
761
762 QueryPos qPos = QueryPos.getInstance(q);
763
764 if (bindUuid) {
765 qPos.add(uuid);
766 }
767
768 qPos.add(groupId);
769
770 List<MBThread> list = q.list();
771
772 if (list.isEmpty()) {
773 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
774 finderArgs, list);
775 }
776 else {
777 MBThread mbThread = list.get(0);
778
779 result = mbThread;
780
781 cacheResult(mbThread);
782
783 if ((mbThread.getUuid() == null) ||
784 !mbThread.getUuid().equals(uuid) ||
785 (mbThread.getGroupId() != groupId)) {
786 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
787 finderArgs, mbThread);
788 }
789 }
790 }
791 catch (Exception e) {
792 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
793
794 throw processException(e);
795 }
796 finally {
797 closeSession(session);
798 }
799 }
800
801 if (result instanceof List<?>) {
802 return null;
803 }
804 else {
805 return (MBThread)result;
806 }
807 }
808
809
816 @Override
817 public MBThread removeByUUID_G(String uuid, long groupId)
818 throws NoSuchThreadException {
819 MBThread mbThread = findByUUID_G(uuid, groupId);
820
821 return remove(mbThread);
822 }
823
824
831 @Override
832 public int countByUUID_G(String uuid, long groupId) {
833 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
834
835 Object[] finderArgs = new Object[] { uuid, groupId };
836
837 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
838
839 if (count == null) {
840 StringBundler query = new StringBundler(3);
841
842 query.append(_SQL_COUNT_MBTHREAD_WHERE);
843
844 boolean bindUuid = false;
845
846 if (uuid == null) {
847 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
848 }
849 else if (uuid.equals(StringPool.BLANK)) {
850 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
851 }
852 else {
853 bindUuid = true;
854
855 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
856 }
857
858 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
859
860 String sql = query.toString();
861
862 Session session = null;
863
864 try {
865 session = openSession();
866
867 Query q = session.createQuery(sql);
868
869 QueryPos qPos = QueryPos.getInstance(q);
870
871 if (bindUuid) {
872 qPos.add(uuid);
873 }
874
875 qPos.add(groupId);
876
877 count = (Long)q.uniqueResult();
878
879 finderCache.putResult(finderPath, finderArgs, count);
880 }
881 catch (Exception e) {
882 finderCache.removeResult(finderPath, finderArgs);
883
884 throw processException(e);
885 }
886 finally {
887 closeSession(session);
888 }
889 }
890
891 return count.intValue();
892 }
893
894 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbThread.uuid IS NULL AND ";
895 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbThread.uuid = ? AND ";
896 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbThread.uuid IS NULL OR mbThread.uuid = '') AND ";
897 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbThread.groupId = ?";
898 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
899 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
900 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
901 new String[] {
902 String.class.getName(), Long.class.getName(),
903
904 Integer.class.getName(), Integer.class.getName(),
905 OrderByComparator.class.getName()
906 });
907 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
908 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
909 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
910 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
911 new String[] { String.class.getName(), Long.class.getName() },
912 MBThreadModelImpl.UUID_COLUMN_BITMASK |
913 MBThreadModelImpl.COMPANYID_COLUMN_BITMASK |
914 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
915 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
916 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
917 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
918 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
919 new String[] { String.class.getName(), Long.class.getName() });
920
921
928 @Override
929 public List<MBThread> findByUuid_C(String uuid, long companyId) {
930 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
931 QueryUtil.ALL_POS, null);
932 }
933
934
947 @Override
948 public List<MBThread> findByUuid_C(String uuid, long companyId, int start,
949 int end) {
950 return findByUuid_C(uuid, companyId, start, end, null);
951 }
952
953
967 @Override
968 public List<MBThread> findByUuid_C(String uuid, long companyId, int start,
969 int end, OrderByComparator<MBThread> orderByComparator) {
970 return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
971 }
972
973
988 @Override
989 public List<MBThread> findByUuid_C(String uuid, long companyId, int start,
990 int end, OrderByComparator<MBThread> orderByComparator,
991 boolean retrieveFromCache) {
992 boolean pagination = true;
993 FinderPath finderPath = null;
994 Object[] finderArgs = null;
995
996 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
997 (orderByComparator == null)) {
998 pagination = false;
999 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1000 finderArgs = new Object[] { uuid, companyId };
1001 }
1002 else {
1003 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1004 finderArgs = new Object[] {
1005 uuid, companyId,
1006
1007 start, end, orderByComparator
1008 };
1009 }
1010
1011 List<MBThread> list = null;
1012
1013 if (retrieveFromCache) {
1014 list = (List<MBThread>)finderCache.getResult(finderPath,
1015 finderArgs, this);
1016
1017 if ((list != null) && !list.isEmpty()) {
1018 for (MBThread mbThread : list) {
1019 if (!Validator.equals(uuid, mbThread.getUuid()) ||
1020 (companyId != mbThread.getCompanyId())) {
1021 list = null;
1022
1023 break;
1024 }
1025 }
1026 }
1027 }
1028
1029 if (list == null) {
1030 StringBundler query = null;
1031
1032 if (orderByComparator != null) {
1033 query = new StringBundler(4 +
1034 (orderByComparator.getOrderByFields().length * 3));
1035 }
1036 else {
1037 query = new StringBundler(4);
1038 }
1039
1040 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1041
1042 boolean bindUuid = false;
1043
1044 if (uuid == null) {
1045 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1046 }
1047 else if (uuid.equals(StringPool.BLANK)) {
1048 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1049 }
1050 else {
1051 bindUuid = true;
1052
1053 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1054 }
1055
1056 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1057
1058 if (orderByComparator != null) {
1059 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1060 orderByComparator);
1061 }
1062 else
1063 if (pagination) {
1064 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1065 }
1066
1067 String sql = query.toString();
1068
1069 Session session = null;
1070
1071 try {
1072 session = openSession();
1073
1074 Query q = session.createQuery(sql);
1075
1076 QueryPos qPos = QueryPos.getInstance(q);
1077
1078 if (bindUuid) {
1079 qPos.add(uuid);
1080 }
1081
1082 qPos.add(companyId);
1083
1084 if (!pagination) {
1085 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
1086 start, end, false);
1087
1088 Collections.sort(list);
1089
1090 list = Collections.unmodifiableList(list);
1091 }
1092 else {
1093 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
1094 start, end);
1095 }
1096
1097 cacheResult(list);
1098
1099 finderCache.putResult(finderPath, finderArgs, list);
1100 }
1101 catch (Exception e) {
1102 finderCache.removeResult(finderPath, finderArgs);
1103
1104 throw processException(e);
1105 }
1106 finally {
1107 closeSession(session);
1108 }
1109 }
1110
1111 return list;
1112 }
1113
1114
1123 @Override
1124 public MBThread findByUuid_C_First(String uuid, long companyId,
1125 OrderByComparator<MBThread> orderByComparator)
1126 throws NoSuchThreadException {
1127 MBThread mbThread = fetchByUuid_C_First(uuid, companyId,
1128 orderByComparator);
1129
1130 if (mbThread != null) {
1131 return mbThread;
1132 }
1133
1134 StringBundler msg = new StringBundler(6);
1135
1136 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1137
1138 msg.append("uuid=");
1139 msg.append(uuid);
1140
1141 msg.append(", companyId=");
1142 msg.append(companyId);
1143
1144 msg.append(StringPool.CLOSE_CURLY_BRACE);
1145
1146 throw new NoSuchThreadException(msg.toString());
1147 }
1148
1149
1157 @Override
1158 public MBThread fetchByUuid_C_First(String uuid, long companyId,
1159 OrderByComparator<MBThread> orderByComparator) {
1160 List<MBThread> list = findByUuid_C(uuid, companyId, 0, 1,
1161 orderByComparator);
1162
1163 if (!list.isEmpty()) {
1164 return list.get(0);
1165 }
1166
1167 return null;
1168 }
1169
1170
1179 @Override
1180 public MBThread findByUuid_C_Last(String uuid, long companyId,
1181 OrderByComparator<MBThread> orderByComparator)
1182 throws NoSuchThreadException {
1183 MBThread mbThread = fetchByUuid_C_Last(uuid, companyId,
1184 orderByComparator);
1185
1186 if (mbThread != null) {
1187 return mbThread;
1188 }
1189
1190 StringBundler msg = new StringBundler(6);
1191
1192 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1193
1194 msg.append("uuid=");
1195 msg.append(uuid);
1196
1197 msg.append(", companyId=");
1198 msg.append(companyId);
1199
1200 msg.append(StringPool.CLOSE_CURLY_BRACE);
1201
1202 throw new NoSuchThreadException(msg.toString());
1203 }
1204
1205
1213 @Override
1214 public MBThread fetchByUuid_C_Last(String uuid, long companyId,
1215 OrderByComparator<MBThread> orderByComparator) {
1216 int count = countByUuid_C(uuid, companyId);
1217
1218 if (count == 0) {
1219 return null;
1220 }
1221
1222 List<MBThread> list = findByUuid_C(uuid, companyId, count - 1, count,
1223 orderByComparator);
1224
1225 if (!list.isEmpty()) {
1226 return list.get(0);
1227 }
1228
1229 return null;
1230 }
1231
1232
1242 @Override
1243 public MBThread[] findByUuid_C_PrevAndNext(long threadId, String uuid,
1244 long companyId, OrderByComparator<MBThread> orderByComparator)
1245 throws NoSuchThreadException {
1246 MBThread mbThread = findByPrimaryKey(threadId);
1247
1248 Session session = null;
1249
1250 try {
1251 session = openSession();
1252
1253 MBThread[] array = new MBThreadImpl[3];
1254
1255 array[0] = getByUuid_C_PrevAndNext(session, mbThread, uuid,
1256 companyId, orderByComparator, true);
1257
1258 array[1] = mbThread;
1259
1260 array[2] = getByUuid_C_PrevAndNext(session, mbThread, uuid,
1261 companyId, orderByComparator, false);
1262
1263 return array;
1264 }
1265 catch (Exception e) {
1266 throw processException(e);
1267 }
1268 finally {
1269 closeSession(session);
1270 }
1271 }
1272
1273 protected MBThread getByUuid_C_PrevAndNext(Session session,
1274 MBThread mbThread, String uuid, long companyId,
1275 OrderByComparator<MBThread> orderByComparator, boolean previous) {
1276 StringBundler query = null;
1277
1278 if (orderByComparator != null) {
1279 query = new StringBundler(6 +
1280 (orderByComparator.getOrderByFields().length * 6));
1281 }
1282 else {
1283 query = new StringBundler(3);
1284 }
1285
1286 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1287
1288 boolean bindUuid = false;
1289
1290 if (uuid == null) {
1291 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1292 }
1293 else if (uuid.equals(StringPool.BLANK)) {
1294 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1295 }
1296 else {
1297 bindUuid = true;
1298
1299 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1300 }
1301
1302 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1303
1304 if (orderByComparator != null) {
1305 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1306
1307 if (orderByConditionFields.length > 0) {
1308 query.append(WHERE_AND);
1309 }
1310
1311 for (int i = 0; i < orderByConditionFields.length; i++) {
1312 query.append(_ORDER_BY_ENTITY_ALIAS);
1313 query.append(orderByConditionFields[i]);
1314
1315 if ((i + 1) < orderByConditionFields.length) {
1316 if (orderByComparator.isAscending() ^ previous) {
1317 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1318 }
1319 else {
1320 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1321 }
1322 }
1323 else {
1324 if (orderByComparator.isAscending() ^ previous) {
1325 query.append(WHERE_GREATER_THAN);
1326 }
1327 else {
1328 query.append(WHERE_LESSER_THAN);
1329 }
1330 }
1331 }
1332
1333 query.append(ORDER_BY_CLAUSE);
1334
1335 String[] orderByFields = orderByComparator.getOrderByFields();
1336
1337 for (int i = 0; i < orderByFields.length; i++) {
1338 query.append(_ORDER_BY_ENTITY_ALIAS);
1339 query.append(orderByFields[i]);
1340
1341 if ((i + 1) < orderByFields.length) {
1342 if (orderByComparator.isAscending() ^ previous) {
1343 query.append(ORDER_BY_ASC_HAS_NEXT);
1344 }
1345 else {
1346 query.append(ORDER_BY_DESC_HAS_NEXT);
1347 }
1348 }
1349 else {
1350 if (orderByComparator.isAscending() ^ previous) {
1351 query.append(ORDER_BY_ASC);
1352 }
1353 else {
1354 query.append(ORDER_BY_DESC);
1355 }
1356 }
1357 }
1358 }
1359 else {
1360 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1361 }
1362
1363 String sql = query.toString();
1364
1365 Query q = session.createQuery(sql);
1366
1367 q.setFirstResult(0);
1368 q.setMaxResults(2);
1369
1370 QueryPos qPos = QueryPos.getInstance(q);
1371
1372 if (bindUuid) {
1373 qPos.add(uuid);
1374 }
1375
1376 qPos.add(companyId);
1377
1378 if (orderByComparator != null) {
1379 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
1380
1381 for (Object value : values) {
1382 qPos.add(value);
1383 }
1384 }
1385
1386 List<MBThread> list = q.list();
1387
1388 if (list.size() == 2) {
1389 return list.get(1);
1390 }
1391 else {
1392 return null;
1393 }
1394 }
1395
1396
1402 @Override
1403 public void removeByUuid_C(String uuid, long companyId) {
1404 for (MBThread mbThread : findByUuid_C(uuid, companyId,
1405 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1406 remove(mbThread);
1407 }
1408 }
1409
1410
1417 @Override
1418 public int countByUuid_C(String uuid, long companyId) {
1419 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1420
1421 Object[] finderArgs = new Object[] { uuid, companyId };
1422
1423 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1424
1425 if (count == null) {
1426 StringBundler query = new StringBundler(3);
1427
1428 query.append(_SQL_COUNT_MBTHREAD_WHERE);
1429
1430 boolean bindUuid = false;
1431
1432 if (uuid == null) {
1433 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1434 }
1435 else if (uuid.equals(StringPool.BLANK)) {
1436 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1437 }
1438 else {
1439 bindUuid = true;
1440
1441 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1442 }
1443
1444 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1445
1446 String sql = query.toString();
1447
1448 Session session = null;
1449
1450 try {
1451 session = openSession();
1452
1453 Query q = session.createQuery(sql);
1454
1455 QueryPos qPos = QueryPos.getInstance(q);
1456
1457 if (bindUuid) {
1458 qPos.add(uuid);
1459 }
1460
1461 qPos.add(companyId);
1462
1463 count = (Long)q.uniqueResult();
1464
1465 finderCache.putResult(finderPath, finderArgs, count);
1466 }
1467 catch (Exception e) {
1468 finderCache.removeResult(finderPath, finderArgs);
1469
1470 throw processException(e);
1471 }
1472 finally {
1473 closeSession(session);
1474 }
1475 }
1476
1477 return count.intValue();
1478 }
1479
1480 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mbThread.uuid IS NULL AND ";
1481 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mbThread.uuid = ? AND ";
1482 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mbThread.uuid IS NULL OR mbThread.uuid = '') AND ";
1483 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mbThread.companyId = ?";
1484 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
1485 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
1486 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1487 new String[] {
1488 Long.class.getName(),
1489
1490 Integer.class.getName(), Integer.class.getName(),
1491 OrderByComparator.class.getName()
1492 });
1493 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1494 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
1495 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
1496 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1497 new String[] { Long.class.getName() },
1498 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
1499 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
1500 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
1501 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
1502 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
1503 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1504 new String[] { Long.class.getName() });
1505
1506
1512 @Override
1513 public List<MBThread> findByGroupId(long groupId) {
1514 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1515 }
1516
1517
1529 @Override
1530 public List<MBThread> findByGroupId(long groupId, int start, int end) {
1531 return findByGroupId(groupId, start, end, null);
1532 }
1533
1534
1547 @Override
1548 public List<MBThread> findByGroupId(long groupId, int start, int end,
1549 OrderByComparator<MBThread> orderByComparator) {
1550 return findByGroupId(groupId, start, end, orderByComparator, true);
1551 }
1552
1553
1567 @Override
1568 public List<MBThread> findByGroupId(long groupId, int start, int end,
1569 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
1570 boolean pagination = true;
1571 FinderPath finderPath = null;
1572 Object[] finderArgs = null;
1573
1574 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1575 (orderByComparator == null)) {
1576 pagination = false;
1577 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1578 finderArgs = new Object[] { groupId };
1579 }
1580 else {
1581 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1582 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1583 }
1584
1585 List<MBThread> list = null;
1586
1587 if (retrieveFromCache) {
1588 list = (List<MBThread>)finderCache.getResult(finderPath,
1589 finderArgs, this);
1590
1591 if ((list != null) && !list.isEmpty()) {
1592 for (MBThread mbThread : list) {
1593 if ((groupId != mbThread.getGroupId())) {
1594 list = null;
1595
1596 break;
1597 }
1598 }
1599 }
1600 }
1601
1602 if (list == null) {
1603 StringBundler query = null;
1604
1605 if (orderByComparator != null) {
1606 query = new StringBundler(3 +
1607 (orderByComparator.getOrderByFields().length * 3));
1608 }
1609 else {
1610 query = new StringBundler(3);
1611 }
1612
1613 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1614
1615 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1616
1617 if (orderByComparator != null) {
1618 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1619 orderByComparator);
1620 }
1621 else
1622 if (pagination) {
1623 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1624 }
1625
1626 String sql = query.toString();
1627
1628 Session session = null;
1629
1630 try {
1631 session = openSession();
1632
1633 Query q = session.createQuery(sql);
1634
1635 QueryPos qPos = QueryPos.getInstance(q);
1636
1637 qPos.add(groupId);
1638
1639 if (!pagination) {
1640 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
1641 start, end, false);
1642
1643 Collections.sort(list);
1644
1645 list = Collections.unmodifiableList(list);
1646 }
1647 else {
1648 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
1649 start, end);
1650 }
1651
1652 cacheResult(list);
1653
1654 finderCache.putResult(finderPath, finderArgs, list);
1655 }
1656 catch (Exception e) {
1657 finderCache.removeResult(finderPath, finderArgs);
1658
1659 throw processException(e);
1660 }
1661 finally {
1662 closeSession(session);
1663 }
1664 }
1665
1666 return list;
1667 }
1668
1669
1677 @Override
1678 public MBThread findByGroupId_First(long groupId,
1679 OrderByComparator<MBThread> orderByComparator)
1680 throws NoSuchThreadException {
1681 MBThread mbThread = fetchByGroupId_First(groupId, orderByComparator);
1682
1683 if (mbThread != null) {
1684 return mbThread;
1685 }
1686
1687 StringBundler msg = new StringBundler(4);
1688
1689 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1690
1691 msg.append("groupId=");
1692 msg.append(groupId);
1693
1694 msg.append(StringPool.CLOSE_CURLY_BRACE);
1695
1696 throw new NoSuchThreadException(msg.toString());
1697 }
1698
1699
1706 @Override
1707 public MBThread fetchByGroupId_First(long groupId,
1708 OrderByComparator<MBThread> orderByComparator) {
1709 List<MBThread> list = findByGroupId(groupId, 0, 1, orderByComparator);
1710
1711 if (!list.isEmpty()) {
1712 return list.get(0);
1713 }
1714
1715 return null;
1716 }
1717
1718
1726 @Override
1727 public MBThread findByGroupId_Last(long groupId,
1728 OrderByComparator<MBThread> orderByComparator)
1729 throws NoSuchThreadException {
1730 MBThread mbThread = fetchByGroupId_Last(groupId, orderByComparator);
1731
1732 if (mbThread != null) {
1733 return mbThread;
1734 }
1735
1736 StringBundler msg = new StringBundler(4);
1737
1738 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1739
1740 msg.append("groupId=");
1741 msg.append(groupId);
1742
1743 msg.append(StringPool.CLOSE_CURLY_BRACE);
1744
1745 throw new NoSuchThreadException(msg.toString());
1746 }
1747
1748
1755 @Override
1756 public MBThread fetchByGroupId_Last(long groupId,
1757 OrderByComparator<MBThread> orderByComparator) {
1758 int count = countByGroupId(groupId);
1759
1760 if (count == 0) {
1761 return null;
1762 }
1763
1764 List<MBThread> list = findByGroupId(groupId, count - 1, count,
1765 orderByComparator);
1766
1767 if (!list.isEmpty()) {
1768 return list.get(0);
1769 }
1770
1771 return null;
1772 }
1773
1774
1783 @Override
1784 public MBThread[] findByGroupId_PrevAndNext(long threadId, long groupId,
1785 OrderByComparator<MBThread> orderByComparator)
1786 throws NoSuchThreadException {
1787 MBThread mbThread = findByPrimaryKey(threadId);
1788
1789 Session session = null;
1790
1791 try {
1792 session = openSession();
1793
1794 MBThread[] array = new MBThreadImpl[3];
1795
1796 array[0] = getByGroupId_PrevAndNext(session, mbThread, groupId,
1797 orderByComparator, true);
1798
1799 array[1] = mbThread;
1800
1801 array[2] = getByGroupId_PrevAndNext(session, mbThread, groupId,
1802 orderByComparator, false);
1803
1804 return array;
1805 }
1806 catch (Exception e) {
1807 throw processException(e);
1808 }
1809 finally {
1810 closeSession(session);
1811 }
1812 }
1813
1814 protected MBThread getByGroupId_PrevAndNext(Session session,
1815 MBThread mbThread, long groupId,
1816 OrderByComparator<MBThread> orderByComparator, boolean previous) {
1817 StringBundler query = null;
1818
1819 if (orderByComparator != null) {
1820 query = new StringBundler(6 +
1821 (orderByComparator.getOrderByFields().length * 6));
1822 }
1823 else {
1824 query = new StringBundler(3);
1825 }
1826
1827 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1828
1829 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1830
1831 if (orderByComparator != null) {
1832 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1833
1834 if (orderByConditionFields.length > 0) {
1835 query.append(WHERE_AND);
1836 }
1837
1838 for (int i = 0; i < orderByConditionFields.length; i++) {
1839 query.append(_ORDER_BY_ENTITY_ALIAS);
1840 query.append(orderByConditionFields[i]);
1841
1842 if ((i + 1) < orderByConditionFields.length) {
1843 if (orderByComparator.isAscending() ^ previous) {
1844 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1845 }
1846 else {
1847 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1848 }
1849 }
1850 else {
1851 if (orderByComparator.isAscending() ^ previous) {
1852 query.append(WHERE_GREATER_THAN);
1853 }
1854 else {
1855 query.append(WHERE_LESSER_THAN);
1856 }
1857 }
1858 }
1859
1860 query.append(ORDER_BY_CLAUSE);
1861
1862 String[] orderByFields = orderByComparator.getOrderByFields();
1863
1864 for (int i = 0; i < orderByFields.length; i++) {
1865 query.append(_ORDER_BY_ENTITY_ALIAS);
1866 query.append(orderByFields[i]);
1867
1868 if ((i + 1) < orderByFields.length) {
1869 if (orderByComparator.isAscending() ^ previous) {
1870 query.append(ORDER_BY_ASC_HAS_NEXT);
1871 }
1872 else {
1873 query.append(ORDER_BY_DESC_HAS_NEXT);
1874 }
1875 }
1876 else {
1877 if (orderByComparator.isAscending() ^ previous) {
1878 query.append(ORDER_BY_ASC);
1879 }
1880 else {
1881 query.append(ORDER_BY_DESC);
1882 }
1883 }
1884 }
1885 }
1886 else {
1887 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1888 }
1889
1890 String sql = query.toString();
1891
1892 Query q = session.createQuery(sql);
1893
1894 q.setFirstResult(0);
1895 q.setMaxResults(2);
1896
1897 QueryPos qPos = QueryPos.getInstance(q);
1898
1899 qPos.add(groupId);
1900
1901 if (orderByComparator != null) {
1902 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
1903
1904 for (Object value : values) {
1905 qPos.add(value);
1906 }
1907 }
1908
1909 List<MBThread> list = q.list();
1910
1911 if (list.size() == 2) {
1912 return list.get(1);
1913 }
1914 else {
1915 return null;
1916 }
1917 }
1918
1919
1925 @Override
1926 public List<MBThread> filterFindByGroupId(long groupId) {
1927 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1928 QueryUtil.ALL_POS, null);
1929 }
1930
1931
1943 @Override
1944 public List<MBThread> filterFindByGroupId(long groupId, int start, int end) {
1945 return filterFindByGroupId(groupId, start, end, null);
1946 }
1947
1948
1961 @Override
1962 public List<MBThread> filterFindByGroupId(long groupId, int start, int end,
1963 OrderByComparator<MBThread> orderByComparator) {
1964 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1965 return findByGroupId(groupId, start, end, orderByComparator);
1966 }
1967
1968 StringBundler query = null;
1969
1970 if (orderByComparator != null) {
1971 query = new StringBundler(3 +
1972 (orderByComparator.getOrderByFields().length * 3));
1973 }
1974 else {
1975 query = new StringBundler(3);
1976 }
1977
1978 if (getDB().isSupportsInlineDistinct()) {
1979 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
1980 }
1981 else {
1982 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
1983 }
1984
1985 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1986
1987 if (!getDB().isSupportsInlineDistinct()) {
1988 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
1989 }
1990
1991 if (orderByComparator != null) {
1992 if (getDB().isSupportsInlineDistinct()) {
1993 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1994 orderByComparator, true);
1995 }
1996 else {
1997 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1998 orderByComparator, true);
1999 }
2000 }
2001 else {
2002 if (getDB().isSupportsInlineDistinct()) {
2003 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2004 }
2005 else {
2006 query.append(MBThreadModelImpl.ORDER_BY_SQL);
2007 }
2008 }
2009
2010 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2011 MBThread.class.getName(),
2012 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2013
2014 Session session = null;
2015
2016 try {
2017 session = openSession();
2018
2019 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2020
2021 if (getDB().isSupportsInlineDistinct()) {
2022 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
2023 }
2024 else {
2025 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
2026 }
2027
2028 QueryPos qPos = QueryPos.getInstance(q);
2029
2030 qPos.add(groupId);
2031
2032 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
2033 }
2034 catch (Exception e) {
2035 throw processException(e);
2036 }
2037 finally {
2038 closeSession(session);
2039 }
2040 }
2041
2042
2051 @Override
2052 public MBThread[] filterFindByGroupId_PrevAndNext(long threadId,
2053 long groupId, OrderByComparator<MBThread> orderByComparator)
2054 throws NoSuchThreadException {
2055 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2056 return findByGroupId_PrevAndNext(threadId, groupId,
2057 orderByComparator);
2058 }
2059
2060 MBThread mbThread = findByPrimaryKey(threadId);
2061
2062 Session session = null;
2063
2064 try {
2065 session = openSession();
2066
2067 MBThread[] array = new MBThreadImpl[3];
2068
2069 array[0] = filterGetByGroupId_PrevAndNext(session, mbThread,
2070 groupId, orderByComparator, true);
2071
2072 array[1] = mbThread;
2073
2074 array[2] = filterGetByGroupId_PrevAndNext(session, mbThread,
2075 groupId, orderByComparator, false);
2076
2077 return array;
2078 }
2079 catch (Exception e) {
2080 throw processException(e);
2081 }
2082 finally {
2083 closeSession(session);
2084 }
2085 }
2086
2087 protected MBThread filterGetByGroupId_PrevAndNext(Session session,
2088 MBThread mbThread, long groupId,
2089 OrderByComparator<MBThread> orderByComparator, boolean previous) {
2090 StringBundler query = null;
2091
2092 if (orderByComparator != null) {
2093 query = new StringBundler(6 +
2094 (orderByComparator.getOrderByFields().length * 6));
2095 }
2096 else {
2097 query = new StringBundler(3);
2098 }
2099
2100 if (getDB().isSupportsInlineDistinct()) {
2101 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
2102 }
2103 else {
2104 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
2105 }
2106
2107 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2108
2109 if (!getDB().isSupportsInlineDistinct()) {
2110 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
2111 }
2112
2113 if (orderByComparator != null) {
2114 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2115
2116 if (orderByConditionFields.length > 0) {
2117 query.append(WHERE_AND);
2118 }
2119
2120 for (int i = 0; i < orderByConditionFields.length; i++) {
2121 if (getDB().isSupportsInlineDistinct()) {
2122 query.append(_ORDER_BY_ENTITY_ALIAS);
2123 }
2124 else {
2125 query.append(_ORDER_BY_ENTITY_TABLE);
2126 }
2127
2128 query.append(orderByConditionFields[i]);
2129
2130 if ((i + 1) < orderByConditionFields.length) {
2131 if (orderByComparator.isAscending() ^ previous) {
2132 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2133 }
2134 else {
2135 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2136 }
2137 }
2138 else {
2139 if (orderByComparator.isAscending() ^ previous) {
2140 query.append(WHERE_GREATER_THAN);
2141 }
2142 else {
2143 query.append(WHERE_LESSER_THAN);
2144 }
2145 }
2146 }
2147
2148 query.append(ORDER_BY_CLAUSE);
2149
2150 String[] orderByFields = orderByComparator.getOrderByFields();
2151
2152 for (int i = 0; i < orderByFields.length; i++) {
2153 if (getDB().isSupportsInlineDistinct()) {
2154 query.append(_ORDER_BY_ENTITY_ALIAS);
2155 }
2156 else {
2157 query.append(_ORDER_BY_ENTITY_TABLE);
2158 }
2159
2160 query.append(orderByFields[i]);
2161
2162 if ((i + 1) < orderByFields.length) {
2163 if (orderByComparator.isAscending() ^ previous) {
2164 query.append(ORDER_BY_ASC_HAS_NEXT);
2165 }
2166 else {
2167 query.append(ORDER_BY_DESC_HAS_NEXT);
2168 }
2169 }
2170 else {
2171 if (orderByComparator.isAscending() ^ previous) {
2172 query.append(ORDER_BY_ASC);
2173 }
2174 else {
2175 query.append(ORDER_BY_DESC);
2176 }
2177 }
2178 }
2179 }
2180 else {
2181 if (getDB().isSupportsInlineDistinct()) {
2182 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2183 }
2184 else {
2185 query.append(MBThreadModelImpl.ORDER_BY_SQL);
2186 }
2187 }
2188
2189 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2190 MBThread.class.getName(),
2191 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2192
2193 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2194
2195 q.setFirstResult(0);
2196 q.setMaxResults(2);
2197
2198 if (getDB().isSupportsInlineDistinct()) {
2199 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
2200 }
2201 else {
2202 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
2203 }
2204
2205 QueryPos qPos = QueryPos.getInstance(q);
2206
2207 qPos.add(groupId);
2208
2209 if (orderByComparator != null) {
2210 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
2211
2212 for (Object value : values) {
2213 qPos.add(value);
2214 }
2215 }
2216
2217 List<MBThread> list = q.list();
2218
2219 if (list.size() == 2) {
2220 return list.get(1);
2221 }
2222 else {
2223 return null;
2224 }
2225 }
2226
2227
2232 @Override
2233 public void removeByGroupId(long groupId) {
2234 for (MBThread mbThread : findByGroupId(groupId, QueryUtil.ALL_POS,
2235 QueryUtil.ALL_POS, null)) {
2236 remove(mbThread);
2237 }
2238 }
2239
2240
2246 @Override
2247 public int countByGroupId(long groupId) {
2248 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2249
2250 Object[] finderArgs = new Object[] { groupId };
2251
2252 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2253
2254 if (count == null) {
2255 StringBundler query = new StringBundler(2);
2256
2257 query.append(_SQL_COUNT_MBTHREAD_WHERE);
2258
2259 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2260
2261 String sql = query.toString();
2262
2263 Session session = null;
2264
2265 try {
2266 session = openSession();
2267
2268 Query q = session.createQuery(sql);
2269
2270 QueryPos qPos = QueryPos.getInstance(q);
2271
2272 qPos.add(groupId);
2273
2274 count = (Long)q.uniqueResult();
2275
2276 finderCache.putResult(finderPath, finderArgs, count);
2277 }
2278 catch (Exception e) {
2279 finderCache.removeResult(finderPath, finderArgs);
2280
2281 throw processException(e);
2282 }
2283 finally {
2284 closeSession(session);
2285 }
2286 }
2287
2288 return count.intValue();
2289 }
2290
2291
2297 @Override
2298 public int filterCountByGroupId(long groupId) {
2299 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2300 return countByGroupId(groupId);
2301 }
2302
2303 StringBundler query = new StringBundler(2);
2304
2305 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
2306
2307 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2308
2309 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2310 MBThread.class.getName(),
2311 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2312
2313 Session session = null;
2314
2315 try {
2316 session = openSession();
2317
2318 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2319
2320 q.addScalar(COUNT_COLUMN_NAME,
2321 com.liferay.portal.kernel.dao.orm.Type.LONG);
2322
2323 QueryPos qPos = QueryPos.getInstance(q);
2324
2325 qPos.add(groupId);
2326
2327 Long count = (Long)q.uniqueResult();
2328
2329 return count.intValue();
2330 }
2331 catch (Exception e) {
2332 throw processException(e);
2333 }
2334 finally {
2335 closeSession(session);
2336 }
2337 }
2338
2339 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbThread.groupId = ? AND mbThread.categoryId != -1";
2340 public static final FinderPath FINDER_PATH_FETCH_BY_ROOTMESSAGEID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2341 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
2342 FINDER_CLASS_NAME_ENTITY, "fetchByRootMessageId",
2343 new String[] { Long.class.getName() },
2344 MBThreadModelImpl.ROOTMESSAGEID_COLUMN_BITMASK);
2345 public static final FinderPath FINDER_PATH_COUNT_BY_ROOTMESSAGEID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2346 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
2347 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRootMessageId",
2348 new String[] { Long.class.getName() });
2349
2350
2357 @Override
2358 public MBThread findByRootMessageId(long rootMessageId)
2359 throws NoSuchThreadException {
2360 MBThread mbThread = fetchByRootMessageId(rootMessageId);
2361
2362 if (mbThread == null) {
2363 StringBundler msg = new StringBundler(4);
2364
2365 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2366
2367 msg.append("rootMessageId=");
2368 msg.append(rootMessageId);
2369
2370 msg.append(StringPool.CLOSE_CURLY_BRACE);
2371
2372 if (_log.isWarnEnabled()) {
2373 _log.warn(msg.toString());
2374 }
2375
2376 throw new NoSuchThreadException(msg.toString());
2377 }
2378
2379 return mbThread;
2380 }
2381
2382
2388 @Override
2389 public MBThread fetchByRootMessageId(long rootMessageId) {
2390 return fetchByRootMessageId(rootMessageId, true);
2391 }
2392
2393
2400 @Override
2401 public MBThread fetchByRootMessageId(long rootMessageId,
2402 boolean retrieveFromCache) {
2403 Object[] finderArgs = new Object[] { rootMessageId };
2404
2405 Object result = null;
2406
2407 if (retrieveFromCache) {
2408 result = finderCache.getResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
2409 finderArgs, this);
2410 }
2411
2412 if (result instanceof MBThread) {
2413 MBThread mbThread = (MBThread)result;
2414
2415 if ((rootMessageId != mbThread.getRootMessageId())) {
2416 result = null;
2417 }
2418 }
2419
2420 if (result == null) {
2421 StringBundler query = new StringBundler(3);
2422
2423 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2424
2425 query.append(_FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2);
2426
2427 String sql = query.toString();
2428
2429 Session session = null;
2430
2431 try {
2432 session = openSession();
2433
2434 Query q = session.createQuery(sql);
2435
2436 QueryPos qPos = QueryPos.getInstance(q);
2437
2438 qPos.add(rootMessageId);
2439
2440 List<MBThread> list = q.list();
2441
2442 if (list.isEmpty()) {
2443 finderCache.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
2444 finderArgs, list);
2445 }
2446 else {
2447 if ((list.size() > 1) && _log.isWarnEnabled()) {
2448 _log.warn(
2449 "MBThreadPersistenceImpl.fetchByRootMessageId(long, boolean) with parameters (" +
2450 StringUtil.merge(finderArgs) +
2451 ") 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.");
2452 }
2453
2454 MBThread mbThread = list.get(0);
2455
2456 result = mbThread;
2457
2458 cacheResult(mbThread);
2459
2460 if ((mbThread.getRootMessageId() != rootMessageId)) {
2461 finderCache.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
2462 finderArgs, mbThread);
2463 }
2464 }
2465 }
2466 catch (Exception e) {
2467 finderCache.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
2468 finderArgs);
2469
2470 throw processException(e);
2471 }
2472 finally {
2473 closeSession(session);
2474 }
2475 }
2476
2477 if (result instanceof List<?>) {
2478 return null;
2479 }
2480 else {
2481 return (MBThread)result;
2482 }
2483 }
2484
2485
2491 @Override
2492 public MBThread removeByRootMessageId(long rootMessageId)
2493 throws NoSuchThreadException {
2494 MBThread mbThread = findByRootMessageId(rootMessageId);
2495
2496 return remove(mbThread);
2497 }
2498
2499
2505 @Override
2506 public int countByRootMessageId(long rootMessageId) {
2507 FinderPath finderPath = FINDER_PATH_COUNT_BY_ROOTMESSAGEID;
2508
2509 Object[] finderArgs = new Object[] { rootMessageId };
2510
2511 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2512
2513 if (count == null) {
2514 StringBundler query = new StringBundler(2);
2515
2516 query.append(_SQL_COUNT_MBTHREAD_WHERE);
2517
2518 query.append(_FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2);
2519
2520 String sql = query.toString();
2521
2522 Session session = null;
2523
2524 try {
2525 session = openSession();
2526
2527 Query q = session.createQuery(sql);
2528
2529 QueryPos qPos = QueryPos.getInstance(q);
2530
2531 qPos.add(rootMessageId);
2532
2533 count = (Long)q.uniqueResult();
2534
2535 finderCache.putResult(finderPath, finderArgs, count);
2536 }
2537 catch (Exception e) {
2538 finderCache.removeResult(finderPath, finderArgs);
2539
2540 throw processException(e);
2541 }
2542 finally {
2543 closeSession(session);
2544 }
2545 }
2546
2547 return count.intValue();
2548 }
2549
2550 private static final String _FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2 = "mbThread.rootMessageId = ?";
2551 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2552 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
2553 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C",
2554 new String[] {
2555 Long.class.getName(), Long.class.getName(),
2556
2557 Integer.class.getName(), Integer.class.getName(),
2558 OrderByComparator.class.getName()
2559 });
2560 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2561 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
2562 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C",
2563 new String[] { Long.class.getName(), Long.class.getName() },
2564 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
2565 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
2566 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
2567 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
2568 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2569 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
2570 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
2571 new String[] { Long.class.getName(), Long.class.getName() });
2572 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
2573 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
2574 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_C",
2575 new String[] { Long.class.getName(), Long.class.getName() });
2576
2577
2584 @Override
2585 public List<MBThread> findByG_C(long groupId, long categoryId) {
2586 return findByG_C(groupId, categoryId, QueryUtil.ALL_POS,
2587 QueryUtil.ALL_POS, null);
2588 }
2589
2590
2603 @Override
2604 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
2605 int end) {
2606 return findByG_C(groupId, categoryId, start, end, null);
2607 }
2608
2609
2623 @Override
2624 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
2625 int end, OrderByComparator<MBThread> orderByComparator) {
2626 return findByG_C(groupId, categoryId, start, end, orderByComparator,
2627 true);
2628 }
2629
2630
2645 @Override
2646 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
2647 int end, OrderByComparator<MBThread> orderByComparator,
2648 boolean retrieveFromCache) {
2649 boolean pagination = true;
2650 FinderPath finderPath = null;
2651 Object[] finderArgs = null;
2652
2653 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2654 (orderByComparator == null)) {
2655 pagination = false;
2656 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C;
2657 finderArgs = new Object[] { groupId, categoryId };
2658 }
2659 else {
2660 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C;
2661 finderArgs = new Object[] {
2662 groupId, categoryId,
2663
2664 start, end, orderByComparator
2665 };
2666 }
2667
2668 List<MBThread> list = null;
2669
2670 if (retrieveFromCache) {
2671 list = (List<MBThread>)finderCache.getResult(finderPath,
2672 finderArgs, this);
2673
2674 if ((list != null) && !list.isEmpty()) {
2675 for (MBThread mbThread : list) {
2676 if ((groupId != mbThread.getGroupId()) ||
2677 (categoryId != mbThread.getCategoryId())) {
2678 list = null;
2679
2680 break;
2681 }
2682 }
2683 }
2684 }
2685
2686 if (list == null) {
2687 StringBundler query = null;
2688
2689 if (orderByComparator != null) {
2690 query = new StringBundler(4 +
2691 (orderByComparator.getOrderByFields().length * 3));
2692 }
2693 else {
2694 query = new StringBundler(4);
2695 }
2696
2697 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2698
2699 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2700
2701 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2702
2703 if (orderByComparator != null) {
2704 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2705 orderByComparator);
2706 }
2707 else
2708 if (pagination) {
2709 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2710 }
2711
2712 String sql = query.toString();
2713
2714 Session session = null;
2715
2716 try {
2717 session = openSession();
2718
2719 Query q = session.createQuery(sql);
2720
2721 QueryPos qPos = QueryPos.getInstance(q);
2722
2723 qPos.add(groupId);
2724
2725 qPos.add(categoryId);
2726
2727 if (!pagination) {
2728 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
2729 start, end, false);
2730
2731 Collections.sort(list);
2732
2733 list = Collections.unmodifiableList(list);
2734 }
2735 else {
2736 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
2737 start, end);
2738 }
2739
2740 cacheResult(list);
2741
2742 finderCache.putResult(finderPath, finderArgs, list);
2743 }
2744 catch (Exception e) {
2745 finderCache.removeResult(finderPath, finderArgs);
2746
2747 throw processException(e);
2748 }
2749 finally {
2750 closeSession(session);
2751 }
2752 }
2753
2754 return list;
2755 }
2756
2757
2766 @Override
2767 public MBThread findByG_C_First(long groupId, long categoryId,
2768 OrderByComparator<MBThread> orderByComparator)
2769 throws NoSuchThreadException {
2770 MBThread mbThread = fetchByG_C_First(groupId, categoryId,
2771 orderByComparator);
2772
2773 if (mbThread != null) {
2774 return mbThread;
2775 }
2776
2777 StringBundler msg = new StringBundler(6);
2778
2779 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2780
2781 msg.append("groupId=");
2782 msg.append(groupId);
2783
2784 msg.append(", categoryId=");
2785 msg.append(categoryId);
2786
2787 msg.append(StringPool.CLOSE_CURLY_BRACE);
2788
2789 throw new NoSuchThreadException(msg.toString());
2790 }
2791
2792
2800 @Override
2801 public MBThread fetchByG_C_First(long groupId, long categoryId,
2802 OrderByComparator<MBThread> orderByComparator) {
2803 List<MBThread> list = findByG_C(groupId, categoryId, 0, 1,
2804 orderByComparator);
2805
2806 if (!list.isEmpty()) {
2807 return list.get(0);
2808 }
2809
2810 return null;
2811 }
2812
2813
2822 @Override
2823 public MBThread findByG_C_Last(long groupId, long categoryId,
2824 OrderByComparator<MBThread> orderByComparator)
2825 throws NoSuchThreadException {
2826 MBThread mbThread = fetchByG_C_Last(groupId, categoryId,
2827 orderByComparator);
2828
2829 if (mbThread != null) {
2830 return mbThread;
2831 }
2832
2833 StringBundler msg = new StringBundler(6);
2834
2835 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2836
2837 msg.append("groupId=");
2838 msg.append(groupId);
2839
2840 msg.append(", categoryId=");
2841 msg.append(categoryId);
2842
2843 msg.append(StringPool.CLOSE_CURLY_BRACE);
2844
2845 throw new NoSuchThreadException(msg.toString());
2846 }
2847
2848
2856 @Override
2857 public MBThread fetchByG_C_Last(long groupId, long categoryId,
2858 OrderByComparator<MBThread> orderByComparator) {
2859 int count = countByG_C(groupId, categoryId);
2860
2861 if (count == 0) {
2862 return null;
2863 }
2864
2865 List<MBThread> list = findByG_C(groupId, categoryId, count - 1, count,
2866 orderByComparator);
2867
2868 if (!list.isEmpty()) {
2869 return list.get(0);
2870 }
2871
2872 return null;
2873 }
2874
2875
2885 @Override
2886 public MBThread[] findByG_C_PrevAndNext(long threadId, long groupId,
2887 long categoryId, OrderByComparator<MBThread> orderByComparator)
2888 throws NoSuchThreadException {
2889 MBThread mbThread = findByPrimaryKey(threadId);
2890
2891 Session session = null;
2892
2893 try {
2894 session = openSession();
2895
2896 MBThread[] array = new MBThreadImpl[3];
2897
2898 array[0] = getByG_C_PrevAndNext(session, mbThread, groupId,
2899 categoryId, orderByComparator, true);
2900
2901 array[1] = mbThread;
2902
2903 array[2] = getByG_C_PrevAndNext(session, mbThread, groupId,
2904 categoryId, orderByComparator, false);
2905
2906 return array;
2907 }
2908 catch (Exception e) {
2909 throw processException(e);
2910 }
2911 finally {
2912 closeSession(session);
2913 }
2914 }
2915
2916 protected MBThread getByG_C_PrevAndNext(Session session, MBThread mbThread,
2917 long groupId, long categoryId,
2918 OrderByComparator<MBThread> orderByComparator, boolean previous) {
2919 StringBundler query = null;
2920
2921 if (orderByComparator != null) {
2922 query = new StringBundler(6 +
2923 (orderByComparator.getOrderByFields().length * 6));
2924 }
2925 else {
2926 query = new StringBundler(3);
2927 }
2928
2929 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2930
2931 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2932
2933 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2934
2935 if (orderByComparator != null) {
2936 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2937
2938 if (orderByConditionFields.length > 0) {
2939 query.append(WHERE_AND);
2940 }
2941
2942 for (int i = 0; i < orderByConditionFields.length; i++) {
2943 query.append(_ORDER_BY_ENTITY_ALIAS);
2944 query.append(orderByConditionFields[i]);
2945
2946 if ((i + 1) < orderByConditionFields.length) {
2947 if (orderByComparator.isAscending() ^ previous) {
2948 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2949 }
2950 else {
2951 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2952 }
2953 }
2954 else {
2955 if (orderByComparator.isAscending() ^ previous) {
2956 query.append(WHERE_GREATER_THAN);
2957 }
2958 else {
2959 query.append(WHERE_LESSER_THAN);
2960 }
2961 }
2962 }
2963
2964 query.append(ORDER_BY_CLAUSE);
2965
2966 String[] orderByFields = orderByComparator.getOrderByFields();
2967
2968 for (int i = 0; i < orderByFields.length; i++) {
2969 query.append(_ORDER_BY_ENTITY_ALIAS);
2970 query.append(orderByFields[i]);
2971
2972 if ((i + 1) < orderByFields.length) {
2973 if (orderByComparator.isAscending() ^ previous) {
2974 query.append(ORDER_BY_ASC_HAS_NEXT);
2975 }
2976 else {
2977 query.append(ORDER_BY_DESC_HAS_NEXT);
2978 }
2979 }
2980 else {
2981 if (orderByComparator.isAscending() ^ previous) {
2982 query.append(ORDER_BY_ASC);
2983 }
2984 else {
2985 query.append(ORDER_BY_DESC);
2986 }
2987 }
2988 }
2989 }
2990 else {
2991 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2992 }
2993
2994 String sql = query.toString();
2995
2996 Query q = session.createQuery(sql);
2997
2998 q.setFirstResult(0);
2999 q.setMaxResults(2);
3000
3001 QueryPos qPos = QueryPos.getInstance(q);
3002
3003 qPos.add(groupId);
3004
3005 qPos.add(categoryId);
3006
3007 if (orderByComparator != null) {
3008 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
3009
3010 for (Object value : values) {
3011 qPos.add(value);
3012 }
3013 }
3014
3015 List<MBThread> list = q.list();
3016
3017 if (list.size() == 2) {
3018 return list.get(1);
3019 }
3020 else {
3021 return null;
3022 }
3023 }
3024
3025
3032 @Override
3033 public List<MBThread> filterFindByG_C(long groupId, long categoryId) {
3034 return filterFindByG_C(groupId, categoryId, QueryUtil.ALL_POS,
3035 QueryUtil.ALL_POS, null);
3036 }
3037
3038
3051 @Override
3052 public List<MBThread> filterFindByG_C(long groupId, long categoryId,
3053 int start, int end) {
3054 return filterFindByG_C(groupId, categoryId, start, end, null);
3055 }
3056
3057
3071 @Override
3072 public List<MBThread> filterFindByG_C(long groupId, long categoryId,
3073 int start, int end, OrderByComparator<MBThread> orderByComparator) {
3074 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3075 return findByG_C(groupId, categoryId, start, end, orderByComparator);
3076 }
3077
3078 StringBundler query = null;
3079
3080 if (orderByComparator != null) {
3081 query = new StringBundler(4 +
3082 (orderByComparator.getOrderByFields().length * 3));
3083 }
3084 else {
3085 query = new StringBundler(4);
3086 }
3087
3088 if (getDB().isSupportsInlineDistinct()) {
3089 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3090 }
3091 else {
3092 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3093 }
3094
3095 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3096
3097 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
3098
3099 if (!getDB().isSupportsInlineDistinct()) {
3100 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3101 }
3102
3103 if (orderByComparator != null) {
3104 if (getDB().isSupportsInlineDistinct()) {
3105 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3106 orderByComparator, true);
3107 }
3108 else {
3109 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3110 orderByComparator, true);
3111 }
3112 }
3113 else {
3114 if (getDB().isSupportsInlineDistinct()) {
3115 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3116 }
3117 else {
3118 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3119 }
3120 }
3121
3122 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3123 MBThread.class.getName(),
3124 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3125
3126 Session session = null;
3127
3128 try {
3129 session = openSession();
3130
3131 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3132
3133 if (getDB().isSupportsInlineDistinct()) {
3134 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3135 }
3136 else {
3137 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3138 }
3139
3140 QueryPos qPos = QueryPos.getInstance(q);
3141
3142 qPos.add(groupId);
3143
3144 qPos.add(categoryId);
3145
3146 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
3147 }
3148 catch (Exception e) {
3149 throw processException(e);
3150 }
3151 finally {
3152 closeSession(session);
3153 }
3154 }
3155
3156
3166 @Override
3167 public MBThread[] filterFindByG_C_PrevAndNext(long threadId, long groupId,
3168 long categoryId, OrderByComparator<MBThread> orderByComparator)
3169 throws NoSuchThreadException {
3170 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3171 return findByG_C_PrevAndNext(threadId, groupId, categoryId,
3172 orderByComparator);
3173 }
3174
3175 MBThread mbThread = findByPrimaryKey(threadId);
3176
3177 Session session = null;
3178
3179 try {
3180 session = openSession();
3181
3182 MBThread[] array = new MBThreadImpl[3];
3183
3184 array[0] = filterGetByG_C_PrevAndNext(session, mbThread, groupId,
3185 categoryId, orderByComparator, true);
3186
3187 array[1] = mbThread;
3188
3189 array[2] = filterGetByG_C_PrevAndNext(session, mbThread, groupId,
3190 categoryId, orderByComparator, false);
3191
3192 return array;
3193 }
3194 catch (Exception e) {
3195 throw processException(e);
3196 }
3197 finally {
3198 closeSession(session);
3199 }
3200 }
3201
3202 protected MBThread filterGetByG_C_PrevAndNext(Session session,
3203 MBThread mbThread, long groupId, long categoryId,
3204 OrderByComparator<MBThread> orderByComparator, boolean previous) {
3205 StringBundler query = null;
3206
3207 if (orderByComparator != null) {
3208 query = new StringBundler(6 +
3209 (orderByComparator.getOrderByFields().length * 6));
3210 }
3211 else {
3212 query = new StringBundler(3);
3213 }
3214
3215 if (getDB().isSupportsInlineDistinct()) {
3216 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3217 }
3218 else {
3219 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3220 }
3221
3222 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3223
3224 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
3225
3226 if (!getDB().isSupportsInlineDistinct()) {
3227 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3228 }
3229
3230 if (orderByComparator != null) {
3231 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3232
3233 if (orderByConditionFields.length > 0) {
3234 query.append(WHERE_AND);
3235 }
3236
3237 for (int i = 0; i < orderByConditionFields.length; i++) {
3238 if (getDB().isSupportsInlineDistinct()) {
3239 query.append(_ORDER_BY_ENTITY_ALIAS);
3240 }
3241 else {
3242 query.append(_ORDER_BY_ENTITY_TABLE);
3243 }
3244
3245 query.append(orderByConditionFields[i]);
3246
3247 if ((i + 1) < orderByConditionFields.length) {
3248 if (orderByComparator.isAscending() ^ previous) {
3249 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3250 }
3251 else {
3252 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3253 }
3254 }
3255 else {
3256 if (orderByComparator.isAscending() ^ previous) {
3257 query.append(WHERE_GREATER_THAN);
3258 }
3259 else {
3260 query.append(WHERE_LESSER_THAN);
3261 }
3262 }
3263 }
3264
3265 query.append(ORDER_BY_CLAUSE);
3266
3267 String[] orderByFields = orderByComparator.getOrderByFields();
3268
3269 for (int i = 0; i < orderByFields.length; i++) {
3270 if (getDB().isSupportsInlineDistinct()) {
3271 query.append(_ORDER_BY_ENTITY_ALIAS);
3272 }
3273 else {
3274 query.append(_ORDER_BY_ENTITY_TABLE);
3275 }
3276
3277 query.append(orderByFields[i]);
3278
3279 if ((i + 1) < orderByFields.length) {
3280 if (orderByComparator.isAscending() ^ previous) {
3281 query.append(ORDER_BY_ASC_HAS_NEXT);
3282 }
3283 else {
3284 query.append(ORDER_BY_DESC_HAS_NEXT);
3285 }
3286 }
3287 else {
3288 if (orderByComparator.isAscending() ^ previous) {
3289 query.append(ORDER_BY_ASC);
3290 }
3291 else {
3292 query.append(ORDER_BY_DESC);
3293 }
3294 }
3295 }
3296 }
3297 else {
3298 if (getDB().isSupportsInlineDistinct()) {
3299 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3300 }
3301 else {
3302 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3303 }
3304 }
3305
3306 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3307 MBThread.class.getName(),
3308 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3309
3310 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3311
3312 q.setFirstResult(0);
3313 q.setMaxResults(2);
3314
3315 if (getDB().isSupportsInlineDistinct()) {
3316 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3317 }
3318 else {
3319 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3320 }
3321
3322 QueryPos qPos = QueryPos.getInstance(q);
3323
3324 qPos.add(groupId);
3325
3326 qPos.add(categoryId);
3327
3328 if (orderByComparator != null) {
3329 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
3330
3331 for (Object value : values) {
3332 qPos.add(value);
3333 }
3334 }
3335
3336 List<MBThread> list = q.list();
3337
3338 if (list.size() == 2) {
3339 return list.get(1);
3340 }
3341 else {
3342 return null;
3343 }
3344 }
3345
3346
3353 @Override
3354 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds) {
3355 return filterFindByG_C(groupId, categoryIds, QueryUtil.ALL_POS,
3356 QueryUtil.ALL_POS, null);
3357 }
3358
3359
3372 @Override
3373 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds,
3374 int start, int end) {
3375 return filterFindByG_C(groupId, categoryIds, start, end, null);
3376 }
3377
3378
3392 @Override
3393 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds,
3394 int start, int end, OrderByComparator<MBThread> orderByComparator) {
3395 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3396 return findByG_C(groupId, categoryIds, start, end, orderByComparator);
3397 }
3398
3399 if (categoryIds == null) {
3400 categoryIds = new long[0];
3401 }
3402 else if (categoryIds.length > 1) {
3403 categoryIds = ArrayUtil.unique(categoryIds);
3404
3405 Arrays.sort(categoryIds);
3406 }
3407
3408 StringBundler query = new StringBundler();
3409
3410 if (getDB().isSupportsInlineDistinct()) {
3411 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3412 }
3413 else {
3414 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3415 }
3416
3417 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3418
3419 if (categoryIds.length > 0) {
3420 query.append(StringPool.OPEN_PARENTHESIS);
3421
3422 query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
3423
3424 query.append(StringUtil.merge(categoryIds));
3425
3426 query.append(StringPool.CLOSE_PARENTHESIS);
3427
3428 query.append(StringPool.CLOSE_PARENTHESIS);
3429 }
3430
3431 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
3432 query.index() - 1);
3433
3434 if (!getDB().isSupportsInlineDistinct()) {
3435 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3436 }
3437
3438 if (orderByComparator != null) {
3439 if (getDB().isSupportsInlineDistinct()) {
3440 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3441 orderByComparator, true);
3442 }
3443 else {
3444 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3445 orderByComparator, true);
3446 }
3447 }
3448 else {
3449 if (getDB().isSupportsInlineDistinct()) {
3450 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3451 }
3452 else {
3453 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3454 }
3455 }
3456
3457 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3458 MBThread.class.getName(),
3459 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3460
3461 Session session = null;
3462
3463 try {
3464 session = openSession();
3465
3466 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3467
3468 if (getDB().isSupportsInlineDistinct()) {
3469 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3470 }
3471 else {
3472 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3473 }
3474
3475 QueryPos qPos = QueryPos.getInstance(q);
3476
3477 qPos.add(groupId);
3478
3479 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
3480 }
3481 catch (Exception e) {
3482 throw processException(e);
3483 }
3484 finally {
3485 closeSession(session);
3486 }
3487 }
3488
3489
3500 @Override
3501 public List<MBThread> findByG_C(long groupId, long[] categoryIds) {
3502 return findByG_C(groupId, categoryIds, QueryUtil.ALL_POS,
3503 QueryUtil.ALL_POS, null);
3504 }
3505
3506
3519 @Override
3520 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
3521 int start, int end) {
3522 return findByG_C(groupId, categoryIds, start, end, null);
3523 }
3524
3525
3539 @Override
3540 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
3541 int start, int end, OrderByComparator<MBThread> orderByComparator) {
3542 return findByG_C(groupId, categoryIds, start, end, orderByComparator,
3543 true);
3544 }
3545
3546
3561 @Override
3562 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
3563 int start, int end, OrderByComparator<MBThread> orderByComparator,
3564 boolean retrieveFromCache) {
3565 if (categoryIds == null) {
3566 categoryIds = new long[0];
3567 }
3568 else if (categoryIds.length > 1) {
3569 categoryIds = ArrayUtil.unique(categoryIds);
3570
3571 Arrays.sort(categoryIds);
3572 }
3573
3574 if (categoryIds.length == 1) {
3575 return findByG_C(groupId, categoryIds[0], start, end,
3576 orderByComparator);
3577 }
3578
3579 boolean pagination = true;
3580 Object[] finderArgs = null;
3581
3582 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3583 (orderByComparator == null)) {
3584 pagination = false;
3585 finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds) };
3586 }
3587 else {
3588 finderArgs = new Object[] {
3589 groupId, StringUtil.merge(categoryIds),
3590
3591 start, end, orderByComparator
3592 };
3593 }
3594
3595 List<MBThread> list = null;
3596
3597 if (retrieveFromCache) {
3598 list = (List<MBThread>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C,
3599 finderArgs, this);
3600
3601 if ((list != null) && !list.isEmpty()) {
3602 for (MBThread mbThread : list) {
3603 if ((groupId != mbThread.getGroupId()) ||
3604 !ArrayUtil.contains(categoryIds,
3605 mbThread.getCategoryId())) {
3606 list = null;
3607
3608 break;
3609 }
3610 }
3611 }
3612 }
3613
3614 if (list == null) {
3615 StringBundler query = new StringBundler();
3616
3617 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3618
3619 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3620
3621 if (categoryIds.length > 0) {
3622 query.append(StringPool.OPEN_PARENTHESIS);
3623
3624 query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
3625
3626 query.append(StringUtil.merge(categoryIds));
3627
3628 query.append(StringPool.CLOSE_PARENTHESIS);
3629
3630 query.append(StringPool.CLOSE_PARENTHESIS);
3631 }
3632
3633 query.setStringAt(removeConjunction(query.stringAt(query.index() -
3634 1)), query.index() - 1);
3635
3636 if (orderByComparator != null) {
3637 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3638 orderByComparator);
3639 }
3640 else
3641 if (pagination) {
3642 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3643 }
3644
3645 String sql = query.toString();
3646
3647 Session session = null;
3648
3649 try {
3650 session = openSession();
3651
3652 Query q = session.createQuery(sql);
3653
3654 QueryPos qPos = QueryPos.getInstance(q);
3655
3656 qPos.add(groupId);
3657
3658 if (!pagination) {
3659 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
3660 start, end, false);
3661
3662 Collections.sort(list);
3663
3664 list = Collections.unmodifiableList(list);
3665 }
3666 else {
3667 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
3668 start, end);
3669 }
3670
3671 cacheResult(list);
3672
3673 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C,
3674 finderArgs, list);
3675 }
3676 catch (Exception e) {
3677 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C,
3678 finderArgs);
3679
3680 throw processException(e);
3681 }
3682 finally {
3683 closeSession(session);
3684 }
3685 }
3686
3687 return list;
3688 }
3689
3690
3696 @Override
3697 public void removeByG_C(long groupId, long categoryId) {
3698 for (MBThread mbThread : findByG_C(groupId, categoryId,
3699 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3700 remove(mbThread);
3701 }
3702 }
3703
3704
3711 @Override
3712 public int countByG_C(long groupId, long categoryId) {
3713 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C;
3714
3715 Object[] finderArgs = new Object[] { groupId, categoryId };
3716
3717 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3718
3719 if (count == null) {
3720 StringBundler query = new StringBundler(3);
3721
3722 query.append(_SQL_COUNT_MBTHREAD_WHERE);
3723
3724 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3725
3726 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
3727
3728 String sql = query.toString();
3729
3730 Session session = null;
3731
3732 try {
3733 session = openSession();
3734
3735 Query q = session.createQuery(sql);
3736
3737 QueryPos qPos = QueryPos.getInstance(q);
3738
3739 qPos.add(groupId);
3740
3741 qPos.add(categoryId);
3742
3743 count = (Long)q.uniqueResult();
3744
3745 finderCache.putResult(finderPath, finderArgs, count);
3746 }
3747 catch (Exception e) {
3748 finderCache.removeResult(finderPath, finderArgs);
3749
3750 throw processException(e);
3751 }
3752 finally {
3753 closeSession(session);
3754 }
3755 }
3756
3757 return count.intValue();
3758 }
3759
3760
3767 @Override
3768 public int countByG_C(long groupId, long[] categoryIds) {
3769 if (categoryIds == null) {
3770 categoryIds = new long[0];
3771 }
3772 else if (categoryIds.length > 1) {
3773 categoryIds = ArrayUtil.unique(categoryIds);
3774
3775 Arrays.sort(categoryIds);
3776 }
3777
3778 Object[] finderArgs = new Object[] {
3779 groupId, StringUtil.merge(categoryIds)
3780 };
3781
3782 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
3783 finderArgs, this);
3784
3785 if (count == null) {
3786 StringBundler query = new StringBundler();
3787
3788 query.append(_SQL_COUNT_MBTHREAD_WHERE);
3789
3790 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3791
3792 if (categoryIds.length > 0) {
3793 query.append(StringPool.OPEN_PARENTHESIS);
3794
3795 query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
3796
3797 query.append(StringUtil.merge(categoryIds));
3798
3799 query.append(StringPool.CLOSE_PARENTHESIS);
3800
3801 query.append(StringPool.CLOSE_PARENTHESIS);
3802 }
3803
3804 query.setStringAt(removeConjunction(query.stringAt(query.index() -
3805 1)), query.index() - 1);
3806
3807 String sql = query.toString();
3808
3809 Session session = null;
3810
3811 try {
3812 session = openSession();
3813
3814 Query q = session.createQuery(sql);
3815
3816 QueryPos qPos = QueryPos.getInstance(q);
3817
3818 qPos.add(groupId);
3819
3820 count = (Long)q.uniqueResult();
3821
3822 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
3823 finderArgs, count);
3824 }
3825 catch (Exception e) {
3826 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
3827 finderArgs);
3828
3829 throw processException(e);
3830 }
3831 finally {
3832 closeSession(session);
3833 }
3834 }
3835
3836 return count.intValue();
3837 }
3838
3839
3846 @Override
3847 public int filterCountByG_C(long groupId, long categoryId) {
3848 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3849 return countByG_C(groupId, categoryId);
3850 }
3851
3852 StringBundler query = new StringBundler(3);
3853
3854 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
3855
3856 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3857
3858 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
3859
3860 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3861 MBThread.class.getName(),
3862 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3863
3864 Session session = null;
3865
3866 try {
3867 session = openSession();
3868
3869 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3870
3871 q.addScalar(COUNT_COLUMN_NAME,
3872 com.liferay.portal.kernel.dao.orm.Type.LONG);
3873
3874 QueryPos qPos = QueryPos.getInstance(q);
3875
3876 qPos.add(groupId);
3877
3878 qPos.add(categoryId);
3879
3880 Long count = (Long)q.uniqueResult();
3881
3882 return count.intValue();
3883 }
3884 catch (Exception e) {
3885 throw processException(e);
3886 }
3887 finally {
3888 closeSession(session);
3889 }
3890 }
3891
3892
3899 @Override
3900 public int filterCountByG_C(long groupId, long[] categoryIds) {
3901 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3902 return countByG_C(groupId, categoryIds);
3903 }
3904
3905 if (categoryIds == null) {
3906 categoryIds = new long[0];
3907 }
3908 else if (categoryIds.length > 1) {
3909 categoryIds = ArrayUtil.unique(categoryIds);
3910
3911 Arrays.sort(categoryIds);
3912 }
3913
3914 StringBundler query = new StringBundler();
3915
3916 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
3917
3918 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3919
3920 if (categoryIds.length > 0) {
3921 query.append(StringPool.OPEN_PARENTHESIS);
3922
3923 query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
3924
3925 query.append(StringUtil.merge(categoryIds));
3926
3927 query.append(StringPool.CLOSE_PARENTHESIS);
3928
3929 query.append(StringPool.CLOSE_PARENTHESIS);
3930 }
3931
3932 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
3933 query.index() - 1);
3934
3935 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3936 MBThread.class.getName(),
3937 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3938
3939 Session session = null;
3940
3941 try {
3942 session = openSession();
3943
3944 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3945
3946 q.addScalar(COUNT_COLUMN_NAME,
3947 com.liferay.portal.kernel.dao.orm.Type.LONG);
3948
3949 QueryPos qPos = QueryPos.getInstance(q);
3950
3951 qPos.add(groupId);
3952
3953 Long count = (Long)q.uniqueResult();
3954
3955 return count.intValue();
3956 }
3957 catch (Exception e) {
3958 throw processException(e);
3959 }
3960 finally {
3961 closeSession(session);
3962 }
3963 }
3964
3965 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbThread.groupId = ? AND ";
3966 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbThread.categoryId = ?";
3967 private static final String _FINDER_COLUMN_G_C_CATEGORYID_7 = "mbThread.categoryId IN (";
3968 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
3969 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
3970 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotC",
3971 new String[] {
3972 Long.class.getName(), Long.class.getName(),
3973
3974 Integer.class.getName(), Integer.class.getName(),
3975 OrderByComparator.class.getName()
3976 });
3977 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
3978 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
3979 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotC",
3980 new String[] { Long.class.getName(), Long.class.getName() });
3981
3982
3989 @Override
3990 public List<MBThread> findByG_NotC(long groupId, long categoryId) {
3991 return findByG_NotC(groupId, categoryId, QueryUtil.ALL_POS,
3992 QueryUtil.ALL_POS, null);
3993 }
3994
3995
4008 @Override
4009 public List<MBThread> findByG_NotC(long groupId, long categoryId,
4010 int start, int end) {
4011 return findByG_NotC(groupId, categoryId, start, end, null);
4012 }
4013
4014
4028 @Override
4029 public List<MBThread> findByG_NotC(long groupId, long categoryId,
4030 int start, int end, OrderByComparator<MBThread> orderByComparator) {
4031 return findByG_NotC(groupId, categoryId, start, end, orderByComparator,
4032 true);
4033 }
4034
4035
4050 @Override
4051 public List<MBThread> findByG_NotC(long groupId, long categoryId,
4052 int start, int end, OrderByComparator<MBThread> orderByComparator,
4053 boolean retrieveFromCache) {
4054 boolean pagination = true;
4055 FinderPath finderPath = null;
4056 Object[] finderArgs = null;
4057
4058 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC;
4059 finderArgs = new Object[] {
4060 groupId, categoryId,
4061
4062 start, end, orderByComparator
4063 };
4064
4065 List<MBThread> list = null;
4066
4067 if (retrieveFromCache) {
4068 list = (List<MBThread>)finderCache.getResult(finderPath,
4069 finderArgs, this);
4070
4071 if ((list != null) && !list.isEmpty()) {
4072 for (MBThread mbThread : list) {
4073 if ((groupId != mbThread.getGroupId()) ||
4074 (categoryId == mbThread.getCategoryId())) {
4075 list = null;
4076
4077 break;
4078 }
4079 }
4080 }
4081 }
4082
4083 if (list == null) {
4084 StringBundler query = null;
4085
4086 if (orderByComparator != null) {
4087 query = new StringBundler(4 +
4088 (orderByComparator.getOrderByFields().length * 3));
4089 }
4090 else {
4091 query = new StringBundler(4);
4092 }
4093
4094 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4095
4096 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4097
4098 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4099
4100 if (orderByComparator != null) {
4101 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4102 orderByComparator);
4103 }
4104 else
4105 if (pagination) {
4106 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4107 }
4108
4109 String sql = query.toString();
4110
4111 Session session = null;
4112
4113 try {
4114 session = openSession();
4115
4116 Query q = session.createQuery(sql);
4117
4118 QueryPos qPos = QueryPos.getInstance(q);
4119
4120 qPos.add(groupId);
4121
4122 qPos.add(categoryId);
4123
4124 if (!pagination) {
4125 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
4126 start, end, false);
4127
4128 Collections.sort(list);
4129
4130 list = Collections.unmodifiableList(list);
4131 }
4132 else {
4133 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
4134 start, end);
4135 }
4136
4137 cacheResult(list);
4138
4139 finderCache.putResult(finderPath, finderArgs, list);
4140 }
4141 catch (Exception e) {
4142 finderCache.removeResult(finderPath, finderArgs);
4143
4144 throw processException(e);
4145 }
4146 finally {
4147 closeSession(session);
4148 }
4149 }
4150
4151 return list;
4152 }
4153
4154
4163 @Override
4164 public MBThread findByG_NotC_First(long groupId, long categoryId,
4165 OrderByComparator<MBThread> orderByComparator)
4166 throws NoSuchThreadException {
4167 MBThread mbThread = fetchByG_NotC_First(groupId, categoryId,
4168 orderByComparator);
4169
4170 if (mbThread != null) {
4171 return mbThread;
4172 }
4173
4174 StringBundler msg = new StringBundler(6);
4175
4176 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4177
4178 msg.append("groupId=");
4179 msg.append(groupId);
4180
4181 msg.append(", categoryId=");
4182 msg.append(categoryId);
4183
4184 msg.append(StringPool.CLOSE_CURLY_BRACE);
4185
4186 throw new NoSuchThreadException(msg.toString());
4187 }
4188
4189
4197 @Override
4198 public MBThread fetchByG_NotC_First(long groupId, long categoryId,
4199 OrderByComparator<MBThread> orderByComparator) {
4200 List<MBThread> list = findByG_NotC(groupId, categoryId, 0, 1,
4201 orderByComparator);
4202
4203 if (!list.isEmpty()) {
4204 return list.get(0);
4205 }
4206
4207 return null;
4208 }
4209
4210
4219 @Override
4220 public MBThread findByG_NotC_Last(long groupId, long categoryId,
4221 OrderByComparator<MBThread> orderByComparator)
4222 throws NoSuchThreadException {
4223 MBThread mbThread = fetchByG_NotC_Last(groupId, categoryId,
4224 orderByComparator);
4225
4226 if (mbThread != null) {
4227 return mbThread;
4228 }
4229
4230 StringBundler msg = new StringBundler(6);
4231
4232 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4233
4234 msg.append("groupId=");
4235 msg.append(groupId);
4236
4237 msg.append(", categoryId=");
4238 msg.append(categoryId);
4239
4240 msg.append(StringPool.CLOSE_CURLY_BRACE);
4241
4242 throw new NoSuchThreadException(msg.toString());
4243 }
4244
4245
4253 @Override
4254 public MBThread fetchByG_NotC_Last(long groupId, long categoryId,
4255 OrderByComparator<MBThread> orderByComparator) {
4256 int count = countByG_NotC(groupId, categoryId);
4257
4258 if (count == 0) {
4259 return null;
4260 }
4261
4262 List<MBThread> list = findByG_NotC(groupId, categoryId, count - 1,
4263 count, orderByComparator);
4264
4265 if (!list.isEmpty()) {
4266 return list.get(0);
4267 }
4268
4269 return null;
4270 }
4271
4272
4282 @Override
4283 public MBThread[] findByG_NotC_PrevAndNext(long threadId, long groupId,
4284 long categoryId, OrderByComparator<MBThread> orderByComparator)
4285 throws NoSuchThreadException {
4286 MBThread mbThread = findByPrimaryKey(threadId);
4287
4288 Session session = null;
4289
4290 try {
4291 session = openSession();
4292
4293 MBThread[] array = new MBThreadImpl[3];
4294
4295 array[0] = getByG_NotC_PrevAndNext(session, mbThread, groupId,
4296 categoryId, orderByComparator, true);
4297
4298 array[1] = mbThread;
4299
4300 array[2] = getByG_NotC_PrevAndNext(session, mbThread, groupId,
4301 categoryId, orderByComparator, false);
4302
4303 return array;
4304 }
4305 catch (Exception e) {
4306 throw processException(e);
4307 }
4308 finally {
4309 closeSession(session);
4310 }
4311 }
4312
4313 protected MBThread getByG_NotC_PrevAndNext(Session session,
4314 MBThread mbThread, long groupId, long categoryId,
4315 OrderByComparator<MBThread> orderByComparator, boolean previous) {
4316 StringBundler query = null;
4317
4318 if (orderByComparator != null) {
4319 query = new StringBundler(6 +
4320 (orderByComparator.getOrderByFields().length * 6));
4321 }
4322 else {
4323 query = new StringBundler(3);
4324 }
4325
4326 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4327
4328 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4329
4330 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4331
4332 if (orderByComparator != null) {
4333 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4334
4335 if (orderByConditionFields.length > 0) {
4336 query.append(WHERE_AND);
4337 }
4338
4339 for (int i = 0; i < orderByConditionFields.length; i++) {
4340 query.append(_ORDER_BY_ENTITY_ALIAS);
4341 query.append(orderByConditionFields[i]);
4342
4343 if ((i + 1) < orderByConditionFields.length) {
4344 if (orderByComparator.isAscending() ^ previous) {
4345 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4346 }
4347 else {
4348 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4349 }
4350 }
4351 else {
4352 if (orderByComparator.isAscending() ^ previous) {
4353 query.append(WHERE_GREATER_THAN);
4354 }
4355 else {
4356 query.append(WHERE_LESSER_THAN);
4357 }
4358 }
4359 }
4360
4361 query.append(ORDER_BY_CLAUSE);
4362
4363 String[] orderByFields = orderByComparator.getOrderByFields();
4364
4365 for (int i = 0; i < orderByFields.length; i++) {
4366 query.append(_ORDER_BY_ENTITY_ALIAS);
4367 query.append(orderByFields[i]);
4368
4369 if ((i + 1) < orderByFields.length) {
4370 if (orderByComparator.isAscending() ^ previous) {
4371 query.append(ORDER_BY_ASC_HAS_NEXT);
4372 }
4373 else {
4374 query.append(ORDER_BY_DESC_HAS_NEXT);
4375 }
4376 }
4377 else {
4378 if (orderByComparator.isAscending() ^ previous) {
4379 query.append(ORDER_BY_ASC);
4380 }
4381 else {
4382 query.append(ORDER_BY_DESC);
4383 }
4384 }
4385 }
4386 }
4387 else {
4388 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4389 }
4390
4391 String sql = query.toString();
4392
4393 Query q = session.createQuery(sql);
4394
4395 q.setFirstResult(0);
4396 q.setMaxResults(2);
4397
4398 QueryPos qPos = QueryPos.getInstance(q);
4399
4400 qPos.add(groupId);
4401
4402 qPos.add(categoryId);
4403
4404 if (orderByComparator != null) {
4405 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
4406
4407 for (Object value : values) {
4408 qPos.add(value);
4409 }
4410 }
4411
4412 List<MBThread> list = q.list();
4413
4414 if (list.size() == 2) {
4415 return list.get(1);
4416 }
4417 else {
4418 return null;
4419 }
4420 }
4421
4422
4429 @Override
4430 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId) {
4431 return filterFindByG_NotC(groupId, categoryId, QueryUtil.ALL_POS,
4432 QueryUtil.ALL_POS, null);
4433 }
4434
4435
4448 @Override
4449 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId,
4450 int start, int end) {
4451 return filterFindByG_NotC(groupId, categoryId, start, end, null);
4452 }
4453
4454
4468 @Override
4469 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId,
4470 int start, int end, OrderByComparator<MBThread> orderByComparator) {
4471 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4472 return findByG_NotC(groupId, categoryId, start, end,
4473 orderByComparator);
4474 }
4475
4476 StringBundler query = null;
4477
4478 if (orderByComparator != null) {
4479 query = new StringBundler(4 +
4480 (orderByComparator.getOrderByFields().length * 3));
4481 }
4482 else {
4483 query = new StringBundler(4);
4484 }
4485
4486 if (getDB().isSupportsInlineDistinct()) {
4487 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
4488 }
4489 else {
4490 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
4491 }
4492
4493 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4494
4495 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4496
4497 if (!getDB().isSupportsInlineDistinct()) {
4498 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
4499 }
4500
4501 if (orderByComparator != null) {
4502 if (getDB().isSupportsInlineDistinct()) {
4503 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4504 orderByComparator, true);
4505 }
4506 else {
4507 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4508 orderByComparator, true);
4509 }
4510 }
4511 else {
4512 if (getDB().isSupportsInlineDistinct()) {
4513 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4514 }
4515 else {
4516 query.append(MBThreadModelImpl.ORDER_BY_SQL);
4517 }
4518 }
4519
4520 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4521 MBThread.class.getName(),
4522 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4523
4524 Session session = null;
4525
4526 try {
4527 session = openSession();
4528
4529 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4530
4531 if (getDB().isSupportsInlineDistinct()) {
4532 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
4533 }
4534 else {
4535 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
4536 }
4537
4538 QueryPos qPos = QueryPos.getInstance(q);
4539
4540 qPos.add(groupId);
4541
4542 qPos.add(categoryId);
4543
4544 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
4545 }
4546 catch (Exception e) {
4547 throw processException(e);
4548 }
4549 finally {
4550 closeSession(session);
4551 }
4552 }
4553
4554
4564 @Override
4565 public MBThread[] filterFindByG_NotC_PrevAndNext(long threadId,
4566 long groupId, long categoryId,
4567 OrderByComparator<MBThread> orderByComparator)
4568 throws NoSuchThreadException {
4569 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4570 return findByG_NotC_PrevAndNext(threadId, groupId, categoryId,
4571 orderByComparator);
4572 }
4573
4574 MBThread mbThread = findByPrimaryKey(threadId);
4575
4576 Session session = null;
4577
4578 try {
4579 session = openSession();
4580
4581 MBThread[] array = new MBThreadImpl[3];
4582
4583 array[0] = filterGetByG_NotC_PrevAndNext(session, mbThread,
4584 groupId, categoryId, orderByComparator, true);
4585
4586 array[1] = mbThread;
4587
4588 array[2] = filterGetByG_NotC_PrevAndNext(session, mbThread,
4589 groupId, categoryId, orderByComparator, false);
4590
4591 return array;
4592 }
4593 catch (Exception e) {
4594 throw processException(e);
4595 }
4596 finally {
4597 closeSession(session);
4598 }
4599 }
4600
4601 protected MBThread filterGetByG_NotC_PrevAndNext(Session session,
4602 MBThread mbThread, long groupId, long categoryId,
4603 OrderByComparator<MBThread> orderByComparator, boolean previous) {
4604 StringBundler query = null;
4605
4606 if (orderByComparator != null) {
4607 query = new StringBundler(6 +
4608 (orderByComparator.getOrderByFields().length * 6));
4609 }
4610 else {
4611 query = new StringBundler(3);
4612 }
4613
4614 if (getDB().isSupportsInlineDistinct()) {
4615 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
4616 }
4617 else {
4618 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
4619 }
4620
4621 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4622
4623 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4624
4625 if (!getDB().isSupportsInlineDistinct()) {
4626 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
4627 }
4628
4629 if (orderByComparator != null) {
4630 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4631
4632 if (orderByConditionFields.length > 0) {
4633 query.append(WHERE_AND);
4634 }
4635
4636 for (int i = 0; i < orderByConditionFields.length; i++) {
4637 if (getDB().isSupportsInlineDistinct()) {
4638 query.append(_ORDER_BY_ENTITY_ALIAS);
4639 }
4640 else {
4641 query.append(_ORDER_BY_ENTITY_TABLE);
4642 }
4643
4644 query.append(orderByConditionFields[i]);
4645
4646 if ((i + 1) < orderByConditionFields.length) {
4647 if (orderByComparator.isAscending() ^ previous) {
4648 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4649 }
4650 else {
4651 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4652 }
4653 }
4654 else {
4655 if (orderByComparator.isAscending() ^ previous) {
4656 query.append(WHERE_GREATER_THAN);
4657 }
4658 else {
4659 query.append(WHERE_LESSER_THAN);
4660 }
4661 }
4662 }
4663
4664 query.append(ORDER_BY_CLAUSE);
4665
4666 String[] orderByFields = orderByComparator.getOrderByFields();
4667
4668 for (int i = 0; i < orderByFields.length; i++) {
4669 if (getDB().isSupportsInlineDistinct()) {
4670 query.append(_ORDER_BY_ENTITY_ALIAS);
4671 }
4672 else {
4673 query.append(_ORDER_BY_ENTITY_TABLE);
4674 }
4675
4676 query.append(orderByFields[i]);
4677
4678 if ((i + 1) < orderByFields.length) {
4679 if (orderByComparator.isAscending() ^ previous) {
4680 query.append(ORDER_BY_ASC_HAS_NEXT);
4681 }
4682 else {
4683 query.append(ORDER_BY_DESC_HAS_NEXT);
4684 }
4685 }
4686 else {
4687 if (orderByComparator.isAscending() ^ previous) {
4688 query.append(ORDER_BY_ASC);
4689 }
4690 else {
4691 query.append(ORDER_BY_DESC);
4692 }
4693 }
4694 }
4695 }
4696 else {
4697 if (getDB().isSupportsInlineDistinct()) {
4698 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4699 }
4700 else {
4701 query.append(MBThreadModelImpl.ORDER_BY_SQL);
4702 }
4703 }
4704
4705 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4706 MBThread.class.getName(),
4707 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4708
4709 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4710
4711 q.setFirstResult(0);
4712 q.setMaxResults(2);
4713
4714 if (getDB().isSupportsInlineDistinct()) {
4715 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
4716 }
4717 else {
4718 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
4719 }
4720
4721 QueryPos qPos = QueryPos.getInstance(q);
4722
4723 qPos.add(groupId);
4724
4725 qPos.add(categoryId);
4726
4727 if (orderByComparator != null) {
4728 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
4729
4730 for (Object value : values) {
4731 qPos.add(value);
4732 }
4733 }
4734
4735 List<MBThread> list = q.list();
4736
4737 if (list.size() == 2) {
4738 return list.get(1);
4739 }
4740 else {
4741 return null;
4742 }
4743 }
4744
4745
4751 @Override
4752 public void removeByG_NotC(long groupId, long categoryId) {
4753 for (MBThread mbThread : findByG_NotC(groupId, categoryId,
4754 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4755 remove(mbThread);
4756 }
4757 }
4758
4759
4766 @Override
4767 public int countByG_NotC(long groupId, long categoryId) {
4768 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC;
4769
4770 Object[] finderArgs = new Object[] { groupId, categoryId };
4771
4772 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4773
4774 if (count == null) {
4775 StringBundler query = new StringBundler(3);
4776
4777 query.append(_SQL_COUNT_MBTHREAD_WHERE);
4778
4779 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4780
4781 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4782
4783 String sql = query.toString();
4784
4785 Session session = null;
4786
4787 try {
4788 session = openSession();
4789
4790 Query q = session.createQuery(sql);
4791
4792 QueryPos qPos = QueryPos.getInstance(q);
4793
4794 qPos.add(groupId);
4795
4796 qPos.add(categoryId);
4797
4798 count = (Long)q.uniqueResult();
4799
4800 finderCache.putResult(finderPath, finderArgs, count);
4801 }
4802 catch (Exception e) {
4803 finderCache.removeResult(finderPath, finderArgs);
4804
4805 throw processException(e);
4806 }
4807 finally {
4808 closeSession(session);
4809 }
4810 }
4811
4812 return count.intValue();
4813 }
4814
4815
4822 @Override
4823 public int filterCountByG_NotC(long groupId, long categoryId) {
4824 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4825 return countByG_NotC(groupId, categoryId);
4826 }
4827
4828 StringBundler query = new StringBundler(3);
4829
4830 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
4831
4832 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
4833
4834 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
4835
4836 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4837 MBThread.class.getName(),
4838 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4839
4840 Session session = null;
4841
4842 try {
4843 session = openSession();
4844
4845 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4846
4847 q.addScalar(COUNT_COLUMN_NAME,
4848 com.liferay.portal.kernel.dao.orm.Type.LONG);
4849
4850 QueryPos qPos = QueryPos.getInstance(q);
4851
4852 qPos.add(groupId);
4853
4854 qPos.add(categoryId);
4855
4856 Long count = (Long)q.uniqueResult();
4857
4858 return count.intValue();
4859 }
4860 catch (Exception e) {
4861 throw processException(e);
4862 }
4863 finally {
4864 closeSession(session);
4865 }
4866 }
4867
4868 private static final String _FINDER_COLUMN_G_NOTC_GROUPID_2 = "mbThread.groupId = ? AND ";
4869 private static final String _FINDER_COLUMN_G_NOTC_CATEGORYID_2 = "mbThread.categoryId != ?";
4870 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
4871 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
4872 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
4873 new String[] {
4874 Long.class.getName(), Integer.class.getName(),
4875
4876 Integer.class.getName(), Integer.class.getName(),
4877 OrderByComparator.class.getName()
4878 });
4879 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
4880 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
4881 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
4882 new String[] { Long.class.getName(), Integer.class.getName() },
4883 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
4884 MBThreadModelImpl.STATUS_COLUMN_BITMASK |
4885 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
4886 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
4887 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
4888 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
4889 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
4890 new String[] { Long.class.getName(), Integer.class.getName() });
4891
4892
4899 @Override
4900 public List<MBThread> findByG_S(long groupId, int status) {
4901 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4902 null);
4903 }
4904
4905
4918 @Override
4919 public List<MBThread> findByG_S(long groupId, int status, int start, int end) {
4920 return findByG_S(groupId, status, start, end, null);
4921 }
4922
4923
4937 @Override
4938 public List<MBThread> findByG_S(long groupId, int status, int start,
4939 int end, OrderByComparator<MBThread> orderByComparator) {
4940 return findByG_S(groupId, status, start, end, orderByComparator, true);
4941 }
4942
4943
4958 @Override
4959 public List<MBThread> findByG_S(long groupId, int status, int start,
4960 int end, OrderByComparator<MBThread> orderByComparator,
4961 boolean retrieveFromCache) {
4962 boolean pagination = true;
4963 FinderPath finderPath = null;
4964 Object[] finderArgs = null;
4965
4966 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4967 (orderByComparator == null)) {
4968 pagination = false;
4969 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4970 finderArgs = new Object[] { groupId, status };
4971 }
4972 else {
4973 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4974 finderArgs = new Object[] {
4975 groupId, status,
4976
4977 start, end, orderByComparator
4978 };
4979 }
4980
4981 List<MBThread> list = null;
4982
4983 if (retrieveFromCache) {
4984 list = (List<MBThread>)finderCache.getResult(finderPath,
4985 finderArgs, this);
4986
4987 if ((list != null) && !list.isEmpty()) {
4988 for (MBThread mbThread : list) {
4989 if ((groupId != mbThread.getGroupId()) ||
4990 (status != mbThread.getStatus())) {
4991 list = null;
4992
4993 break;
4994 }
4995 }
4996 }
4997 }
4998
4999 if (list == null) {
5000 StringBundler query = null;
5001
5002 if (orderByComparator != null) {
5003 query = new StringBundler(4 +
5004 (orderByComparator.getOrderByFields().length * 3));
5005 }
5006 else {
5007 query = new StringBundler(4);
5008 }
5009
5010 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5011
5012 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5013
5014 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5015
5016 if (orderByComparator != null) {
5017 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5018 orderByComparator);
5019 }
5020 else
5021 if (pagination) {
5022 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5023 }
5024
5025 String sql = query.toString();
5026
5027 Session session = null;
5028
5029 try {
5030 session = openSession();
5031
5032 Query q = session.createQuery(sql);
5033
5034 QueryPos qPos = QueryPos.getInstance(q);
5035
5036 qPos.add(groupId);
5037
5038 qPos.add(status);
5039
5040 if (!pagination) {
5041 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
5042 start, end, false);
5043
5044 Collections.sort(list);
5045
5046 list = Collections.unmodifiableList(list);
5047 }
5048 else {
5049 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
5050 start, end);
5051 }
5052
5053 cacheResult(list);
5054
5055 finderCache.putResult(finderPath, finderArgs, list);
5056 }
5057 catch (Exception e) {
5058 finderCache.removeResult(finderPath, finderArgs);
5059
5060 throw processException(e);
5061 }
5062 finally {
5063 closeSession(session);
5064 }
5065 }
5066
5067 return list;
5068 }
5069
5070
5079 @Override
5080 public MBThread findByG_S_First(long groupId, int status,
5081 OrderByComparator<MBThread> orderByComparator)
5082 throws NoSuchThreadException {
5083 MBThread mbThread = fetchByG_S_First(groupId, status, orderByComparator);
5084
5085 if (mbThread != null) {
5086 return mbThread;
5087 }
5088
5089 StringBundler msg = new StringBundler(6);
5090
5091 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5092
5093 msg.append("groupId=");
5094 msg.append(groupId);
5095
5096 msg.append(", status=");
5097 msg.append(status);
5098
5099 msg.append(StringPool.CLOSE_CURLY_BRACE);
5100
5101 throw new NoSuchThreadException(msg.toString());
5102 }
5103
5104
5112 @Override
5113 public MBThread fetchByG_S_First(long groupId, int status,
5114 OrderByComparator<MBThread> orderByComparator) {
5115 List<MBThread> list = findByG_S(groupId, status, 0, 1, orderByComparator);
5116
5117 if (!list.isEmpty()) {
5118 return list.get(0);
5119 }
5120
5121 return null;
5122 }
5123
5124
5133 @Override
5134 public MBThread findByG_S_Last(long groupId, int status,
5135 OrderByComparator<MBThread> orderByComparator)
5136 throws NoSuchThreadException {
5137 MBThread mbThread = fetchByG_S_Last(groupId, status, orderByComparator);
5138
5139 if (mbThread != null) {
5140 return mbThread;
5141 }
5142
5143 StringBundler msg = new StringBundler(6);
5144
5145 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5146
5147 msg.append("groupId=");
5148 msg.append(groupId);
5149
5150 msg.append(", status=");
5151 msg.append(status);
5152
5153 msg.append(StringPool.CLOSE_CURLY_BRACE);
5154
5155 throw new NoSuchThreadException(msg.toString());
5156 }
5157
5158
5166 @Override
5167 public MBThread fetchByG_S_Last(long groupId, int status,
5168 OrderByComparator<MBThread> orderByComparator) {
5169 int count = countByG_S(groupId, status);
5170
5171 if (count == 0) {
5172 return null;
5173 }
5174
5175 List<MBThread> list = findByG_S(groupId, status, count - 1, count,
5176 orderByComparator);
5177
5178 if (!list.isEmpty()) {
5179 return list.get(0);
5180 }
5181
5182 return null;
5183 }
5184
5185
5195 @Override
5196 public MBThread[] findByG_S_PrevAndNext(long threadId, long groupId,
5197 int status, OrderByComparator<MBThread> orderByComparator)
5198 throws NoSuchThreadException {
5199 MBThread mbThread = findByPrimaryKey(threadId);
5200
5201 Session session = null;
5202
5203 try {
5204 session = openSession();
5205
5206 MBThread[] array = new MBThreadImpl[3];
5207
5208 array[0] = getByG_S_PrevAndNext(session, mbThread, groupId, status,
5209 orderByComparator, true);
5210
5211 array[1] = mbThread;
5212
5213 array[2] = getByG_S_PrevAndNext(session, mbThread, groupId, status,
5214 orderByComparator, false);
5215
5216 return array;
5217 }
5218 catch (Exception e) {
5219 throw processException(e);
5220 }
5221 finally {
5222 closeSession(session);
5223 }
5224 }
5225
5226 protected MBThread getByG_S_PrevAndNext(Session session, MBThread mbThread,
5227 long groupId, int status,
5228 OrderByComparator<MBThread> orderByComparator, boolean previous) {
5229 StringBundler query = null;
5230
5231 if (orderByComparator != null) {
5232 query = new StringBundler(6 +
5233 (orderByComparator.getOrderByFields().length * 6));
5234 }
5235 else {
5236 query = new StringBundler(3);
5237 }
5238
5239 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5240
5241 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5242
5243 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5244
5245 if (orderByComparator != null) {
5246 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5247
5248 if (orderByConditionFields.length > 0) {
5249 query.append(WHERE_AND);
5250 }
5251
5252 for (int i = 0; i < orderByConditionFields.length; i++) {
5253 query.append(_ORDER_BY_ENTITY_ALIAS);
5254 query.append(orderByConditionFields[i]);
5255
5256 if ((i + 1) < orderByConditionFields.length) {
5257 if (orderByComparator.isAscending() ^ previous) {
5258 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5259 }
5260 else {
5261 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5262 }
5263 }
5264 else {
5265 if (orderByComparator.isAscending() ^ previous) {
5266 query.append(WHERE_GREATER_THAN);
5267 }
5268 else {
5269 query.append(WHERE_LESSER_THAN);
5270 }
5271 }
5272 }
5273
5274 query.append(ORDER_BY_CLAUSE);
5275
5276 String[] orderByFields = orderByComparator.getOrderByFields();
5277
5278 for (int i = 0; i < orderByFields.length; i++) {
5279 query.append(_ORDER_BY_ENTITY_ALIAS);
5280 query.append(orderByFields[i]);
5281
5282 if ((i + 1) < orderByFields.length) {
5283 if (orderByComparator.isAscending() ^ previous) {
5284 query.append(ORDER_BY_ASC_HAS_NEXT);
5285 }
5286 else {
5287 query.append(ORDER_BY_DESC_HAS_NEXT);
5288 }
5289 }
5290 else {
5291 if (orderByComparator.isAscending() ^ previous) {
5292 query.append(ORDER_BY_ASC);
5293 }
5294 else {
5295 query.append(ORDER_BY_DESC);
5296 }
5297 }
5298 }
5299 }
5300 else {
5301 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5302 }
5303
5304 String sql = query.toString();
5305
5306 Query q = session.createQuery(sql);
5307
5308 q.setFirstResult(0);
5309 q.setMaxResults(2);
5310
5311 QueryPos qPos = QueryPos.getInstance(q);
5312
5313 qPos.add(groupId);
5314
5315 qPos.add(status);
5316
5317 if (orderByComparator != null) {
5318 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
5319
5320 for (Object value : values) {
5321 qPos.add(value);
5322 }
5323 }
5324
5325 List<MBThread> list = q.list();
5326
5327 if (list.size() == 2) {
5328 return list.get(1);
5329 }
5330 else {
5331 return null;
5332 }
5333 }
5334
5335
5342 @Override
5343 public List<MBThread> filterFindByG_S(long groupId, int status) {
5344 return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
5345 QueryUtil.ALL_POS, null);
5346 }
5347
5348
5361 @Override
5362 public List<MBThread> filterFindByG_S(long groupId, int status, int start,
5363 int end) {
5364 return filterFindByG_S(groupId, status, start, end, null);
5365 }
5366
5367
5381 @Override
5382 public List<MBThread> filterFindByG_S(long groupId, int status, int start,
5383 int end, OrderByComparator<MBThread> orderByComparator) {
5384 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5385 return findByG_S(groupId, status, start, end, orderByComparator);
5386 }
5387
5388 StringBundler query = null;
5389
5390 if (orderByComparator != null) {
5391 query = new StringBundler(4 +
5392 (orderByComparator.getOrderByFields().length * 3));
5393 }
5394 else {
5395 query = new StringBundler(4);
5396 }
5397
5398 if (getDB().isSupportsInlineDistinct()) {
5399 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
5400 }
5401 else {
5402 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
5403 }
5404
5405 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5406
5407 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5408
5409 if (!getDB().isSupportsInlineDistinct()) {
5410 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
5411 }
5412
5413 if (orderByComparator != null) {
5414 if (getDB().isSupportsInlineDistinct()) {
5415 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5416 orderByComparator, true);
5417 }
5418 else {
5419 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5420 orderByComparator, true);
5421 }
5422 }
5423 else {
5424 if (getDB().isSupportsInlineDistinct()) {
5425 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5426 }
5427 else {
5428 query.append(MBThreadModelImpl.ORDER_BY_SQL);
5429 }
5430 }
5431
5432 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5433 MBThread.class.getName(),
5434 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5435
5436 Session session = null;
5437
5438 try {
5439 session = openSession();
5440
5441 SQLQuery q = session.createSynchronizedSQLQuery(sql);
5442
5443 if (getDB().isSupportsInlineDistinct()) {
5444 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
5445 }
5446 else {
5447 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
5448 }
5449
5450 QueryPos qPos = QueryPos.getInstance(q);
5451
5452 qPos.add(groupId);
5453
5454 qPos.add(status);
5455
5456 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
5457 }
5458 catch (Exception e) {
5459 throw processException(e);
5460 }
5461 finally {
5462 closeSession(session);
5463 }
5464 }
5465
5466
5476 @Override
5477 public MBThread[] filterFindByG_S_PrevAndNext(long threadId, long groupId,
5478 int status, OrderByComparator<MBThread> orderByComparator)
5479 throws NoSuchThreadException {
5480 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5481 return findByG_S_PrevAndNext(threadId, groupId, status,
5482 orderByComparator);
5483 }
5484
5485 MBThread mbThread = findByPrimaryKey(threadId);
5486
5487 Session session = null;
5488
5489 try {
5490 session = openSession();
5491
5492 MBThread[] array = new MBThreadImpl[3];
5493
5494 array[0] = filterGetByG_S_PrevAndNext(session, mbThread, groupId,
5495 status, orderByComparator, true);
5496
5497 array[1] = mbThread;
5498
5499 array[2] = filterGetByG_S_PrevAndNext(session, mbThread, groupId,
5500 status, orderByComparator, false);
5501
5502 return array;
5503 }
5504 catch (Exception e) {
5505 throw processException(e);
5506 }
5507 finally {
5508 closeSession(session);
5509 }
5510 }
5511
5512 protected MBThread filterGetByG_S_PrevAndNext(Session session,
5513 MBThread mbThread, long groupId, int status,
5514 OrderByComparator<MBThread> orderByComparator, boolean previous) {
5515 StringBundler query = null;
5516
5517 if (orderByComparator != null) {
5518 query = new StringBundler(6 +
5519 (orderByComparator.getOrderByFields().length * 6));
5520 }
5521 else {
5522 query = new StringBundler(3);
5523 }
5524
5525 if (getDB().isSupportsInlineDistinct()) {
5526 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
5527 }
5528 else {
5529 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
5530 }
5531
5532 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5533
5534 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5535
5536 if (!getDB().isSupportsInlineDistinct()) {
5537 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
5538 }
5539
5540 if (orderByComparator != null) {
5541 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5542
5543 if (orderByConditionFields.length > 0) {
5544 query.append(WHERE_AND);
5545 }
5546
5547 for (int i = 0; i < orderByConditionFields.length; i++) {
5548 if (getDB().isSupportsInlineDistinct()) {
5549 query.append(_ORDER_BY_ENTITY_ALIAS);
5550 }
5551 else {
5552 query.append(_ORDER_BY_ENTITY_TABLE);
5553 }
5554
5555 query.append(orderByConditionFields[i]);
5556
5557 if ((i + 1) < orderByConditionFields.length) {
5558 if (orderByComparator.isAscending() ^ previous) {
5559 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5560 }
5561 else {
5562 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5563 }
5564 }
5565 else {
5566 if (orderByComparator.isAscending() ^ previous) {
5567 query.append(WHERE_GREATER_THAN);
5568 }
5569 else {
5570 query.append(WHERE_LESSER_THAN);
5571 }
5572 }
5573 }
5574
5575 query.append(ORDER_BY_CLAUSE);
5576
5577 String[] orderByFields = orderByComparator.getOrderByFields();
5578
5579 for (int i = 0; i < orderByFields.length; i++) {
5580 if (getDB().isSupportsInlineDistinct()) {
5581 query.append(_ORDER_BY_ENTITY_ALIAS);
5582 }
5583 else {
5584 query.append(_ORDER_BY_ENTITY_TABLE);
5585 }
5586
5587 query.append(orderByFields[i]);
5588
5589 if ((i + 1) < orderByFields.length) {
5590 if (orderByComparator.isAscending() ^ previous) {
5591 query.append(ORDER_BY_ASC_HAS_NEXT);
5592 }
5593 else {
5594 query.append(ORDER_BY_DESC_HAS_NEXT);
5595 }
5596 }
5597 else {
5598 if (orderByComparator.isAscending() ^ previous) {
5599 query.append(ORDER_BY_ASC);
5600 }
5601 else {
5602 query.append(ORDER_BY_DESC);
5603 }
5604 }
5605 }
5606 }
5607 else {
5608 if (getDB().isSupportsInlineDistinct()) {
5609 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5610 }
5611 else {
5612 query.append(MBThreadModelImpl.ORDER_BY_SQL);
5613 }
5614 }
5615
5616 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5617 MBThread.class.getName(),
5618 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5619
5620 SQLQuery q = session.createSynchronizedSQLQuery(sql);
5621
5622 q.setFirstResult(0);
5623 q.setMaxResults(2);
5624
5625 if (getDB().isSupportsInlineDistinct()) {
5626 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
5627 }
5628 else {
5629 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
5630 }
5631
5632 QueryPos qPos = QueryPos.getInstance(q);
5633
5634 qPos.add(groupId);
5635
5636 qPos.add(status);
5637
5638 if (orderByComparator != null) {
5639 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
5640
5641 for (Object value : values) {
5642 qPos.add(value);
5643 }
5644 }
5645
5646 List<MBThread> list = q.list();
5647
5648 if (list.size() == 2) {
5649 return list.get(1);
5650 }
5651 else {
5652 return null;
5653 }
5654 }
5655
5656
5662 @Override
5663 public void removeByG_S(long groupId, int status) {
5664 for (MBThread mbThread : findByG_S(groupId, status, QueryUtil.ALL_POS,
5665 QueryUtil.ALL_POS, null)) {
5666 remove(mbThread);
5667 }
5668 }
5669
5670
5677 @Override
5678 public int countByG_S(long groupId, int status) {
5679 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
5680
5681 Object[] finderArgs = new Object[] { groupId, status };
5682
5683 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5684
5685 if (count == null) {
5686 StringBundler query = new StringBundler(3);
5687
5688 query.append(_SQL_COUNT_MBTHREAD_WHERE);
5689
5690 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5691
5692 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5693
5694 String sql = query.toString();
5695
5696 Session session = null;
5697
5698 try {
5699 session = openSession();
5700
5701 Query q = session.createQuery(sql);
5702
5703 QueryPos qPos = QueryPos.getInstance(q);
5704
5705 qPos.add(groupId);
5706
5707 qPos.add(status);
5708
5709 count = (Long)q.uniqueResult();
5710
5711 finderCache.putResult(finderPath, finderArgs, count);
5712 }
5713 catch (Exception e) {
5714 finderCache.removeResult(finderPath, finderArgs);
5715
5716 throw processException(e);
5717 }
5718 finally {
5719 closeSession(session);
5720 }
5721 }
5722
5723 return count.intValue();
5724 }
5725
5726
5733 @Override
5734 public int filterCountByG_S(long groupId, int status) {
5735 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5736 return countByG_S(groupId, status);
5737 }
5738
5739 StringBundler query = new StringBundler(3);
5740
5741 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
5742
5743 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5744
5745 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5746
5747 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5748 MBThread.class.getName(),
5749 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5750
5751 Session session = null;
5752
5753 try {
5754 session = openSession();
5755
5756 SQLQuery q = session.createSynchronizedSQLQuery(sql);
5757
5758 q.addScalar(COUNT_COLUMN_NAME,
5759 com.liferay.portal.kernel.dao.orm.Type.LONG);
5760
5761 QueryPos qPos = QueryPos.getInstance(q);
5762
5763 qPos.add(groupId);
5764
5765 qPos.add(status);
5766
5767 Long count = (Long)q.uniqueResult();
5768
5769 return count.intValue();
5770 }
5771 catch (Exception e) {
5772 throw processException(e);
5773 }
5774 finally {
5775 closeSession(session);
5776 }
5777 }
5778
5779 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "mbThread.groupId = ? AND ";
5780 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbThread.status = ? AND mbThread.categoryId != -1";
5781 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
5782 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
5783 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P",
5784 new String[] {
5785 Long.class.getName(), Double.class.getName(),
5786
5787 Integer.class.getName(), Integer.class.getName(),
5788 OrderByComparator.class.getName()
5789 });
5790 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
5791 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
5792 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P",
5793 new String[] { Long.class.getName(), Double.class.getName() },
5794 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
5795 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
5796 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
5797 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
5798 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
5799 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P",
5800 new String[] { Long.class.getName(), Double.class.getName() });
5801
5802
5809 @Override
5810 public List<MBThread> findByC_P(long categoryId, double priority) {
5811 return findByC_P(categoryId, priority, QueryUtil.ALL_POS,
5812 QueryUtil.ALL_POS, null);
5813 }
5814
5815
5828 @Override
5829 public List<MBThread> findByC_P(long categoryId, double priority,
5830 int start, int end) {
5831 return findByC_P(categoryId, priority, start, end, null);
5832 }
5833
5834
5848 @Override
5849 public List<MBThread> findByC_P(long categoryId, double priority,
5850 int start, int end, OrderByComparator<MBThread> orderByComparator) {
5851 return findByC_P(categoryId, priority, start, end, orderByComparator,
5852 true);
5853 }
5854
5855
5870 @Override
5871 public List<MBThread> findByC_P(long categoryId, double priority,
5872 int start, int end, OrderByComparator<MBThread> orderByComparator,
5873 boolean retrieveFromCache) {
5874 boolean pagination = true;
5875 FinderPath finderPath = null;
5876 Object[] finderArgs = null;
5877
5878 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5879 (orderByComparator == null)) {
5880 pagination = false;
5881 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
5882 finderArgs = new Object[] { categoryId, priority };
5883 }
5884 else {
5885 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
5886 finderArgs = new Object[] {
5887 categoryId, priority,
5888
5889 start, end, orderByComparator
5890 };
5891 }
5892
5893 List<MBThread> list = null;
5894
5895 if (retrieveFromCache) {
5896 list = (List<MBThread>)finderCache.getResult(finderPath,
5897 finderArgs, this);
5898
5899 if ((list != null) && !list.isEmpty()) {
5900 for (MBThread mbThread : list) {
5901 if ((categoryId != mbThread.getCategoryId()) ||
5902 (priority != mbThread.getPriority())) {
5903 list = null;
5904
5905 break;
5906 }
5907 }
5908 }
5909 }
5910
5911 if (list == null) {
5912 StringBundler query = null;
5913
5914 if (orderByComparator != null) {
5915 query = new StringBundler(4 +
5916 (orderByComparator.getOrderByFields().length * 3));
5917 }
5918 else {
5919 query = new StringBundler(4);
5920 }
5921
5922 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5923
5924 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
5925
5926 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
5927
5928 if (orderByComparator != null) {
5929 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5930 orderByComparator);
5931 }
5932 else
5933 if (pagination) {
5934 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5935 }
5936
5937 String sql = query.toString();
5938
5939 Session session = null;
5940
5941 try {
5942 session = openSession();
5943
5944 Query q = session.createQuery(sql);
5945
5946 QueryPos qPos = QueryPos.getInstance(q);
5947
5948 qPos.add(categoryId);
5949
5950 qPos.add(priority);
5951
5952 if (!pagination) {
5953 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
5954 start, end, false);
5955
5956 Collections.sort(list);
5957
5958 list = Collections.unmodifiableList(list);
5959 }
5960 else {
5961 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
5962 start, end);
5963 }
5964
5965 cacheResult(list);
5966
5967 finderCache.putResult(finderPath, finderArgs, list);
5968 }
5969 catch (Exception e) {
5970 finderCache.removeResult(finderPath, finderArgs);
5971
5972 throw processException(e);
5973 }
5974 finally {
5975 closeSession(session);
5976 }
5977 }
5978
5979 return list;
5980 }
5981
5982
5991 @Override
5992 public MBThread findByC_P_First(long categoryId, double priority,
5993 OrderByComparator<MBThread> orderByComparator)
5994 throws NoSuchThreadException {
5995 MBThread mbThread = fetchByC_P_First(categoryId, priority,
5996 orderByComparator);
5997
5998 if (mbThread != null) {
5999 return mbThread;
6000 }
6001
6002 StringBundler msg = new StringBundler(6);
6003
6004 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6005
6006 msg.append("categoryId=");
6007 msg.append(categoryId);
6008
6009 msg.append(", priority=");
6010 msg.append(priority);
6011
6012 msg.append(StringPool.CLOSE_CURLY_BRACE);
6013
6014 throw new NoSuchThreadException(msg.toString());
6015 }
6016
6017
6025 @Override
6026 public MBThread fetchByC_P_First(long categoryId, double priority,
6027 OrderByComparator<MBThread> orderByComparator) {
6028 List<MBThread> list = findByC_P(categoryId, priority, 0, 1,
6029 orderByComparator);
6030
6031 if (!list.isEmpty()) {
6032 return list.get(0);
6033 }
6034
6035 return null;
6036 }
6037
6038
6047 @Override
6048 public MBThread findByC_P_Last(long categoryId, double priority,
6049 OrderByComparator<MBThread> orderByComparator)
6050 throws NoSuchThreadException {
6051 MBThread mbThread = fetchByC_P_Last(categoryId, priority,
6052 orderByComparator);
6053
6054 if (mbThread != null) {
6055 return mbThread;
6056 }
6057
6058 StringBundler msg = new StringBundler(6);
6059
6060 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6061
6062 msg.append("categoryId=");
6063 msg.append(categoryId);
6064
6065 msg.append(", priority=");
6066 msg.append(priority);
6067
6068 msg.append(StringPool.CLOSE_CURLY_BRACE);
6069
6070 throw new NoSuchThreadException(msg.toString());
6071 }
6072
6073
6081 @Override
6082 public MBThread fetchByC_P_Last(long categoryId, double priority,
6083 OrderByComparator<MBThread> orderByComparator) {
6084 int count = countByC_P(categoryId, priority);
6085
6086 if (count == 0) {
6087 return null;
6088 }
6089
6090 List<MBThread> list = findByC_P(categoryId, priority, count - 1, count,
6091 orderByComparator);
6092
6093 if (!list.isEmpty()) {
6094 return list.get(0);
6095 }
6096
6097 return null;
6098 }
6099
6100
6110 @Override
6111 public MBThread[] findByC_P_PrevAndNext(long threadId, long categoryId,
6112 double priority, OrderByComparator<MBThread> orderByComparator)
6113 throws NoSuchThreadException {
6114 MBThread mbThread = findByPrimaryKey(threadId);
6115
6116 Session session = null;
6117
6118 try {
6119 session = openSession();
6120
6121 MBThread[] array = new MBThreadImpl[3];
6122
6123 array[0] = getByC_P_PrevAndNext(session, mbThread, categoryId,
6124 priority, orderByComparator, true);
6125
6126 array[1] = mbThread;
6127
6128 array[2] = getByC_P_PrevAndNext(session, mbThread, categoryId,
6129 priority, orderByComparator, false);
6130
6131 return array;
6132 }
6133 catch (Exception e) {
6134 throw processException(e);
6135 }
6136 finally {
6137 closeSession(session);
6138 }
6139 }
6140
6141 protected MBThread getByC_P_PrevAndNext(Session session, MBThread mbThread,
6142 long categoryId, double priority,
6143 OrderByComparator<MBThread> orderByComparator, boolean previous) {
6144 StringBundler query = null;
6145
6146 if (orderByComparator != null) {
6147 query = new StringBundler(6 +
6148 (orderByComparator.getOrderByFields().length * 6));
6149 }
6150 else {
6151 query = new StringBundler(3);
6152 }
6153
6154 query.append(_SQL_SELECT_MBTHREAD_WHERE);
6155
6156 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
6157
6158 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
6159
6160 if (orderByComparator != null) {
6161 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6162
6163 if (orderByConditionFields.length > 0) {
6164 query.append(WHERE_AND);
6165 }
6166
6167 for (int i = 0; i < orderByConditionFields.length; i++) {
6168 query.append(_ORDER_BY_ENTITY_ALIAS);
6169 query.append(orderByConditionFields[i]);
6170
6171 if ((i + 1) < orderByConditionFields.length) {
6172 if (orderByComparator.isAscending() ^ previous) {
6173 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6174 }
6175 else {
6176 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6177 }
6178 }
6179 else {
6180 if (orderByComparator.isAscending() ^ previous) {
6181 query.append(WHERE_GREATER_THAN);
6182 }
6183 else {
6184 query.append(WHERE_LESSER_THAN);
6185 }
6186 }
6187 }
6188
6189 query.append(ORDER_BY_CLAUSE);
6190
6191 String[] orderByFields = orderByComparator.getOrderByFields();
6192
6193 for (int i = 0; i < orderByFields.length; i++) {
6194 query.append(_ORDER_BY_ENTITY_ALIAS);
6195 query.append(orderByFields[i]);
6196
6197 if ((i + 1) < orderByFields.length) {
6198 if (orderByComparator.isAscending() ^ previous) {
6199 query.append(ORDER_BY_ASC_HAS_NEXT);
6200 }
6201 else {
6202 query.append(ORDER_BY_DESC_HAS_NEXT);
6203 }
6204 }
6205 else {
6206 if (orderByComparator.isAscending() ^ previous) {
6207 query.append(ORDER_BY_ASC);
6208 }
6209 else {
6210 query.append(ORDER_BY_DESC);
6211 }
6212 }
6213 }
6214 }
6215 else {
6216 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6217 }
6218
6219 String sql = query.toString();
6220
6221 Query q = session.createQuery(sql);
6222
6223 q.setFirstResult(0);
6224 q.setMaxResults(2);
6225
6226 QueryPos qPos = QueryPos.getInstance(q);
6227
6228 qPos.add(categoryId);
6229
6230 qPos.add(priority);
6231
6232 if (orderByComparator != null) {
6233 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
6234
6235 for (Object value : values) {
6236 qPos.add(value);
6237 }
6238 }
6239
6240 List<MBThread> list = q.list();
6241
6242 if (list.size() == 2) {
6243 return list.get(1);
6244 }
6245 else {
6246 return null;
6247 }
6248 }
6249
6250
6256 @Override
6257 public void removeByC_P(long categoryId, double priority) {
6258 for (MBThread mbThread : findByC_P(categoryId, priority,
6259 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6260 remove(mbThread);
6261 }
6262 }
6263
6264
6271 @Override
6272 public int countByC_P(long categoryId, double priority) {
6273 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_P;
6274
6275 Object[] finderArgs = new Object[] { categoryId, priority };
6276
6277 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6278
6279 if (count == null) {
6280 StringBundler query = new StringBundler(3);
6281
6282 query.append(_SQL_COUNT_MBTHREAD_WHERE);
6283
6284 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
6285
6286 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
6287
6288 String sql = query.toString();
6289
6290 Session session = null;
6291
6292 try {
6293 session = openSession();
6294
6295 Query q = session.createQuery(sql);
6296
6297 QueryPos qPos = QueryPos.getInstance(q);
6298
6299 qPos.add(categoryId);
6300
6301 qPos.add(priority);
6302
6303 count = (Long)q.uniqueResult();
6304
6305 finderCache.putResult(finderPath, finderArgs, count);
6306 }
6307 catch (Exception e) {
6308 finderCache.removeResult(finderPath, finderArgs);
6309
6310 throw processException(e);
6311 }
6312 finally {
6313 closeSession(session);
6314 }
6315 }
6316
6317 return count.intValue();
6318 }
6319
6320 private static final String _FINDER_COLUMN_C_P_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
6321 private static final String _FINDER_COLUMN_C_P_PRIORITY_2 = "mbThread.priority = ?";
6322 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6323 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
6324 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByL_P",
6325 new String[] {
6326 Date.class.getName(), Double.class.getName(),
6327
6328 Integer.class.getName(), Integer.class.getName(),
6329 OrderByComparator.class.getName()
6330 });
6331 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6332 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
6333 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P",
6334 new String[] { Date.class.getName(), Double.class.getName() },
6335 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK |
6336 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK);
6337 public static final FinderPath FINDER_PATH_COUNT_BY_L_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6338 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
6339 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P",
6340 new String[] { Date.class.getName(), Double.class.getName() });
6341
6342
6349 @Override
6350 public List<MBThread> findByL_P(Date lastPostDate, double priority) {
6351 return findByL_P(lastPostDate, priority, QueryUtil.ALL_POS,
6352 QueryUtil.ALL_POS, null);
6353 }
6354
6355
6368 @Override
6369 public List<MBThread> findByL_P(Date lastPostDate, double priority,
6370 int start, int end) {
6371 return findByL_P(lastPostDate, priority, start, end, null);
6372 }
6373
6374
6388 @Override
6389 public List<MBThread> findByL_P(Date lastPostDate, double priority,
6390 int start, int end, OrderByComparator<MBThread> orderByComparator) {
6391 return findByL_P(lastPostDate, priority, start, end, orderByComparator,
6392 true);
6393 }
6394
6395
6410 @Override
6411 public List<MBThread> findByL_P(Date lastPostDate, double priority,
6412 int start, int end, OrderByComparator<MBThread> orderByComparator,
6413 boolean retrieveFromCache) {
6414 boolean pagination = true;
6415 FinderPath finderPath = null;
6416 Object[] finderArgs = null;
6417
6418 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6419 (orderByComparator == null)) {
6420 pagination = false;
6421 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P;
6422 finderArgs = new Object[] { lastPostDate, priority };
6423 }
6424 else {
6425 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P;
6426 finderArgs = new Object[] {
6427 lastPostDate, priority,
6428
6429 start, end, orderByComparator
6430 };
6431 }
6432
6433 List<MBThread> list = null;
6434
6435 if (retrieveFromCache) {
6436 list = (List<MBThread>)finderCache.getResult(finderPath,
6437 finderArgs, this);
6438
6439 if ((list != null) && !list.isEmpty()) {
6440 for (MBThread mbThread : list) {
6441 if (!Validator.equals(lastPostDate,
6442 mbThread.getLastPostDate()) ||
6443 (priority != mbThread.getPriority())) {
6444 list = null;
6445
6446 break;
6447 }
6448 }
6449 }
6450 }
6451
6452 if (list == null) {
6453 StringBundler query = null;
6454
6455 if (orderByComparator != null) {
6456 query = new StringBundler(4 +
6457 (orderByComparator.getOrderByFields().length * 3));
6458 }
6459 else {
6460 query = new StringBundler(4);
6461 }
6462
6463 query.append(_SQL_SELECT_MBTHREAD_WHERE);
6464
6465 boolean bindLastPostDate = false;
6466
6467 if (lastPostDate == null) {
6468 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
6469 }
6470 else {
6471 bindLastPostDate = true;
6472
6473 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
6474 }
6475
6476 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
6477
6478 if (orderByComparator != null) {
6479 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6480 orderByComparator);
6481 }
6482 else
6483 if (pagination) {
6484 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6485 }
6486
6487 String sql = query.toString();
6488
6489 Session session = null;
6490
6491 try {
6492 session = openSession();
6493
6494 Query q = session.createQuery(sql);
6495
6496 QueryPos qPos = QueryPos.getInstance(q);
6497
6498 if (bindLastPostDate) {
6499 qPos.add(new Timestamp(lastPostDate.getTime()));
6500 }
6501
6502 qPos.add(priority);
6503
6504 if (!pagination) {
6505 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
6506 start, end, false);
6507
6508 Collections.sort(list);
6509
6510 list = Collections.unmodifiableList(list);
6511 }
6512 else {
6513 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
6514 start, end);
6515 }
6516
6517 cacheResult(list);
6518
6519 finderCache.putResult(finderPath, finderArgs, list);
6520 }
6521 catch (Exception e) {
6522 finderCache.removeResult(finderPath, finderArgs);
6523
6524 throw processException(e);
6525 }
6526 finally {
6527 closeSession(session);
6528 }
6529 }
6530
6531 return list;
6532 }
6533
6534
6543 @Override
6544 public MBThread findByL_P_First(Date lastPostDate, double priority,
6545 OrderByComparator<MBThread> orderByComparator)
6546 throws NoSuchThreadException {
6547 MBThread mbThread = fetchByL_P_First(lastPostDate, priority,
6548 orderByComparator);
6549
6550 if (mbThread != null) {
6551 return mbThread;
6552 }
6553
6554 StringBundler msg = new StringBundler(6);
6555
6556 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6557
6558 msg.append("lastPostDate=");
6559 msg.append(lastPostDate);
6560
6561 msg.append(", priority=");
6562 msg.append(priority);
6563
6564 msg.append(StringPool.CLOSE_CURLY_BRACE);
6565
6566 throw new NoSuchThreadException(msg.toString());
6567 }
6568
6569
6577 @Override
6578 public MBThread fetchByL_P_First(Date lastPostDate, double priority,
6579 OrderByComparator<MBThread> orderByComparator) {
6580 List<MBThread> list = findByL_P(lastPostDate, priority, 0, 1,
6581 orderByComparator);
6582
6583 if (!list.isEmpty()) {
6584 return list.get(0);
6585 }
6586
6587 return null;
6588 }
6589
6590
6599 @Override
6600 public MBThread findByL_P_Last(Date lastPostDate, double priority,
6601 OrderByComparator<MBThread> orderByComparator)
6602 throws NoSuchThreadException {
6603 MBThread mbThread = fetchByL_P_Last(lastPostDate, priority,
6604 orderByComparator);
6605
6606 if (mbThread != null) {
6607 return mbThread;
6608 }
6609
6610 StringBundler msg = new StringBundler(6);
6611
6612 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6613
6614 msg.append("lastPostDate=");
6615 msg.append(lastPostDate);
6616
6617 msg.append(", priority=");
6618 msg.append(priority);
6619
6620 msg.append(StringPool.CLOSE_CURLY_BRACE);
6621
6622 throw new NoSuchThreadException(msg.toString());
6623 }
6624
6625
6633 @Override
6634 public MBThread fetchByL_P_Last(Date lastPostDate, double priority,
6635 OrderByComparator<MBThread> orderByComparator) {
6636 int count = countByL_P(lastPostDate, priority);
6637
6638 if (count == 0) {
6639 return null;
6640 }
6641
6642 List<MBThread> list = findByL_P(lastPostDate, priority, count - 1,
6643 count, orderByComparator);
6644
6645 if (!list.isEmpty()) {
6646 return list.get(0);
6647 }
6648
6649 return null;
6650 }
6651
6652
6662 @Override
6663 public MBThread[] findByL_P_PrevAndNext(long threadId, Date lastPostDate,
6664 double priority, OrderByComparator<MBThread> orderByComparator)
6665 throws NoSuchThreadException {
6666 MBThread mbThread = findByPrimaryKey(threadId);
6667
6668 Session session = null;
6669
6670 try {
6671 session = openSession();
6672
6673 MBThread[] array = new MBThreadImpl[3];
6674
6675 array[0] = getByL_P_PrevAndNext(session, mbThread, lastPostDate,
6676 priority, orderByComparator, true);
6677
6678 array[1] = mbThread;
6679
6680 array[2] = getByL_P_PrevAndNext(session, mbThread, lastPostDate,
6681 priority, orderByComparator, false);
6682
6683 return array;
6684 }
6685 catch (Exception e) {
6686 throw processException(e);
6687 }
6688 finally {
6689 closeSession(session);
6690 }
6691 }
6692
6693 protected MBThread getByL_P_PrevAndNext(Session session, MBThread mbThread,
6694 Date lastPostDate, double priority,
6695 OrderByComparator<MBThread> orderByComparator, boolean previous) {
6696 StringBundler query = null;
6697
6698 if (orderByComparator != null) {
6699 query = new StringBundler(6 +
6700 (orderByComparator.getOrderByFields().length * 6));
6701 }
6702 else {
6703 query = new StringBundler(3);
6704 }
6705
6706 query.append(_SQL_SELECT_MBTHREAD_WHERE);
6707
6708 boolean bindLastPostDate = false;
6709
6710 if (lastPostDate == null) {
6711 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
6712 }
6713 else {
6714 bindLastPostDate = true;
6715
6716 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
6717 }
6718
6719 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
6720
6721 if (orderByComparator != null) {
6722 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6723
6724 if (orderByConditionFields.length > 0) {
6725 query.append(WHERE_AND);
6726 }
6727
6728 for (int i = 0; i < orderByConditionFields.length; i++) {
6729 query.append(_ORDER_BY_ENTITY_ALIAS);
6730 query.append(orderByConditionFields[i]);
6731
6732 if ((i + 1) < orderByConditionFields.length) {
6733 if (orderByComparator.isAscending() ^ previous) {
6734 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6735 }
6736 else {
6737 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6738 }
6739 }
6740 else {
6741 if (orderByComparator.isAscending() ^ previous) {
6742 query.append(WHERE_GREATER_THAN);
6743 }
6744 else {
6745 query.append(WHERE_LESSER_THAN);
6746 }
6747 }
6748 }
6749
6750 query.append(ORDER_BY_CLAUSE);
6751
6752 String[] orderByFields = orderByComparator.getOrderByFields();
6753
6754 for (int i = 0; i < orderByFields.length; i++) {
6755 query.append(_ORDER_BY_ENTITY_ALIAS);
6756 query.append(orderByFields[i]);
6757
6758 if ((i + 1) < orderByFields.length) {
6759 if (orderByComparator.isAscending() ^ previous) {
6760 query.append(ORDER_BY_ASC_HAS_NEXT);
6761 }
6762 else {
6763 query.append(ORDER_BY_DESC_HAS_NEXT);
6764 }
6765 }
6766 else {
6767 if (orderByComparator.isAscending() ^ previous) {
6768 query.append(ORDER_BY_ASC);
6769 }
6770 else {
6771 query.append(ORDER_BY_DESC);
6772 }
6773 }
6774 }
6775 }
6776 else {
6777 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6778 }
6779
6780 String sql = query.toString();
6781
6782 Query q = session.createQuery(sql);
6783
6784 q.setFirstResult(0);
6785 q.setMaxResults(2);
6786
6787 QueryPos qPos = QueryPos.getInstance(q);
6788
6789 if (bindLastPostDate) {
6790 qPos.add(new Timestamp(lastPostDate.getTime()));
6791 }
6792
6793 qPos.add(priority);
6794
6795 if (orderByComparator != null) {
6796 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
6797
6798 for (Object value : values) {
6799 qPos.add(value);
6800 }
6801 }
6802
6803 List<MBThread> list = q.list();
6804
6805 if (list.size() == 2) {
6806 return list.get(1);
6807 }
6808 else {
6809 return null;
6810 }
6811 }
6812
6813
6819 @Override
6820 public void removeByL_P(Date lastPostDate, double priority) {
6821 for (MBThread mbThread : findByL_P(lastPostDate, priority,
6822 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6823 remove(mbThread);
6824 }
6825 }
6826
6827
6834 @Override
6835 public int countByL_P(Date lastPostDate, double priority) {
6836 FinderPath finderPath = FINDER_PATH_COUNT_BY_L_P;
6837
6838 Object[] finderArgs = new Object[] { lastPostDate, priority };
6839
6840 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6841
6842 if (count == null) {
6843 StringBundler query = new StringBundler(3);
6844
6845 query.append(_SQL_COUNT_MBTHREAD_WHERE);
6846
6847 boolean bindLastPostDate = false;
6848
6849 if (lastPostDate == null) {
6850 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
6851 }
6852 else {
6853 bindLastPostDate = true;
6854
6855 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
6856 }
6857
6858 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
6859
6860 String sql = query.toString();
6861
6862 Session session = null;
6863
6864 try {
6865 session = openSession();
6866
6867 Query q = session.createQuery(sql);
6868
6869 QueryPos qPos = QueryPos.getInstance(q);
6870
6871 if (bindLastPostDate) {
6872 qPos.add(new Timestamp(lastPostDate.getTime()));
6873 }
6874
6875 qPos.add(priority);
6876
6877 count = (Long)q.uniqueResult();
6878
6879 finderCache.putResult(finderPath, finderArgs, count);
6880 }
6881 catch (Exception e) {
6882 finderCache.removeResult(finderPath, finderArgs);
6883
6884 throw processException(e);
6885 }
6886 finally {
6887 closeSession(session);
6888 }
6889 }
6890
6891 return count.intValue();
6892 }
6893
6894 private static final String _FINDER_COLUMN_L_P_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL AND ";
6895 private static final String _FINDER_COLUMN_L_P_LASTPOSTDATE_2 = "mbThread.lastPostDate = ? AND ";
6896 private static final String _FINDER_COLUMN_L_P_PRIORITY_2 = "mbThread.priority = ? AND mbThread.categoryId != -1";
6897 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6898 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
6899 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_L",
6900 new String[] {
6901 Long.class.getName(), Long.class.getName(), Date.class.getName(),
6902
6903 Integer.class.getName(), Integer.class.getName(),
6904 OrderByComparator.class.getName()
6905 });
6906 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6907 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
6908 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
6909 new String[] {
6910 Long.class.getName(), Long.class.getName(), Date.class.getName()
6911 },
6912 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
6913 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
6914 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK |
6915 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK);
6916 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
6917 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
6918 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
6919 new String[] {
6920 Long.class.getName(), Long.class.getName(), Date.class.getName()
6921 });
6922
6923
6931 @Override
6932 public List<MBThread> findByG_C_L(long groupId, long categoryId,
6933 Date lastPostDate) {
6934 return findByG_C_L(groupId, categoryId, lastPostDate,
6935 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6936 }
6937
6938
6952 @Override
6953 public List<MBThread> findByG_C_L(long groupId, long categoryId,
6954 Date lastPostDate, int start, int end) {
6955 return findByG_C_L(groupId, categoryId, lastPostDate, start, end, null);
6956 }
6957
6958
6973 @Override
6974 public List<MBThread> findByG_C_L(long groupId, long categoryId,
6975 Date lastPostDate, int start, int end,
6976 OrderByComparator<MBThread> orderByComparator) {
6977 return findByG_C_L(groupId, categoryId, lastPostDate, start, end,
6978 orderByComparator, true);
6979 }
6980
6981
6997 @Override
6998 public List<MBThread> findByG_C_L(long groupId, long categoryId,
6999 Date lastPostDate, int start, int end,
7000 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
7001 boolean pagination = true;
7002 FinderPath finderPath = null;
7003 Object[] finderArgs = null;
7004
7005 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7006 (orderByComparator == null)) {
7007 pagination = false;
7008 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
7009 finderArgs = new Object[] { groupId, categoryId, lastPostDate };
7010 }
7011 else {
7012 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
7013 finderArgs = new Object[] {
7014 groupId, categoryId, lastPostDate,
7015
7016 start, end, orderByComparator
7017 };
7018 }
7019
7020 List<MBThread> list = null;
7021
7022 if (retrieveFromCache) {
7023 list = (List<MBThread>)finderCache.getResult(finderPath,
7024 finderArgs, this);
7025
7026 if ((list != null) && !list.isEmpty()) {
7027 for (MBThread mbThread : list) {
7028 if ((groupId != mbThread.getGroupId()) ||
7029 (categoryId != mbThread.getCategoryId()) ||
7030 !Validator.equals(lastPostDate,
7031 mbThread.getLastPostDate())) {
7032 list = null;
7033
7034 break;
7035 }
7036 }
7037 }
7038 }
7039
7040 if (list == null) {
7041 StringBundler query = null;
7042
7043 if (orderByComparator != null) {
7044 query = new StringBundler(5 +
7045 (orderByComparator.getOrderByFields().length * 3));
7046 }
7047 else {
7048 query = new StringBundler(5);
7049 }
7050
7051 query.append(_SQL_SELECT_MBTHREAD_WHERE);
7052
7053 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7054
7055 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7056
7057 boolean bindLastPostDate = false;
7058
7059 if (lastPostDate == null) {
7060 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7061 }
7062 else {
7063 bindLastPostDate = true;
7064
7065 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7066 }
7067
7068 if (orderByComparator != null) {
7069 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7070 orderByComparator);
7071 }
7072 else
7073 if (pagination) {
7074 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7075 }
7076
7077 String sql = query.toString();
7078
7079 Session session = null;
7080
7081 try {
7082 session = openSession();
7083
7084 Query q = session.createQuery(sql);
7085
7086 QueryPos qPos = QueryPos.getInstance(q);
7087
7088 qPos.add(groupId);
7089
7090 qPos.add(categoryId);
7091
7092 if (bindLastPostDate) {
7093 qPos.add(new Timestamp(lastPostDate.getTime()));
7094 }
7095
7096 if (!pagination) {
7097 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
7098 start, end, false);
7099
7100 Collections.sort(list);
7101
7102 list = Collections.unmodifiableList(list);
7103 }
7104 else {
7105 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
7106 start, end);
7107 }
7108
7109 cacheResult(list);
7110
7111 finderCache.putResult(finderPath, finderArgs, list);
7112 }
7113 catch (Exception e) {
7114 finderCache.removeResult(finderPath, finderArgs);
7115
7116 throw processException(e);
7117 }
7118 finally {
7119 closeSession(session);
7120 }
7121 }
7122
7123 return list;
7124 }
7125
7126
7136 @Override
7137 public MBThread findByG_C_L_First(long groupId, long categoryId,
7138 Date lastPostDate, OrderByComparator<MBThread> orderByComparator)
7139 throws NoSuchThreadException {
7140 MBThread mbThread = fetchByG_C_L_First(groupId, categoryId,
7141 lastPostDate, orderByComparator);
7142
7143 if (mbThread != null) {
7144 return mbThread;
7145 }
7146
7147 StringBundler msg = new StringBundler(8);
7148
7149 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7150
7151 msg.append("groupId=");
7152 msg.append(groupId);
7153
7154 msg.append(", categoryId=");
7155 msg.append(categoryId);
7156
7157 msg.append(", lastPostDate=");
7158 msg.append(lastPostDate);
7159
7160 msg.append(StringPool.CLOSE_CURLY_BRACE);
7161
7162 throw new NoSuchThreadException(msg.toString());
7163 }
7164
7165
7174 @Override
7175 public MBThread fetchByG_C_L_First(long groupId, long categoryId,
7176 Date lastPostDate, OrderByComparator<MBThread> orderByComparator) {
7177 List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate, 0,
7178 1, orderByComparator);
7179
7180 if (!list.isEmpty()) {
7181 return list.get(0);
7182 }
7183
7184 return null;
7185 }
7186
7187
7197 @Override
7198 public MBThread findByG_C_L_Last(long groupId, long categoryId,
7199 Date lastPostDate, OrderByComparator<MBThread> orderByComparator)
7200 throws NoSuchThreadException {
7201 MBThread mbThread = fetchByG_C_L_Last(groupId, categoryId,
7202 lastPostDate, orderByComparator);
7203
7204 if (mbThread != null) {
7205 return mbThread;
7206 }
7207
7208 StringBundler msg = new StringBundler(8);
7209
7210 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7211
7212 msg.append("groupId=");
7213 msg.append(groupId);
7214
7215 msg.append(", categoryId=");
7216 msg.append(categoryId);
7217
7218 msg.append(", lastPostDate=");
7219 msg.append(lastPostDate);
7220
7221 msg.append(StringPool.CLOSE_CURLY_BRACE);
7222
7223 throw new NoSuchThreadException(msg.toString());
7224 }
7225
7226
7235 @Override
7236 public MBThread fetchByG_C_L_Last(long groupId, long categoryId,
7237 Date lastPostDate, OrderByComparator<MBThread> orderByComparator) {
7238 int count = countByG_C_L(groupId, categoryId, lastPostDate);
7239
7240 if (count == 0) {
7241 return null;
7242 }
7243
7244 List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate,
7245 count - 1, count, orderByComparator);
7246
7247 if (!list.isEmpty()) {
7248 return list.get(0);
7249 }
7250
7251 return null;
7252 }
7253
7254
7265 @Override
7266 public MBThread[] findByG_C_L_PrevAndNext(long threadId, long groupId,
7267 long categoryId, Date lastPostDate,
7268 OrderByComparator<MBThread> orderByComparator)
7269 throws NoSuchThreadException {
7270 MBThread mbThread = findByPrimaryKey(threadId);
7271
7272 Session session = null;
7273
7274 try {
7275 session = openSession();
7276
7277 MBThread[] array = new MBThreadImpl[3];
7278
7279 array[0] = getByG_C_L_PrevAndNext(session, mbThread, groupId,
7280 categoryId, lastPostDate, orderByComparator, true);
7281
7282 array[1] = mbThread;
7283
7284 array[2] = getByG_C_L_PrevAndNext(session, mbThread, groupId,
7285 categoryId, lastPostDate, orderByComparator, false);
7286
7287 return array;
7288 }
7289 catch (Exception e) {
7290 throw processException(e);
7291 }
7292 finally {
7293 closeSession(session);
7294 }
7295 }
7296
7297 protected MBThread getByG_C_L_PrevAndNext(Session session,
7298 MBThread mbThread, long groupId, long categoryId, Date lastPostDate,
7299 OrderByComparator<MBThread> orderByComparator, boolean previous) {
7300 StringBundler query = null;
7301
7302 if (orderByComparator != null) {
7303 query = new StringBundler(6 +
7304 (orderByComparator.getOrderByFields().length * 6));
7305 }
7306 else {
7307 query = new StringBundler(3);
7308 }
7309
7310 query.append(_SQL_SELECT_MBTHREAD_WHERE);
7311
7312 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7313
7314 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7315
7316 boolean bindLastPostDate = false;
7317
7318 if (lastPostDate == null) {
7319 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7320 }
7321 else {
7322 bindLastPostDate = true;
7323
7324 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7325 }
7326
7327 if (orderByComparator != null) {
7328 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7329
7330 if (orderByConditionFields.length > 0) {
7331 query.append(WHERE_AND);
7332 }
7333
7334 for (int i = 0; i < orderByConditionFields.length; i++) {
7335 query.append(_ORDER_BY_ENTITY_ALIAS);
7336 query.append(orderByConditionFields[i]);
7337
7338 if ((i + 1) < orderByConditionFields.length) {
7339 if (orderByComparator.isAscending() ^ previous) {
7340 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7341 }
7342 else {
7343 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7344 }
7345 }
7346 else {
7347 if (orderByComparator.isAscending() ^ previous) {
7348 query.append(WHERE_GREATER_THAN);
7349 }
7350 else {
7351 query.append(WHERE_LESSER_THAN);
7352 }
7353 }
7354 }
7355
7356 query.append(ORDER_BY_CLAUSE);
7357
7358 String[] orderByFields = orderByComparator.getOrderByFields();
7359
7360 for (int i = 0; i < orderByFields.length; i++) {
7361 query.append(_ORDER_BY_ENTITY_ALIAS);
7362 query.append(orderByFields[i]);
7363
7364 if ((i + 1) < orderByFields.length) {
7365 if (orderByComparator.isAscending() ^ previous) {
7366 query.append(ORDER_BY_ASC_HAS_NEXT);
7367 }
7368 else {
7369 query.append(ORDER_BY_DESC_HAS_NEXT);
7370 }
7371 }
7372 else {
7373 if (orderByComparator.isAscending() ^ previous) {
7374 query.append(ORDER_BY_ASC);
7375 }
7376 else {
7377 query.append(ORDER_BY_DESC);
7378 }
7379 }
7380 }
7381 }
7382 else {
7383 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7384 }
7385
7386 String sql = query.toString();
7387
7388 Query q = session.createQuery(sql);
7389
7390 q.setFirstResult(0);
7391 q.setMaxResults(2);
7392
7393 QueryPos qPos = QueryPos.getInstance(q);
7394
7395 qPos.add(groupId);
7396
7397 qPos.add(categoryId);
7398
7399 if (bindLastPostDate) {
7400 qPos.add(new Timestamp(lastPostDate.getTime()));
7401 }
7402
7403 if (orderByComparator != null) {
7404 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
7405
7406 for (Object value : values) {
7407 qPos.add(value);
7408 }
7409 }
7410
7411 List<MBThread> list = q.list();
7412
7413 if (list.size() == 2) {
7414 return list.get(1);
7415 }
7416 else {
7417 return null;
7418 }
7419 }
7420
7421
7429 @Override
7430 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
7431 Date lastPostDate) {
7432 return filterFindByG_C_L(groupId, categoryId, lastPostDate,
7433 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7434 }
7435
7436
7450 @Override
7451 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
7452 Date lastPostDate, int start, int end) {
7453 return filterFindByG_C_L(groupId, categoryId, lastPostDate, start, end,
7454 null);
7455 }
7456
7457
7472 @Override
7473 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
7474 Date lastPostDate, int start, int end,
7475 OrderByComparator<MBThread> orderByComparator) {
7476 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7477 return findByG_C_L(groupId, categoryId, lastPostDate, start, end,
7478 orderByComparator);
7479 }
7480
7481 StringBundler query = null;
7482
7483 if (orderByComparator != null) {
7484 query = new StringBundler(5 +
7485 (orderByComparator.getOrderByFields().length * 3));
7486 }
7487 else {
7488 query = new StringBundler(5);
7489 }
7490
7491 if (getDB().isSupportsInlineDistinct()) {
7492 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
7493 }
7494 else {
7495 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
7496 }
7497
7498 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7499
7500 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7501
7502 boolean bindLastPostDate = false;
7503
7504 if (lastPostDate == null) {
7505 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7506 }
7507 else {
7508 bindLastPostDate = true;
7509
7510 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7511 }
7512
7513 if (!getDB().isSupportsInlineDistinct()) {
7514 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
7515 }
7516
7517 if (orderByComparator != null) {
7518 if (getDB().isSupportsInlineDistinct()) {
7519 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7520 orderByComparator, true);
7521 }
7522 else {
7523 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7524 orderByComparator, true);
7525 }
7526 }
7527 else {
7528 if (getDB().isSupportsInlineDistinct()) {
7529 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7530 }
7531 else {
7532 query.append(MBThreadModelImpl.ORDER_BY_SQL);
7533 }
7534 }
7535
7536 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7537 MBThread.class.getName(),
7538 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7539
7540 Session session = null;
7541
7542 try {
7543 session = openSession();
7544
7545 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7546
7547 if (getDB().isSupportsInlineDistinct()) {
7548 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
7549 }
7550 else {
7551 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
7552 }
7553
7554 QueryPos qPos = QueryPos.getInstance(q);
7555
7556 qPos.add(groupId);
7557
7558 qPos.add(categoryId);
7559
7560 if (bindLastPostDate) {
7561 qPos.add(new Timestamp(lastPostDate.getTime()));
7562 }
7563
7564 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
7565 }
7566 catch (Exception e) {
7567 throw processException(e);
7568 }
7569 finally {
7570 closeSession(session);
7571 }
7572 }
7573
7574
7585 @Override
7586 public MBThread[] filterFindByG_C_L_PrevAndNext(long threadId,
7587 long groupId, long categoryId, Date lastPostDate,
7588 OrderByComparator<MBThread> orderByComparator)
7589 throws NoSuchThreadException {
7590 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7591 return findByG_C_L_PrevAndNext(threadId, groupId, categoryId,
7592 lastPostDate, orderByComparator);
7593 }
7594
7595 MBThread mbThread = findByPrimaryKey(threadId);
7596
7597 Session session = null;
7598
7599 try {
7600 session = openSession();
7601
7602 MBThread[] array = new MBThreadImpl[3];
7603
7604 array[0] = filterGetByG_C_L_PrevAndNext(session, mbThread, groupId,
7605 categoryId, lastPostDate, orderByComparator, true);
7606
7607 array[1] = mbThread;
7608
7609 array[2] = filterGetByG_C_L_PrevAndNext(session, mbThread, groupId,
7610 categoryId, lastPostDate, orderByComparator, false);
7611
7612 return array;
7613 }
7614 catch (Exception e) {
7615 throw processException(e);
7616 }
7617 finally {
7618 closeSession(session);
7619 }
7620 }
7621
7622 protected MBThread filterGetByG_C_L_PrevAndNext(Session session,
7623 MBThread mbThread, long groupId, long categoryId, Date lastPostDate,
7624 OrderByComparator<MBThread> orderByComparator, boolean previous) {
7625 StringBundler query = null;
7626
7627 if (orderByComparator != null) {
7628 query = new StringBundler(6 +
7629 (orderByComparator.getOrderByFields().length * 6));
7630 }
7631 else {
7632 query = new StringBundler(3);
7633 }
7634
7635 if (getDB().isSupportsInlineDistinct()) {
7636 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
7637 }
7638 else {
7639 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
7640 }
7641
7642 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7643
7644 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7645
7646 boolean bindLastPostDate = false;
7647
7648 if (lastPostDate == null) {
7649 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7650 }
7651 else {
7652 bindLastPostDate = true;
7653
7654 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7655 }
7656
7657 if (!getDB().isSupportsInlineDistinct()) {
7658 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
7659 }
7660
7661 if (orderByComparator != null) {
7662 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7663
7664 if (orderByConditionFields.length > 0) {
7665 query.append(WHERE_AND);
7666 }
7667
7668 for (int i = 0; i < orderByConditionFields.length; i++) {
7669 if (getDB().isSupportsInlineDistinct()) {
7670 query.append(_ORDER_BY_ENTITY_ALIAS);
7671 }
7672 else {
7673 query.append(_ORDER_BY_ENTITY_TABLE);
7674 }
7675
7676 query.append(orderByConditionFields[i]);
7677
7678 if ((i + 1) < orderByConditionFields.length) {
7679 if (orderByComparator.isAscending() ^ previous) {
7680 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7681 }
7682 else {
7683 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7684 }
7685 }
7686 else {
7687 if (orderByComparator.isAscending() ^ previous) {
7688 query.append(WHERE_GREATER_THAN);
7689 }
7690 else {
7691 query.append(WHERE_LESSER_THAN);
7692 }
7693 }
7694 }
7695
7696 query.append(ORDER_BY_CLAUSE);
7697
7698 String[] orderByFields = orderByComparator.getOrderByFields();
7699
7700 for (int i = 0; i < orderByFields.length; i++) {
7701 if (getDB().isSupportsInlineDistinct()) {
7702 query.append(_ORDER_BY_ENTITY_ALIAS);
7703 }
7704 else {
7705 query.append(_ORDER_BY_ENTITY_TABLE);
7706 }
7707
7708 query.append(orderByFields[i]);
7709
7710 if ((i + 1) < orderByFields.length) {
7711 if (orderByComparator.isAscending() ^ previous) {
7712 query.append(ORDER_BY_ASC_HAS_NEXT);
7713 }
7714 else {
7715 query.append(ORDER_BY_DESC_HAS_NEXT);
7716 }
7717 }
7718 else {
7719 if (orderByComparator.isAscending() ^ previous) {
7720 query.append(ORDER_BY_ASC);
7721 }
7722 else {
7723 query.append(ORDER_BY_DESC);
7724 }
7725 }
7726 }
7727 }
7728 else {
7729 if (getDB().isSupportsInlineDistinct()) {
7730 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7731 }
7732 else {
7733 query.append(MBThreadModelImpl.ORDER_BY_SQL);
7734 }
7735 }
7736
7737 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7738 MBThread.class.getName(),
7739 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7740
7741 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7742
7743 q.setFirstResult(0);
7744 q.setMaxResults(2);
7745
7746 if (getDB().isSupportsInlineDistinct()) {
7747 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
7748 }
7749 else {
7750 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
7751 }
7752
7753 QueryPos qPos = QueryPos.getInstance(q);
7754
7755 qPos.add(groupId);
7756
7757 qPos.add(categoryId);
7758
7759 if (bindLastPostDate) {
7760 qPos.add(new Timestamp(lastPostDate.getTime()));
7761 }
7762
7763 if (orderByComparator != null) {
7764 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
7765
7766 for (Object value : values) {
7767 qPos.add(value);
7768 }
7769 }
7770
7771 List<MBThread> list = q.list();
7772
7773 if (list.size() == 2) {
7774 return list.get(1);
7775 }
7776 else {
7777 return null;
7778 }
7779 }
7780
7781
7788 @Override
7789 public void removeByG_C_L(long groupId, long categoryId, Date lastPostDate) {
7790 for (MBThread mbThread : findByG_C_L(groupId, categoryId, lastPostDate,
7791 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7792 remove(mbThread);
7793 }
7794 }
7795
7796
7804 @Override
7805 public int countByG_C_L(long groupId, long categoryId, Date lastPostDate) {
7806 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
7807
7808 Object[] finderArgs = new Object[] { groupId, categoryId, lastPostDate };
7809
7810 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7811
7812 if (count == null) {
7813 StringBundler query = new StringBundler(4);
7814
7815 query.append(_SQL_COUNT_MBTHREAD_WHERE);
7816
7817 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7818
7819 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7820
7821 boolean bindLastPostDate = false;
7822
7823 if (lastPostDate == null) {
7824 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7825 }
7826 else {
7827 bindLastPostDate = true;
7828
7829 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7830 }
7831
7832 String sql = query.toString();
7833
7834 Session session = null;
7835
7836 try {
7837 session = openSession();
7838
7839 Query q = session.createQuery(sql);
7840
7841 QueryPos qPos = QueryPos.getInstance(q);
7842
7843 qPos.add(groupId);
7844
7845 qPos.add(categoryId);
7846
7847 if (bindLastPostDate) {
7848 qPos.add(new Timestamp(lastPostDate.getTime()));
7849 }
7850
7851 count = (Long)q.uniqueResult();
7852
7853 finderCache.putResult(finderPath, finderArgs, count);
7854 }
7855 catch (Exception e) {
7856 finderCache.removeResult(finderPath, finderArgs);
7857
7858 throw processException(e);
7859 }
7860 finally {
7861 closeSession(session);
7862 }
7863 }
7864
7865 return count.intValue();
7866 }
7867
7868
7876 @Override
7877 public int filterCountByG_C_L(long groupId, long categoryId,
7878 Date lastPostDate) {
7879 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7880 return countByG_C_L(groupId, categoryId, lastPostDate);
7881 }
7882
7883 StringBundler query = new StringBundler(4);
7884
7885 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
7886
7887 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
7888
7889 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
7890
7891 boolean bindLastPostDate = false;
7892
7893 if (lastPostDate == null) {
7894 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
7895 }
7896 else {
7897 bindLastPostDate = true;
7898
7899 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
7900 }
7901
7902 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7903 MBThread.class.getName(),
7904 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7905
7906 Session session = null;
7907
7908 try {
7909 session = openSession();
7910
7911 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7912
7913 q.addScalar(COUNT_COLUMN_NAME,
7914 com.liferay.portal.kernel.dao.orm.Type.LONG);
7915
7916 QueryPos qPos = QueryPos.getInstance(q);
7917
7918 qPos.add(groupId);
7919
7920 qPos.add(categoryId);
7921
7922 if (bindLastPostDate) {
7923 qPos.add(new Timestamp(lastPostDate.getTime()));
7924 }
7925
7926 Long count = (Long)q.uniqueResult();
7927
7928 return count.intValue();
7929 }
7930 catch (Exception e) {
7931 throw processException(e);
7932 }
7933 finally {
7934 closeSession(session);
7935 }
7936 }
7937
7938 private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "mbThread.groupId = ? AND ";
7939 private static final String _FINDER_COLUMN_G_C_L_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
7940 private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL";
7941 private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_2 = "mbThread.lastPostDate = ?";
7942 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
7943 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
7944 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_S",
7945 new String[] {
7946 Long.class.getName(), Long.class.getName(),
7947 Integer.class.getName(),
7948
7949 Integer.class.getName(), Integer.class.getName(),
7950 OrderByComparator.class.getName()
7951 });
7952 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
7953 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
7954 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_S",
7955 new String[] {
7956 Long.class.getName(), Long.class.getName(),
7957 Integer.class.getName()
7958 },
7959 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
7960 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
7961 MBThreadModelImpl.STATUS_COLUMN_BITMASK |
7962 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK |
7963 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
7964 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
7965 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
7966 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
7967 new String[] {
7968 Long.class.getName(), Long.class.getName(),
7969 Integer.class.getName()
7970 });
7971 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
7972 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
7973 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_C_S",
7974 new String[] {
7975 Long.class.getName(), Long.class.getName(),
7976 Integer.class.getName()
7977 });
7978
7979
7987 @Override
7988 public List<MBThread> findByG_C_S(long groupId, long categoryId, int status) {
7989 return findByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS,
7990 QueryUtil.ALL_POS, null);
7991 }
7992
7993
8007 @Override
8008 public List<MBThread> findByG_C_S(long groupId, long categoryId,
8009 int status, int start, int end) {
8010 return findByG_C_S(groupId, categoryId, status, start, end, null);
8011 }
8012
8013
8028 @Override
8029 public List<MBThread> findByG_C_S(long groupId, long categoryId,
8030 int status, int start, int end,
8031 OrderByComparator<MBThread> orderByComparator) {
8032 return findByG_C_S(groupId, categoryId, status, start, end,
8033 orderByComparator, true);
8034 }
8035
8036
8052 @Override
8053 public List<MBThread> findByG_C_S(long groupId, long categoryId,
8054 int status, int start, int end,
8055 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
8056 boolean pagination = true;
8057 FinderPath finderPath = null;
8058 Object[] finderArgs = null;
8059
8060 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8061 (orderByComparator == null)) {
8062 pagination = false;
8063 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S;
8064 finderArgs = new Object[] { groupId, categoryId, status };
8065 }
8066 else {
8067 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S;
8068 finderArgs = new Object[] {
8069 groupId, categoryId, status,
8070
8071 start, end, orderByComparator
8072 };
8073 }
8074
8075 List<MBThread> list = null;
8076
8077 if (retrieveFromCache) {
8078 list = (List<MBThread>)finderCache.getResult(finderPath,
8079 finderArgs, this);
8080
8081 if ((list != null) && !list.isEmpty()) {
8082 for (MBThread mbThread : list) {
8083 if ((groupId != mbThread.getGroupId()) ||
8084 (categoryId != mbThread.getCategoryId()) ||
8085 (status != mbThread.getStatus())) {
8086 list = null;
8087
8088 break;
8089 }
8090 }
8091 }
8092 }
8093
8094 if (list == null) {
8095 StringBundler query = null;
8096
8097 if (orderByComparator != null) {
8098 query = new StringBundler(5 +
8099 (orderByComparator.getOrderByFields().length * 3));
8100 }
8101 else {
8102 query = new StringBundler(5);
8103 }
8104
8105 query.append(_SQL_SELECT_MBTHREAD_WHERE);
8106
8107 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8108
8109 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8110
8111 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8112
8113 if (orderByComparator != null) {
8114 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8115 orderByComparator);
8116 }
8117 else
8118 if (pagination) {
8119 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
8120 }
8121
8122 String sql = query.toString();
8123
8124 Session session = null;
8125
8126 try {
8127 session = openSession();
8128
8129 Query q = session.createQuery(sql);
8130
8131 QueryPos qPos = QueryPos.getInstance(q);
8132
8133 qPos.add(groupId);
8134
8135 qPos.add(categoryId);
8136
8137 qPos.add(status);
8138
8139 if (!pagination) {
8140 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
8141 start, end, false);
8142
8143 Collections.sort(list);
8144
8145 list = Collections.unmodifiableList(list);
8146 }
8147 else {
8148 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
8149 start, end);
8150 }
8151
8152 cacheResult(list);
8153
8154 finderCache.putResult(finderPath, finderArgs, list);
8155 }
8156 catch (Exception e) {
8157 finderCache.removeResult(finderPath, finderArgs);
8158
8159 throw processException(e);
8160 }
8161 finally {
8162 closeSession(session);
8163 }
8164 }
8165
8166 return list;
8167 }
8168
8169
8179 @Override
8180 public MBThread findByG_C_S_First(long groupId, long categoryId,
8181 int status, OrderByComparator<MBThread> orderByComparator)
8182 throws NoSuchThreadException {
8183 MBThread mbThread = fetchByG_C_S_First(groupId, categoryId, status,
8184 orderByComparator);
8185
8186 if (mbThread != null) {
8187 return mbThread;
8188 }
8189
8190 StringBundler msg = new StringBundler(8);
8191
8192 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8193
8194 msg.append("groupId=");
8195 msg.append(groupId);
8196
8197 msg.append(", categoryId=");
8198 msg.append(categoryId);
8199
8200 msg.append(", status=");
8201 msg.append(status);
8202
8203 msg.append(StringPool.CLOSE_CURLY_BRACE);
8204
8205 throw new NoSuchThreadException(msg.toString());
8206 }
8207
8208
8217 @Override
8218 public MBThread fetchByG_C_S_First(long groupId, long categoryId,
8219 int status, OrderByComparator<MBThread> orderByComparator) {
8220 List<MBThread> list = findByG_C_S(groupId, categoryId, status, 0, 1,
8221 orderByComparator);
8222
8223 if (!list.isEmpty()) {
8224 return list.get(0);
8225 }
8226
8227 return null;
8228 }
8229
8230
8240 @Override
8241 public MBThread findByG_C_S_Last(long groupId, long categoryId, int status,
8242 OrderByComparator<MBThread> orderByComparator)
8243 throws NoSuchThreadException {
8244 MBThread mbThread = fetchByG_C_S_Last(groupId, categoryId, status,
8245 orderByComparator);
8246
8247 if (mbThread != null) {
8248 return mbThread;
8249 }
8250
8251 StringBundler msg = new StringBundler(8);
8252
8253 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8254
8255 msg.append("groupId=");
8256 msg.append(groupId);
8257
8258 msg.append(", categoryId=");
8259 msg.append(categoryId);
8260
8261 msg.append(", status=");
8262 msg.append(status);
8263
8264 msg.append(StringPool.CLOSE_CURLY_BRACE);
8265
8266 throw new NoSuchThreadException(msg.toString());
8267 }
8268
8269
8278 @Override
8279 public MBThread fetchByG_C_S_Last(long groupId, long categoryId,
8280 int status, OrderByComparator<MBThread> orderByComparator) {
8281 int count = countByG_C_S(groupId, categoryId, status);
8282
8283 if (count == 0) {
8284 return null;
8285 }
8286
8287 List<MBThread> list = findByG_C_S(groupId, categoryId, status,
8288 count - 1, count, orderByComparator);
8289
8290 if (!list.isEmpty()) {
8291 return list.get(0);
8292 }
8293
8294 return null;
8295 }
8296
8297
8308 @Override
8309 public MBThread[] findByG_C_S_PrevAndNext(long threadId, long groupId,
8310 long categoryId, int status,
8311 OrderByComparator<MBThread> orderByComparator)
8312 throws NoSuchThreadException {
8313 MBThread mbThread = findByPrimaryKey(threadId);
8314
8315 Session session = null;
8316
8317 try {
8318 session = openSession();
8319
8320 MBThread[] array = new MBThreadImpl[3];
8321
8322 array[0] = getByG_C_S_PrevAndNext(session, mbThread, groupId,
8323 categoryId, status, orderByComparator, true);
8324
8325 array[1] = mbThread;
8326
8327 array[2] = getByG_C_S_PrevAndNext(session, mbThread, groupId,
8328 categoryId, status, orderByComparator, false);
8329
8330 return array;
8331 }
8332 catch (Exception e) {
8333 throw processException(e);
8334 }
8335 finally {
8336 closeSession(session);
8337 }
8338 }
8339
8340 protected MBThread getByG_C_S_PrevAndNext(Session session,
8341 MBThread mbThread, long groupId, long categoryId, int status,
8342 OrderByComparator<MBThread> orderByComparator, boolean previous) {
8343 StringBundler query = null;
8344
8345 if (orderByComparator != null) {
8346 query = new StringBundler(6 +
8347 (orderByComparator.getOrderByFields().length * 6));
8348 }
8349 else {
8350 query = new StringBundler(3);
8351 }
8352
8353 query.append(_SQL_SELECT_MBTHREAD_WHERE);
8354
8355 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8356
8357 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8358
8359 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8360
8361 if (orderByComparator != null) {
8362 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8363
8364 if (orderByConditionFields.length > 0) {
8365 query.append(WHERE_AND);
8366 }
8367
8368 for (int i = 0; i < orderByConditionFields.length; i++) {
8369 query.append(_ORDER_BY_ENTITY_ALIAS);
8370 query.append(orderByConditionFields[i]);
8371
8372 if ((i + 1) < orderByConditionFields.length) {
8373 if (orderByComparator.isAscending() ^ previous) {
8374 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8375 }
8376 else {
8377 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8378 }
8379 }
8380 else {
8381 if (orderByComparator.isAscending() ^ previous) {
8382 query.append(WHERE_GREATER_THAN);
8383 }
8384 else {
8385 query.append(WHERE_LESSER_THAN);
8386 }
8387 }
8388 }
8389
8390 query.append(ORDER_BY_CLAUSE);
8391
8392 String[] orderByFields = orderByComparator.getOrderByFields();
8393
8394 for (int i = 0; i < orderByFields.length; i++) {
8395 query.append(_ORDER_BY_ENTITY_ALIAS);
8396 query.append(orderByFields[i]);
8397
8398 if ((i + 1) < orderByFields.length) {
8399 if (orderByComparator.isAscending() ^ previous) {
8400 query.append(ORDER_BY_ASC_HAS_NEXT);
8401 }
8402 else {
8403 query.append(ORDER_BY_DESC_HAS_NEXT);
8404 }
8405 }
8406 else {
8407 if (orderByComparator.isAscending() ^ previous) {
8408 query.append(ORDER_BY_ASC);
8409 }
8410 else {
8411 query.append(ORDER_BY_DESC);
8412 }
8413 }
8414 }
8415 }
8416 else {
8417 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
8418 }
8419
8420 String sql = query.toString();
8421
8422 Query q = session.createQuery(sql);
8423
8424 q.setFirstResult(0);
8425 q.setMaxResults(2);
8426
8427 QueryPos qPos = QueryPos.getInstance(q);
8428
8429 qPos.add(groupId);
8430
8431 qPos.add(categoryId);
8432
8433 qPos.add(status);
8434
8435 if (orderByComparator != null) {
8436 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
8437
8438 for (Object value : values) {
8439 qPos.add(value);
8440 }
8441 }
8442
8443 List<MBThread> list = q.list();
8444
8445 if (list.size() == 2) {
8446 return list.get(1);
8447 }
8448 else {
8449 return null;
8450 }
8451 }
8452
8453
8461 @Override
8462 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
8463 int status) {
8464 return filterFindByG_C_S(groupId, categoryId, status,
8465 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8466 }
8467
8468
8482 @Override
8483 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
8484 int status, int start, int end) {
8485 return filterFindByG_C_S(groupId, categoryId, status, start, end, null);
8486 }
8487
8488
8503 @Override
8504 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
8505 int status, int start, int end,
8506 OrderByComparator<MBThread> orderByComparator) {
8507 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8508 return findByG_C_S(groupId, categoryId, status, start, end,
8509 orderByComparator);
8510 }
8511
8512 StringBundler query = null;
8513
8514 if (orderByComparator != null) {
8515 query = new StringBundler(5 +
8516 (orderByComparator.getOrderByFields().length * 3));
8517 }
8518 else {
8519 query = new StringBundler(5);
8520 }
8521
8522 if (getDB().isSupportsInlineDistinct()) {
8523 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
8524 }
8525 else {
8526 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
8527 }
8528
8529 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8530
8531 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8532
8533 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8534
8535 if (!getDB().isSupportsInlineDistinct()) {
8536 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
8537 }
8538
8539 if (orderByComparator != null) {
8540 if (getDB().isSupportsInlineDistinct()) {
8541 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8542 orderByComparator, true);
8543 }
8544 else {
8545 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8546 orderByComparator, true);
8547 }
8548 }
8549 else {
8550 if (getDB().isSupportsInlineDistinct()) {
8551 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
8552 }
8553 else {
8554 query.append(MBThreadModelImpl.ORDER_BY_SQL);
8555 }
8556 }
8557
8558 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8559 MBThread.class.getName(),
8560 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8561
8562 Session session = null;
8563
8564 try {
8565 session = openSession();
8566
8567 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8568
8569 if (getDB().isSupportsInlineDistinct()) {
8570 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
8571 }
8572 else {
8573 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
8574 }
8575
8576 QueryPos qPos = QueryPos.getInstance(q);
8577
8578 qPos.add(groupId);
8579
8580 qPos.add(categoryId);
8581
8582 qPos.add(status);
8583
8584 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
8585 }
8586 catch (Exception e) {
8587 throw processException(e);
8588 }
8589 finally {
8590 closeSession(session);
8591 }
8592 }
8593
8594
8605 @Override
8606 public MBThread[] filterFindByG_C_S_PrevAndNext(long threadId,
8607 long groupId, long categoryId, int status,
8608 OrderByComparator<MBThread> orderByComparator)
8609 throws NoSuchThreadException {
8610 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8611 return findByG_C_S_PrevAndNext(threadId, groupId, categoryId,
8612 status, orderByComparator);
8613 }
8614
8615 MBThread mbThread = findByPrimaryKey(threadId);
8616
8617 Session session = null;
8618
8619 try {
8620 session = openSession();
8621
8622 MBThread[] array = new MBThreadImpl[3];
8623
8624 array[0] = filterGetByG_C_S_PrevAndNext(session, mbThread, groupId,
8625 categoryId, status, orderByComparator, true);
8626
8627 array[1] = mbThread;
8628
8629 array[2] = filterGetByG_C_S_PrevAndNext(session, mbThread, groupId,
8630 categoryId, status, orderByComparator, false);
8631
8632 return array;
8633 }
8634 catch (Exception e) {
8635 throw processException(e);
8636 }
8637 finally {
8638 closeSession(session);
8639 }
8640 }
8641
8642 protected MBThread filterGetByG_C_S_PrevAndNext(Session session,
8643 MBThread mbThread, long groupId, long categoryId, int status,
8644 OrderByComparator<MBThread> orderByComparator, boolean previous) {
8645 StringBundler query = null;
8646
8647 if (orderByComparator != null) {
8648 query = new StringBundler(6 +
8649 (orderByComparator.getOrderByFields().length * 6));
8650 }
8651 else {
8652 query = new StringBundler(3);
8653 }
8654
8655 if (getDB().isSupportsInlineDistinct()) {
8656 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
8657 }
8658 else {
8659 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
8660 }
8661
8662 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8663
8664 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8665
8666 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8667
8668 if (!getDB().isSupportsInlineDistinct()) {
8669 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
8670 }
8671
8672 if (orderByComparator != null) {
8673 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8674
8675 if (orderByConditionFields.length > 0) {
8676 query.append(WHERE_AND);
8677 }
8678
8679 for (int i = 0; i < orderByConditionFields.length; i++) {
8680 if (getDB().isSupportsInlineDistinct()) {
8681 query.append(_ORDER_BY_ENTITY_ALIAS);
8682 }
8683 else {
8684 query.append(_ORDER_BY_ENTITY_TABLE);
8685 }
8686
8687 query.append(orderByConditionFields[i]);
8688
8689 if ((i + 1) < orderByConditionFields.length) {
8690 if (orderByComparator.isAscending() ^ previous) {
8691 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8692 }
8693 else {
8694 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8695 }
8696 }
8697 else {
8698 if (orderByComparator.isAscending() ^ previous) {
8699 query.append(WHERE_GREATER_THAN);
8700 }
8701 else {
8702 query.append(WHERE_LESSER_THAN);
8703 }
8704 }
8705 }
8706
8707 query.append(ORDER_BY_CLAUSE);
8708
8709 String[] orderByFields = orderByComparator.getOrderByFields();
8710
8711 for (int i = 0; i < orderByFields.length; i++) {
8712 if (getDB().isSupportsInlineDistinct()) {
8713 query.append(_ORDER_BY_ENTITY_ALIAS);
8714 }
8715 else {
8716 query.append(_ORDER_BY_ENTITY_TABLE);
8717 }
8718
8719 query.append(orderByFields[i]);
8720
8721 if ((i + 1) < orderByFields.length) {
8722 if (orderByComparator.isAscending() ^ previous) {
8723 query.append(ORDER_BY_ASC_HAS_NEXT);
8724 }
8725 else {
8726 query.append(ORDER_BY_DESC_HAS_NEXT);
8727 }
8728 }
8729 else {
8730 if (orderByComparator.isAscending() ^ previous) {
8731 query.append(ORDER_BY_ASC);
8732 }
8733 else {
8734 query.append(ORDER_BY_DESC);
8735 }
8736 }
8737 }
8738 }
8739 else {
8740 if (getDB().isSupportsInlineDistinct()) {
8741 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
8742 }
8743 else {
8744 query.append(MBThreadModelImpl.ORDER_BY_SQL);
8745 }
8746 }
8747
8748 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8749 MBThread.class.getName(),
8750 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8751
8752 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8753
8754 q.setFirstResult(0);
8755 q.setMaxResults(2);
8756
8757 if (getDB().isSupportsInlineDistinct()) {
8758 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
8759 }
8760 else {
8761 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
8762 }
8763
8764 QueryPos qPos = QueryPos.getInstance(q);
8765
8766 qPos.add(groupId);
8767
8768 qPos.add(categoryId);
8769
8770 qPos.add(status);
8771
8772 if (orderByComparator != null) {
8773 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
8774
8775 for (Object value : values) {
8776 qPos.add(value);
8777 }
8778 }
8779
8780 List<MBThread> list = q.list();
8781
8782 if (list.size() == 2) {
8783 return list.get(1);
8784 }
8785 else {
8786 return null;
8787 }
8788 }
8789
8790
8798 @Override
8799 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
8800 int status) {
8801 return filterFindByG_C_S(groupId, categoryIds, status,
8802 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8803 }
8804
8805
8819 @Override
8820 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
8821 int status, int start, int end) {
8822 return filterFindByG_C_S(groupId, categoryIds, status, start, end, null);
8823 }
8824
8825
8840 @Override
8841 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
8842 int status, int start, int end,
8843 OrderByComparator<MBThread> orderByComparator) {
8844 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8845 return findByG_C_S(groupId, categoryIds, status, start, end,
8846 orderByComparator);
8847 }
8848
8849 if (categoryIds == null) {
8850 categoryIds = new long[0];
8851 }
8852 else if (categoryIds.length > 1) {
8853 categoryIds = ArrayUtil.unique(categoryIds);
8854
8855 Arrays.sort(categoryIds);
8856 }
8857
8858 StringBundler query = new StringBundler();
8859
8860 if (getDB().isSupportsInlineDistinct()) {
8861 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
8862 }
8863 else {
8864 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
8865 }
8866
8867 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8868
8869 if (categoryIds.length > 0) {
8870 query.append(StringPool.OPEN_PARENTHESIS);
8871
8872 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_7);
8873
8874 query.append(StringUtil.merge(categoryIds));
8875
8876 query.append(StringPool.CLOSE_PARENTHESIS);
8877
8878 query.append(StringPool.CLOSE_PARENTHESIS);
8879
8880 query.append(WHERE_AND);
8881 }
8882
8883 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8884
8885 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8886 query.index() - 1);
8887
8888 if (!getDB().isSupportsInlineDistinct()) {
8889 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
8890 }
8891
8892 if (orderByComparator != null) {
8893 if (getDB().isSupportsInlineDistinct()) {
8894 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8895 orderByComparator, true);
8896 }
8897 else {
8898 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8899 orderByComparator, true);
8900 }
8901 }
8902 else {
8903 if (getDB().isSupportsInlineDistinct()) {
8904 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
8905 }
8906 else {
8907 query.append(MBThreadModelImpl.ORDER_BY_SQL);
8908 }
8909 }
8910
8911 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8912 MBThread.class.getName(),
8913 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8914
8915 Session session = null;
8916
8917 try {
8918 session = openSession();
8919
8920 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8921
8922 if (getDB().isSupportsInlineDistinct()) {
8923 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
8924 }
8925 else {
8926 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
8927 }
8928
8929 QueryPos qPos = QueryPos.getInstance(q);
8930
8931 qPos.add(groupId);
8932
8933 qPos.add(status);
8934
8935 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
8936 }
8937 catch (Exception e) {
8938 throw processException(e);
8939 }
8940 finally {
8941 closeSession(session);
8942 }
8943 }
8944
8945
8957 @Override
8958 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
8959 int status) {
8960 return findByG_C_S(groupId, categoryIds, status, QueryUtil.ALL_POS,
8961 QueryUtil.ALL_POS, null);
8962 }
8963
8964
8978 @Override
8979 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
8980 int status, int start, int end) {
8981 return findByG_C_S(groupId, categoryIds, status, start, end, null);
8982 }
8983
8984
8999 @Override
9000 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
9001 int status, int start, int end,
9002 OrderByComparator<MBThread> orderByComparator) {
9003 return findByG_C_S(groupId, categoryIds, status, start, end,
9004 orderByComparator, true);
9005 }
9006
9007
9023 @Override
9024 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
9025 int status, int start, int end,
9026 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
9027 if (categoryIds == null) {
9028 categoryIds = new long[0];
9029 }
9030 else if (categoryIds.length > 1) {
9031 categoryIds = ArrayUtil.unique(categoryIds);
9032
9033 Arrays.sort(categoryIds);
9034 }
9035
9036 if (categoryIds.length == 1) {
9037 return findByG_C_S(groupId, categoryIds[0], status, start, end,
9038 orderByComparator);
9039 }
9040
9041 boolean pagination = true;
9042 Object[] finderArgs = null;
9043
9044 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9045 (orderByComparator == null)) {
9046 pagination = false;
9047 finderArgs = new Object[] {
9048 groupId, StringUtil.merge(categoryIds), status
9049 };
9050 }
9051 else {
9052 finderArgs = new Object[] {
9053 groupId, StringUtil.merge(categoryIds), status,
9054
9055 start, end, orderByComparator
9056 };
9057 }
9058
9059 List<MBThread> list = null;
9060
9061 if (retrieveFromCache) {
9062 list = (List<MBThread>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S,
9063 finderArgs, this);
9064
9065 if ((list != null) && !list.isEmpty()) {
9066 for (MBThread mbThread : list) {
9067 if ((groupId != mbThread.getGroupId()) ||
9068 !ArrayUtil.contains(categoryIds,
9069 mbThread.getCategoryId()) ||
9070 (status != mbThread.getStatus())) {
9071 list = null;
9072
9073 break;
9074 }
9075 }
9076 }
9077 }
9078
9079 if (list == null) {
9080 StringBundler query = new StringBundler();
9081
9082 query.append(_SQL_SELECT_MBTHREAD_WHERE);
9083
9084 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9085
9086 if (categoryIds.length > 0) {
9087 query.append(StringPool.OPEN_PARENTHESIS);
9088
9089 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_7);
9090
9091 query.append(StringUtil.merge(categoryIds));
9092
9093 query.append(StringPool.CLOSE_PARENTHESIS);
9094
9095 query.append(StringPool.CLOSE_PARENTHESIS);
9096
9097 query.append(WHERE_AND);
9098 }
9099
9100 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9101
9102 query.setStringAt(removeConjunction(query.stringAt(query.index() -
9103 1)), query.index() - 1);
9104
9105 if (orderByComparator != null) {
9106 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9107 orderByComparator);
9108 }
9109 else
9110 if (pagination) {
9111 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
9112 }
9113
9114 String sql = query.toString();
9115
9116 Session session = null;
9117
9118 try {
9119 session = openSession();
9120
9121 Query q = session.createQuery(sql);
9122
9123 QueryPos qPos = QueryPos.getInstance(q);
9124
9125 qPos.add(groupId);
9126
9127 qPos.add(status);
9128
9129 if (!pagination) {
9130 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
9131 start, end, false);
9132
9133 Collections.sort(list);
9134
9135 list = Collections.unmodifiableList(list);
9136 }
9137 else {
9138 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
9139 start, end);
9140 }
9141
9142 cacheResult(list);
9143
9144 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S,
9145 finderArgs, list);
9146 }
9147 catch (Exception e) {
9148 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S,
9149 finderArgs);
9150
9151 throw processException(e);
9152 }
9153 finally {
9154 closeSession(session);
9155 }
9156 }
9157
9158 return list;
9159 }
9160
9161
9168 @Override
9169 public void removeByG_C_S(long groupId, long categoryId, int status) {
9170 for (MBThread mbThread : findByG_C_S(groupId, categoryId, status,
9171 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9172 remove(mbThread);
9173 }
9174 }
9175
9176
9184 @Override
9185 public int countByG_C_S(long groupId, long categoryId, int status) {
9186 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
9187
9188 Object[] finderArgs = new Object[] { groupId, categoryId, status };
9189
9190 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9191
9192 if (count == null) {
9193 StringBundler query = new StringBundler(4);
9194
9195 query.append(_SQL_COUNT_MBTHREAD_WHERE);
9196
9197 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9198
9199 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
9200
9201 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9202
9203 String sql = query.toString();
9204
9205 Session session = null;
9206
9207 try {
9208 session = openSession();
9209
9210 Query q = session.createQuery(sql);
9211
9212 QueryPos qPos = QueryPos.getInstance(q);
9213
9214 qPos.add(groupId);
9215
9216 qPos.add(categoryId);
9217
9218 qPos.add(status);
9219
9220 count = (Long)q.uniqueResult();
9221
9222 finderCache.putResult(finderPath, finderArgs, count);
9223 }
9224 catch (Exception e) {
9225 finderCache.removeResult(finderPath, finderArgs);
9226
9227 throw processException(e);
9228 }
9229 finally {
9230 closeSession(session);
9231 }
9232 }
9233
9234 return count.intValue();
9235 }
9236
9237
9245 @Override
9246 public int countByG_C_S(long groupId, long[] categoryIds, int status) {
9247 if (categoryIds == null) {
9248 categoryIds = new long[0];
9249 }
9250 else if (categoryIds.length > 1) {
9251 categoryIds = ArrayUtil.unique(categoryIds);
9252
9253 Arrays.sort(categoryIds);
9254 }
9255
9256 Object[] finderArgs = new Object[] {
9257 groupId, StringUtil.merge(categoryIds), status
9258 };
9259
9260 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S,
9261 finderArgs, this);
9262
9263 if (count == null) {
9264 StringBundler query = new StringBundler();
9265
9266 query.append(_SQL_COUNT_MBTHREAD_WHERE);
9267
9268 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9269
9270 if (categoryIds.length > 0) {
9271 query.append(StringPool.OPEN_PARENTHESIS);
9272
9273 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_7);
9274
9275 query.append(StringUtil.merge(categoryIds));
9276
9277 query.append(StringPool.CLOSE_PARENTHESIS);
9278
9279 query.append(StringPool.CLOSE_PARENTHESIS);
9280
9281 query.append(WHERE_AND);
9282 }
9283
9284 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9285
9286 query.setStringAt(removeConjunction(query.stringAt(query.index() -
9287 1)), query.index() - 1);
9288
9289 String sql = query.toString();
9290
9291 Session session = null;
9292
9293 try {
9294 session = openSession();
9295
9296 Query q = session.createQuery(sql);
9297
9298 QueryPos qPos = QueryPos.getInstance(q);
9299
9300 qPos.add(groupId);
9301
9302 qPos.add(status);
9303
9304 count = (Long)q.uniqueResult();
9305
9306 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S,
9307 finderArgs, count);
9308 }
9309 catch (Exception e) {
9310 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S,
9311 finderArgs);
9312
9313 throw processException(e);
9314 }
9315 finally {
9316 closeSession(session);
9317 }
9318 }
9319
9320 return count.intValue();
9321 }
9322
9323
9331 @Override
9332 public int filterCountByG_C_S(long groupId, long categoryId, int status) {
9333 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9334 return countByG_C_S(groupId, categoryId, status);
9335 }
9336
9337 StringBundler query = new StringBundler(4);
9338
9339 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
9340
9341 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9342
9343 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
9344
9345 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9346
9347 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9348 MBThread.class.getName(),
9349 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9350
9351 Session session = null;
9352
9353 try {
9354 session = openSession();
9355
9356 SQLQuery q = session.createSynchronizedSQLQuery(sql);
9357
9358 q.addScalar(COUNT_COLUMN_NAME,
9359 com.liferay.portal.kernel.dao.orm.Type.LONG);
9360
9361 QueryPos qPos = QueryPos.getInstance(q);
9362
9363 qPos.add(groupId);
9364
9365 qPos.add(categoryId);
9366
9367 qPos.add(status);
9368
9369 Long count = (Long)q.uniqueResult();
9370
9371 return count.intValue();
9372 }
9373 catch (Exception e) {
9374 throw processException(e);
9375 }
9376 finally {
9377 closeSession(session);
9378 }
9379 }
9380
9381
9389 @Override
9390 public int filterCountByG_C_S(long groupId, long[] categoryIds, int status) {
9391 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9392 return countByG_C_S(groupId, categoryIds, status);
9393 }
9394
9395 if (categoryIds == null) {
9396 categoryIds = new long[0];
9397 }
9398 else if (categoryIds.length > 1) {
9399 categoryIds = ArrayUtil.unique(categoryIds);
9400
9401 Arrays.sort(categoryIds);
9402 }
9403
9404 StringBundler query = new StringBundler();
9405
9406 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
9407
9408 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9409
9410 if (categoryIds.length > 0) {
9411 query.append(StringPool.OPEN_PARENTHESIS);
9412
9413 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_7);
9414
9415 query.append(StringUtil.merge(categoryIds));
9416
9417 query.append(StringPool.CLOSE_PARENTHESIS);
9418
9419 query.append(StringPool.CLOSE_PARENTHESIS);
9420
9421 query.append(WHERE_AND);
9422 }
9423
9424 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9425
9426 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
9427 query.index() - 1);
9428
9429 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9430 MBThread.class.getName(),
9431 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9432
9433 Session session = null;
9434
9435 try {
9436 session = openSession();
9437
9438 SQLQuery q = session.createSynchronizedSQLQuery(sql);
9439
9440 q.addScalar(COUNT_COLUMN_NAME,
9441 com.liferay.portal.kernel.dao.orm.Type.LONG);
9442
9443 QueryPos qPos = QueryPos.getInstance(q);
9444
9445 qPos.add(groupId);
9446
9447 qPos.add(status);
9448
9449 Long count = (Long)q.uniqueResult();
9450
9451 return count.intValue();
9452 }
9453 catch (Exception e) {
9454 throw processException(e);
9455 }
9456 finally {
9457 closeSession(session);
9458 }
9459 }
9460
9461 private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "mbThread.groupId = ? AND ";
9462 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
9463 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_7 = "mbThread.categoryId IN (";
9464 private static final String _FINDER_COLUMN_G_C_S_STATUS_2 = "mbThread.status = ?";
9465 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_NOTS = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
9466 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
9467 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_NotS",
9468 new String[] {
9469 Long.class.getName(), Long.class.getName(),
9470 Integer.class.getName(),
9471
9472 Integer.class.getName(), Integer.class.getName(),
9473 OrderByComparator.class.getName()
9474 });
9475 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_NOTS =
9476 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
9477 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
9478 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_C_NotS",
9479 new String[] {
9480 Long.class.getName(), Long.class.getName(),
9481 Integer.class.getName()
9482 });
9483
9484
9492 @Override
9493 public List<MBThread> findByG_C_NotS(long groupId, long categoryId,
9494 int status) {
9495 return findByG_C_NotS(groupId, categoryId, status, QueryUtil.ALL_POS,
9496 QueryUtil.ALL_POS, null);
9497 }
9498
9499
9513 @Override
9514 public List<MBThread> findByG_C_NotS(long groupId, long categoryId,
9515 int status, int start, int end) {
9516 return findByG_C_NotS(groupId, categoryId, status, start, end, null);
9517 }
9518
9519
9534 @Override
9535 public List<MBThread> findByG_C_NotS(long groupId, long categoryId,
9536 int status, int start, int end,
9537 OrderByComparator<MBThread> orderByComparator) {
9538 return findByG_C_NotS(groupId, categoryId, status, start, end,
9539 orderByComparator, true);
9540 }
9541
9542
9558 @Override
9559 public List<MBThread> findByG_C_NotS(long groupId, long categoryId,
9560 int status, int start, int end,
9561 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
9562 boolean pagination = true;
9563 FinderPath finderPath = null;
9564 Object[] finderArgs = null;
9565
9566 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_NOTS;
9567 finderArgs = new Object[] {
9568 groupId, categoryId, status,
9569
9570 start, end, orderByComparator
9571 };
9572
9573 List<MBThread> list = null;
9574
9575 if (retrieveFromCache) {
9576 list = (List<MBThread>)finderCache.getResult(finderPath,
9577 finderArgs, this);
9578
9579 if ((list != null) && !list.isEmpty()) {
9580 for (MBThread mbThread : list) {
9581 if ((groupId != mbThread.getGroupId()) ||
9582 (categoryId != mbThread.getCategoryId()) ||
9583 (status == mbThread.getStatus())) {
9584 list = null;
9585
9586 break;
9587 }
9588 }
9589 }
9590 }
9591
9592 if (list == null) {
9593 StringBundler query = null;
9594
9595 if (orderByComparator != null) {
9596 query = new StringBundler(5 +
9597 (orderByComparator.getOrderByFields().length * 3));
9598 }
9599 else {
9600 query = new StringBundler(5);
9601 }
9602
9603 query.append(_SQL_SELECT_MBTHREAD_WHERE);
9604
9605 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
9606
9607 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
9608
9609 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
9610
9611 if (orderByComparator != null) {
9612 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9613 orderByComparator);
9614 }
9615 else
9616 if (pagination) {
9617 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
9618 }
9619
9620 String sql = query.toString();
9621
9622 Session session = null;
9623
9624 try {
9625 session = openSession();
9626
9627 Query q = session.createQuery(sql);
9628
9629 QueryPos qPos = QueryPos.getInstance(q);
9630
9631 qPos.add(groupId);
9632
9633 qPos.add(categoryId);
9634
9635 qPos.add(status);
9636
9637 if (!pagination) {
9638 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
9639 start, end, false);
9640
9641 Collections.sort(list);
9642
9643 list = Collections.unmodifiableList(list);
9644 }
9645 else {
9646 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
9647 start, end);
9648 }
9649
9650 cacheResult(list);
9651
9652 finderCache.putResult(finderPath, finderArgs, list);
9653 }
9654 catch (Exception e) {
9655 finderCache.removeResult(finderPath, finderArgs);
9656
9657 throw processException(e);
9658 }
9659 finally {
9660 closeSession(session);
9661 }
9662 }
9663
9664 return list;
9665 }
9666
9667
9677 @Override
9678 public MBThread findByG_C_NotS_First(long groupId, long categoryId,
9679 int status, OrderByComparator<MBThread> orderByComparator)
9680 throws NoSuchThreadException {
9681 MBThread mbThread = fetchByG_C_NotS_First(groupId, categoryId, status,
9682 orderByComparator);
9683
9684 if (mbThread != null) {
9685 return mbThread;
9686 }
9687
9688 StringBundler msg = new StringBundler(8);
9689
9690 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9691
9692 msg.append("groupId=");
9693 msg.append(groupId);
9694
9695 msg.append(", categoryId=");
9696 msg.append(categoryId);
9697
9698 msg.append(", status=");
9699 msg.append(status);
9700
9701 msg.append(StringPool.CLOSE_CURLY_BRACE);
9702
9703 throw new NoSuchThreadException(msg.toString());
9704 }
9705
9706
9715 @Override
9716 public MBThread fetchByG_C_NotS_First(long groupId, long categoryId,
9717 int status, OrderByComparator<MBThread> orderByComparator) {
9718 List<MBThread> list = findByG_C_NotS(groupId, categoryId, status, 0, 1,
9719 orderByComparator);
9720
9721 if (!list.isEmpty()) {
9722 return list.get(0);
9723 }
9724
9725 return null;
9726 }
9727
9728
9738 @Override
9739 public MBThread findByG_C_NotS_Last(long groupId, long categoryId,
9740 int status, OrderByComparator<MBThread> orderByComparator)
9741 throws NoSuchThreadException {
9742 MBThread mbThread = fetchByG_C_NotS_Last(groupId, categoryId, status,
9743 orderByComparator);
9744
9745 if (mbThread != null) {
9746 return mbThread;
9747 }
9748
9749 StringBundler msg = new StringBundler(8);
9750
9751 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9752
9753 msg.append("groupId=");
9754 msg.append(groupId);
9755
9756 msg.append(", categoryId=");
9757 msg.append(categoryId);
9758
9759 msg.append(", status=");
9760 msg.append(status);
9761
9762 msg.append(StringPool.CLOSE_CURLY_BRACE);
9763
9764 throw new NoSuchThreadException(msg.toString());
9765 }
9766
9767
9776 @Override
9777 public MBThread fetchByG_C_NotS_Last(long groupId, long categoryId,
9778 int status, OrderByComparator<MBThread> orderByComparator) {
9779 int count = countByG_C_NotS(groupId, categoryId, status);
9780
9781 if (count == 0) {
9782 return null;
9783 }
9784
9785 List<MBThread> list = findByG_C_NotS(groupId, categoryId, status,
9786 count - 1, count, orderByComparator);
9787
9788 if (!list.isEmpty()) {
9789 return list.get(0);
9790 }
9791
9792 return null;
9793 }
9794
9795
9806 @Override
9807 public MBThread[] findByG_C_NotS_PrevAndNext(long threadId, long groupId,
9808 long categoryId, int status,
9809 OrderByComparator<MBThread> orderByComparator)
9810 throws NoSuchThreadException {
9811 MBThread mbThread = findByPrimaryKey(threadId);
9812
9813 Session session = null;
9814
9815 try {
9816 session = openSession();
9817
9818 MBThread[] array = new MBThreadImpl[3];
9819
9820 array[0] = getByG_C_NotS_PrevAndNext(session, mbThread, groupId,
9821 categoryId, status, orderByComparator, true);
9822
9823 array[1] = mbThread;
9824
9825 array[2] = getByG_C_NotS_PrevAndNext(session, mbThread, groupId,
9826 categoryId, status, orderByComparator, false);
9827
9828 return array;
9829 }
9830 catch (Exception e) {
9831 throw processException(e);
9832 }
9833 finally {
9834 closeSession(session);
9835 }
9836 }
9837
9838 protected MBThread getByG_C_NotS_PrevAndNext(Session session,
9839 MBThread mbThread, long groupId, long categoryId, int status,
9840 OrderByComparator<MBThread> orderByComparator, boolean previous) {
9841 StringBundler query = null;
9842
9843 if (orderByComparator != null) {
9844 query = new StringBundler(6 +
9845 (orderByComparator.getOrderByFields().length * 6));
9846 }
9847 else {
9848 query = new StringBundler(3);
9849 }
9850
9851 query.append(_SQL_SELECT_MBTHREAD_WHERE);
9852
9853 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
9854
9855 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
9856
9857 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
9858
9859 if (orderByComparator != null) {
9860 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9861
9862 if (orderByConditionFields.length > 0) {
9863 query.append(WHERE_AND);
9864 }
9865
9866 for (int i = 0; i < orderByConditionFields.length; i++) {
9867 query.append(_ORDER_BY_ENTITY_ALIAS);
9868 query.append(orderByConditionFields[i]);
9869
9870 if ((i + 1) < orderByConditionFields.length) {
9871 if (orderByComparator.isAscending() ^ previous) {
9872 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9873 }
9874 else {
9875 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9876 }
9877 }
9878 else {
9879 if (orderByComparator.isAscending() ^ previous) {
9880 query.append(WHERE_GREATER_THAN);
9881 }
9882 else {
9883 query.append(WHERE_LESSER_THAN);
9884 }
9885 }
9886 }
9887
9888 query.append(ORDER_BY_CLAUSE);
9889
9890 String[] orderByFields = orderByComparator.getOrderByFields();
9891
9892 for (int i = 0; i < orderByFields.length; i++) {
9893 query.append(_ORDER_BY_ENTITY_ALIAS);
9894 query.append(orderByFields[i]);
9895
9896 if ((i + 1) < orderByFields.length) {
9897 if (orderByComparator.isAscending() ^ previous) {
9898 query.append(ORDER_BY_ASC_HAS_NEXT);
9899 }
9900 else {
9901 query.append(ORDER_BY_DESC_HAS_NEXT);
9902 }
9903 }
9904 else {
9905 if (orderByComparator.isAscending() ^ previous) {
9906 query.append(ORDER_BY_ASC);
9907 }
9908 else {
9909 query.append(ORDER_BY_DESC);
9910 }
9911 }
9912 }
9913 }
9914 else {
9915 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
9916 }
9917
9918 String sql = query.toString();
9919
9920 Query q = session.createQuery(sql);
9921
9922 q.setFirstResult(0);
9923 q.setMaxResults(2);
9924
9925 QueryPos qPos = QueryPos.getInstance(q);
9926
9927 qPos.add(groupId);
9928
9929 qPos.add(categoryId);
9930
9931 qPos.add(status);
9932
9933 if (orderByComparator != null) {
9934 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
9935
9936 for (Object value : values) {
9937 qPos.add(value);
9938 }
9939 }
9940
9941 List<MBThread> list = q.list();
9942
9943 if (list.size() == 2) {
9944 return list.get(1);
9945 }
9946 else {
9947 return null;
9948 }
9949 }
9950
9951
9959 @Override
9960 public List<MBThread> filterFindByG_C_NotS(long groupId, long categoryId,
9961 int status) {
9962 return filterFindByG_C_NotS(groupId, categoryId, status,
9963 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9964 }
9965
9966
9980 @Override
9981 public List<MBThread> filterFindByG_C_NotS(long groupId, long categoryId,
9982 int status, int start, int end) {
9983 return filterFindByG_C_NotS(groupId, categoryId, status, start, end,
9984 null);
9985 }
9986
9987
10002 @Override
10003 public List<MBThread> filterFindByG_C_NotS(long groupId, long categoryId,
10004 int status, int start, int end,
10005 OrderByComparator<MBThread> orderByComparator) {
10006 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10007 return findByG_C_NotS(groupId, categoryId, status, start, end,
10008 orderByComparator);
10009 }
10010
10011 StringBundler query = null;
10012
10013 if (orderByComparator != null) {
10014 query = new StringBundler(5 +
10015 (orderByComparator.getOrderByFields().length * 3));
10016 }
10017 else {
10018 query = new StringBundler(5);
10019 }
10020
10021 if (getDB().isSupportsInlineDistinct()) {
10022 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
10023 }
10024 else {
10025 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
10026 }
10027
10028 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10029
10030 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
10031
10032 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10033
10034 if (!getDB().isSupportsInlineDistinct()) {
10035 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
10036 }
10037
10038 if (orderByComparator != null) {
10039 if (getDB().isSupportsInlineDistinct()) {
10040 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10041 orderByComparator, true);
10042 }
10043 else {
10044 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10045 orderByComparator, true);
10046 }
10047 }
10048 else {
10049 if (getDB().isSupportsInlineDistinct()) {
10050 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
10051 }
10052 else {
10053 query.append(MBThreadModelImpl.ORDER_BY_SQL);
10054 }
10055 }
10056
10057 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10058 MBThread.class.getName(),
10059 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10060
10061 Session session = null;
10062
10063 try {
10064 session = openSession();
10065
10066 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10067
10068 if (getDB().isSupportsInlineDistinct()) {
10069 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
10070 }
10071 else {
10072 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
10073 }
10074
10075 QueryPos qPos = QueryPos.getInstance(q);
10076
10077 qPos.add(groupId);
10078
10079 qPos.add(categoryId);
10080
10081 qPos.add(status);
10082
10083 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
10084 }
10085 catch (Exception e) {
10086 throw processException(e);
10087 }
10088 finally {
10089 closeSession(session);
10090 }
10091 }
10092
10093
10104 @Override
10105 public MBThread[] filterFindByG_C_NotS_PrevAndNext(long threadId,
10106 long groupId, long categoryId, int status,
10107 OrderByComparator<MBThread> orderByComparator)
10108 throws NoSuchThreadException {
10109 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10110 return findByG_C_NotS_PrevAndNext(threadId, groupId, categoryId,
10111 status, orderByComparator);
10112 }
10113
10114 MBThread mbThread = findByPrimaryKey(threadId);
10115
10116 Session session = null;
10117
10118 try {
10119 session = openSession();
10120
10121 MBThread[] array = new MBThreadImpl[3];
10122
10123 array[0] = filterGetByG_C_NotS_PrevAndNext(session, mbThread,
10124 groupId, categoryId, status, orderByComparator, true);
10125
10126 array[1] = mbThread;
10127
10128 array[2] = filterGetByG_C_NotS_PrevAndNext(session, mbThread,
10129 groupId, categoryId, status, orderByComparator, false);
10130
10131 return array;
10132 }
10133 catch (Exception e) {
10134 throw processException(e);
10135 }
10136 finally {
10137 closeSession(session);
10138 }
10139 }
10140
10141 protected MBThread filterGetByG_C_NotS_PrevAndNext(Session session,
10142 MBThread mbThread, long groupId, long categoryId, int status,
10143 OrderByComparator<MBThread> orderByComparator, boolean previous) {
10144 StringBundler query = null;
10145
10146 if (orderByComparator != null) {
10147 query = new StringBundler(6 +
10148 (orderByComparator.getOrderByFields().length * 6));
10149 }
10150 else {
10151 query = new StringBundler(3);
10152 }
10153
10154 if (getDB().isSupportsInlineDistinct()) {
10155 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
10156 }
10157 else {
10158 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
10159 }
10160
10161 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10162
10163 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
10164
10165 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10166
10167 if (!getDB().isSupportsInlineDistinct()) {
10168 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
10169 }
10170
10171 if (orderByComparator != null) {
10172 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10173
10174 if (orderByConditionFields.length > 0) {
10175 query.append(WHERE_AND);
10176 }
10177
10178 for (int i = 0; i < orderByConditionFields.length; i++) {
10179 if (getDB().isSupportsInlineDistinct()) {
10180 query.append(_ORDER_BY_ENTITY_ALIAS);
10181 }
10182 else {
10183 query.append(_ORDER_BY_ENTITY_TABLE);
10184 }
10185
10186 query.append(orderByConditionFields[i]);
10187
10188 if ((i + 1) < orderByConditionFields.length) {
10189 if (orderByComparator.isAscending() ^ previous) {
10190 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10191 }
10192 else {
10193 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10194 }
10195 }
10196 else {
10197 if (orderByComparator.isAscending() ^ previous) {
10198 query.append(WHERE_GREATER_THAN);
10199 }
10200 else {
10201 query.append(WHERE_LESSER_THAN);
10202 }
10203 }
10204 }
10205
10206 query.append(ORDER_BY_CLAUSE);
10207
10208 String[] orderByFields = orderByComparator.getOrderByFields();
10209
10210 for (int i = 0; i < orderByFields.length; i++) {
10211 if (getDB().isSupportsInlineDistinct()) {
10212 query.append(_ORDER_BY_ENTITY_ALIAS);
10213 }
10214 else {
10215 query.append(_ORDER_BY_ENTITY_TABLE);
10216 }
10217
10218 query.append(orderByFields[i]);
10219
10220 if ((i + 1) < orderByFields.length) {
10221 if (orderByComparator.isAscending() ^ previous) {
10222 query.append(ORDER_BY_ASC_HAS_NEXT);
10223 }
10224 else {
10225 query.append(ORDER_BY_DESC_HAS_NEXT);
10226 }
10227 }
10228 else {
10229 if (orderByComparator.isAscending() ^ previous) {
10230 query.append(ORDER_BY_ASC);
10231 }
10232 else {
10233 query.append(ORDER_BY_DESC);
10234 }
10235 }
10236 }
10237 }
10238 else {
10239 if (getDB().isSupportsInlineDistinct()) {
10240 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
10241 }
10242 else {
10243 query.append(MBThreadModelImpl.ORDER_BY_SQL);
10244 }
10245 }
10246
10247 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10248 MBThread.class.getName(),
10249 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10250
10251 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10252
10253 q.setFirstResult(0);
10254 q.setMaxResults(2);
10255
10256 if (getDB().isSupportsInlineDistinct()) {
10257 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
10258 }
10259 else {
10260 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
10261 }
10262
10263 QueryPos qPos = QueryPos.getInstance(q);
10264
10265 qPos.add(groupId);
10266
10267 qPos.add(categoryId);
10268
10269 qPos.add(status);
10270
10271 if (orderByComparator != null) {
10272 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
10273
10274 for (Object value : values) {
10275 qPos.add(value);
10276 }
10277 }
10278
10279 List<MBThread> list = q.list();
10280
10281 if (list.size() == 2) {
10282 return list.get(1);
10283 }
10284 else {
10285 return null;
10286 }
10287 }
10288
10289
10297 @Override
10298 public List<MBThread> filterFindByG_C_NotS(long groupId,
10299 long[] categoryIds, int status) {
10300 return filterFindByG_C_NotS(groupId, categoryIds, status,
10301 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10302 }
10303
10304
10318 @Override
10319 public List<MBThread> filterFindByG_C_NotS(long groupId,
10320 long[] categoryIds, int status, int start, int end) {
10321 return filterFindByG_C_NotS(groupId, categoryIds, status, start, end,
10322 null);
10323 }
10324
10325
10340 @Override
10341 public List<MBThread> filterFindByG_C_NotS(long groupId,
10342 long[] categoryIds, int status, int start, int end,
10343 OrderByComparator<MBThread> orderByComparator) {
10344 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10345 return findByG_C_NotS(groupId, categoryIds, status, start, end,
10346 orderByComparator);
10347 }
10348
10349 if (categoryIds == null) {
10350 categoryIds = new long[0];
10351 }
10352 else if (categoryIds.length > 1) {
10353 categoryIds = ArrayUtil.unique(categoryIds);
10354
10355 Arrays.sort(categoryIds);
10356 }
10357
10358 StringBundler query = new StringBundler();
10359
10360 if (getDB().isSupportsInlineDistinct()) {
10361 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
10362 }
10363 else {
10364 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
10365 }
10366
10367 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10368
10369 if (categoryIds.length > 0) {
10370 query.append(StringPool.OPEN_PARENTHESIS);
10371
10372 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_7);
10373
10374 query.append(StringUtil.merge(categoryIds));
10375
10376 query.append(StringPool.CLOSE_PARENTHESIS);
10377
10378 query.append(StringPool.CLOSE_PARENTHESIS);
10379
10380 query.append(WHERE_AND);
10381 }
10382
10383 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10384
10385 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
10386 query.index() - 1);
10387
10388 if (!getDB().isSupportsInlineDistinct()) {
10389 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
10390 }
10391
10392 if (orderByComparator != null) {
10393 if (getDB().isSupportsInlineDistinct()) {
10394 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10395 orderByComparator, true);
10396 }
10397 else {
10398 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10399 orderByComparator, true);
10400 }
10401 }
10402 else {
10403 if (getDB().isSupportsInlineDistinct()) {
10404 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
10405 }
10406 else {
10407 query.append(MBThreadModelImpl.ORDER_BY_SQL);
10408 }
10409 }
10410
10411 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10412 MBThread.class.getName(),
10413 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10414
10415 Session session = null;
10416
10417 try {
10418 session = openSession();
10419
10420 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10421
10422 if (getDB().isSupportsInlineDistinct()) {
10423 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
10424 }
10425 else {
10426 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
10427 }
10428
10429 QueryPos qPos = QueryPos.getInstance(q);
10430
10431 qPos.add(groupId);
10432
10433 qPos.add(status);
10434
10435 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
10436 }
10437 catch (Exception e) {
10438 throw processException(e);
10439 }
10440 finally {
10441 closeSession(session);
10442 }
10443 }
10444
10445
10457 @Override
10458 public List<MBThread> findByG_C_NotS(long groupId, long[] categoryIds,
10459 int status) {
10460 return findByG_C_NotS(groupId, categoryIds, status, QueryUtil.ALL_POS,
10461 QueryUtil.ALL_POS, null);
10462 }
10463
10464
10478 @Override
10479 public List<MBThread> findByG_C_NotS(long groupId, long[] categoryIds,
10480 int status, int start, int end) {
10481 return findByG_C_NotS(groupId, categoryIds, status, start, end, null);
10482 }
10483
10484
10499 @Override
10500 public List<MBThread> findByG_C_NotS(long groupId, long[] categoryIds,
10501 int status, int start, int end,
10502 OrderByComparator<MBThread> orderByComparator) {
10503 return findByG_C_NotS(groupId, categoryIds, status, start, end,
10504 orderByComparator, true);
10505 }
10506
10507
10523 @Override
10524 public List<MBThread> findByG_C_NotS(long groupId, long[] categoryIds,
10525 int status, int start, int end,
10526 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
10527 if (categoryIds == null) {
10528 categoryIds = new long[0];
10529 }
10530 else if (categoryIds.length > 1) {
10531 categoryIds = ArrayUtil.unique(categoryIds);
10532
10533 Arrays.sort(categoryIds);
10534 }
10535
10536 if (categoryIds.length == 1) {
10537 return findByG_C_NotS(groupId, categoryIds[0], status, start, end,
10538 orderByComparator);
10539 }
10540
10541 boolean pagination = true;
10542 Object[] finderArgs = null;
10543
10544 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10545 (orderByComparator == null)) {
10546 pagination = false;
10547 finderArgs = new Object[] {
10548 groupId, StringUtil.merge(categoryIds), status
10549 };
10550 }
10551 else {
10552 finderArgs = new Object[] {
10553 groupId, StringUtil.merge(categoryIds), status,
10554
10555 start, end, orderByComparator
10556 };
10557 }
10558
10559 List<MBThread> list = null;
10560
10561 if (retrieveFromCache) {
10562 list = (List<MBThread>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_NOTS,
10563 finderArgs, this);
10564
10565 if ((list != null) && !list.isEmpty()) {
10566 for (MBThread mbThread : list) {
10567 if ((groupId != mbThread.getGroupId()) ||
10568 !ArrayUtil.contains(categoryIds,
10569 mbThread.getCategoryId()) ||
10570 (status == mbThread.getStatus())) {
10571 list = null;
10572
10573 break;
10574 }
10575 }
10576 }
10577 }
10578
10579 if (list == null) {
10580 StringBundler query = new StringBundler();
10581
10582 query.append(_SQL_SELECT_MBTHREAD_WHERE);
10583
10584 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10585
10586 if (categoryIds.length > 0) {
10587 query.append(StringPool.OPEN_PARENTHESIS);
10588
10589 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_7);
10590
10591 query.append(StringUtil.merge(categoryIds));
10592
10593 query.append(StringPool.CLOSE_PARENTHESIS);
10594
10595 query.append(StringPool.CLOSE_PARENTHESIS);
10596
10597 query.append(WHERE_AND);
10598 }
10599
10600 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10601
10602 query.setStringAt(removeConjunction(query.stringAt(query.index() -
10603 1)), query.index() - 1);
10604
10605 if (orderByComparator != null) {
10606 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10607 orderByComparator);
10608 }
10609 else
10610 if (pagination) {
10611 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
10612 }
10613
10614 String sql = query.toString();
10615
10616 Session session = null;
10617
10618 try {
10619 session = openSession();
10620
10621 Query q = session.createQuery(sql);
10622
10623 QueryPos qPos = QueryPos.getInstance(q);
10624
10625 qPos.add(groupId);
10626
10627 qPos.add(status);
10628
10629 if (!pagination) {
10630 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
10631 start, end, false);
10632
10633 Collections.sort(list);
10634
10635 list = Collections.unmodifiableList(list);
10636 }
10637 else {
10638 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
10639 start, end);
10640 }
10641
10642 cacheResult(list);
10643
10644 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_NOTS,
10645 finderArgs, list);
10646 }
10647 catch (Exception e) {
10648 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_NOTS,
10649 finderArgs);
10650
10651 throw processException(e);
10652 }
10653 finally {
10654 closeSession(session);
10655 }
10656 }
10657
10658 return list;
10659 }
10660
10661
10668 @Override
10669 public void removeByG_C_NotS(long groupId, long categoryId, int status) {
10670 for (MBThread mbThread : findByG_C_NotS(groupId, categoryId, status,
10671 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10672 remove(mbThread);
10673 }
10674 }
10675
10676
10684 @Override
10685 public int countByG_C_NotS(long groupId, long categoryId, int status) {
10686 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_NOTS;
10687
10688 Object[] finderArgs = new Object[] { groupId, categoryId, status };
10689
10690 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10691
10692 if (count == null) {
10693 StringBundler query = new StringBundler(4);
10694
10695 query.append(_SQL_COUNT_MBTHREAD_WHERE);
10696
10697 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10698
10699 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
10700
10701 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10702
10703 String sql = query.toString();
10704
10705 Session session = null;
10706
10707 try {
10708 session = openSession();
10709
10710 Query q = session.createQuery(sql);
10711
10712 QueryPos qPos = QueryPos.getInstance(q);
10713
10714 qPos.add(groupId);
10715
10716 qPos.add(categoryId);
10717
10718 qPos.add(status);
10719
10720 count = (Long)q.uniqueResult();
10721
10722 finderCache.putResult(finderPath, finderArgs, count);
10723 }
10724 catch (Exception e) {
10725 finderCache.removeResult(finderPath, finderArgs);
10726
10727 throw processException(e);
10728 }
10729 finally {
10730 closeSession(session);
10731 }
10732 }
10733
10734 return count.intValue();
10735 }
10736
10737
10745 @Override
10746 public int countByG_C_NotS(long groupId, long[] categoryIds, int status) {
10747 if (categoryIds == null) {
10748 categoryIds = new long[0];
10749 }
10750 else if (categoryIds.length > 1) {
10751 categoryIds = ArrayUtil.unique(categoryIds);
10752
10753 Arrays.sort(categoryIds);
10754 }
10755
10756 Object[] finderArgs = new Object[] {
10757 groupId, StringUtil.merge(categoryIds), status
10758 };
10759
10760 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_NOTS,
10761 finderArgs, this);
10762
10763 if (count == null) {
10764 StringBundler query = new StringBundler();
10765
10766 query.append(_SQL_COUNT_MBTHREAD_WHERE);
10767
10768 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10769
10770 if (categoryIds.length > 0) {
10771 query.append(StringPool.OPEN_PARENTHESIS);
10772
10773 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_7);
10774
10775 query.append(StringUtil.merge(categoryIds));
10776
10777 query.append(StringPool.CLOSE_PARENTHESIS);
10778
10779 query.append(StringPool.CLOSE_PARENTHESIS);
10780
10781 query.append(WHERE_AND);
10782 }
10783
10784 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10785
10786 query.setStringAt(removeConjunction(query.stringAt(query.index() -
10787 1)), query.index() - 1);
10788
10789 String sql = query.toString();
10790
10791 Session session = null;
10792
10793 try {
10794 session = openSession();
10795
10796 Query q = session.createQuery(sql);
10797
10798 QueryPos qPos = QueryPos.getInstance(q);
10799
10800 qPos.add(groupId);
10801
10802 qPos.add(status);
10803
10804 count = (Long)q.uniqueResult();
10805
10806 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_NOTS,
10807 finderArgs, count);
10808 }
10809 catch (Exception e) {
10810 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_NOTS,
10811 finderArgs);
10812
10813 throw processException(e);
10814 }
10815 finally {
10816 closeSession(session);
10817 }
10818 }
10819
10820 return count.intValue();
10821 }
10822
10823
10831 @Override
10832 public int filterCountByG_C_NotS(long groupId, long categoryId, int status) {
10833 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10834 return countByG_C_NotS(groupId, categoryId, status);
10835 }
10836
10837 StringBundler query = new StringBundler(4);
10838
10839 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
10840
10841 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10842
10843 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_2);
10844
10845 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10846
10847 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10848 MBThread.class.getName(),
10849 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10850
10851 Session session = null;
10852
10853 try {
10854 session = openSession();
10855
10856 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10857
10858 q.addScalar(COUNT_COLUMN_NAME,
10859 com.liferay.portal.kernel.dao.orm.Type.LONG);
10860
10861 QueryPos qPos = QueryPos.getInstance(q);
10862
10863 qPos.add(groupId);
10864
10865 qPos.add(categoryId);
10866
10867 qPos.add(status);
10868
10869 Long count = (Long)q.uniqueResult();
10870
10871 return count.intValue();
10872 }
10873 catch (Exception e) {
10874 throw processException(e);
10875 }
10876 finally {
10877 closeSession(session);
10878 }
10879 }
10880
10881
10889 @Override
10890 public int filterCountByG_C_NotS(long groupId, long[] categoryIds,
10891 int status) {
10892 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10893 return countByG_C_NotS(groupId, categoryIds, status);
10894 }
10895
10896 if (categoryIds == null) {
10897 categoryIds = new long[0];
10898 }
10899 else if (categoryIds.length > 1) {
10900 categoryIds = ArrayUtil.unique(categoryIds);
10901
10902 Arrays.sort(categoryIds);
10903 }
10904
10905 StringBundler query = new StringBundler();
10906
10907 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
10908
10909 query.append(_FINDER_COLUMN_G_C_NOTS_GROUPID_2);
10910
10911 if (categoryIds.length > 0) {
10912 query.append(StringPool.OPEN_PARENTHESIS);
10913
10914 query.append(_FINDER_COLUMN_G_C_NOTS_CATEGORYID_7);
10915
10916 query.append(StringUtil.merge(categoryIds));
10917
10918 query.append(StringPool.CLOSE_PARENTHESIS);
10919
10920 query.append(StringPool.CLOSE_PARENTHESIS);
10921
10922 query.append(WHERE_AND);
10923 }
10924
10925 query.append(_FINDER_COLUMN_G_C_NOTS_STATUS_2);
10926
10927 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
10928 query.index() - 1);
10929
10930 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10931 MBThread.class.getName(),
10932 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10933
10934 Session session = null;
10935
10936 try {
10937 session = openSession();
10938
10939 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10940
10941 q.addScalar(COUNT_COLUMN_NAME,
10942 com.liferay.portal.kernel.dao.orm.Type.LONG);
10943
10944 QueryPos qPos = QueryPos.getInstance(q);
10945
10946 qPos.add(groupId);
10947
10948 qPos.add(status);
10949
10950 Long count = (Long)q.uniqueResult();
10951
10952 return count.intValue();
10953 }
10954 catch (Exception e) {
10955 throw processException(e);
10956 }
10957 finally {
10958 closeSession(session);
10959 }
10960 }
10961
10962 private static final String _FINDER_COLUMN_G_C_NOTS_GROUPID_2 = "mbThread.groupId = ? AND ";
10963 private static final String _FINDER_COLUMN_G_C_NOTS_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
10964 private static final String _FINDER_COLUMN_G_C_NOTS_CATEGORYID_7 = "mbThread.categoryId IN (";
10965 private static final String _FINDER_COLUMN_G_C_NOTS_STATUS_2 = "mbThread.status != ?";
10966 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
10967 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
10968 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotC_S",
10969 new String[] {
10970 Long.class.getName(), Long.class.getName(),
10971 Integer.class.getName(),
10972
10973 Integer.class.getName(), Integer.class.getName(),
10974 OrderByComparator.class.getName()
10975 });
10976 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_S =
10977 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
10978 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
10979 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotC_S",
10980 new String[] {
10981 Long.class.getName(), Long.class.getName(),
10982 Integer.class.getName()
10983 });
10984
10985
10993 @Override
10994 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
10995 int status) {
10996 return findByG_NotC_S(groupId, categoryId, status, QueryUtil.ALL_POS,
10997 QueryUtil.ALL_POS, null);
10998 }
10999
11000
11014 @Override
11015 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
11016 int status, int start, int end) {
11017 return findByG_NotC_S(groupId, categoryId, status, start, end, null);
11018 }
11019
11020
11035 @Override
11036 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
11037 int status, int start, int end,
11038 OrderByComparator<MBThread> orderByComparator) {
11039 return findByG_NotC_S(groupId, categoryId, status, start, end,
11040 orderByComparator, true);
11041 }
11042
11043
11059 @Override
11060 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
11061 int status, int start, int end,
11062 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
11063 boolean pagination = true;
11064 FinderPath finderPath = null;
11065 Object[] finderArgs = null;
11066
11067 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_S;
11068 finderArgs = new Object[] {
11069 groupId, categoryId, status,
11070
11071 start, end, orderByComparator
11072 };
11073
11074 List<MBThread> list = null;
11075
11076 if (retrieveFromCache) {
11077 list = (List<MBThread>)finderCache.getResult(finderPath,
11078 finderArgs, this);
11079
11080 if ((list != null) && !list.isEmpty()) {
11081 for (MBThread mbThread : list) {
11082 if ((groupId != mbThread.getGroupId()) ||
11083 (categoryId == mbThread.getCategoryId()) ||
11084 (status != mbThread.getStatus())) {
11085 list = null;
11086
11087 break;
11088 }
11089 }
11090 }
11091 }
11092
11093 if (list == null) {
11094 StringBundler query = null;
11095
11096 if (orderByComparator != null) {
11097 query = new StringBundler(5 +
11098 (orderByComparator.getOrderByFields().length * 3));
11099 }
11100 else {
11101 query = new StringBundler(5);
11102 }
11103
11104 query.append(_SQL_SELECT_MBTHREAD_WHERE);
11105
11106 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11107
11108 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11109
11110 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11111
11112 if (orderByComparator != null) {
11113 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11114 orderByComparator);
11115 }
11116 else
11117 if (pagination) {
11118 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
11119 }
11120
11121 String sql = query.toString();
11122
11123 Session session = null;
11124
11125 try {
11126 session = openSession();
11127
11128 Query q = session.createQuery(sql);
11129
11130 QueryPos qPos = QueryPos.getInstance(q);
11131
11132 qPos.add(groupId);
11133
11134 qPos.add(categoryId);
11135
11136 qPos.add(status);
11137
11138 if (!pagination) {
11139 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
11140 start, end, false);
11141
11142 Collections.sort(list);
11143
11144 list = Collections.unmodifiableList(list);
11145 }
11146 else {
11147 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
11148 start, end);
11149 }
11150
11151 cacheResult(list);
11152
11153 finderCache.putResult(finderPath, finderArgs, list);
11154 }
11155 catch (Exception e) {
11156 finderCache.removeResult(finderPath, finderArgs);
11157
11158 throw processException(e);
11159 }
11160 finally {
11161 closeSession(session);
11162 }
11163 }
11164
11165 return list;
11166 }
11167
11168
11178 @Override
11179 public MBThread findByG_NotC_S_First(long groupId, long categoryId,
11180 int status, OrderByComparator<MBThread> orderByComparator)
11181 throws NoSuchThreadException {
11182 MBThread mbThread = fetchByG_NotC_S_First(groupId, categoryId, status,
11183 orderByComparator);
11184
11185 if (mbThread != null) {
11186 return mbThread;
11187 }
11188
11189 StringBundler msg = new StringBundler(8);
11190
11191 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11192
11193 msg.append("groupId=");
11194 msg.append(groupId);
11195
11196 msg.append(", categoryId=");
11197 msg.append(categoryId);
11198
11199 msg.append(", status=");
11200 msg.append(status);
11201
11202 msg.append(StringPool.CLOSE_CURLY_BRACE);
11203
11204 throw new NoSuchThreadException(msg.toString());
11205 }
11206
11207
11216 @Override
11217 public MBThread fetchByG_NotC_S_First(long groupId, long categoryId,
11218 int status, OrderByComparator<MBThread> orderByComparator) {
11219 List<MBThread> list = findByG_NotC_S(groupId, categoryId, status, 0, 1,
11220 orderByComparator);
11221
11222 if (!list.isEmpty()) {
11223 return list.get(0);
11224 }
11225
11226 return null;
11227 }
11228
11229
11239 @Override
11240 public MBThread findByG_NotC_S_Last(long groupId, long categoryId,
11241 int status, OrderByComparator<MBThread> orderByComparator)
11242 throws NoSuchThreadException {
11243 MBThread mbThread = fetchByG_NotC_S_Last(groupId, categoryId, status,
11244 orderByComparator);
11245
11246 if (mbThread != null) {
11247 return mbThread;
11248 }
11249
11250 StringBundler msg = new StringBundler(8);
11251
11252 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11253
11254 msg.append("groupId=");
11255 msg.append(groupId);
11256
11257 msg.append(", categoryId=");
11258 msg.append(categoryId);
11259
11260 msg.append(", status=");
11261 msg.append(status);
11262
11263 msg.append(StringPool.CLOSE_CURLY_BRACE);
11264
11265 throw new NoSuchThreadException(msg.toString());
11266 }
11267
11268
11277 @Override
11278 public MBThread fetchByG_NotC_S_Last(long groupId, long categoryId,
11279 int status, OrderByComparator<MBThread> orderByComparator) {
11280 int count = countByG_NotC_S(groupId, categoryId, status);
11281
11282 if (count == 0) {
11283 return null;
11284 }
11285
11286 List<MBThread> list = findByG_NotC_S(groupId, categoryId, status,
11287 count - 1, count, orderByComparator);
11288
11289 if (!list.isEmpty()) {
11290 return list.get(0);
11291 }
11292
11293 return null;
11294 }
11295
11296
11307 @Override
11308 public MBThread[] findByG_NotC_S_PrevAndNext(long threadId, long groupId,
11309 long categoryId, int status,
11310 OrderByComparator<MBThread> orderByComparator)
11311 throws NoSuchThreadException {
11312 MBThread mbThread = findByPrimaryKey(threadId);
11313
11314 Session session = null;
11315
11316 try {
11317 session = openSession();
11318
11319 MBThread[] array = new MBThreadImpl[3];
11320
11321 array[0] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId,
11322 categoryId, status, orderByComparator, true);
11323
11324 array[1] = mbThread;
11325
11326 array[2] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId,
11327 categoryId, status, orderByComparator, false);
11328
11329 return array;
11330 }
11331 catch (Exception e) {
11332 throw processException(e);
11333 }
11334 finally {
11335 closeSession(session);
11336 }
11337 }
11338
11339 protected MBThread getByG_NotC_S_PrevAndNext(Session session,
11340 MBThread mbThread, long groupId, long categoryId, int status,
11341 OrderByComparator<MBThread> orderByComparator, boolean previous) {
11342 StringBundler query = null;
11343
11344 if (orderByComparator != null) {
11345 query = new StringBundler(6 +
11346 (orderByComparator.getOrderByFields().length * 6));
11347 }
11348 else {
11349 query = new StringBundler(3);
11350 }
11351
11352 query.append(_SQL_SELECT_MBTHREAD_WHERE);
11353
11354 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11355
11356 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11357
11358 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11359
11360 if (orderByComparator != null) {
11361 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11362
11363 if (orderByConditionFields.length > 0) {
11364 query.append(WHERE_AND);
11365 }
11366
11367 for (int i = 0; i < orderByConditionFields.length; i++) {
11368 query.append(_ORDER_BY_ENTITY_ALIAS);
11369 query.append(orderByConditionFields[i]);
11370
11371 if ((i + 1) < orderByConditionFields.length) {
11372 if (orderByComparator.isAscending() ^ previous) {
11373 query.append(WHERE_GREATER_THAN_HAS_NEXT);
11374 }
11375 else {
11376 query.append(WHERE_LESSER_THAN_HAS_NEXT);
11377 }
11378 }
11379 else {
11380 if (orderByComparator.isAscending() ^ previous) {
11381 query.append(WHERE_GREATER_THAN);
11382 }
11383 else {
11384 query.append(WHERE_LESSER_THAN);
11385 }
11386 }
11387 }
11388
11389 query.append(ORDER_BY_CLAUSE);
11390
11391 String[] orderByFields = orderByComparator.getOrderByFields();
11392
11393 for (int i = 0; i < orderByFields.length; i++) {
11394 query.append(_ORDER_BY_ENTITY_ALIAS);
11395 query.append(orderByFields[i]);
11396
11397 if ((i + 1) < orderByFields.length) {
11398 if (orderByComparator.isAscending() ^ previous) {
11399 query.append(ORDER_BY_ASC_HAS_NEXT);
11400 }
11401 else {
11402 query.append(ORDER_BY_DESC_HAS_NEXT);
11403 }
11404 }
11405 else {
11406 if (orderByComparator.isAscending() ^ previous) {
11407 query.append(ORDER_BY_ASC);
11408 }
11409 else {
11410 query.append(ORDER_BY_DESC);
11411 }
11412 }
11413 }
11414 }
11415 else {
11416 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
11417 }
11418
11419 String sql = query.toString();
11420
11421 Query q = session.createQuery(sql);
11422
11423 q.setFirstResult(0);
11424 q.setMaxResults(2);
11425
11426 QueryPos qPos = QueryPos.getInstance(q);
11427
11428 qPos.add(groupId);
11429
11430 qPos.add(categoryId);
11431
11432 qPos.add(status);
11433
11434 if (orderByComparator != null) {
11435 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
11436
11437 for (Object value : values) {
11438 qPos.add(value);
11439 }
11440 }
11441
11442 List<MBThread> list = q.list();
11443
11444 if (list.size() == 2) {
11445 return list.get(1);
11446 }
11447 else {
11448 return null;
11449 }
11450 }
11451
11452
11460 @Override
11461 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
11462 int status) {
11463 return filterFindByG_NotC_S(groupId, categoryId, status,
11464 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11465 }
11466
11467
11481 @Override
11482 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
11483 int status, int start, int end) {
11484 return filterFindByG_NotC_S(groupId, categoryId, status, start, end,
11485 null);
11486 }
11487
11488
11503 @Override
11504 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
11505 int status, int start, int end,
11506 OrderByComparator<MBThread> orderByComparator) {
11507 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11508 return findByG_NotC_S(groupId, categoryId, status, start, end,
11509 orderByComparator);
11510 }
11511
11512 StringBundler query = null;
11513
11514 if (orderByComparator != null) {
11515 query = new StringBundler(5 +
11516 (orderByComparator.getOrderByFields().length * 3));
11517 }
11518 else {
11519 query = new StringBundler(5);
11520 }
11521
11522 if (getDB().isSupportsInlineDistinct()) {
11523 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
11524 }
11525 else {
11526 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
11527 }
11528
11529 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11530
11531 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11532
11533 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11534
11535 if (!getDB().isSupportsInlineDistinct()) {
11536 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
11537 }
11538
11539 if (orderByComparator != null) {
11540 if (getDB().isSupportsInlineDistinct()) {
11541 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11542 orderByComparator, true);
11543 }
11544 else {
11545 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11546 orderByComparator, true);
11547 }
11548 }
11549 else {
11550 if (getDB().isSupportsInlineDistinct()) {
11551 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
11552 }
11553 else {
11554 query.append(MBThreadModelImpl.ORDER_BY_SQL);
11555 }
11556 }
11557
11558 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11559 MBThread.class.getName(),
11560 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11561
11562 Session session = null;
11563
11564 try {
11565 session = openSession();
11566
11567 SQLQuery q = session.createSynchronizedSQLQuery(sql);
11568
11569 if (getDB().isSupportsInlineDistinct()) {
11570 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
11571 }
11572 else {
11573 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
11574 }
11575
11576 QueryPos qPos = QueryPos.getInstance(q);
11577
11578 qPos.add(groupId);
11579
11580 qPos.add(categoryId);
11581
11582 qPos.add(status);
11583
11584 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
11585 }
11586 catch (Exception e) {
11587 throw processException(e);
11588 }
11589 finally {
11590 closeSession(session);
11591 }
11592 }
11593
11594
11605 @Override
11606 public MBThread[] filterFindByG_NotC_S_PrevAndNext(long threadId,
11607 long groupId, long categoryId, int status,
11608 OrderByComparator<MBThread> orderByComparator)
11609 throws NoSuchThreadException {
11610 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11611 return findByG_NotC_S_PrevAndNext(threadId, groupId, categoryId,
11612 status, orderByComparator);
11613 }
11614
11615 MBThread mbThread = findByPrimaryKey(threadId);
11616
11617 Session session = null;
11618
11619 try {
11620 session = openSession();
11621
11622 MBThread[] array = new MBThreadImpl[3];
11623
11624 array[0] = filterGetByG_NotC_S_PrevAndNext(session, mbThread,
11625 groupId, categoryId, status, orderByComparator, true);
11626
11627 array[1] = mbThread;
11628
11629 array[2] = filterGetByG_NotC_S_PrevAndNext(session, mbThread,
11630 groupId, categoryId, status, orderByComparator, false);
11631
11632 return array;
11633 }
11634 catch (Exception e) {
11635 throw processException(e);
11636 }
11637 finally {
11638 closeSession(session);
11639 }
11640 }
11641
11642 protected MBThread filterGetByG_NotC_S_PrevAndNext(Session session,
11643 MBThread mbThread, long groupId, long categoryId, int status,
11644 OrderByComparator<MBThread> orderByComparator, boolean previous) {
11645 StringBundler query = null;
11646
11647 if (orderByComparator != null) {
11648 query = new StringBundler(6 +
11649 (orderByComparator.getOrderByFields().length * 6));
11650 }
11651 else {
11652 query = new StringBundler(3);
11653 }
11654
11655 if (getDB().isSupportsInlineDistinct()) {
11656 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
11657 }
11658 else {
11659 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
11660 }
11661
11662 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11663
11664 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11665
11666 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11667
11668 if (!getDB().isSupportsInlineDistinct()) {
11669 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
11670 }
11671
11672 if (orderByComparator != null) {
11673 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11674
11675 if (orderByConditionFields.length > 0) {
11676 query.append(WHERE_AND);
11677 }
11678
11679 for (int i = 0; i < orderByConditionFields.length; i++) {
11680 if (getDB().isSupportsInlineDistinct()) {
11681 query.append(_ORDER_BY_ENTITY_ALIAS);
11682 }
11683 else {
11684 query.append(_ORDER_BY_ENTITY_TABLE);
11685 }
11686
11687 query.append(orderByConditionFields[i]);
11688
11689 if ((i + 1) < orderByConditionFields.length) {
11690 if (orderByComparator.isAscending() ^ previous) {
11691 query.append(WHERE_GREATER_THAN_HAS_NEXT);
11692 }
11693 else {
11694 query.append(WHERE_LESSER_THAN_HAS_NEXT);
11695 }
11696 }
11697 else {
11698 if (orderByComparator.isAscending() ^ previous) {
11699 query.append(WHERE_GREATER_THAN);
11700 }
11701 else {
11702 query.append(WHERE_LESSER_THAN);
11703 }
11704 }
11705 }
11706
11707 query.append(ORDER_BY_CLAUSE);
11708
11709 String[] orderByFields = orderByComparator.getOrderByFields();
11710
11711 for (int i = 0; i < orderByFields.length; i++) {
11712 if (getDB().isSupportsInlineDistinct()) {
11713 query.append(_ORDER_BY_ENTITY_ALIAS);
11714 }
11715 else {
11716 query.append(_ORDER_BY_ENTITY_TABLE);
11717 }
11718
11719 query.append(orderByFields[i]);
11720
11721 if ((i + 1) < orderByFields.length) {
11722 if (orderByComparator.isAscending() ^ previous) {
11723 query.append(ORDER_BY_ASC_HAS_NEXT);
11724 }
11725 else {
11726 query.append(ORDER_BY_DESC_HAS_NEXT);
11727 }
11728 }
11729 else {
11730 if (orderByComparator.isAscending() ^ previous) {
11731 query.append(ORDER_BY_ASC);
11732 }
11733 else {
11734 query.append(ORDER_BY_DESC);
11735 }
11736 }
11737 }
11738 }
11739 else {
11740 if (getDB().isSupportsInlineDistinct()) {
11741 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
11742 }
11743 else {
11744 query.append(MBThreadModelImpl.ORDER_BY_SQL);
11745 }
11746 }
11747
11748 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11749 MBThread.class.getName(),
11750 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11751
11752 SQLQuery q = session.createSynchronizedSQLQuery(sql);
11753
11754 q.setFirstResult(0);
11755 q.setMaxResults(2);
11756
11757 if (getDB().isSupportsInlineDistinct()) {
11758 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
11759 }
11760 else {
11761 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
11762 }
11763
11764 QueryPos qPos = QueryPos.getInstance(q);
11765
11766 qPos.add(groupId);
11767
11768 qPos.add(categoryId);
11769
11770 qPos.add(status);
11771
11772 if (orderByComparator != null) {
11773 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
11774
11775 for (Object value : values) {
11776 qPos.add(value);
11777 }
11778 }
11779
11780 List<MBThread> list = q.list();
11781
11782 if (list.size() == 2) {
11783 return list.get(1);
11784 }
11785 else {
11786 return null;
11787 }
11788 }
11789
11790
11797 @Override
11798 public void removeByG_NotC_S(long groupId, long categoryId, int status) {
11799 for (MBThread mbThread : findByG_NotC_S(groupId, categoryId, status,
11800 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11801 remove(mbThread);
11802 }
11803 }
11804
11805
11813 @Override
11814 public int countByG_NotC_S(long groupId, long categoryId, int status) {
11815 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_S;
11816
11817 Object[] finderArgs = new Object[] { groupId, categoryId, status };
11818
11819 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
11820
11821 if (count == null) {
11822 StringBundler query = new StringBundler(4);
11823
11824 query.append(_SQL_COUNT_MBTHREAD_WHERE);
11825
11826 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11827
11828 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11829
11830 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11831
11832 String sql = query.toString();
11833
11834 Session session = null;
11835
11836 try {
11837 session = openSession();
11838
11839 Query q = session.createQuery(sql);
11840
11841 QueryPos qPos = QueryPos.getInstance(q);
11842
11843 qPos.add(groupId);
11844
11845 qPos.add(categoryId);
11846
11847 qPos.add(status);
11848
11849 count = (Long)q.uniqueResult();
11850
11851 finderCache.putResult(finderPath, finderArgs, count);
11852 }
11853 catch (Exception e) {
11854 finderCache.removeResult(finderPath, finderArgs);
11855
11856 throw processException(e);
11857 }
11858 finally {
11859 closeSession(session);
11860 }
11861 }
11862
11863 return count.intValue();
11864 }
11865
11866
11874 @Override
11875 public int filterCountByG_NotC_S(long groupId, long categoryId, int status) {
11876 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11877 return countByG_NotC_S(groupId, categoryId, status);
11878 }
11879
11880 StringBundler query = new StringBundler(4);
11881
11882 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
11883
11884 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
11885
11886 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
11887
11888 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
11889
11890 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11891 MBThread.class.getName(),
11892 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11893
11894 Session session = null;
11895
11896 try {
11897 session = openSession();
11898
11899 SQLQuery q = session.createSynchronizedSQLQuery(sql);
11900
11901 q.addScalar(COUNT_COLUMN_NAME,
11902 com.liferay.portal.kernel.dao.orm.Type.LONG);
11903
11904 QueryPos qPos = QueryPos.getInstance(q);
11905
11906 qPos.add(groupId);
11907
11908 qPos.add(categoryId);
11909
11910 qPos.add(status);
11911
11912 Long count = (Long)q.uniqueResult();
11913
11914 return count.intValue();
11915 }
11916 catch (Exception e) {
11917 throw processException(e);
11918 }
11919 finally {
11920 closeSession(session);
11921 }
11922 }
11923
11924 private static final String _FINDER_COLUMN_G_NOTC_S_GROUPID_2 = "mbThread.groupId = ? AND ";
11925 private static final String _FINDER_COLUMN_G_NOTC_S_CATEGORYID_2 = "mbThread.categoryId != ? AND ";
11926 private static final String _FINDER_COLUMN_G_NOTC_S_STATUS_2 = "mbThread.status = ?";
11927 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_NOTS =
11928 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
11929 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
11930 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotC_NotS",
11931 new String[] {
11932 Long.class.getName(), Long.class.getName(),
11933 Integer.class.getName(),
11934
11935 Integer.class.getName(), Integer.class.getName(),
11936 OrderByComparator.class.getName()
11937 });
11938 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_NOTS =
11939 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
11940 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
11941 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotC_NotS",
11942 new String[] {
11943 Long.class.getName(), Long.class.getName(),
11944 Integer.class.getName()
11945 });
11946
11947
11955 @Override
11956 public List<MBThread> findByG_NotC_NotS(long groupId, long categoryId,
11957 int status) {
11958 return findByG_NotC_NotS(groupId, categoryId, status,
11959 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11960 }
11961
11962
11976 @Override
11977 public List<MBThread> findByG_NotC_NotS(long groupId, long categoryId,
11978 int status, int start, int end) {
11979 return findByG_NotC_NotS(groupId, categoryId, status, start, end, null);
11980 }
11981
11982
11997 @Override
11998 public List<MBThread> findByG_NotC_NotS(long groupId, long categoryId,
11999 int status, int start, int end,
12000 OrderByComparator<MBThread> orderByComparator) {
12001 return findByG_NotC_NotS(groupId, categoryId, status, start, end,
12002 orderByComparator, true);
12003 }
12004
12005
12021 @Override
12022 public List<MBThread> findByG_NotC_NotS(long groupId, long categoryId,
12023 int status, int start, int end,
12024 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
12025 boolean pagination = true;
12026 FinderPath finderPath = null;
12027 Object[] finderArgs = null;
12028
12029 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_NOTS;
12030 finderArgs = new Object[] {
12031 groupId, categoryId, status,
12032
12033 start, end, orderByComparator
12034 };
12035
12036 List<MBThread> list = null;
12037
12038 if (retrieveFromCache) {
12039 list = (List<MBThread>)finderCache.getResult(finderPath,
12040 finderArgs, this);
12041
12042 if ((list != null) && !list.isEmpty()) {
12043 for (MBThread mbThread : list) {
12044 if ((groupId != mbThread.getGroupId()) ||
12045 (categoryId == mbThread.getCategoryId()) ||
12046 (status == mbThread.getStatus())) {
12047 list = null;
12048
12049 break;
12050 }
12051 }
12052 }
12053 }
12054
12055 if (list == null) {
12056 StringBundler query = null;
12057
12058 if (orderByComparator != null) {
12059 query = new StringBundler(5 +
12060 (orderByComparator.getOrderByFields().length * 3));
12061 }
12062 else {
12063 query = new StringBundler(5);
12064 }
12065
12066 query.append(_SQL_SELECT_MBTHREAD_WHERE);
12067
12068 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12069
12070 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12071
12072 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12073
12074 if (orderByComparator != null) {
12075 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12076 orderByComparator);
12077 }
12078 else
12079 if (pagination) {
12080 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
12081 }
12082
12083 String sql = query.toString();
12084
12085 Session session = null;
12086
12087 try {
12088 session = openSession();
12089
12090 Query q = session.createQuery(sql);
12091
12092 QueryPos qPos = QueryPos.getInstance(q);
12093
12094 qPos.add(groupId);
12095
12096 qPos.add(categoryId);
12097
12098 qPos.add(status);
12099
12100 if (!pagination) {
12101 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
12102 start, end, false);
12103
12104 Collections.sort(list);
12105
12106 list = Collections.unmodifiableList(list);
12107 }
12108 else {
12109 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
12110 start, end);
12111 }
12112
12113 cacheResult(list);
12114
12115 finderCache.putResult(finderPath, finderArgs, list);
12116 }
12117 catch (Exception e) {
12118 finderCache.removeResult(finderPath, finderArgs);
12119
12120 throw processException(e);
12121 }
12122 finally {
12123 closeSession(session);
12124 }
12125 }
12126
12127 return list;
12128 }
12129
12130
12140 @Override
12141 public MBThread findByG_NotC_NotS_First(long groupId, long categoryId,
12142 int status, OrderByComparator<MBThread> orderByComparator)
12143 throws NoSuchThreadException {
12144 MBThread mbThread = fetchByG_NotC_NotS_First(groupId, categoryId,
12145 status, orderByComparator);
12146
12147 if (mbThread != null) {
12148 return mbThread;
12149 }
12150
12151 StringBundler msg = new StringBundler(8);
12152
12153 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12154
12155 msg.append("groupId=");
12156 msg.append(groupId);
12157
12158 msg.append(", categoryId=");
12159 msg.append(categoryId);
12160
12161 msg.append(", status=");
12162 msg.append(status);
12163
12164 msg.append(StringPool.CLOSE_CURLY_BRACE);
12165
12166 throw new NoSuchThreadException(msg.toString());
12167 }
12168
12169
12178 @Override
12179 public MBThread fetchByG_NotC_NotS_First(long groupId, long categoryId,
12180 int status, OrderByComparator<MBThread> orderByComparator) {
12181 List<MBThread> list = findByG_NotC_NotS(groupId, categoryId, status, 0,
12182 1, orderByComparator);
12183
12184 if (!list.isEmpty()) {
12185 return list.get(0);
12186 }
12187
12188 return null;
12189 }
12190
12191
12201 @Override
12202 public MBThread findByG_NotC_NotS_Last(long groupId, long categoryId,
12203 int status, OrderByComparator<MBThread> orderByComparator)
12204 throws NoSuchThreadException {
12205 MBThread mbThread = fetchByG_NotC_NotS_Last(groupId, categoryId,
12206 status, orderByComparator);
12207
12208 if (mbThread != null) {
12209 return mbThread;
12210 }
12211
12212 StringBundler msg = new StringBundler(8);
12213
12214 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12215
12216 msg.append("groupId=");
12217 msg.append(groupId);
12218
12219 msg.append(", categoryId=");
12220 msg.append(categoryId);
12221
12222 msg.append(", status=");
12223 msg.append(status);
12224
12225 msg.append(StringPool.CLOSE_CURLY_BRACE);
12226
12227 throw new NoSuchThreadException(msg.toString());
12228 }
12229
12230
12239 @Override
12240 public MBThread fetchByG_NotC_NotS_Last(long groupId, long categoryId,
12241 int status, OrderByComparator<MBThread> orderByComparator) {
12242 int count = countByG_NotC_NotS(groupId, categoryId, status);
12243
12244 if (count == 0) {
12245 return null;
12246 }
12247
12248 List<MBThread> list = findByG_NotC_NotS(groupId, categoryId, status,
12249 count - 1, count, orderByComparator);
12250
12251 if (!list.isEmpty()) {
12252 return list.get(0);
12253 }
12254
12255 return null;
12256 }
12257
12258
12269 @Override
12270 public MBThread[] findByG_NotC_NotS_PrevAndNext(long threadId,
12271 long groupId, long categoryId, int status,
12272 OrderByComparator<MBThread> orderByComparator)
12273 throws NoSuchThreadException {
12274 MBThread mbThread = findByPrimaryKey(threadId);
12275
12276 Session session = null;
12277
12278 try {
12279 session = openSession();
12280
12281 MBThread[] array = new MBThreadImpl[3];
12282
12283 array[0] = getByG_NotC_NotS_PrevAndNext(session, mbThread, groupId,
12284 categoryId, status, orderByComparator, true);
12285
12286 array[1] = mbThread;
12287
12288 array[2] = getByG_NotC_NotS_PrevAndNext(session, mbThread, groupId,
12289 categoryId, status, orderByComparator, false);
12290
12291 return array;
12292 }
12293 catch (Exception e) {
12294 throw processException(e);
12295 }
12296 finally {
12297 closeSession(session);
12298 }
12299 }
12300
12301 protected MBThread getByG_NotC_NotS_PrevAndNext(Session session,
12302 MBThread mbThread, long groupId, long categoryId, int status,
12303 OrderByComparator<MBThread> orderByComparator, boolean previous) {
12304 StringBundler query = null;
12305
12306 if (orderByComparator != null) {
12307 query = new StringBundler(6 +
12308 (orderByComparator.getOrderByFields().length * 6));
12309 }
12310 else {
12311 query = new StringBundler(3);
12312 }
12313
12314 query.append(_SQL_SELECT_MBTHREAD_WHERE);
12315
12316 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12317
12318 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12319
12320 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12321
12322 if (orderByComparator != null) {
12323 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12324
12325 if (orderByConditionFields.length > 0) {
12326 query.append(WHERE_AND);
12327 }
12328
12329 for (int i = 0; i < orderByConditionFields.length; i++) {
12330 query.append(_ORDER_BY_ENTITY_ALIAS);
12331 query.append(orderByConditionFields[i]);
12332
12333 if ((i + 1) < orderByConditionFields.length) {
12334 if (orderByComparator.isAscending() ^ previous) {
12335 query.append(WHERE_GREATER_THAN_HAS_NEXT);
12336 }
12337 else {
12338 query.append(WHERE_LESSER_THAN_HAS_NEXT);
12339 }
12340 }
12341 else {
12342 if (orderByComparator.isAscending() ^ previous) {
12343 query.append(WHERE_GREATER_THAN);
12344 }
12345 else {
12346 query.append(WHERE_LESSER_THAN);
12347 }
12348 }
12349 }
12350
12351 query.append(ORDER_BY_CLAUSE);
12352
12353 String[] orderByFields = orderByComparator.getOrderByFields();
12354
12355 for (int i = 0; i < orderByFields.length; i++) {
12356 query.append(_ORDER_BY_ENTITY_ALIAS);
12357 query.append(orderByFields[i]);
12358
12359 if ((i + 1) < orderByFields.length) {
12360 if (orderByComparator.isAscending() ^ previous) {
12361 query.append(ORDER_BY_ASC_HAS_NEXT);
12362 }
12363 else {
12364 query.append(ORDER_BY_DESC_HAS_NEXT);
12365 }
12366 }
12367 else {
12368 if (orderByComparator.isAscending() ^ previous) {
12369 query.append(ORDER_BY_ASC);
12370 }
12371 else {
12372 query.append(ORDER_BY_DESC);
12373 }
12374 }
12375 }
12376 }
12377 else {
12378 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
12379 }
12380
12381 String sql = query.toString();
12382
12383 Query q = session.createQuery(sql);
12384
12385 q.setFirstResult(0);
12386 q.setMaxResults(2);
12387
12388 QueryPos qPos = QueryPos.getInstance(q);
12389
12390 qPos.add(groupId);
12391
12392 qPos.add(categoryId);
12393
12394 qPos.add(status);
12395
12396 if (orderByComparator != null) {
12397 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
12398
12399 for (Object value : values) {
12400 qPos.add(value);
12401 }
12402 }
12403
12404 List<MBThread> list = q.list();
12405
12406 if (list.size() == 2) {
12407 return list.get(1);
12408 }
12409 else {
12410 return null;
12411 }
12412 }
12413
12414
12422 @Override
12423 public List<MBThread> filterFindByG_NotC_NotS(long groupId,
12424 long categoryId, int status) {
12425 return filterFindByG_NotC_NotS(groupId, categoryId, status,
12426 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12427 }
12428
12429
12443 @Override
12444 public List<MBThread> filterFindByG_NotC_NotS(long groupId,
12445 long categoryId, int status, int start, int end) {
12446 return filterFindByG_NotC_NotS(groupId, categoryId, status, start, end,
12447 null);
12448 }
12449
12450
12465 @Override
12466 public List<MBThread> filterFindByG_NotC_NotS(long groupId,
12467 long categoryId, int status, int start, int end,
12468 OrderByComparator<MBThread> orderByComparator) {
12469 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12470 return findByG_NotC_NotS(groupId, categoryId, status, start, end,
12471 orderByComparator);
12472 }
12473
12474 StringBundler query = null;
12475
12476 if (orderByComparator != null) {
12477 query = new StringBundler(5 +
12478 (orderByComparator.getOrderByFields().length * 3));
12479 }
12480 else {
12481 query = new StringBundler(5);
12482 }
12483
12484 if (getDB().isSupportsInlineDistinct()) {
12485 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
12486 }
12487 else {
12488 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
12489 }
12490
12491 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12492
12493 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12494
12495 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12496
12497 if (!getDB().isSupportsInlineDistinct()) {
12498 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
12499 }
12500
12501 if (orderByComparator != null) {
12502 if (getDB().isSupportsInlineDistinct()) {
12503 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12504 orderByComparator, true);
12505 }
12506 else {
12507 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12508 orderByComparator, true);
12509 }
12510 }
12511 else {
12512 if (getDB().isSupportsInlineDistinct()) {
12513 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
12514 }
12515 else {
12516 query.append(MBThreadModelImpl.ORDER_BY_SQL);
12517 }
12518 }
12519
12520 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12521 MBThread.class.getName(),
12522 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12523
12524 Session session = null;
12525
12526 try {
12527 session = openSession();
12528
12529 SQLQuery q = session.createSynchronizedSQLQuery(sql);
12530
12531 if (getDB().isSupportsInlineDistinct()) {
12532 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
12533 }
12534 else {
12535 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
12536 }
12537
12538 QueryPos qPos = QueryPos.getInstance(q);
12539
12540 qPos.add(groupId);
12541
12542 qPos.add(categoryId);
12543
12544 qPos.add(status);
12545
12546 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
12547 }
12548 catch (Exception e) {
12549 throw processException(e);
12550 }
12551 finally {
12552 closeSession(session);
12553 }
12554 }
12555
12556
12567 @Override
12568 public MBThread[] filterFindByG_NotC_NotS_PrevAndNext(long threadId,
12569 long groupId, long categoryId, int status,
12570 OrderByComparator<MBThread> orderByComparator)
12571 throws NoSuchThreadException {
12572 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12573 return findByG_NotC_NotS_PrevAndNext(threadId, groupId, categoryId,
12574 status, orderByComparator);
12575 }
12576
12577 MBThread mbThread = findByPrimaryKey(threadId);
12578
12579 Session session = null;
12580
12581 try {
12582 session = openSession();
12583
12584 MBThread[] array = new MBThreadImpl[3];
12585
12586 array[0] = filterGetByG_NotC_NotS_PrevAndNext(session, mbThread,
12587 groupId, categoryId, status, orderByComparator, true);
12588
12589 array[1] = mbThread;
12590
12591 array[2] = filterGetByG_NotC_NotS_PrevAndNext(session, mbThread,
12592 groupId, categoryId, status, orderByComparator, false);
12593
12594 return array;
12595 }
12596 catch (Exception e) {
12597 throw processException(e);
12598 }
12599 finally {
12600 closeSession(session);
12601 }
12602 }
12603
12604 protected MBThread filterGetByG_NotC_NotS_PrevAndNext(Session session,
12605 MBThread mbThread, long groupId, long categoryId, int status,
12606 OrderByComparator<MBThread> orderByComparator, boolean previous) {
12607 StringBundler query = null;
12608
12609 if (orderByComparator != null) {
12610 query = new StringBundler(6 +
12611 (orderByComparator.getOrderByFields().length * 6));
12612 }
12613 else {
12614 query = new StringBundler(3);
12615 }
12616
12617 if (getDB().isSupportsInlineDistinct()) {
12618 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
12619 }
12620 else {
12621 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
12622 }
12623
12624 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12625
12626 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12627
12628 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12629
12630 if (!getDB().isSupportsInlineDistinct()) {
12631 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
12632 }
12633
12634 if (orderByComparator != null) {
12635 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12636
12637 if (orderByConditionFields.length > 0) {
12638 query.append(WHERE_AND);
12639 }
12640
12641 for (int i = 0; i < orderByConditionFields.length; i++) {
12642 if (getDB().isSupportsInlineDistinct()) {
12643 query.append(_ORDER_BY_ENTITY_ALIAS);
12644 }
12645 else {
12646 query.append(_ORDER_BY_ENTITY_TABLE);
12647 }
12648
12649 query.append(orderByConditionFields[i]);
12650
12651 if ((i + 1) < orderByConditionFields.length) {
12652 if (orderByComparator.isAscending() ^ previous) {
12653 query.append(WHERE_GREATER_THAN_HAS_NEXT);
12654 }
12655 else {
12656 query.append(WHERE_LESSER_THAN_HAS_NEXT);
12657 }
12658 }
12659 else {
12660 if (orderByComparator.isAscending() ^ previous) {
12661 query.append(WHERE_GREATER_THAN);
12662 }
12663 else {
12664 query.append(WHERE_LESSER_THAN);
12665 }
12666 }
12667 }
12668
12669 query.append(ORDER_BY_CLAUSE);
12670
12671 String[] orderByFields = orderByComparator.getOrderByFields();
12672
12673 for (int i = 0; i < orderByFields.length; i++) {
12674 if (getDB().isSupportsInlineDistinct()) {
12675 query.append(_ORDER_BY_ENTITY_ALIAS);
12676 }
12677 else {
12678 query.append(_ORDER_BY_ENTITY_TABLE);
12679 }
12680
12681 query.append(orderByFields[i]);
12682
12683 if ((i + 1) < orderByFields.length) {
12684 if (orderByComparator.isAscending() ^ previous) {
12685 query.append(ORDER_BY_ASC_HAS_NEXT);
12686 }
12687 else {
12688 query.append(ORDER_BY_DESC_HAS_NEXT);
12689 }
12690 }
12691 else {
12692 if (orderByComparator.isAscending() ^ previous) {
12693 query.append(ORDER_BY_ASC);
12694 }
12695 else {
12696 query.append(ORDER_BY_DESC);
12697 }
12698 }
12699 }
12700 }
12701 else {
12702 if (getDB().isSupportsInlineDistinct()) {
12703 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
12704 }
12705 else {
12706 query.append(MBThreadModelImpl.ORDER_BY_SQL);
12707 }
12708 }
12709
12710 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12711 MBThread.class.getName(),
12712 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12713
12714 SQLQuery q = session.createSynchronizedSQLQuery(sql);
12715
12716 q.setFirstResult(0);
12717 q.setMaxResults(2);
12718
12719 if (getDB().isSupportsInlineDistinct()) {
12720 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
12721 }
12722 else {
12723 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
12724 }
12725
12726 QueryPos qPos = QueryPos.getInstance(q);
12727
12728 qPos.add(groupId);
12729
12730 qPos.add(categoryId);
12731
12732 qPos.add(status);
12733
12734 if (orderByComparator != null) {
12735 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
12736
12737 for (Object value : values) {
12738 qPos.add(value);
12739 }
12740 }
12741
12742 List<MBThread> list = q.list();
12743
12744 if (list.size() == 2) {
12745 return list.get(1);
12746 }
12747 else {
12748 return null;
12749 }
12750 }
12751
12752
12759 @Override
12760 public void removeByG_NotC_NotS(long groupId, long categoryId, int status) {
12761 for (MBThread mbThread : findByG_NotC_NotS(groupId, categoryId, status,
12762 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12763 remove(mbThread);
12764 }
12765 }
12766
12767
12775 @Override
12776 public int countByG_NotC_NotS(long groupId, long categoryId, int status) {
12777 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_NOTS;
12778
12779 Object[] finderArgs = new Object[] { groupId, categoryId, status };
12780
12781 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
12782
12783 if (count == null) {
12784 StringBundler query = new StringBundler(4);
12785
12786 query.append(_SQL_COUNT_MBTHREAD_WHERE);
12787
12788 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12789
12790 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12791
12792 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12793
12794 String sql = query.toString();
12795
12796 Session session = null;
12797
12798 try {
12799 session = openSession();
12800
12801 Query q = session.createQuery(sql);
12802
12803 QueryPos qPos = QueryPos.getInstance(q);
12804
12805 qPos.add(groupId);
12806
12807 qPos.add(categoryId);
12808
12809 qPos.add(status);
12810
12811 count = (Long)q.uniqueResult();
12812
12813 finderCache.putResult(finderPath, finderArgs, count);
12814 }
12815 catch (Exception e) {
12816 finderCache.removeResult(finderPath, finderArgs);
12817
12818 throw processException(e);
12819 }
12820 finally {
12821 closeSession(session);
12822 }
12823 }
12824
12825 return count.intValue();
12826 }
12827
12828
12836 @Override
12837 public int filterCountByG_NotC_NotS(long groupId, long categoryId,
12838 int status) {
12839 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12840 return countByG_NotC_NotS(groupId, categoryId, status);
12841 }
12842
12843 StringBundler query = new StringBundler(4);
12844
12845 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
12846
12847 query.append(_FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2);
12848
12849 query.append(_FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2);
12850
12851 query.append(_FINDER_COLUMN_G_NOTC_NOTS_STATUS_2);
12852
12853 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12854 MBThread.class.getName(),
12855 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12856
12857 Session session = null;
12858
12859 try {
12860 session = openSession();
12861
12862 SQLQuery q = session.createSynchronizedSQLQuery(sql);
12863
12864 q.addScalar(COUNT_COLUMN_NAME,
12865 com.liferay.portal.kernel.dao.orm.Type.LONG);
12866
12867 QueryPos qPos = QueryPos.getInstance(q);
12868
12869 qPos.add(groupId);
12870
12871 qPos.add(categoryId);
12872
12873 qPos.add(status);
12874
12875 Long count = (Long)q.uniqueResult();
12876
12877 return count.intValue();
12878 }
12879 catch (Exception e) {
12880 throw processException(e);
12881 }
12882 finally {
12883 closeSession(session);
12884 }
12885 }
12886
12887 private static final String _FINDER_COLUMN_G_NOTC_NOTS_GROUPID_2 = "mbThread.groupId = ? AND ";
12888 private static final String _FINDER_COLUMN_G_NOTC_NOTS_CATEGORYID_2 = "mbThread.categoryId != ? AND ";
12889 private static final String _FINDER_COLUMN_G_NOTC_NOTS_STATUS_2 = "mbThread.status != ?";
12890
12891 public MBThreadPersistenceImpl() {
12892 setModelClass(MBThread.class);
12893 }
12894
12895
12900 @Override
12901 public void cacheResult(MBThread mbThread) {
12902 entityCache.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
12903 MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread);
12904
12905 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
12906 new Object[] { mbThread.getUuid(), mbThread.getGroupId() }, mbThread);
12907
12908 finderCache.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
12909 new Object[] { mbThread.getRootMessageId() }, mbThread);
12910
12911 mbThread.resetOriginalValues();
12912 }
12913
12914
12919 @Override
12920 public void cacheResult(List<MBThread> mbThreads) {
12921 for (MBThread mbThread : mbThreads) {
12922 if (entityCache.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
12923 MBThreadImpl.class, mbThread.getPrimaryKey()) == null) {
12924 cacheResult(mbThread);
12925 }
12926 else {
12927 mbThread.resetOriginalValues();
12928 }
12929 }
12930 }
12931
12932
12939 @Override
12940 public void clearCache() {
12941 entityCache.clearCache(MBThreadImpl.class);
12942
12943 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
12944 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12945 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12946 }
12947
12948
12955 @Override
12956 public void clearCache(MBThread mbThread) {
12957 entityCache.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
12958 MBThreadImpl.class, mbThread.getPrimaryKey());
12959
12960 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12961 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12962
12963 clearUniqueFindersCache((MBThreadModelImpl)mbThread);
12964 }
12965
12966 @Override
12967 public void clearCache(List<MBThread> mbThreads) {
12968 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12969 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12970
12971 for (MBThread mbThread : mbThreads) {
12972 entityCache.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
12973 MBThreadImpl.class, mbThread.getPrimaryKey());
12974
12975 clearUniqueFindersCache((MBThreadModelImpl)mbThread);
12976 }
12977 }
12978
12979 protected void cacheUniqueFindersCache(
12980 MBThreadModelImpl mbThreadModelImpl, boolean isNew) {
12981 if (isNew) {
12982 Object[] args = new Object[] {
12983 mbThreadModelImpl.getUuid(), mbThreadModelImpl.getGroupId()
12984 };
12985
12986 finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
12987 Long.valueOf(1));
12988 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
12989 mbThreadModelImpl);
12990
12991 args = new Object[] { mbThreadModelImpl.getRootMessageId() };
12992
12993 finderCache.putResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args,
12994 Long.valueOf(1));
12995 finderCache.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args,
12996 mbThreadModelImpl);
12997 }
12998 else {
12999 if ((mbThreadModelImpl.getColumnBitmask() &
13000 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
13001 Object[] args = new Object[] {
13002 mbThreadModelImpl.getUuid(),
13003 mbThreadModelImpl.getGroupId()
13004 };
13005
13006 finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
13007 Long.valueOf(1));
13008 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
13009 mbThreadModelImpl);
13010 }
13011
13012 if ((mbThreadModelImpl.getColumnBitmask() &
13013 FINDER_PATH_FETCH_BY_ROOTMESSAGEID.getColumnBitmask()) != 0) {
13014 Object[] args = new Object[] {
13015 mbThreadModelImpl.getRootMessageId()
13016 };
13017
13018 finderCache.putResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args,
13019 Long.valueOf(1));
13020 finderCache.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args,
13021 mbThreadModelImpl);
13022 }
13023 }
13024 }
13025
13026 protected void clearUniqueFindersCache(MBThreadModelImpl mbThreadModelImpl) {
13027 Object[] args = new Object[] {
13028 mbThreadModelImpl.getUuid(), mbThreadModelImpl.getGroupId()
13029 };
13030
13031 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
13032 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
13033
13034 if ((mbThreadModelImpl.getColumnBitmask() &
13035 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
13036 args = new Object[] {
13037 mbThreadModelImpl.getOriginalUuid(),
13038 mbThreadModelImpl.getOriginalGroupId()
13039 };
13040
13041 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
13042 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
13043 }
13044
13045 args = new Object[] { mbThreadModelImpl.getRootMessageId() };
13046
13047 finderCache.removeResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args);
13048 finderCache.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args);
13049
13050 if ((mbThreadModelImpl.getColumnBitmask() &
13051 FINDER_PATH_FETCH_BY_ROOTMESSAGEID.getColumnBitmask()) != 0) {
13052 args = new Object[] { mbThreadModelImpl.getOriginalRootMessageId() };
13053
13054 finderCache.removeResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args);
13055 finderCache.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args);
13056 }
13057 }
13058
13059
13065 @Override
13066 public MBThread create(long threadId) {
13067 MBThread mbThread = new MBThreadImpl();
13068
13069 mbThread.setNew(true);
13070 mbThread.setPrimaryKey(threadId);
13071
13072 String uuid = PortalUUIDUtil.generate();
13073
13074 mbThread.setUuid(uuid);
13075
13076 return mbThread;
13077 }
13078
13079
13086 @Override
13087 public MBThread remove(long threadId) throws NoSuchThreadException {
13088 return remove((Serializable)threadId);
13089 }
13090
13091
13098 @Override
13099 public MBThread remove(Serializable primaryKey)
13100 throws NoSuchThreadException {
13101 Session session = null;
13102
13103 try {
13104 session = openSession();
13105
13106 MBThread mbThread = (MBThread)session.get(MBThreadImpl.class,
13107 primaryKey);
13108
13109 if (mbThread == null) {
13110 if (_log.isWarnEnabled()) {
13111 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
13112 }
13113
13114 throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
13115 primaryKey);
13116 }
13117
13118 return remove(mbThread);
13119 }
13120 catch (NoSuchThreadException nsee) {
13121 throw nsee;
13122 }
13123 catch (Exception e) {
13124 throw processException(e);
13125 }
13126 finally {
13127 closeSession(session);
13128 }
13129 }
13130
13131 @Override
13132 protected MBThread removeImpl(MBThread mbThread) {
13133 mbThread = toUnwrappedModel(mbThread);
13134
13135 Session session = null;
13136
13137 try {
13138 session = openSession();
13139
13140 if (!session.contains(mbThread)) {
13141 mbThread = (MBThread)session.get(MBThreadImpl.class,
13142 mbThread.getPrimaryKeyObj());
13143 }
13144
13145 if (mbThread != null) {
13146 session.delete(mbThread);
13147 }
13148 }
13149 catch (Exception e) {
13150 throw processException(e);
13151 }
13152 finally {
13153 closeSession(session);
13154 }
13155
13156 if (mbThread != null) {
13157 clearCache(mbThread);
13158 }
13159
13160 return mbThread;
13161 }
13162
13163 @Override
13164 public MBThread updateImpl(MBThread mbThread) {
13165 mbThread = toUnwrappedModel(mbThread);
13166
13167 boolean isNew = mbThread.isNew();
13168
13169 MBThreadModelImpl mbThreadModelImpl = (MBThreadModelImpl)mbThread;
13170
13171 if (Validator.isNull(mbThread.getUuid())) {
13172 String uuid = PortalUUIDUtil.generate();
13173
13174 mbThread.setUuid(uuid);
13175 }
13176
13177 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
13178
13179 Date now = new Date();
13180
13181 if (isNew && (mbThread.getCreateDate() == null)) {
13182 if (serviceContext == null) {
13183 mbThread.setCreateDate(now);
13184 }
13185 else {
13186 mbThread.setCreateDate(serviceContext.getCreateDate(now));
13187 }
13188 }
13189
13190 if (!mbThreadModelImpl.hasSetModifiedDate()) {
13191 if (serviceContext == null) {
13192 mbThread.setModifiedDate(now);
13193 }
13194 else {
13195 mbThread.setModifiedDate(serviceContext.getModifiedDate(now));
13196 }
13197 }
13198
13199 Session session = null;
13200
13201 try {
13202 session = openSession();
13203
13204 if (mbThread.isNew()) {
13205 session.save(mbThread);
13206
13207 mbThread.setNew(false);
13208 }
13209 else {
13210 mbThread = (MBThread)session.merge(mbThread);
13211 }
13212 }
13213 catch (Exception e) {
13214 throw processException(e);
13215 }
13216 finally {
13217 closeSession(session);
13218 }
13219
13220 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
13221
13222 if (isNew || !MBThreadModelImpl.COLUMN_BITMASK_ENABLED) {
13223 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
13224 }
13225
13226 else {
13227 if ((mbThreadModelImpl.getColumnBitmask() &
13228 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
13229 Object[] args = new Object[] { mbThreadModelImpl.getOriginalUuid() };
13230
13231 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
13232 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
13233 args);
13234
13235 args = new Object[] { mbThreadModelImpl.getUuid() };
13236
13237 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
13238 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
13239 args);
13240 }
13241
13242 if ((mbThreadModelImpl.getColumnBitmask() &
13243 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
13244 Object[] args = new Object[] {
13245 mbThreadModelImpl.getOriginalUuid(),
13246 mbThreadModelImpl.getOriginalCompanyId()
13247 };
13248
13249 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
13250 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
13251 args);
13252
13253 args = new Object[] {
13254 mbThreadModelImpl.getUuid(),
13255 mbThreadModelImpl.getCompanyId()
13256 };
13257
13258 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
13259 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
13260 args);
13261 }
13262
13263 if ((mbThreadModelImpl.getColumnBitmask() &
13264 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
13265 Object[] args = new Object[] {
13266 mbThreadModelImpl.getOriginalGroupId()
13267 };
13268
13269 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
13270 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
13271 args);
13272
13273 args = new Object[] { mbThreadModelImpl.getGroupId() };
13274
13275 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
13276 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
13277 args);
13278 }
13279
13280 if ((mbThreadModelImpl.getColumnBitmask() &
13281 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C.getColumnBitmask()) != 0) {
13282 Object[] args = new Object[] {
13283 mbThreadModelImpl.getOriginalGroupId(),
13284 mbThreadModelImpl.getOriginalCategoryId()
13285 };
13286
13287 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
13288 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
13289 args);
13290
13291 args = new Object[] {
13292 mbThreadModelImpl.getGroupId(),
13293 mbThreadModelImpl.getCategoryId()
13294 };
13295
13296 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
13297 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
13298 args);
13299 }
13300
13301 if ((mbThreadModelImpl.getColumnBitmask() &
13302 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
13303 Object[] args = new Object[] {
13304 mbThreadModelImpl.getOriginalGroupId(),
13305 mbThreadModelImpl.getOriginalStatus()
13306 };
13307
13308 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
13309 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
13310 args);
13311
13312 args = new Object[] {
13313 mbThreadModelImpl.getGroupId(),
13314 mbThreadModelImpl.getStatus()
13315 };
13316
13317 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
13318 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
13319 args);
13320 }
13321
13322 if ((mbThreadModelImpl.getColumnBitmask() &
13323 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
13324 Object[] args = new Object[] {
13325 mbThreadModelImpl.getOriginalCategoryId(),
13326 mbThreadModelImpl.getOriginalPriority()
13327 };
13328
13329 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
13330 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
13331 args);
13332
13333 args = new Object[] {
13334 mbThreadModelImpl.getCategoryId(),
13335 mbThreadModelImpl.getPriority()
13336 };
13337
13338 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
13339 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
13340 args);
13341 }
13342
13343 if ((mbThreadModelImpl.getColumnBitmask() &
13344 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P.getColumnBitmask()) != 0) {
13345 Object[] args = new Object[] {
13346 mbThreadModelImpl.getOriginalLastPostDate(),
13347 mbThreadModelImpl.getOriginalPriority()
13348 };
13349
13350 finderCache.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
13351 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
13352 args);
13353
13354 args = new Object[] {
13355 mbThreadModelImpl.getLastPostDate(),
13356 mbThreadModelImpl.getPriority()
13357 };
13358
13359 finderCache.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
13360 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
13361 args);
13362 }
13363
13364 if ((mbThreadModelImpl.getColumnBitmask() &
13365 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
13366 Object[] args = new Object[] {
13367 mbThreadModelImpl.getOriginalGroupId(),
13368 mbThreadModelImpl.getOriginalCategoryId(),
13369 mbThreadModelImpl.getOriginalLastPostDate()
13370 };
13371
13372 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
13373 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
13374 args);
13375
13376 args = new Object[] {
13377 mbThreadModelImpl.getGroupId(),
13378 mbThreadModelImpl.getCategoryId(),
13379 mbThreadModelImpl.getLastPostDate()
13380 };
13381
13382 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
13383 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
13384 args);
13385 }
13386
13387 if ((mbThreadModelImpl.getColumnBitmask() &
13388 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S.getColumnBitmask()) != 0) {
13389 Object[] args = new Object[] {
13390 mbThreadModelImpl.getOriginalGroupId(),
13391 mbThreadModelImpl.getOriginalCategoryId(),
13392 mbThreadModelImpl.getOriginalStatus()
13393 };
13394
13395 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
13396 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S,
13397 args);
13398
13399 args = new Object[] {
13400 mbThreadModelImpl.getGroupId(),
13401 mbThreadModelImpl.getCategoryId(),
13402 mbThreadModelImpl.getStatus()
13403 };
13404
13405 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
13406 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S,
13407 args);
13408 }
13409 }
13410
13411 entityCache.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13412 MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread, false);
13413
13414 clearUniqueFindersCache(mbThreadModelImpl);
13415 cacheUniqueFindersCache(mbThreadModelImpl, isNew);
13416
13417 mbThread.resetOriginalValues();
13418
13419 return mbThread;
13420 }
13421
13422 protected MBThread toUnwrappedModel(MBThread mbThread) {
13423 if (mbThread instanceof MBThreadImpl) {
13424 return mbThread;
13425 }
13426
13427 MBThreadImpl mbThreadImpl = new MBThreadImpl();
13428
13429 mbThreadImpl.setNew(mbThread.isNew());
13430 mbThreadImpl.setPrimaryKey(mbThread.getPrimaryKey());
13431
13432 mbThreadImpl.setUuid(mbThread.getUuid());
13433 mbThreadImpl.setThreadId(mbThread.getThreadId());
13434 mbThreadImpl.setGroupId(mbThread.getGroupId());
13435 mbThreadImpl.setCompanyId(mbThread.getCompanyId());
13436 mbThreadImpl.setUserId(mbThread.getUserId());
13437 mbThreadImpl.setUserName(mbThread.getUserName());
13438 mbThreadImpl.setCreateDate(mbThread.getCreateDate());
13439 mbThreadImpl.setModifiedDate(mbThread.getModifiedDate());
13440 mbThreadImpl.setCategoryId(mbThread.getCategoryId());
13441 mbThreadImpl.setRootMessageId(mbThread.getRootMessageId());
13442 mbThreadImpl.setRootMessageUserId(mbThread.getRootMessageUserId());
13443 mbThreadImpl.setMessageCount(mbThread.getMessageCount());
13444 mbThreadImpl.setViewCount(mbThread.getViewCount());
13445 mbThreadImpl.setLastPostByUserId(mbThread.getLastPostByUserId());
13446 mbThreadImpl.setLastPostDate(mbThread.getLastPostDate());
13447 mbThreadImpl.setPriority(mbThread.getPriority());
13448 mbThreadImpl.setQuestion(mbThread.isQuestion());
13449 mbThreadImpl.setLastPublishDate(mbThread.getLastPublishDate());
13450 mbThreadImpl.setStatus(mbThread.getStatus());
13451 mbThreadImpl.setStatusByUserId(mbThread.getStatusByUserId());
13452 mbThreadImpl.setStatusByUserName(mbThread.getStatusByUserName());
13453 mbThreadImpl.setStatusDate(mbThread.getStatusDate());
13454
13455 return mbThreadImpl;
13456 }
13457
13458
13465 @Override
13466 public MBThread findByPrimaryKey(Serializable primaryKey)
13467 throws NoSuchThreadException {
13468 MBThread mbThread = fetchByPrimaryKey(primaryKey);
13469
13470 if (mbThread == null) {
13471 if (_log.isWarnEnabled()) {
13472 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
13473 }
13474
13475 throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
13476 primaryKey);
13477 }
13478
13479 return mbThread;
13480 }
13481
13482
13489 @Override
13490 public MBThread findByPrimaryKey(long threadId)
13491 throws NoSuchThreadException {
13492 return findByPrimaryKey((Serializable)threadId);
13493 }
13494
13495
13501 @Override
13502 public MBThread fetchByPrimaryKey(Serializable primaryKey) {
13503 MBThread mbThread = (MBThread)entityCache.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13504 MBThreadImpl.class, primaryKey);
13505
13506 if (mbThread == _nullMBThread) {
13507 return null;
13508 }
13509
13510 if (mbThread == null) {
13511 Session session = null;
13512
13513 try {
13514 session = openSession();
13515
13516 mbThread = (MBThread)session.get(MBThreadImpl.class, primaryKey);
13517
13518 if (mbThread != null) {
13519 cacheResult(mbThread);
13520 }
13521 else {
13522 entityCache.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13523 MBThreadImpl.class, primaryKey, _nullMBThread);
13524 }
13525 }
13526 catch (Exception e) {
13527 entityCache.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13528 MBThreadImpl.class, primaryKey);
13529
13530 throw processException(e);
13531 }
13532 finally {
13533 closeSession(session);
13534 }
13535 }
13536
13537 return mbThread;
13538 }
13539
13540
13546 @Override
13547 public MBThread fetchByPrimaryKey(long threadId) {
13548 return fetchByPrimaryKey((Serializable)threadId);
13549 }
13550
13551 @Override
13552 public Map<Serializable, MBThread> fetchByPrimaryKeys(
13553 Set<Serializable> primaryKeys) {
13554 if (primaryKeys.isEmpty()) {
13555 return Collections.emptyMap();
13556 }
13557
13558 Map<Serializable, MBThread> map = new HashMap<Serializable, MBThread>();
13559
13560 if (primaryKeys.size() == 1) {
13561 Iterator<Serializable> iterator = primaryKeys.iterator();
13562
13563 Serializable primaryKey = iterator.next();
13564
13565 MBThread mbThread = fetchByPrimaryKey(primaryKey);
13566
13567 if (mbThread != null) {
13568 map.put(primaryKey, mbThread);
13569 }
13570
13571 return map;
13572 }
13573
13574 Set<Serializable> uncachedPrimaryKeys = null;
13575
13576 for (Serializable primaryKey : primaryKeys) {
13577 MBThread mbThread = (MBThread)entityCache.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13578 MBThreadImpl.class, primaryKey);
13579
13580 if (mbThread == null) {
13581 if (uncachedPrimaryKeys == null) {
13582 uncachedPrimaryKeys = new HashSet<Serializable>();
13583 }
13584
13585 uncachedPrimaryKeys.add(primaryKey);
13586 }
13587 else {
13588 map.put(primaryKey, mbThread);
13589 }
13590 }
13591
13592 if (uncachedPrimaryKeys == null) {
13593 return map;
13594 }
13595
13596 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
13597 1);
13598
13599 query.append(_SQL_SELECT_MBTHREAD_WHERE_PKS_IN);
13600
13601 for (Serializable primaryKey : uncachedPrimaryKeys) {
13602 query.append(String.valueOf(primaryKey));
13603
13604 query.append(StringPool.COMMA);
13605 }
13606
13607 query.setIndex(query.index() - 1);
13608
13609 query.append(StringPool.CLOSE_PARENTHESIS);
13610
13611 String sql = query.toString();
13612
13613 Session session = null;
13614
13615 try {
13616 session = openSession();
13617
13618 Query q = session.createQuery(sql);
13619
13620 for (MBThread mbThread : (List<MBThread>)q.list()) {
13621 map.put(mbThread.getPrimaryKeyObj(), mbThread);
13622
13623 cacheResult(mbThread);
13624
13625 uncachedPrimaryKeys.remove(mbThread.getPrimaryKeyObj());
13626 }
13627
13628 for (Serializable primaryKey : uncachedPrimaryKeys) {
13629 entityCache.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
13630 MBThreadImpl.class, primaryKey, _nullMBThread);
13631 }
13632 }
13633 catch (Exception e) {
13634 throw processException(e);
13635 }
13636 finally {
13637 closeSession(session);
13638 }
13639
13640 return map;
13641 }
13642
13643
13648 @Override
13649 public List<MBThread> findAll() {
13650 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13651 }
13652
13653
13664 @Override
13665 public List<MBThread> findAll(int start, int end) {
13666 return findAll(start, end, null);
13667 }
13668
13669
13681 @Override
13682 public List<MBThread> findAll(int start, int end,
13683 OrderByComparator<MBThread> orderByComparator) {
13684 return findAll(start, end, orderByComparator, true);
13685 }
13686
13687
13700 @Override
13701 public List<MBThread> findAll(int start, int end,
13702 OrderByComparator<MBThread> orderByComparator, boolean retrieveFromCache) {
13703 boolean pagination = true;
13704 FinderPath finderPath = null;
13705 Object[] finderArgs = null;
13706
13707 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13708 (orderByComparator == null)) {
13709 pagination = false;
13710 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
13711 finderArgs = FINDER_ARGS_EMPTY;
13712 }
13713 else {
13714 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
13715 finderArgs = new Object[] { start, end, orderByComparator };
13716 }
13717
13718 List<MBThread> list = null;
13719
13720 if (retrieveFromCache) {
13721 list = (List<MBThread>)finderCache.getResult(finderPath,
13722 finderArgs, this);
13723 }
13724
13725 if (list == null) {
13726 StringBundler query = null;
13727 String sql = null;
13728
13729 if (orderByComparator != null) {
13730 query = new StringBundler(2 +
13731 (orderByComparator.getOrderByFields().length * 3));
13732
13733 query.append(_SQL_SELECT_MBTHREAD);
13734
13735 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13736 orderByComparator);
13737
13738 sql = query.toString();
13739 }
13740 else {
13741 sql = _SQL_SELECT_MBTHREAD;
13742
13743 if (pagination) {
13744 sql = sql.concat(MBThreadModelImpl.ORDER_BY_JPQL);
13745 }
13746 }
13747
13748 Session session = null;
13749
13750 try {
13751 session = openSession();
13752
13753 Query q = session.createQuery(sql);
13754
13755 if (!pagination) {
13756 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
13757 start, end, false);
13758
13759 Collections.sort(list);
13760
13761 list = Collections.unmodifiableList(list);
13762 }
13763 else {
13764 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
13765 start, end);
13766 }
13767
13768 cacheResult(list);
13769
13770 finderCache.putResult(finderPath, finderArgs, list);
13771 }
13772 catch (Exception e) {
13773 finderCache.removeResult(finderPath, finderArgs);
13774
13775 throw processException(e);
13776 }
13777 finally {
13778 closeSession(session);
13779 }
13780 }
13781
13782 return list;
13783 }
13784
13785
13789 @Override
13790 public void removeAll() {
13791 for (MBThread mbThread : findAll()) {
13792 remove(mbThread);
13793 }
13794 }
13795
13796
13801 @Override
13802 public int countAll() {
13803 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
13804 FINDER_ARGS_EMPTY, this);
13805
13806 if (count == null) {
13807 Session session = null;
13808
13809 try {
13810 session = openSession();
13811
13812 Query q = session.createQuery(_SQL_COUNT_MBTHREAD);
13813
13814 count = (Long)q.uniqueResult();
13815
13816 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
13817 count);
13818 }
13819 catch (Exception e) {
13820 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
13821 FINDER_ARGS_EMPTY);
13822
13823 throw processException(e);
13824 }
13825 finally {
13826 closeSession(session);
13827 }
13828 }
13829
13830 return count.intValue();
13831 }
13832
13833 @Override
13834 public Set<String> getBadColumnNames() {
13835 return _badColumnNames;
13836 }
13837
13838 @Override
13839 protected Map<String, Integer> getTableColumnsMap() {
13840 return MBThreadModelImpl.TABLE_COLUMNS_MAP;
13841 }
13842
13843
13846 public void afterPropertiesSet() {
13847 }
13848
13849 public void destroy() {
13850 entityCache.removeCache(MBThreadImpl.class.getName());
13851 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
13852 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
13853 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
13854 }
13855
13856 @BeanReference(type = CompanyProvider.class)
13857 protected CompanyProvider companyProvider;
13858 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
13859 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
13860 private static final String _SQL_SELECT_MBTHREAD = "SELECT mbThread FROM MBThread mbThread";
13861 private static final String _SQL_SELECT_MBTHREAD_WHERE_PKS_IN = "SELECT mbThread FROM MBThread mbThread WHERE threadId IN (";
13862 private static final String _SQL_SELECT_MBTHREAD_WHERE = "SELECT mbThread FROM MBThread mbThread WHERE ";
13863 private static final String _SQL_COUNT_MBTHREAD = "SELECT COUNT(mbThread) FROM MBThread mbThread";
13864 private static final String _SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(mbThread) FROM MBThread mbThread WHERE ";
13865 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mbThread.threadId";
13866 private static final String _FILTER_SQL_SELECT_MBTHREAD_WHERE = "SELECT DISTINCT {mbThread.*} FROM MBThread mbThread WHERE ";
13867 private static final String _FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1 =
13868 "SELECT {MBThread.*} FROM (SELECT DISTINCT mbThread.threadId FROM MBThread mbThread WHERE ";
13869 private static final String _FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2 =
13870 ") TEMP_TABLE INNER JOIN MBThread ON TEMP_TABLE.threadId = MBThread.threadId";
13871 private static final String _FILTER_SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(DISTINCT mbThread.threadId) AS COUNT_VALUE FROM MBThread mbThread WHERE ";
13872 private static final String _FILTER_ENTITY_ALIAS = "mbThread";
13873 private static final String _FILTER_ENTITY_TABLE = "MBThread";
13874 private static final String _ORDER_BY_ENTITY_ALIAS = "mbThread.";
13875 private static final String _ORDER_BY_ENTITY_TABLE = "MBThread.";
13876 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBThread exists with the primary key ";
13877 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBThread exists with the key {";
13878 private static final Log _log = LogFactoryUtil.getLog(MBThreadPersistenceImpl.class);
13879 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
13880 "uuid"
13881 });
13882 private static final MBThread _nullMBThread = new MBThreadImpl() {
13883 @Override
13884 public Object clone() {
13885 return this;
13886 }
13887
13888 @Override
13889 public CacheModel<MBThread> toCacheModel() {
13890 return _nullMBThreadCacheModel;
13891 }
13892 };
13893
13894 private static final CacheModel<MBThread> _nullMBThreadCacheModel = new CacheModel<MBThread>() {
13895 @Override
13896 public MBThread toEntityModel() {
13897 return _nullMBThread;
13898 }
13899 };
13900 }