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