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.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.ArrayUtil;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.SetUtil;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
040 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041
042 import com.liferay.portlet.messageboards.NoSuchCategoryException;
043 import com.liferay.portlet.messageboards.model.MBCategory;
044 import com.liferay.portlet.messageboards.model.impl.MBCategoryImpl;
045 import com.liferay.portlet.messageboards.model.impl.MBCategoryModelImpl;
046 import com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence;
047
048 import java.io.Serializable;
049
050 import java.util.Collections;
051 import java.util.HashMap;
052 import java.util.HashSet;
053 import java.util.Iterator;
054 import java.util.List;
055 import java.util.Map;
056 import java.util.Set;
057
058
070 @ProviderType
071 public class MBCategoryPersistenceImpl extends BasePersistenceImpl<MBCategory>
072 implements MBCategoryPersistence {
073
078 public static final String FINDER_CLASS_NAME_ENTITY = MBCategoryImpl.class.getName();
079 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List1";
081 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List2";
083 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
084 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
085 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
086 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
087 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
089 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
090 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
091 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
092 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
093 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
094 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
095 new String[] {
096 String.class.getName(),
097
098 Integer.class.getName(), Integer.class.getName(),
099 OrderByComparator.class.getName()
100 });
101 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
102 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
104 new String[] { String.class.getName() },
105 MBCategoryModelImpl.UUID_COLUMN_BITMASK |
106 MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
107 MBCategoryModelImpl.NAME_COLUMN_BITMASK);
108 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
109 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
111 new String[] { String.class.getName() });
112
113
119 @Override
120 public List<MBCategory> findByUuid(String uuid) {
121 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
122 }
123
124
136 @Override
137 public List<MBCategory> findByUuid(String uuid, int start, int end) {
138 return findByUuid(uuid, start, end, null);
139 }
140
141
154 @Override
155 public List<MBCategory> findByUuid(String uuid, int start, int end,
156 OrderByComparator<MBCategory> orderByComparator) {
157 boolean pagination = true;
158 FinderPath finderPath = null;
159 Object[] finderArgs = null;
160
161 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
162 (orderByComparator == null)) {
163 pagination = false;
164 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
165 finderArgs = new Object[] { uuid };
166 }
167 else {
168 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
169 finderArgs = new Object[] { uuid, start, end, orderByComparator };
170 }
171
172 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
173 finderArgs, this);
174
175 if ((list != null) && !list.isEmpty()) {
176 for (MBCategory mbCategory : list) {
177 if (!Validator.equals(uuid, mbCategory.getUuid())) {
178 list = null;
179
180 break;
181 }
182 }
183 }
184
185 if (list == null) {
186 StringBundler query = null;
187
188 if (orderByComparator != null) {
189 query = new StringBundler(3 +
190 (orderByComparator.getOrderByFields().length * 3));
191 }
192 else {
193 query = new StringBundler(3);
194 }
195
196 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
197
198 boolean bindUuid = false;
199
200 if (uuid == null) {
201 query.append(_FINDER_COLUMN_UUID_UUID_1);
202 }
203 else if (uuid.equals(StringPool.BLANK)) {
204 query.append(_FINDER_COLUMN_UUID_UUID_3);
205 }
206 else {
207 bindUuid = true;
208
209 query.append(_FINDER_COLUMN_UUID_UUID_2);
210 }
211
212 if (orderByComparator != null) {
213 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
214 orderByComparator);
215 }
216 else
217 if (pagination) {
218 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
219 }
220
221 String sql = query.toString();
222
223 Session session = null;
224
225 try {
226 session = openSession();
227
228 Query q = session.createQuery(sql);
229
230 QueryPos qPos = QueryPos.getInstance(q);
231
232 if (bindUuid) {
233 qPos.add(uuid);
234 }
235
236 if (!pagination) {
237 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
238 start, end, false);
239
240 Collections.sort(list);
241
242 list = Collections.unmodifiableList(list);
243 }
244 else {
245 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
246 start, end);
247 }
248
249 cacheResult(list);
250
251 FinderCacheUtil.putResult(finderPath, finderArgs, list);
252 }
253 catch (Exception e) {
254 FinderCacheUtil.removeResult(finderPath, finderArgs);
255
256 throw processException(e);
257 }
258 finally {
259 closeSession(session);
260 }
261 }
262
263 return list;
264 }
265
266
274 @Override
275 public MBCategory findByUuid_First(String uuid,
276 OrderByComparator<MBCategory> orderByComparator)
277 throws NoSuchCategoryException {
278 MBCategory mbCategory = fetchByUuid_First(uuid, orderByComparator);
279
280 if (mbCategory != null) {
281 return mbCategory;
282 }
283
284 StringBundler msg = new StringBundler(4);
285
286 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
287
288 msg.append("uuid=");
289 msg.append(uuid);
290
291 msg.append(StringPool.CLOSE_CURLY_BRACE);
292
293 throw new NoSuchCategoryException(msg.toString());
294 }
295
296
303 @Override
304 public MBCategory fetchByUuid_First(String uuid,
305 OrderByComparator<MBCategory> orderByComparator) {
306 List<MBCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
307
308 if (!list.isEmpty()) {
309 return list.get(0);
310 }
311
312 return null;
313 }
314
315
323 @Override
324 public MBCategory findByUuid_Last(String uuid,
325 OrderByComparator<MBCategory> orderByComparator)
326 throws NoSuchCategoryException {
327 MBCategory mbCategory = fetchByUuid_Last(uuid, orderByComparator);
328
329 if (mbCategory != null) {
330 return mbCategory;
331 }
332
333 StringBundler msg = new StringBundler(4);
334
335 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
336
337 msg.append("uuid=");
338 msg.append(uuid);
339
340 msg.append(StringPool.CLOSE_CURLY_BRACE);
341
342 throw new NoSuchCategoryException(msg.toString());
343 }
344
345
352 @Override
353 public MBCategory fetchByUuid_Last(String uuid,
354 OrderByComparator<MBCategory> orderByComparator) {
355 int count = countByUuid(uuid);
356
357 if (count == 0) {
358 return null;
359 }
360
361 List<MBCategory> list = findByUuid(uuid, count - 1, count,
362 orderByComparator);
363
364 if (!list.isEmpty()) {
365 return list.get(0);
366 }
367
368 return null;
369 }
370
371
380 @Override
381 public MBCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
382 OrderByComparator<MBCategory> orderByComparator)
383 throws NoSuchCategoryException {
384 MBCategory mbCategory = findByPrimaryKey(categoryId);
385
386 Session session = null;
387
388 try {
389 session = openSession();
390
391 MBCategory[] array = new MBCategoryImpl[3];
392
393 array[0] = getByUuid_PrevAndNext(session, mbCategory, uuid,
394 orderByComparator, true);
395
396 array[1] = mbCategory;
397
398 array[2] = getByUuid_PrevAndNext(session, mbCategory, uuid,
399 orderByComparator, false);
400
401 return array;
402 }
403 catch (Exception e) {
404 throw processException(e);
405 }
406 finally {
407 closeSession(session);
408 }
409 }
410
411 protected MBCategory getByUuid_PrevAndNext(Session session,
412 MBCategory mbCategory, String uuid,
413 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
414 StringBundler query = null;
415
416 if (orderByComparator != null) {
417 query = new StringBundler(6 +
418 (orderByComparator.getOrderByFields().length * 6));
419 }
420 else {
421 query = new StringBundler(3);
422 }
423
424 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
425
426 boolean bindUuid = false;
427
428 if (uuid == null) {
429 query.append(_FINDER_COLUMN_UUID_UUID_1);
430 }
431 else if (uuid.equals(StringPool.BLANK)) {
432 query.append(_FINDER_COLUMN_UUID_UUID_3);
433 }
434 else {
435 bindUuid = true;
436
437 query.append(_FINDER_COLUMN_UUID_UUID_2);
438 }
439
440 if (orderByComparator != null) {
441 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
442
443 if (orderByConditionFields.length > 0) {
444 query.append(WHERE_AND);
445 }
446
447 for (int i = 0; i < orderByConditionFields.length; i++) {
448 query.append(_ORDER_BY_ENTITY_ALIAS);
449 query.append(orderByConditionFields[i]);
450
451 if ((i + 1) < orderByConditionFields.length) {
452 if (orderByComparator.isAscending() ^ previous) {
453 query.append(WHERE_GREATER_THAN_HAS_NEXT);
454 }
455 else {
456 query.append(WHERE_LESSER_THAN_HAS_NEXT);
457 }
458 }
459 else {
460 if (orderByComparator.isAscending() ^ previous) {
461 query.append(WHERE_GREATER_THAN);
462 }
463 else {
464 query.append(WHERE_LESSER_THAN);
465 }
466 }
467 }
468
469 query.append(ORDER_BY_CLAUSE);
470
471 String[] orderByFields = orderByComparator.getOrderByFields();
472
473 for (int i = 0; i < orderByFields.length; i++) {
474 query.append(_ORDER_BY_ENTITY_ALIAS);
475 query.append(orderByFields[i]);
476
477 if ((i + 1) < orderByFields.length) {
478 if (orderByComparator.isAscending() ^ previous) {
479 query.append(ORDER_BY_ASC_HAS_NEXT);
480 }
481 else {
482 query.append(ORDER_BY_DESC_HAS_NEXT);
483 }
484 }
485 else {
486 if (orderByComparator.isAscending() ^ previous) {
487 query.append(ORDER_BY_ASC);
488 }
489 else {
490 query.append(ORDER_BY_DESC);
491 }
492 }
493 }
494 }
495 else {
496 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
497 }
498
499 String sql = query.toString();
500
501 Query q = session.createQuery(sql);
502
503 q.setFirstResult(0);
504 q.setMaxResults(2);
505
506 QueryPos qPos = QueryPos.getInstance(q);
507
508 if (bindUuid) {
509 qPos.add(uuid);
510 }
511
512 if (orderByComparator != null) {
513 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
514
515 for (Object value : values) {
516 qPos.add(value);
517 }
518 }
519
520 List<MBCategory> list = q.list();
521
522 if (list.size() == 2) {
523 return list.get(1);
524 }
525 else {
526 return null;
527 }
528 }
529
530
535 @Override
536 public void removeByUuid(String uuid) {
537 for (MBCategory mbCategory : findByUuid(uuid, QueryUtil.ALL_POS,
538 QueryUtil.ALL_POS, null)) {
539 remove(mbCategory);
540 }
541 }
542
543
549 @Override
550 public int countByUuid(String uuid) {
551 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
552
553 Object[] finderArgs = new Object[] { uuid };
554
555 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
556 this);
557
558 if (count == null) {
559 StringBundler query = new StringBundler(2);
560
561 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
562
563 boolean bindUuid = false;
564
565 if (uuid == null) {
566 query.append(_FINDER_COLUMN_UUID_UUID_1);
567 }
568 else if (uuid.equals(StringPool.BLANK)) {
569 query.append(_FINDER_COLUMN_UUID_UUID_3);
570 }
571 else {
572 bindUuid = true;
573
574 query.append(_FINDER_COLUMN_UUID_UUID_2);
575 }
576
577 String sql = query.toString();
578
579 Session session = null;
580
581 try {
582 session = openSession();
583
584 Query q = session.createQuery(sql);
585
586 QueryPos qPos = QueryPos.getInstance(q);
587
588 if (bindUuid) {
589 qPos.add(uuid);
590 }
591
592 count = (Long)q.uniqueResult();
593
594 FinderCacheUtil.putResult(finderPath, finderArgs, count);
595 }
596 catch (Exception e) {
597 FinderCacheUtil.removeResult(finderPath, finderArgs);
598
599 throw processException(e);
600 }
601 finally {
602 closeSession(session);
603 }
604 }
605
606 return count.intValue();
607 }
608
609 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbCategory.uuid IS NULL";
610 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbCategory.uuid = ?";
611 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbCategory.uuid IS NULL OR mbCategory.uuid = '')";
612 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
613 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
614 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
615 new String[] { String.class.getName(), Long.class.getName() },
616 MBCategoryModelImpl.UUID_COLUMN_BITMASK |
617 MBCategoryModelImpl.GROUPID_COLUMN_BITMASK);
618 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
619 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
620 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
621 new String[] { String.class.getName(), Long.class.getName() });
622
623
631 @Override
632 public MBCategory findByUUID_G(String uuid, long groupId)
633 throws NoSuchCategoryException {
634 MBCategory mbCategory = fetchByUUID_G(uuid, groupId);
635
636 if (mbCategory == null) {
637 StringBundler msg = new StringBundler(6);
638
639 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
640
641 msg.append("uuid=");
642 msg.append(uuid);
643
644 msg.append(", groupId=");
645 msg.append(groupId);
646
647 msg.append(StringPool.CLOSE_CURLY_BRACE);
648
649 if (_log.isWarnEnabled()) {
650 _log.warn(msg.toString());
651 }
652
653 throw new NoSuchCategoryException(msg.toString());
654 }
655
656 return mbCategory;
657 }
658
659
666 @Override
667 public MBCategory fetchByUUID_G(String uuid, long groupId) {
668 return fetchByUUID_G(uuid, groupId, true);
669 }
670
671
679 @Override
680 public MBCategory fetchByUUID_G(String uuid, long groupId,
681 boolean retrieveFromCache) {
682 Object[] finderArgs = new Object[] { uuid, groupId };
683
684 Object result = null;
685
686 if (retrieveFromCache) {
687 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
688 finderArgs, this);
689 }
690
691 if (result instanceof MBCategory) {
692 MBCategory mbCategory = (MBCategory)result;
693
694 if (!Validator.equals(uuid, mbCategory.getUuid()) ||
695 (groupId != mbCategory.getGroupId())) {
696 result = null;
697 }
698 }
699
700 if (result == null) {
701 StringBundler query = new StringBundler(4);
702
703 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
704
705 boolean bindUuid = false;
706
707 if (uuid == null) {
708 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
709 }
710 else if (uuid.equals(StringPool.BLANK)) {
711 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
712 }
713 else {
714 bindUuid = true;
715
716 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
717 }
718
719 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
720
721 String sql = query.toString();
722
723 Session session = null;
724
725 try {
726 session = openSession();
727
728 Query q = session.createQuery(sql);
729
730 QueryPos qPos = QueryPos.getInstance(q);
731
732 if (bindUuid) {
733 qPos.add(uuid);
734 }
735
736 qPos.add(groupId);
737
738 List<MBCategory> list = q.list();
739
740 if (list.isEmpty()) {
741 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
742 finderArgs, list);
743 }
744 else {
745 MBCategory mbCategory = list.get(0);
746
747 result = mbCategory;
748
749 cacheResult(mbCategory);
750
751 if ((mbCategory.getUuid() == null) ||
752 !mbCategory.getUuid().equals(uuid) ||
753 (mbCategory.getGroupId() != groupId)) {
754 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
755 finderArgs, mbCategory);
756 }
757 }
758 }
759 catch (Exception e) {
760 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
761 finderArgs);
762
763 throw processException(e);
764 }
765 finally {
766 closeSession(session);
767 }
768 }
769
770 if (result instanceof List<?>) {
771 return null;
772 }
773 else {
774 return (MBCategory)result;
775 }
776 }
777
778
785 @Override
786 public MBCategory removeByUUID_G(String uuid, long groupId)
787 throws NoSuchCategoryException {
788 MBCategory mbCategory = findByUUID_G(uuid, groupId);
789
790 return remove(mbCategory);
791 }
792
793
800 @Override
801 public int countByUUID_G(String uuid, long groupId) {
802 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
803
804 Object[] finderArgs = new Object[] { uuid, groupId };
805
806 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
807 this);
808
809 if (count == null) {
810 StringBundler query = new StringBundler(3);
811
812 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
813
814 boolean bindUuid = false;
815
816 if (uuid == null) {
817 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
818 }
819 else if (uuid.equals(StringPool.BLANK)) {
820 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
821 }
822 else {
823 bindUuid = true;
824
825 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
826 }
827
828 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
829
830 String sql = query.toString();
831
832 Session session = null;
833
834 try {
835 session = openSession();
836
837 Query q = session.createQuery(sql);
838
839 QueryPos qPos = QueryPos.getInstance(q);
840
841 if (bindUuid) {
842 qPos.add(uuid);
843 }
844
845 qPos.add(groupId);
846
847 count = (Long)q.uniqueResult();
848
849 FinderCacheUtil.putResult(finderPath, finderArgs, count);
850 }
851 catch (Exception e) {
852 FinderCacheUtil.removeResult(finderPath, finderArgs);
853
854 throw processException(e);
855 }
856 finally {
857 closeSession(session);
858 }
859 }
860
861 return count.intValue();
862 }
863
864 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbCategory.uuid IS NULL AND ";
865 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbCategory.uuid = ? AND ";
866 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbCategory.uuid IS NULL OR mbCategory.uuid = '') AND ";
867 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbCategory.groupId = ?";
868 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
869 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
870 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
871 new String[] {
872 String.class.getName(), Long.class.getName(),
873
874 Integer.class.getName(), Integer.class.getName(),
875 OrderByComparator.class.getName()
876 });
877 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
878 new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
879 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
880 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
881 new String[] { String.class.getName(), Long.class.getName() },
882 MBCategoryModelImpl.UUID_COLUMN_BITMASK |
883 MBCategoryModelImpl.COMPANYID_COLUMN_BITMASK |
884 MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
885 MBCategoryModelImpl.NAME_COLUMN_BITMASK);
886 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
887 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
888 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
889 new String[] { String.class.getName(), Long.class.getName() });
890
891
898 @Override
899 public List<MBCategory> findByUuid_C(String uuid, long companyId) {
900 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
901 QueryUtil.ALL_POS, null);
902 }
903
904
917 @Override
918 public List<MBCategory> findByUuid_C(String uuid, long companyId,
919 int start, int end) {
920 return findByUuid_C(uuid, companyId, start, end, null);
921 }
922
923
937 @Override
938 public List<MBCategory> findByUuid_C(String uuid, long companyId,
939 int start, int end, OrderByComparator<MBCategory> orderByComparator) {
940 boolean pagination = true;
941 FinderPath finderPath = null;
942 Object[] finderArgs = null;
943
944 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
945 (orderByComparator == null)) {
946 pagination = false;
947 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
948 finderArgs = new Object[] { uuid, companyId };
949 }
950 else {
951 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
952 finderArgs = new Object[] {
953 uuid, companyId,
954
955 start, end, orderByComparator
956 };
957 }
958
959 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
960 finderArgs, this);
961
962 if ((list != null) && !list.isEmpty()) {
963 for (MBCategory mbCategory : list) {
964 if (!Validator.equals(uuid, mbCategory.getUuid()) ||
965 (companyId != mbCategory.getCompanyId())) {
966 list = null;
967
968 break;
969 }
970 }
971 }
972
973 if (list == null) {
974 StringBundler query = null;
975
976 if (orderByComparator != null) {
977 query = new StringBundler(4 +
978 (orderByComparator.getOrderByFields().length * 3));
979 }
980 else {
981 query = new StringBundler(4);
982 }
983
984 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
985
986 boolean bindUuid = false;
987
988 if (uuid == null) {
989 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
990 }
991 else if (uuid.equals(StringPool.BLANK)) {
992 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
993 }
994 else {
995 bindUuid = true;
996
997 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
998 }
999
1000 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1001
1002 if (orderByComparator != null) {
1003 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1004 orderByComparator);
1005 }
1006 else
1007 if (pagination) {
1008 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1009 }
1010
1011 String sql = query.toString();
1012
1013 Session session = null;
1014
1015 try {
1016 session = openSession();
1017
1018 Query q = session.createQuery(sql);
1019
1020 QueryPos qPos = QueryPos.getInstance(q);
1021
1022 if (bindUuid) {
1023 qPos.add(uuid);
1024 }
1025
1026 qPos.add(companyId);
1027
1028 if (!pagination) {
1029 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
1030 start, end, false);
1031
1032 Collections.sort(list);
1033
1034 list = Collections.unmodifiableList(list);
1035 }
1036 else {
1037 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
1038 start, end);
1039 }
1040
1041 cacheResult(list);
1042
1043 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1044 }
1045 catch (Exception e) {
1046 FinderCacheUtil.removeResult(finderPath, finderArgs);
1047
1048 throw processException(e);
1049 }
1050 finally {
1051 closeSession(session);
1052 }
1053 }
1054
1055 return list;
1056 }
1057
1058
1067 @Override
1068 public MBCategory findByUuid_C_First(String uuid, long companyId,
1069 OrderByComparator<MBCategory> orderByComparator)
1070 throws NoSuchCategoryException {
1071 MBCategory mbCategory = fetchByUuid_C_First(uuid, companyId,
1072 orderByComparator);
1073
1074 if (mbCategory != null) {
1075 return mbCategory;
1076 }
1077
1078 StringBundler msg = new StringBundler(6);
1079
1080 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1081
1082 msg.append("uuid=");
1083 msg.append(uuid);
1084
1085 msg.append(", companyId=");
1086 msg.append(companyId);
1087
1088 msg.append(StringPool.CLOSE_CURLY_BRACE);
1089
1090 throw new NoSuchCategoryException(msg.toString());
1091 }
1092
1093
1101 @Override
1102 public MBCategory fetchByUuid_C_First(String uuid, long companyId,
1103 OrderByComparator<MBCategory> orderByComparator) {
1104 List<MBCategory> list = findByUuid_C(uuid, companyId, 0, 1,
1105 orderByComparator);
1106
1107 if (!list.isEmpty()) {
1108 return list.get(0);
1109 }
1110
1111 return null;
1112 }
1113
1114
1123 @Override
1124 public MBCategory findByUuid_C_Last(String uuid, long companyId,
1125 OrderByComparator<MBCategory> orderByComparator)
1126 throws NoSuchCategoryException {
1127 MBCategory mbCategory = fetchByUuid_C_Last(uuid, companyId,
1128 orderByComparator);
1129
1130 if (mbCategory != null) {
1131 return mbCategory;
1132 }
1133
1134 StringBundler msg = new StringBundler(6);
1135
1136 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1137
1138 msg.append("uuid=");
1139 msg.append(uuid);
1140
1141 msg.append(", companyId=");
1142 msg.append(companyId);
1143
1144 msg.append(StringPool.CLOSE_CURLY_BRACE);
1145
1146 throw new NoSuchCategoryException(msg.toString());
1147 }
1148
1149
1157 @Override
1158 public MBCategory fetchByUuid_C_Last(String uuid, long companyId,
1159 OrderByComparator<MBCategory> orderByComparator) {
1160 int count = countByUuid_C(uuid, companyId);
1161
1162 if (count == 0) {
1163 return null;
1164 }
1165
1166 List<MBCategory> list = findByUuid_C(uuid, companyId, count - 1, count,
1167 orderByComparator);
1168
1169 if (!list.isEmpty()) {
1170 return list.get(0);
1171 }
1172
1173 return null;
1174 }
1175
1176
1186 @Override
1187 public MBCategory[] findByUuid_C_PrevAndNext(long categoryId, String uuid,
1188 long companyId, OrderByComparator<MBCategory> orderByComparator)
1189 throws NoSuchCategoryException {
1190 MBCategory mbCategory = findByPrimaryKey(categoryId);
1191
1192 Session session = null;
1193
1194 try {
1195 session = openSession();
1196
1197 MBCategory[] array = new MBCategoryImpl[3];
1198
1199 array[0] = getByUuid_C_PrevAndNext(session, mbCategory, uuid,
1200 companyId, orderByComparator, true);
1201
1202 array[1] = mbCategory;
1203
1204 array[2] = getByUuid_C_PrevAndNext(session, mbCategory, uuid,
1205 companyId, orderByComparator, false);
1206
1207 return array;
1208 }
1209 catch (Exception e) {
1210 throw processException(e);
1211 }
1212 finally {
1213 closeSession(session);
1214 }
1215 }
1216
1217 protected MBCategory getByUuid_C_PrevAndNext(Session session,
1218 MBCategory mbCategory, String uuid, long companyId,
1219 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
1220 StringBundler query = null;
1221
1222 if (orderByComparator != null) {
1223 query = new StringBundler(6 +
1224 (orderByComparator.getOrderByFields().length * 6));
1225 }
1226 else {
1227 query = new StringBundler(3);
1228 }
1229
1230 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1231
1232 boolean bindUuid = false;
1233
1234 if (uuid == null) {
1235 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1236 }
1237 else if (uuid.equals(StringPool.BLANK)) {
1238 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1239 }
1240 else {
1241 bindUuid = true;
1242
1243 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1244 }
1245
1246 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1247
1248 if (orderByComparator != null) {
1249 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1250
1251 if (orderByConditionFields.length > 0) {
1252 query.append(WHERE_AND);
1253 }
1254
1255 for (int i = 0; i < orderByConditionFields.length; i++) {
1256 query.append(_ORDER_BY_ENTITY_ALIAS);
1257 query.append(orderByConditionFields[i]);
1258
1259 if ((i + 1) < orderByConditionFields.length) {
1260 if (orderByComparator.isAscending() ^ previous) {
1261 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1262 }
1263 else {
1264 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1265 }
1266 }
1267 else {
1268 if (orderByComparator.isAscending() ^ previous) {
1269 query.append(WHERE_GREATER_THAN);
1270 }
1271 else {
1272 query.append(WHERE_LESSER_THAN);
1273 }
1274 }
1275 }
1276
1277 query.append(ORDER_BY_CLAUSE);
1278
1279 String[] orderByFields = orderByComparator.getOrderByFields();
1280
1281 for (int i = 0; i < orderByFields.length; i++) {
1282 query.append(_ORDER_BY_ENTITY_ALIAS);
1283 query.append(orderByFields[i]);
1284
1285 if ((i + 1) < orderByFields.length) {
1286 if (orderByComparator.isAscending() ^ previous) {
1287 query.append(ORDER_BY_ASC_HAS_NEXT);
1288 }
1289 else {
1290 query.append(ORDER_BY_DESC_HAS_NEXT);
1291 }
1292 }
1293 else {
1294 if (orderByComparator.isAscending() ^ previous) {
1295 query.append(ORDER_BY_ASC);
1296 }
1297 else {
1298 query.append(ORDER_BY_DESC);
1299 }
1300 }
1301 }
1302 }
1303 else {
1304 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1305 }
1306
1307 String sql = query.toString();
1308
1309 Query q = session.createQuery(sql);
1310
1311 q.setFirstResult(0);
1312 q.setMaxResults(2);
1313
1314 QueryPos qPos = QueryPos.getInstance(q);
1315
1316 if (bindUuid) {
1317 qPos.add(uuid);
1318 }
1319
1320 qPos.add(companyId);
1321
1322 if (orderByComparator != null) {
1323 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
1324
1325 for (Object value : values) {
1326 qPos.add(value);
1327 }
1328 }
1329
1330 List<MBCategory> list = q.list();
1331
1332 if (list.size() == 2) {
1333 return list.get(1);
1334 }
1335 else {
1336 return null;
1337 }
1338 }
1339
1340
1346 @Override
1347 public void removeByUuid_C(String uuid, long companyId) {
1348 for (MBCategory mbCategory : findByUuid_C(uuid, companyId,
1349 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1350 remove(mbCategory);
1351 }
1352 }
1353
1354
1361 @Override
1362 public int countByUuid_C(String uuid, long companyId) {
1363 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1364
1365 Object[] finderArgs = new Object[] { uuid, companyId };
1366
1367 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1368 this);
1369
1370 if (count == null) {
1371 StringBundler query = new StringBundler(3);
1372
1373 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
1374
1375 boolean bindUuid = false;
1376
1377 if (uuid == null) {
1378 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1379 }
1380 else if (uuid.equals(StringPool.BLANK)) {
1381 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1382 }
1383 else {
1384 bindUuid = true;
1385
1386 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1387 }
1388
1389 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1390
1391 String sql = query.toString();
1392
1393 Session session = null;
1394
1395 try {
1396 session = openSession();
1397
1398 Query q = session.createQuery(sql);
1399
1400 QueryPos qPos = QueryPos.getInstance(q);
1401
1402 if (bindUuid) {
1403 qPos.add(uuid);
1404 }
1405
1406 qPos.add(companyId);
1407
1408 count = (Long)q.uniqueResult();
1409
1410 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1411 }
1412 catch (Exception e) {
1413 FinderCacheUtil.removeResult(finderPath, finderArgs);
1414
1415 throw processException(e);
1416 }
1417 finally {
1418 closeSession(session);
1419 }
1420 }
1421
1422 return count.intValue();
1423 }
1424
1425 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mbCategory.uuid IS NULL AND ";
1426 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mbCategory.uuid = ? AND ";
1427 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mbCategory.uuid IS NULL OR mbCategory.uuid = '') AND ";
1428 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mbCategory.companyId = ?";
1429 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
1430 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
1431 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1432 new String[] {
1433 Long.class.getName(),
1434
1435 Integer.class.getName(), Integer.class.getName(),
1436 OrderByComparator.class.getName()
1437 });
1438 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1439 new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
1440 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
1441 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1442 new String[] { Long.class.getName() },
1443 MBCategoryModelImpl.GROUPID_COLUMN_BITMASK |
1444 MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
1445 MBCategoryModelImpl.NAME_COLUMN_BITMASK);
1446 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
1447 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1448 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1449 new String[] { Long.class.getName() });
1450
1451
1457 @Override
1458 public List<MBCategory> findByGroupId(long groupId) {
1459 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1460 }
1461
1462
1474 @Override
1475 public List<MBCategory> findByGroupId(long groupId, int start, int end) {
1476 return findByGroupId(groupId, start, end, null);
1477 }
1478
1479
1492 @Override
1493 public List<MBCategory> findByGroupId(long groupId, int start, int end,
1494 OrderByComparator<MBCategory> orderByComparator) {
1495 boolean pagination = true;
1496 FinderPath finderPath = null;
1497 Object[] finderArgs = null;
1498
1499 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1500 (orderByComparator == null)) {
1501 pagination = false;
1502 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1503 finderArgs = new Object[] { groupId };
1504 }
1505 else {
1506 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1507 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1508 }
1509
1510 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
1511 finderArgs, this);
1512
1513 if ((list != null) && !list.isEmpty()) {
1514 for (MBCategory mbCategory : list) {
1515 if ((groupId != mbCategory.getGroupId())) {
1516 list = null;
1517
1518 break;
1519 }
1520 }
1521 }
1522
1523 if (list == null) {
1524 StringBundler query = null;
1525
1526 if (orderByComparator != null) {
1527 query = new StringBundler(3 +
1528 (orderByComparator.getOrderByFields().length * 3));
1529 }
1530 else {
1531 query = new StringBundler(3);
1532 }
1533
1534 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1535
1536 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1537
1538 if (orderByComparator != null) {
1539 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1540 orderByComparator);
1541 }
1542 else
1543 if (pagination) {
1544 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1545 }
1546
1547 String sql = query.toString();
1548
1549 Session session = null;
1550
1551 try {
1552 session = openSession();
1553
1554 Query q = session.createQuery(sql);
1555
1556 QueryPos qPos = QueryPos.getInstance(q);
1557
1558 qPos.add(groupId);
1559
1560 if (!pagination) {
1561 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
1562 start, end, false);
1563
1564 Collections.sort(list);
1565
1566 list = Collections.unmodifiableList(list);
1567 }
1568 else {
1569 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
1570 start, end);
1571 }
1572
1573 cacheResult(list);
1574
1575 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1576 }
1577 catch (Exception e) {
1578 FinderCacheUtil.removeResult(finderPath, finderArgs);
1579
1580 throw processException(e);
1581 }
1582 finally {
1583 closeSession(session);
1584 }
1585 }
1586
1587 return list;
1588 }
1589
1590
1598 @Override
1599 public MBCategory findByGroupId_First(long groupId,
1600 OrderByComparator<MBCategory> orderByComparator)
1601 throws NoSuchCategoryException {
1602 MBCategory mbCategory = fetchByGroupId_First(groupId, orderByComparator);
1603
1604 if (mbCategory != null) {
1605 return mbCategory;
1606 }
1607
1608 StringBundler msg = new StringBundler(4);
1609
1610 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1611
1612 msg.append("groupId=");
1613 msg.append(groupId);
1614
1615 msg.append(StringPool.CLOSE_CURLY_BRACE);
1616
1617 throw new NoSuchCategoryException(msg.toString());
1618 }
1619
1620
1627 @Override
1628 public MBCategory fetchByGroupId_First(long groupId,
1629 OrderByComparator<MBCategory> orderByComparator) {
1630 List<MBCategory> list = findByGroupId(groupId, 0, 1, orderByComparator);
1631
1632 if (!list.isEmpty()) {
1633 return list.get(0);
1634 }
1635
1636 return null;
1637 }
1638
1639
1647 @Override
1648 public MBCategory findByGroupId_Last(long groupId,
1649 OrderByComparator<MBCategory> orderByComparator)
1650 throws NoSuchCategoryException {
1651 MBCategory mbCategory = fetchByGroupId_Last(groupId, orderByComparator);
1652
1653 if (mbCategory != null) {
1654 return mbCategory;
1655 }
1656
1657 StringBundler msg = new StringBundler(4);
1658
1659 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1660
1661 msg.append("groupId=");
1662 msg.append(groupId);
1663
1664 msg.append(StringPool.CLOSE_CURLY_BRACE);
1665
1666 throw new NoSuchCategoryException(msg.toString());
1667 }
1668
1669
1676 @Override
1677 public MBCategory fetchByGroupId_Last(long groupId,
1678 OrderByComparator<MBCategory> orderByComparator) {
1679 int count = countByGroupId(groupId);
1680
1681 if (count == 0) {
1682 return null;
1683 }
1684
1685 List<MBCategory> list = findByGroupId(groupId, count - 1, count,
1686 orderByComparator);
1687
1688 if (!list.isEmpty()) {
1689 return list.get(0);
1690 }
1691
1692 return null;
1693 }
1694
1695
1704 @Override
1705 public MBCategory[] findByGroupId_PrevAndNext(long categoryId,
1706 long groupId, OrderByComparator<MBCategory> orderByComparator)
1707 throws NoSuchCategoryException {
1708 MBCategory mbCategory = findByPrimaryKey(categoryId);
1709
1710 Session session = null;
1711
1712 try {
1713 session = openSession();
1714
1715 MBCategory[] array = new MBCategoryImpl[3];
1716
1717 array[0] = getByGroupId_PrevAndNext(session, mbCategory, groupId,
1718 orderByComparator, true);
1719
1720 array[1] = mbCategory;
1721
1722 array[2] = getByGroupId_PrevAndNext(session, mbCategory, groupId,
1723 orderByComparator, false);
1724
1725 return array;
1726 }
1727 catch (Exception e) {
1728 throw processException(e);
1729 }
1730 finally {
1731 closeSession(session);
1732 }
1733 }
1734
1735 protected MBCategory getByGroupId_PrevAndNext(Session session,
1736 MBCategory mbCategory, long groupId,
1737 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
1738 StringBundler query = null;
1739
1740 if (orderByComparator != null) {
1741 query = new StringBundler(6 +
1742 (orderByComparator.getOrderByFields().length * 6));
1743 }
1744 else {
1745 query = new StringBundler(3);
1746 }
1747
1748 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1749
1750 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1751
1752 if (orderByComparator != null) {
1753 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1754
1755 if (orderByConditionFields.length > 0) {
1756 query.append(WHERE_AND);
1757 }
1758
1759 for (int i = 0; i < orderByConditionFields.length; i++) {
1760 query.append(_ORDER_BY_ENTITY_ALIAS);
1761 query.append(orderByConditionFields[i]);
1762
1763 if ((i + 1) < orderByConditionFields.length) {
1764 if (orderByComparator.isAscending() ^ previous) {
1765 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1766 }
1767 else {
1768 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1769 }
1770 }
1771 else {
1772 if (orderByComparator.isAscending() ^ previous) {
1773 query.append(WHERE_GREATER_THAN);
1774 }
1775 else {
1776 query.append(WHERE_LESSER_THAN);
1777 }
1778 }
1779 }
1780
1781 query.append(ORDER_BY_CLAUSE);
1782
1783 String[] orderByFields = orderByComparator.getOrderByFields();
1784
1785 for (int i = 0; i < orderByFields.length; i++) {
1786 query.append(_ORDER_BY_ENTITY_ALIAS);
1787 query.append(orderByFields[i]);
1788
1789 if ((i + 1) < orderByFields.length) {
1790 if (orderByComparator.isAscending() ^ previous) {
1791 query.append(ORDER_BY_ASC_HAS_NEXT);
1792 }
1793 else {
1794 query.append(ORDER_BY_DESC_HAS_NEXT);
1795 }
1796 }
1797 else {
1798 if (orderByComparator.isAscending() ^ previous) {
1799 query.append(ORDER_BY_ASC);
1800 }
1801 else {
1802 query.append(ORDER_BY_DESC);
1803 }
1804 }
1805 }
1806 }
1807 else {
1808 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1809 }
1810
1811 String sql = query.toString();
1812
1813 Query q = session.createQuery(sql);
1814
1815 q.setFirstResult(0);
1816 q.setMaxResults(2);
1817
1818 QueryPos qPos = QueryPos.getInstance(q);
1819
1820 qPos.add(groupId);
1821
1822 if (orderByComparator != null) {
1823 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
1824
1825 for (Object value : values) {
1826 qPos.add(value);
1827 }
1828 }
1829
1830 List<MBCategory> list = q.list();
1831
1832 if (list.size() == 2) {
1833 return list.get(1);
1834 }
1835 else {
1836 return null;
1837 }
1838 }
1839
1840
1846 @Override
1847 public List<MBCategory> filterFindByGroupId(long groupId) {
1848 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1849 QueryUtil.ALL_POS, null);
1850 }
1851
1852
1864 @Override
1865 public List<MBCategory> filterFindByGroupId(long groupId, int start, int end) {
1866 return filterFindByGroupId(groupId, start, end, null);
1867 }
1868
1869
1882 @Override
1883 public List<MBCategory> filterFindByGroupId(long groupId, int start,
1884 int end, OrderByComparator<MBCategory> orderByComparator) {
1885 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1886 return findByGroupId(groupId, start, end, orderByComparator);
1887 }
1888
1889 StringBundler query = null;
1890
1891 if (orderByComparator != null) {
1892 query = new StringBundler(3 +
1893 (orderByComparator.getOrderByFields().length * 3));
1894 }
1895 else {
1896 query = new StringBundler(3);
1897 }
1898
1899 if (getDB().isSupportsInlineDistinct()) {
1900 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
1901 }
1902 else {
1903 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1904 }
1905
1906 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1907
1908 if (!getDB().isSupportsInlineDistinct()) {
1909 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1910 }
1911
1912 if (orderByComparator != null) {
1913 if (getDB().isSupportsInlineDistinct()) {
1914 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1915 orderByComparator, true);
1916 }
1917 else {
1918 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1919 orderByComparator, true);
1920 }
1921 }
1922 else {
1923 if (getDB().isSupportsInlineDistinct()) {
1924 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1925 }
1926 else {
1927 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
1928 }
1929 }
1930
1931 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1932 MBCategory.class.getName(),
1933 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1934
1935 Session session = null;
1936
1937 try {
1938 session = openSession();
1939
1940 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1941
1942 if (getDB().isSupportsInlineDistinct()) {
1943 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
1944 }
1945 else {
1946 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
1947 }
1948
1949 QueryPos qPos = QueryPos.getInstance(q);
1950
1951 qPos.add(groupId);
1952
1953 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
1954 }
1955 catch (Exception e) {
1956 throw processException(e);
1957 }
1958 finally {
1959 closeSession(session);
1960 }
1961 }
1962
1963
1972 @Override
1973 public MBCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
1974 long groupId, OrderByComparator<MBCategory> orderByComparator)
1975 throws NoSuchCategoryException {
1976 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1977 return findByGroupId_PrevAndNext(categoryId, groupId,
1978 orderByComparator);
1979 }
1980
1981 MBCategory mbCategory = findByPrimaryKey(categoryId);
1982
1983 Session session = null;
1984
1985 try {
1986 session = openSession();
1987
1988 MBCategory[] array = new MBCategoryImpl[3];
1989
1990 array[0] = filterGetByGroupId_PrevAndNext(session, mbCategory,
1991 groupId, orderByComparator, true);
1992
1993 array[1] = mbCategory;
1994
1995 array[2] = filterGetByGroupId_PrevAndNext(session, mbCategory,
1996 groupId, orderByComparator, false);
1997
1998 return array;
1999 }
2000 catch (Exception e) {
2001 throw processException(e);
2002 }
2003 finally {
2004 closeSession(session);
2005 }
2006 }
2007
2008 protected MBCategory filterGetByGroupId_PrevAndNext(Session session,
2009 MBCategory mbCategory, long groupId,
2010 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
2011 StringBundler query = null;
2012
2013 if (orderByComparator != null) {
2014 query = new StringBundler(6 +
2015 (orderByComparator.getOrderByFields().length * 6));
2016 }
2017 else {
2018 query = new StringBundler(3);
2019 }
2020
2021 if (getDB().isSupportsInlineDistinct()) {
2022 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
2023 }
2024 else {
2025 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2026 }
2027
2028 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2029
2030 if (!getDB().isSupportsInlineDistinct()) {
2031 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2032 }
2033
2034 if (orderByComparator != null) {
2035 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2036
2037 if (orderByConditionFields.length > 0) {
2038 query.append(WHERE_AND);
2039 }
2040
2041 for (int i = 0; i < orderByConditionFields.length; i++) {
2042 if (getDB().isSupportsInlineDistinct()) {
2043 query.append(_ORDER_BY_ENTITY_ALIAS);
2044 }
2045 else {
2046 query.append(_ORDER_BY_ENTITY_TABLE);
2047 }
2048
2049 query.append(orderByConditionFields[i]);
2050
2051 if ((i + 1) < orderByConditionFields.length) {
2052 if (orderByComparator.isAscending() ^ previous) {
2053 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2054 }
2055 else {
2056 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2057 }
2058 }
2059 else {
2060 if (orderByComparator.isAscending() ^ previous) {
2061 query.append(WHERE_GREATER_THAN);
2062 }
2063 else {
2064 query.append(WHERE_LESSER_THAN);
2065 }
2066 }
2067 }
2068
2069 query.append(ORDER_BY_CLAUSE);
2070
2071 String[] orderByFields = orderByComparator.getOrderByFields();
2072
2073 for (int i = 0; i < orderByFields.length; i++) {
2074 if (getDB().isSupportsInlineDistinct()) {
2075 query.append(_ORDER_BY_ENTITY_ALIAS);
2076 }
2077 else {
2078 query.append(_ORDER_BY_ENTITY_TABLE);
2079 }
2080
2081 query.append(orderByFields[i]);
2082
2083 if ((i + 1) < orderByFields.length) {
2084 if (orderByComparator.isAscending() ^ previous) {
2085 query.append(ORDER_BY_ASC_HAS_NEXT);
2086 }
2087 else {
2088 query.append(ORDER_BY_DESC_HAS_NEXT);
2089 }
2090 }
2091 else {
2092 if (orderByComparator.isAscending() ^ previous) {
2093 query.append(ORDER_BY_ASC);
2094 }
2095 else {
2096 query.append(ORDER_BY_DESC);
2097 }
2098 }
2099 }
2100 }
2101 else {
2102 if (getDB().isSupportsInlineDistinct()) {
2103 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
2104 }
2105 else {
2106 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
2107 }
2108 }
2109
2110 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2111 MBCategory.class.getName(),
2112 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2113
2114 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2115
2116 q.setFirstResult(0);
2117 q.setMaxResults(2);
2118
2119 if (getDB().isSupportsInlineDistinct()) {
2120 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
2121 }
2122 else {
2123 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
2124 }
2125
2126 QueryPos qPos = QueryPos.getInstance(q);
2127
2128 qPos.add(groupId);
2129
2130 if (orderByComparator != null) {
2131 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
2132
2133 for (Object value : values) {
2134 qPos.add(value);
2135 }
2136 }
2137
2138 List<MBCategory> list = q.list();
2139
2140 if (list.size() == 2) {
2141 return list.get(1);
2142 }
2143 else {
2144 return null;
2145 }
2146 }
2147
2148
2153 @Override
2154 public void removeByGroupId(long groupId) {
2155 for (MBCategory mbCategory : findByGroupId(groupId, QueryUtil.ALL_POS,
2156 QueryUtil.ALL_POS, null)) {
2157 remove(mbCategory);
2158 }
2159 }
2160
2161
2167 @Override
2168 public int countByGroupId(long groupId) {
2169 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2170
2171 Object[] finderArgs = new Object[] { groupId };
2172
2173 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2174 this);
2175
2176 if (count == null) {
2177 StringBundler query = new StringBundler(2);
2178
2179 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
2180
2181 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2182
2183 String sql = query.toString();
2184
2185 Session session = null;
2186
2187 try {
2188 session = openSession();
2189
2190 Query q = session.createQuery(sql);
2191
2192 QueryPos qPos = QueryPos.getInstance(q);
2193
2194 qPos.add(groupId);
2195
2196 count = (Long)q.uniqueResult();
2197
2198 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2199 }
2200 catch (Exception e) {
2201 FinderCacheUtil.removeResult(finderPath, finderArgs);
2202
2203 throw processException(e);
2204 }
2205 finally {
2206 closeSession(session);
2207 }
2208 }
2209
2210 return count.intValue();
2211 }
2212
2213
2219 @Override
2220 public int filterCountByGroupId(long groupId) {
2221 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2222 return countByGroupId(groupId);
2223 }
2224
2225 StringBundler query = new StringBundler(2);
2226
2227 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
2228
2229 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2230
2231 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2232 MBCategory.class.getName(),
2233 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2234
2235 Session session = null;
2236
2237 try {
2238 session = openSession();
2239
2240 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2241
2242 q.addScalar(COUNT_COLUMN_NAME,
2243 com.liferay.portal.kernel.dao.orm.Type.LONG);
2244
2245 QueryPos qPos = QueryPos.getInstance(q);
2246
2247 qPos.add(groupId);
2248
2249 Long count = (Long)q.uniqueResult();
2250
2251 return count.intValue();
2252 }
2253 catch (Exception e) {
2254 throw processException(e);
2255 }
2256 finally {
2257 closeSession(session);
2258 }
2259 }
2260
2261 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbCategory.groupId = ?";
2262 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2263 new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
2264 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
2265 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2266 new String[] {
2267 Long.class.getName(),
2268
2269 Integer.class.getName(), Integer.class.getName(),
2270 OrderByComparator.class.getName()
2271 });
2272 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2273 new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
2274 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
2275 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2276 new String[] { Long.class.getName() },
2277 MBCategoryModelImpl.COMPANYID_COLUMN_BITMASK |
2278 MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
2279 MBCategoryModelImpl.NAME_COLUMN_BITMASK);
2280 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
2281 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2282 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2283 new String[] { Long.class.getName() });
2284
2285
2291 @Override
2292 public List<MBCategory> findByCompanyId(long companyId) {
2293 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2294 null);
2295 }
2296
2297
2309 @Override
2310 public List<MBCategory> findByCompanyId(long companyId, int start, int end) {
2311 return findByCompanyId(companyId, start, end, null);
2312 }
2313
2314
2327 @Override
2328 public List<MBCategory> findByCompanyId(long companyId, int start, int end,
2329 OrderByComparator<MBCategory> orderByComparator) {
2330 boolean pagination = true;
2331 FinderPath finderPath = null;
2332 Object[] finderArgs = null;
2333
2334 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2335 (orderByComparator == null)) {
2336 pagination = false;
2337 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2338 finderArgs = new Object[] { companyId };
2339 }
2340 else {
2341 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2342 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2343 }
2344
2345 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
2346 finderArgs, this);
2347
2348 if ((list != null) && !list.isEmpty()) {
2349 for (MBCategory mbCategory : list) {
2350 if ((companyId != mbCategory.getCompanyId())) {
2351 list = null;
2352
2353 break;
2354 }
2355 }
2356 }
2357
2358 if (list == null) {
2359 StringBundler query = null;
2360
2361 if (orderByComparator != null) {
2362 query = new StringBundler(3 +
2363 (orderByComparator.getOrderByFields().length * 3));
2364 }
2365 else {
2366 query = new StringBundler(3);
2367 }
2368
2369 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
2370
2371 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2372
2373 if (orderByComparator != null) {
2374 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2375 orderByComparator);
2376 }
2377 else
2378 if (pagination) {
2379 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
2380 }
2381
2382 String sql = query.toString();
2383
2384 Session session = null;
2385
2386 try {
2387 session = openSession();
2388
2389 Query q = session.createQuery(sql);
2390
2391 QueryPos qPos = QueryPos.getInstance(q);
2392
2393 qPos.add(companyId);
2394
2395 if (!pagination) {
2396 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
2397 start, end, false);
2398
2399 Collections.sort(list);
2400
2401 list = Collections.unmodifiableList(list);
2402 }
2403 else {
2404 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
2405 start, end);
2406 }
2407
2408 cacheResult(list);
2409
2410 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2411 }
2412 catch (Exception e) {
2413 FinderCacheUtil.removeResult(finderPath, finderArgs);
2414
2415 throw processException(e);
2416 }
2417 finally {
2418 closeSession(session);
2419 }
2420 }
2421
2422 return list;
2423 }
2424
2425
2433 @Override
2434 public MBCategory findByCompanyId_First(long companyId,
2435 OrderByComparator<MBCategory> orderByComparator)
2436 throws NoSuchCategoryException {
2437 MBCategory mbCategory = fetchByCompanyId_First(companyId,
2438 orderByComparator);
2439
2440 if (mbCategory != null) {
2441 return mbCategory;
2442 }
2443
2444 StringBundler msg = new StringBundler(4);
2445
2446 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2447
2448 msg.append("companyId=");
2449 msg.append(companyId);
2450
2451 msg.append(StringPool.CLOSE_CURLY_BRACE);
2452
2453 throw new NoSuchCategoryException(msg.toString());
2454 }
2455
2456
2463 @Override
2464 public MBCategory fetchByCompanyId_First(long companyId,
2465 OrderByComparator<MBCategory> orderByComparator) {
2466 List<MBCategory> list = findByCompanyId(companyId, 0, 1,
2467 orderByComparator);
2468
2469 if (!list.isEmpty()) {
2470 return list.get(0);
2471 }
2472
2473 return null;
2474 }
2475
2476
2484 @Override
2485 public MBCategory findByCompanyId_Last(long companyId,
2486 OrderByComparator<MBCategory> orderByComparator)
2487 throws NoSuchCategoryException {
2488 MBCategory mbCategory = fetchByCompanyId_Last(companyId,
2489 orderByComparator);
2490
2491 if (mbCategory != null) {
2492 return mbCategory;
2493 }
2494
2495 StringBundler msg = new StringBundler(4);
2496
2497 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2498
2499 msg.append("companyId=");
2500 msg.append(companyId);
2501
2502 msg.append(StringPool.CLOSE_CURLY_BRACE);
2503
2504 throw new NoSuchCategoryException(msg.toString());
2505 }
2506
2507
2514 @Override
2515 public MBCategory fetchByCompanyId_Last(long companyId,
2516 OrderByComparator<MBCategory> orderByComparator) {
2517 int count = countByCompanyId(companyId);
2518
2519 if (count == 0) {
2520 return null;
2521 }
2522
2523 List<MBCategory> list = findByCompanyId(companyId, count - 1, count,
2524 orderByComparator);
2525
2526 if (!list.isEmpty()) {
2527 return list.get(0);
2528 }
2529
2530 return null;
2531 }
2532
2533
2542 @Override
2543 public MBCategory[] findByCompanyId_PrevAndNext(long categoryId,
2544 long companyId, OrderByComparator<MBCategory> orderByComparator)
2545 throws NoSuchCategoryException {
2546 MBCategory mbCategory = findByPrimaryKey(categoryId);
2547
2548 Session session = null;
2549
2550 try {
2551 session = openSession();
2552
2553 MBCategory[] array = new MBCategoryImpl[3];
2554
2555 array[0] = getByCompanyId_PrevAndNext(session, mbCategory,
2556 companyId, orderByComparator, true);
2557
2558 array[1] = mbCategory;
2559
2560 array[2] = getByCompanyId_PrevAndNext(session, mbCategory,
2561 companyId, orderByComparator, false);
2562
2563 return array;
2564 }
2565 catch (Exception e) {
2566 throw processException(e);
2567 }
2568 finally {
2569 closeSession(session);
2570 }
2571 }
2572
2573 protected MBCategory getByCompanyId_PrevAndNext(Session session,
2574 MBCategory mbCategory, long companyId,
2575 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
2576 StringBundler query = null;
2577
2578 if (orderByComparator != null) {
2579 query = new StringBundler(6 +
2580 (orderByComparator.getOrderByFields().length * 6));
2581 }
2582 else {
2583 query = new StringBundler(3);
2584 }
2585
2586 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
2587
2588 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2589
2590 if (orderByComparator != null) {
2591 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2592
2593 if (orderByConditionFields.length > 0) {
2594 query.append(WHERE_AND);
2595 }
2596
2597 for (int i = 0; i < orderByConditionFields.length; i++) {
2598 query.append(_ORDER_BY_ENTITY_ALIAS);
2599 query.append(orderByConditionFields[i]);
2600
2601 if ((i + 1) < orderByConditionFields.length) {
2602 if (orderByComparator.isAscending() ^ previous) {
2603 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2604 }
2605 else {
2606 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2607 }
2608 }
2609 else {
2610 if (orderByComparator.isAscending() ^ previous) {
2611 query.append(WHERE_GREATER_THAN);
2612 }
2613 else {
2614 query.append(WHERE_LESSER_THAN);
2615 }
2616 }
2617 }
2618
2619 query.append(ORDER_BY_CLAUSE);
2620
2621 String[] orderByFields = orderByComparator.getOrderByFields();
2622
2623 for (int i = 0; i < orderByFields.length; i++) {
2624 query.append(_ORDER_BY_ENTITY_ALIAS);
2625 query.append(orderByFields[i]);
2626
2627 if ((i + 1) < orderByFields.length) {
2628 if (orderByComparator.isAscending() ^ previous) {
2629 query.append(ORDER_BY_ASC_HAS_NEXT);
2630 }
2631 else {
2632 query.append(ORDER_BY_DESC_HAS_NEXT);
2633 }
2634 }
2635 else {
2636 if (orderByComparator.isAscending() ^ previous) {
2637 query.append(ORDER_BY_ASC);
2638 }
2639 else {
2640 query.append(ORDER_BY_DESC);
2641 }
2642 }
2643 }
2644 }
2645 else {
2646 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
2647 }
2648
2649 String sql = query.toString();
2650
2651 Query q = session.createQuery(sql);
2652
2653 q.setFirstResult(0);
2654 q.setMaxResults(2);
2655
2656 QueryPos qPos = QueryPos.getInstance(q);
2657
2658 qPos.add(companyId);
2659
2660 if (orderByComparator != null) {
2661 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
2662
2663 for (Object value : values) {
2664 qPos.add(value);
2665 }
2666 }
2667
2668 List<MBCategory> list = q.list();
2669
2670 if (list.size() == 2) {
2671 return list.get(1);
2672 }
2673 else {
2674 return null;
2675 }
2676 }
2677
2678
2683 @Override
2684 public void removeByCompanyId(long companyId) {
2685 for (MBCategory mbCategory : findByCompanyId(companyId,
2686 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2687 remove(mbCategory);
2688 }
2689 }
2690
2691
2697 @Override
2698 public int countByCompanyId(long companyId) {
2699 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2700
2701 Object[] finderArgs = new Object[] { companyId };
2702
2703 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2704 this);
2705
2706 if (count == null) {
2707 StringBundler query = new StringBundler(2);
2708
2709 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
2710
2711 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
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(companyId);
2725
2726 count = (Long)q.uniqueResult();
2727
2728 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2729 }
2730 catch (Exception e) {
2731 FinderCacheUtil.removeResult(finderPath, finderArgs);
2732
2733 throw processException(e);
2734 }
2735 finally {
2736 closeSession(session);
2737 }
2738 }
2739
2740 return count.intValue();
2741 }
2742
2743 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "mbCategory.companyId = ?";
2744 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
2745 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
2746 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
2747 new String[] {
2748 Long.class.getName(), Long.class.getName(),
2749
2750 Integer.class.getName(), Integer.class.getName(),
2751 OrderByComparator.class.getName()
2752 });
2753 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
2754 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
2755 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
2756 new String[] { Long.class.getName(), Long.class.getName() },
2757 MBCategoryModelImpl.GROUPID_COLUMN_BITMASK |
2758 MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
2759 MBCategoryModelImpl.NAME_COLUMN_BITMASK);
2760 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
2761 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2762 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
2763 new String[] { Long.class.getName(), Long.class.getName() });
2764 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
2765 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2766 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_P",
2767 new String[] { Long.class.getName(), Long.class.getName() });
2768
2769
2776 @Override
2777 public List<MBCategory> findByG_P(long groupId, long parentCategoryId) {
2778 return findByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS,
2779 QueryUtil.ALL_POS, null);
2780 }
2781
2782
2795 @Override
2796 public List<MBCategory> findByG_P(long groupId, long parentCategoryId,
2797 int start, int end) {
2798 return findByG_P(groupId, parentCategoryId, start, end, null);
2799 }
2800
2801
2815 @Override
2816 public List<MBCategory> findByG_P(long groupId, long parentCategoryId,
2817 int start, int end, OrderByComparator<MBCategory> orderByComparator) {
2818 boolean pagination = true;
2819 FinderPath finderPath = null;
2820 Object[] finderArgs = null;
2821
2822 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2823 (orderByComparator == null)) {
2824 pagination = false;
2825 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
2826 finderArgs = new Object[] { groupId, parentCategoryId };
2827 }
2828 else {
2829 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
2830 finderArgs = new Object[] {
2831 groupId, parentCategoryId,
2832
2833 start, end, orderByComparator
2834 };
2835 }
2836
2837 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
2838 finderArgs, this);
2839
2840 if ((list != null) && !list.isEmpty()) {
2841 for (MBCategory mbCategory : list) {
2842 if ((groupId != mbCategory.getGroupId()) ||
2843 (parentCategoryId != mbCategory.getParentCategoryId())) {
2844 list = null;
2845
2846 break;
2847 }
2848 }
2849 }
2850
2851 if (list == null) {
2852 StringBundler query = null;
2853
2854 if (orderByComparator != null) {
2855 query = new StringBundler(4 +
2856 (orderByComparator.getOrderByFields().length * 3));
2857 }
2858 else {
2859 query = new StringBundler(4);
2860 }
2861
2862 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
2863
2864 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2865
2866 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
2867
2868 if (orderByComparator != null) {
2869 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2870 orderByComparator);
2871 }
2872 else
2873 if (pagination) {
2874 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
2875 }
2876
2877 String sql = query.toString();
2878
2879 Session session = null;
2880
2881 try {
2882 session = openSession();
2883
2884 Query q = session.createQuery(sql);
2885
2886 QueryPos qPos = QueryPos.getInstance(q);
2887
2888 qPos.add(groupId);
2889
2890 qPos.add(parentCategoryId);
2891
2892 if (!pagination) {
2893 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
2894 start, end, false);
2895
2896 Collections.sort(list);
2897
2898 list = Collections.unmodifiableList(list);
2899 }
2900 else {
2901 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
2902 start, end);
2903 }
2904
2905 cacheResult(list);
2906
2907 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2908 }
2909 catch (Exception e) {
2910 FinderCacheUtil.removeResult(finderPath, finderArgs);
2911
2912 throw processException(e);
2913 }
2914 finally {
2915 closeSession(session);
2916 }
2917 }
2918
2919 return list;
2920 }
2921
2922
2931 @Override
2932 public MBCategory findByG_P_First(long groupId, long parentCategoryId,
2933 OrderByComparator<MBCategory> orderByComparator)
2934 throws NoSuchCategoryException {
2935 MBCategory mbCategory = fetchByG_P_First(groupId, parentCategoryId,
2936 orderByComparator);
2937
2938 if (mbCategory != null) {
2939 return mbCategory;
2940 }
2941
2942 StringBundler msg = new StringBundler(6);
2943
2944 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2945
2946 msg.append("groupId=");
2947 msg.append(groupId);
2948
2949 msg.append(", parentCategoryId=");
2950 msg.append(parentCategoryId);
2951
2952 msg.append(StringPool.CLOSE_CURLY_BRACE);
2953
2954 throw new NoSuchCategoryException(msg.toString());
2955 }
2956
2957
2965 @Override
2966 public MBCategory fetchByG_P_First(long groupId, long parentCategoryId,
2967 OrderByComparator<MBCategory> orderByComparator) {
2968 List<MBCategory> list = findByG_P(groupId, parentCategoryId, 0, 1,
2969 orderByComparator);
2970
2971 if (!list.isEmpty()) {
2972 return list.get(0);
2973 }
2974
2975 return null;
2976 }
2977
2978
2987 @Override
2988 public MBCategory findByG_P_Last(long groupId, long parentCategoryId,
2989 OrderByComparator<MBCategory> orderByComparator)
2990 throws NoSuchCategoryException {
2991 MBCategory mbCategory = fetchByG_P_Last(groupId, parentCategoryId,
2992 orderByComparator);
2993
2994 if (mbCategory != null) {
2995 return mbCategory;
2996 }
2997
2998 StringBundler msg = new StringBundler(6);
2999
3000 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3001
3002 msg.append("groupId=");
3003 msg.append(groupId);
3004
3005 msg.append(", parentCategoryId=");
3006 msg.append(parentCategoryId);
3007
3008 msg.append(StringPool.CLOSE_CURLY_BRACE);
3009
3010 throw new NoSuchCategoryException(msg.toString());
3011 }
3012
3013
3021 @Override
3022 public MBCategory fetchByG_P_Last(long groupId, long parentCategoryId,
3023 OrderByComparator<MBCategory> orderByComparator) {
3024 int count = countByG_P(groupId, parentCategoryId);
3025
3026 if (count == 0) {
3027 return null;
3028 }
3029
3030 List<MBCategory> list = findByG_P(groupId, parentCategoryId, count - 1,
3031 count, orderByComparator);
3032
3033 if (!list.isEmpty()) {
3034 return list.get(0);
3035 }
3036
3037 return null;
3038 }
3039
3040
3050 @Override
3051 public MBCategory[] findByG_P_PrevAndNext(long categoryId, long groupId,
3052 long parentCategoryId, OrderByComparator<MBCategory> orderByComparator)
3053 throws NoSuchCategoryException {
3054 MBCategory mbCategory = findByPrimaryKey(categoryId);
3055
3056 Session session = null;
3057
3058 try {
3059 session = openSession();
3060
3061 MBCategory[] array = new MBCategoryImpl[3];
3062
3063 array[0] = getByG_P_PrevAndNext(session, mbCategory, groupId,
3064 parentCategoryId, orderByComparator, true);
3065
3066 array[1] = mbCategory;
3067
3068 array[2] = getByG_P_PrevAndNext(session, mbCategory, groupId,
3069 parentCategoryId, orderByComparator, false);
3070
3071 return array;
3072 }
3073 catch (Exception e) {
3074 throw processException(e);
3075 }
3076 finally {
3077 closeSession(session);
3078 }
3079 }
3080
3081 protected MBCategory getByG_P_PrevAndNext(Session session,
3082 MBCategory mbCategory, long groupId, long parentCategoryId,
3083 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
3084 StringBundler query = null;
3085
3086 if (orderByComparator != null) {
3087 query = new StringBundler(6 +
3088 (orderByComparator.getOrderByFields().length * 6));
3089 }
3090 else {
3091 query = new StringBundler(3);
3092 }
3093
3094 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
3095
3096 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3097
3098 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
3099
3100 if (orderByComparator != null) {
3101 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3102
3103 if (orderByConditionFields.length > 0) {
3104 query.append(WHERE_AND);
3105 }
3106
3107 for (int i = 0; i < orderByConditionFields.length; i++) {
3108 query.append(_ORDER_BY_ENTITY_ALIAS);
3109 query.append(orderByConditionFields[i]);
3110
3111 if ((i + 1) < orderByConditionFields.length) {
3112 if (orderByComparator.isAscending() ^ previous) {
3113 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3114 }
3115 else {
3116 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3117 }
3118 }
3119 else {
3120 if (orderByComparator.isAscending() ^ previous) {
3121 query.append(WHERE_GREATER_THAN);
3122 }
3123 else {
3124 query.append(WHERE_LESSER_THAN);
3125 }
3126 }
3127 }
3128
3129 query.append(ORDER_BY_CLAUSE);
3130
3131 String[] orderByFields = orderByComparator.getOrderByFields();
3132
3133 for (int i = 0; i < orderByFields.length; i++) {
3134 query.append(_ORDER_BY_ENTITY_ALIAS);
3135 query.append(orderByFields[i]);
3136
3137 if ((i + 1) < orderByFields.length) {
3138 if (orderByComparator.isAscending() ^ previous) {
3139 query.append(ORDER_BY_ASC_HAS_NEXT);
3140 }
3141 else {
3142 query.append(ORDER_BY_DESC_HAS_NEXT);
3143 }
3144 }
3145 else {
3146 if (orderByComparator.isAscending() ^ previous) {
3147 query.append(ORDER_BY_ASC);
3148 }
3149 else {
3150 query.append(ORDER_BY_DESC);
3151 }
3152 }
3153 }
3154 }
3155 else {
3156 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
3157 }
3158
3159 String sql = query.toString();
3160
3161 Query q = session.createQuery(sql);
3162
3163 q.setFirstResult(0);
3164 q.setMaxResults(2);
3165
3166 QueryPos qPos = QueryPos.getInstance(q);
3167
3168 qPos.add(groupId);
3169
3170 qPos.add(parentCategoryId);
3171
3172 if (orderByComparator != null) {
3173 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
3174
3175 for (Object value : values) {
3176 qPos.add(value);
3177 }
3178 }
3179
3180 List<MBCategory> list = q.list();
3181
3182 if (list.size() == 2) {
3183 return list.get(1);
3184 }
3185 else {
3186 return null;
3187 }
3188 }
3189
3190
3197 @Override
3198 public List<MBCategory> filterFindByG_P(long groupId, long parentCategoryId) {
3199 return filterFindByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS,
3200 QueryUtil.ALL_POS, null);
3201 }
3202
3203
3216 @Override
3217 public List<MBCategory> filterFindByG_P(long groupId,
3218 long parentCategoryId, int start, int end) {
3219 return filterFindByG_P(groupId, parentCategoryId, start, end, null);
3220 }
3221
3222
3236 @Override
3237 public List<MBCategory> filterFindByG_P(long groupId,
3238 long parentCategoryId, int start, int end,
3239 OrderByComparator<MBCategory> orderByComparator) {
3240 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3241 return findByG_P(groupId, parentCategoryId, start, end,
3242 orderByComparator);
3243 }
3244
3245 StringBundler query = null;
3246
3247 if (orderByComparator != null) {
3248 query = new StringBundler(4 +
3249 (orderByComparator.getOrderByFields().length * 3));
3250 }
3251 else {
3252 query = new StringBundler(4);
3253 }
3254
3255 if (getDB().isSupportsInlineDistinct()) {
3256 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
3257 }
3258 else {
3259 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3260 }
3261
3262 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3263
3264 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
3265
3266 if (!getDB().isSupportsInlineDistinct()) {
3267 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3268 }
3269
3270 if (orderByComparator != null) {
3271 if (getDB().isSupportsInlineDistinct()) {
3272 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3273 orderByComparator, true);
3274 }
3275 else {
3276 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3277 orderByComparator, true);
3278 }
3279 }
3280 else {
3281 if (getDB().isSupportsInlineDistinct()) {
3282 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
3283 }
3284 else {
3285 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
3286 }
3287 }
3288
3289 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3290 MBCategory.class.getName(),
3291 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3292
3293 Session session = null;
3294
3295 try {
3296 session = openSession();
3297
3298 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3299
3300 if (getDB().isSupportsInlineDistinct()) {
3301 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
3302 }
3303 else {
3304 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
3305 }
3306
3307 QueryPos qPos = QueryPos.getInstance(q);
3308
3309 qPos.add(groupId);
3310
3311 qPos.add(parentCategoryId);
3312
3313 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
3314 }
3315 catch (Exception e) {
3316 throw processException(e);
3317 }
3318 finally {
3319 closeSession(session);
3320 }
3321 }
3322
3323
3333 @Override
3334 public MBCategory[] filterFindByG_P_PrevAndNext(long categoryId,
3335 long groupId, long parentCategoryId,
3336 OrderByComparator<MBCategory> orderByComparator)
3337 throws NoSuchCategoryException {
3338 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3339 return findByG_P_PrevAndNext(categoryId, groupId, parentCategoryId,
3340 orderByComparator);
3341 }
3342
3343 MBCategory mbCategory = findByPrimaryKey(categoryId);
3344
3345 Session session = null;
3346
3347 try {
3348 session = openSession();
3349
3350 MBCategory[] array = new MBCategoryImpl[3];
3351
3352 array[0] = filterGetByG_P_PrevAndNext(session, mbCategory, groupId,
3353 parentCategoryId, orderByComparator, true);
3354
3355 array[1] = mbCategory;
3356
3357 array[2] = filterGetByG_P_PrevAndNext(session, mbCategory, groupId,
3358 parentCategoryId, orderByComparator, false);
3359
3360 return array;
3361 }
3362 catch (Exception e) {
3363 throw processException(e);
3364 }
3365 finally {
3366 closeSession(session);
3367 }
3368 }
3369
3370 protected MBCategory filterGetByG_P_PrevAndNext(Session session,
3371 MBCategory mbCategory, long groupId, long parentCategoryId,
3372 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
3373 StringBundler query = null;
3374
3375 if (orderByComparator != null) {
3376 query = new StringBundler(6 +
3377 (orderByComparator.getOrderByFields().length * 6));
3378 }
3379 else {
3380 query = new StringBundler(3);
3381 }
3382
3383 if (getDB().isSupportsInlineDistinct()) {
3384 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
3385 }
3386 else {
3387 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3388 }
3389
3390 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3391
3392 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
3393
3394 if (!getDB().isSupportsInlineDistinct()) {
3395 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3396 }
3397
3398 if (orderByComparator != null) {
3399 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3400
3401 if (orderByConditionFields.length > 0) {
3402 query.append(WHERE_AND);
3403 }
3404
3405 for (int i = 0; i < orderByConditionFields.length; i++) {
3406 if (getDB().isSupportsInlineDistinct()) {
3407 query.append(_ORDER_BY_ENTITY_ALIAS);
3408 }
3409 else {
3410 query.append(_ORDER_BY_ENTITY_TABLE);
3411 }
3412
3413 query.append(orderByConditionFields[i]);
3414
3415 if ((i + 1) < orderByConditionFields.length) {
3416 if (orderByComparator.isAscending() ^ previous) {
3417 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3418 }
3419 else {
3420 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3421 }
3422 }
3423 else {
3424 if (orderByComparator.isAscending() ^ previous) {
3425 query.append(WHERE_GREATER_THAN);
3426 }
3427 else {
3428 query.append(WHERE_LESSER_THAN);
3429 }
3430 }
3431 }
3432
3433 query.append(ORDER_BY_CLAUSE);
3434
3435 String[] orderByFields = orderByComparator.getOrderByFields();
3436
3437 for (int i = 0; i < orderByFields.length; i++) {
3438 if (getDB().isSupportsInlineDistinct()) {
3439 query.append(_ORDER_BY_ENTITY_ALIAS);
3440 }
3441 else {
3442 query.append(_ORDER_BY_ENTITY_TABLE);
3443 }
3444
3445 query.append(orderByFields[i]);
3446
3447 if ((i + 1) < orderByFields.length) {
3448 if (orderByComparator.isAscending() ^ previous) {
3449 query.append(ORDER_BY_ASC_HAS_NEXT);
3450 }
3451 else {
3452 query.append(ORDER_BY_DESC_HAS_NEXT);
3453 }
3454 }
3455 else {
3456 if (orderByComparator.isAscending() ^ previous) {
3457 query.append(ORDER_BY_ASC);
3458 }
3459 else {
3460 query.append(ORDER_BY_DESC);
3461 }
3462 }
3463 }
3464 }
3465 else {
3466 if (getDB().isSupportsInlineDistinct()) {
3467 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
3468 }
3469 else {
3470 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
3471 }
3472 }
3473
3474 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3475 MBCategory.class.getName(),
3476 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3477
3478 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3479
3480 q.setFirstResult(0);
3481 q.setMaxResults(2);
3482
3483 if (getDB().isSupportsInlineDistinct()) {
3484 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
3485 }
3486 else {
3487 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
3488 }
3489
3490 QueryPos qPos = QueryPos.getInstance(q);
3491
3492 qPos.add(groupId);
3493
3494 qPos.add(parentCategoryId);
3495
3496 if (orderByComparator != null) {
3497 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
3498
3499 for (Object value : values) {
3500 qPos.add(value);
3501 }
3502 }
3503
3504 List<MBCategory> list = q.list();
3505
3506 if (list.size() == 2) {
3507 return list.get(1);
3508 }
3509 else {
3510 return null;
3511 }
3512 }
3513
3514
3521 @Override
3522 public List<MBCategory> filterFindByG_P(long groupId,
3523 long[] parentCategoryIds) {
3524 return filterFindByG_P(groupId, parentCategoryIds, QueryUtil.ALL_POS,
3525 QueryUtil.ALL_POS, null);
3526 }
3527
3528
3541 @Override
3542 public List<MBCategory> filterFindByG_P(long groupId,
3543 long[] parentCategoryIds, int start, int end) {
3544 return filterFindByG_P(groupId, parentCategoryIds, start, end, null);
3545 }
3546
3547
3561 @Override
3562 public List<MBCategory> filterFindByG_P(long groupId,
3563 long[] parentCategoryIds, int start, int end,
3564 OrderByComparator<MBCategory> orderByComparator) {
3565 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3566 return findByG_P(groupId, parentCategoryIds, start, end,
3567 orderByComparator);
3568 }
3569
3570 if (parentCategoryIds == null) {
3571 parentCategoryIds = new long[0];
3572 }
3573 else {
3574 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
3575 }
3576
3577 StringBundler query = new StringBundler();
3578
3579 if (getDB().isSupportsInlineDistinct()) {
3580 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
3581 }
3582 else {
3583 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3584 }
3585
3586 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3587
3588 if (parentCategoryIds.length > 0) {
3589 query.append(StringPool.OPEN_PARENTHESIS);
3590
3591 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_7);
3592
3593 query.append(StringUtil.merge(parentCategoryIds));
3594
3595 query.append(StringPool.CLOSE_PARENTHESIS);
3596
3597 query.append(StringPool.CLOSE_PARENTHESIS);
3598 }
3599
3600 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
3601 query.index() - 1);
3602
3603 if (!getDB().isSupportsInlineDistinct()) {
3604 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3605 }
3606
3607 if (orderByComparator != null) {
3608 if (getDB().isSupportsInlineDistinct()) {
3609 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3610 orderByComparator, true);
3611 }
3612 else {
3613 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3614 orderByComparator, true);
3615 }
3616 }
3617 else {
3618 if (getDB().isSupportsInlineDistinct()) {
3619 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
3620 }
3621 else {
3622 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
3623 }
3624 }
3625
3626 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3627 MBCategory.class.getName(),
3628 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3629
3630 Session session = null;
3631
3632 try {
3633 session = openSession();
3634
3635 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3636
3637 if (getDB().isSupportsInlineDistinct()) {
3638 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
3639 }
3640 else {
3641 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
3642 }
3643
3644 QueryPos qPos = QueryPos.getInstance(q);
3645
3646 qPos.add(groupId);
3647
3648 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
3649 }
3650 catch (Exception e) {
3651 throw processException(e);
3652 }
3653 finally {
3654 closeSession(session);
3655 }
3656 }
3657
3658
3669 @Override
3670 public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds) {
3671 return findByG_P(groupId, parentCategoryIds, QueryUtil.ALL_POS,
3672 QueryUtil.ALL_POS, null);
3673 }
3674
3675
3688 @Override
3689 public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds,
3690 int start, int end) {
3691 return findByG_P(groupId, parentCategoryIds, start, end, null);
3692 }
3693
3694
3708 @Override
3709 public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds,
3710 int start, int end, OrderByComparator<MBCategory> orderByComparator) {
3711 if (parentCategoryIds == null) {
3712 parentCategoryIds = new long[0];
3713 }
3714 else {
3715 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
3716 }
3717
3718 if (parentCategoryIds.length == 1) {
3719 return findByG_P(groupId, parentCategoryIds[0], start, end,
3720 orderByComparator);
3721 }
3722
3723 boolean pagination = true;
3724 Object[] finderArgs = null;
3725
3726 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3727 (orderByComparator == null)) {
3728 pagination = false;
3729 finderArgs = new Object[] {
3730 groupId, StringUtil.merge(parentCategoryIds)
3731 };
3732 }
3733 else {
3734 finderArgs = new Object[] {
3735 groupId, StringUtil.merge(parentCategoryIds),
3736
3737 start, end, orderByComparator
3738 };
3739 }
3740
3741 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P,
3742 finderArgs, this);
3743
3744 if ((list != null) && !list.isEmpty()) {
3745 for (MBCategory mbCategory : list) {
3746 if ((groupId != mbCategory.getGroupId()) ||
3747 !ArrayUtil.contains(parentCategoryIds,
3748 mbCategory.getParentCategoryId())) {
3749 list = null;
3750
3751 break;
3752 }
3753 }
3754 }
3755
3756 if (list == null) {
3757 StringBundler query = new StringBundler();
3758
3759 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
3760
3761 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3762
3763 if (parentCategoryIds.length > 0) {
3764 query.append(StringPool.OPEN_PARENTHESIS);
3765
3766 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_7);
3767
3768 query.append(StringUtil.merge(parentCategoryIds));
3769
3770 query.append(StringPool.CLOSE_PARENTHESIS);
3771
3772 query.append(StringPool.CLOSE_PARENTHESIS);
3773 }
3774
3775 query.setStringAt(removeConjunction(query.stringAt(query.index() -
3776 1)), query.index() - 1);
3777
3778 if (orderByComparator != null) {
3779 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3780 orderByComparator);
3781 }
3782 else
3783 if (pagination) {
3784 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
3785 }
3786
3787 String sql = query.toString();
3788
3789 Session session = null;
3790
3791 try {
3792 session = openSession();
3793
3794 Query q = session.createQuery(sql);
3795
3796 QueryPos qPos = QueryPos.getInstance(q);
3797
3798 qPos.add(groupId);
3799
3800 if (!pagination) {
3801 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
3802 start, end, false);
3803
3804 Collections.sort(list);
3805
3806 list = Collections.unmodifiableList(list);
3807 }
3808 else {
3809 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
3810 start, end);
3811 }
3812
3813 cacheResult(list);
3814
3815 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P,
3816 finderArgs, list);
3817 }
3818 catch (Exception e) {
3819 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P,
3820 finderArgs);
3821
3822 throw processException(e);
3823 }
3824 finally {
3825 closeSession(session);
3826 }
3827 }
3828
3829 return list;
3830 }
3831
3832
3838 @Override
3839 public void removeByG_P(long groupId, long parentCategoryId) {
3840 for (MBCategory mbCategory : findByG_P(groupId, parentCategoryId,
3841 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3842 remove(mbCategory);
3843 }
3844 }
3845
3846
3853 @Override
3854 public int countByG_P(long groupId, long parentCategoryId) {
3855 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P;
3856
3857 Object[] finderArgs = new Object[] { groupId, parentCategoryId };
3858
3859 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3860 this);
3861
3862 if (count == null) {
3863 StringBundler query = new StringBundler(3);
3864
3865 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
3866
3867 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3868
3869 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
3870
3871 String sql = query.toString();
3872
3873 Session session = null;
3874
3875 try {
3876 session = openSession();
3877
3878 Query q = session.createQuery(sql);
3879
3880 QueryPos qPos = QueryPos.getInstance(q);
3881
3882 qPos.add(groupId);
3883
3884 qPos.add(parentCategoryId);
3885
3886 count = (Long)q.uniqueResult();
3887
3888 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3889 }
3890 catch (Exception e) {
3891 FinderCacheUtil.removeResult(finderPath, finderArgs);
3892
3893 throw processException(e);
3894 }
3895 finally {
3896 closeSession(session);
3897 }
3898 }
3899
3900 return count.intValue();
3901 }
3902
3903
3910 @Override
3911 public int countByG_P(long groupId, long[] parentCategoryIds) {
3912 if (parentCategoryIds == null) {
3913 parentCategoryIds = new long[0];
3914 }
3915 else {
3916 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
3917 }
3918
3919 Object[] finderArgs = new Object[] {
3920 groupId, StringUtil.merge(parentCategoryIds)
3921 };
3922
3923 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P,
3924 finderArgs, this);
3925
3926 if (count == null) {
3927 StringBundler query = new StringBundler();
3928
3929 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
3930
3931 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3932
3933 if (parentCategoryIds.length > 0) {
3934 query.append(StringPool.OPEN_PARENTHESIS);
3935
3936 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_7);
3937
3938 query.append(StringUtil.merge(parentCategoryIds));
3939
3940 query.append(StringPool.CLOSE_PARENTHESIS);
3941
3942 query.append(StringPool.CLOSE_PARENTHESIS);
3943 }
3944
3945 query.setStringAt(removeConjunction(query.stringAt(query.index() -
3946 1)), query.index() - 1);
3947
3948 String sql = query.toString();
3949
3950 Session session = null;
3951
3952 try {
3953 session = openSession();
3954
3955 Query q = session.createQuery(sql);
3956
3957 QueryPos qPos = QueryPos.getInstance(q);
3958
3959 qPos.add(groupId);
3960
3961 count = (Long)q.uniqueResult();
3962
3963 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P,
3964 finderArgs, count);
3965 }
3966 catch (Exception e) {
3967 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P,
3968 finderArgs);
3969
3970 throw processException(e);
3971 }
3972 finally {
3973 closeSession(session);
3974 }
3975 }
3976
3977 return count.intValue();
3978 }
3979
3980
3987 @Override
3988 public int filterCountByG_P(long groupId, long parentCategoryId) {
3989 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3990 return countByG_P(groupId, parentCategoryId);
3991 }
3992
3993 StringBundler query = new StringBundler(3);
3994
3995 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
3996
3997 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3998
3999 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
4000
4001 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4002 MBCategory.class.getName(),
4003 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4004
4005 Session session = null;
4006
4007 try {
4008 session = openSession();
4009
4010 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4011
4012 q.addScalar(COUNT_COLUMN_NAME,
4013 com.liferay.portal.kernel.dao.orm.Type.LONG);
4014
4015 QueryPos qPos = QueryPos.getInstance(q);
4016
4017 qPos.add(groupId);
4018
4019 qPos.add(parentCategoryId);
4020
4021 Long count = (Long)q.uniqueResult();
4022
4023 return count.intValue();
4024 }
4025 catch (Exception e) {
4026 throw processException(e);
4027 }
4028 finally {
4029 closeSession(session);
4030 }
4031 }
4032
4033
4040 @Override
4041 public int filterCountByG_P(long groupId, long[] parentCategoryIds) {
4042 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4043 return countByG_P(groupId, parentCategoryIds);
4044 }
4045
4046 if (parentCategoryIds == null) {
4047 parentCategoryIds = new long[0];
4048 }
4049 else {
4050 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
4051 }
4052
4053 StringBundler query = new StringBundler();
4054
4055 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
4056
4057 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4058
4059 if (parentCategoryIds.length > 0) {
4060 query.append(StringPool.OPEN_PARENTHESIS);
4061
4062 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_7);
4063
4064 query.append(StringUtil.merge(parentCategoryIds));
4065
4066 query.append(StringPool.CLOSE_PARENTHESIS);
4067
4068 query.append(StringPool.CLOSE_PARENTHESIS);
4069 }
4070
4071 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
4072 query.index() - 1);
4073
4074 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4075 MBCategory.class.getName(),
4076 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4077
4078 Session session = null;
4079
4080 try {
4081 session = openSession();
4082
4083 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4084
4085 q.addScalar(COUNT_COLUMN_NAME,
4086 com.liferay.portal.kernel.dao.orm.Type.LONG);
4087
4088 QueryPos qPos = QueryPos.getInstance(q);
4089
4090 qPos.add(groupId);
4091
4092 Long count = (Long)q.uniqueResult();
4093
4094 return count.intValue();
4095 }
4096 catch (Exception e) {
4097 throw processException(e);
4098 }
4099 finally {
4100 closeSession(session);
4101 }
4102 }
4103
4104 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "mbCategory.groupId = ? AND ";
4105 private static final String _FINDER_COLUMN_G_P_PARENTCATEGORYID_2 = "mbCategory.parentCategoryId = ?";
4106 private static final String _FINDER_COLUMN_G_P_PARENTCATEGORYID_7 = "mbCategory.parentCategoryId IN (";
4107 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
4108 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
4109 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
4110 new String[] {
4111 Long.class.getName(), Integer.class.getName(),
4112
4113 Integer.class.getName(), Integer.class.getName(),
4114 OrderByComparator.class.getName()
4115 });
4116 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
4117 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
4118 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
4119 new String[] { Long.class.getName(), Integer.class.getName() },
4120 MBCategoryModelImpl.GROUPID_COLUMN_BITMASK |
4121 MBCategoryModelImpl.STATUS_COLUMN_BITMASK |
4122 MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
4123 MBCategoryModelImpl.NAME_COLUMN_BITMASK);
4124 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
4125 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4126 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
4127 new String[] { Long.class.getName(), Integer.class.getName() });
4128
4129
4136 @Override
4137 public List<MBCategory> findByG_S(long groupId, int status) {
4138 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4139 null);
4140 }
4141
4142
4155 @Override
4156 public List<MBCategory> findByG_S(long groupId, int status, int start,
4157 int end) {
4158 return findByG_S(groupId, status, start, end, null);
4159 }
4160
4161
4175 @Override
4176 public List<MBCategory> findByG_S(long groupId, int status, int start,
4177 int end, OrderByComparator<MBCategory> orderByComparator) {
4178 boolean pagination = true;
4179 FinderPath finderPath = null;
4180 Object[] finderArgs = null;
4181
4182 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4183 (orderByComparator == null)) {
4184 pagination = false;
4185 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4186 finderArgs = new Object[] { groupId, status };
4187 }
4188 else {
4189 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4190 finderArgs = new Object[] {
4191 groupId, status,
4192
4193 start, end, orderByComparator
4194 };
4195 }
4196
4197 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
4198 finderArgs, this);
4199
4200 if ((list != null) && !list.isEmpty()) {
4201 for (MBCategory mbCategory : list) {
4202 if ((groupId != mbCategory.getGroupId()) ||
4203 (status != mbCategory.getStatus())) {
4204 list = null;
4205
4206 break;
4207 }
4208 }
4209 }
4210
4211 if (list == null) {
4212 StringBundler query = null;
4213
4214 if (orderByComparator != null) {
4215 query = new StringBundler(4 +
4216 (orderByComparator.getOrderByFields().length * 3));
4217 }
4218 else {
4219 query = new StringBundler(4);
4220 }
4221
4222 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
4223
4224 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4225
4226 query.append(_FINDER_COLUMN_G_S_STATUS_2);
4227
4228 if (orderByComparator != null) {
4229 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4230 orderByComparator);
4231 }
4232 else
4233 if (pagination) {
4234 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
4235 }
4236
4237 String sql = query.toString();
4238
4239 Session session = null;
4240
4241 try {
4242 session = openSession();
4243
4244 Query q = session.createQuery(sql);
4245
4246 QueryPos qPos = QueryPos.getInstance(q);
4247
4248 qPos.add(groupId);
4249
4250 qPos.add(status);
4251
4252 if (!pagination) {
4253 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
4254 start, end, false);
4255
4256 Collections.sort(list);
4257
4258 list = Collections.unmodifiableList(list);
4259 }
4260 else {
4261 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
4262 start, end);
4263 }
4264
4265 cacheResult(list);
4266
4267 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4268 }
4269 catch (Exception e) {
4270 FinderCacheUtil.removeResult(finderPath, finderArgs);
4271
4272 throw processException(e);
4273 }
4274 finally {
4275 closeSession(session);
4276 }
4277 }
4278
4279 return list;
4280 }
4281
4282
4291 @Override
4292 public MBCategory findByG_S_First(long groupId, int status,
4293 OrderByComparator<MBCategory> orderByComparator)
4294 throws NoSuchCategoryException {
4295 MBCategory mbCategory = fetchByG_S_First(groupId, status,
4296 orderByComparator);
4297
4298 if (mbCategory != null) {
4299 return mbCategory;
4300 }
4301
4302 StringBundler msg = new StringBundler(6);
4303
4304 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4305
4306 msg.append("groupId=");
4307 msg.append(groupId);
4308
4309 msg.append(", status=");
4310 msg.append(status);
4311
4312 msg.append(StringPool.CLOSE_CURLY_BRACE);
4313
4314 throw new NoSuchCategoryException(msg.toString());
4315 }
4316
4317
4325 @Override
4326 public MBCategory fetchByG_S_First(long groupId, int status,
4327 OrderByComparator<MBCategory> orderByComparator) {
4328 List<MBCategory> list = findByG_S(groupId, status, 0, 1,
4329 orderByComparator);
4330
4331 if (!list.isEmpty()) {
4332 return list.get(0);
4333 }
4334
4335 return null;
4336 }
4337
4338
4347 @Override
4348 public MBCategory findByG_S_Last(long groupId, int status,
4349 OrderByComparator<MBCategory> orderByComparator)
4350 throws NoSuchCategoryException {
4351 MBCategory mbCategory = fetchByG_S_Last(groupId, status,
4352 orderByComparator);
4353
4354 if (mbCategory != null) {
4355 return mbCategory;
4356 }
4357
4358 StringBundler msg = new StringBundler(6);
4359
4360 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4361
4362 msg.append("groupId=");
4363 msg.append(groupId);
4364
4365 msg.append(", status=");
4366 msg.append(status);
4367
4368 msg.append(StringPool.CLOSE_CURLY_BRACE);
4369
4370 throw new NoSuchCategoryException(msg.toString());
4371 }
4372
4373
4381 @Override
4382 public MBCategory fetchByG_S_Last(long groupId, int status,
4383 OrderByComparator<MBCategory> orderByComparator) {
4384 int count = countByG_S(groupId, status);
4385
4386 if (count == 0) {
4387 return null;
4388 }
4389
4390 List<MBCategory> list = findByG_S(groupId, status, count - 1, count,
4391 orderByComparator);
4392
4393 if (!list.isEmpty()) {
4394 return list.get(0);
4395 }
4396
4397 return null;
4398 }
4399
4400
4410 @Override
4411 public MBCategory[] findByG_S_PrevAndNext(long categoryId, long groupId,
4412 int status, OrderByComparator<MBCategory> orderByComparator)
4413 throws NoSuchCategoryException {
4414 MBCategory mbCategory = findByPrimaryKey(categoryId);
4415
4416 Session session = null;
4417
4418 try {
4419 session = openSession();
4420
4421 MBCategory[] array = new MBCategoryImpl[3];
4422
4423 array[0] = getByG_S_PrevAndNext(session, mbCategory, groupId,
4424 status, orderByComparator, true);
4425
4426 array[1] = mbCategory;
4427
4428 array[2] = getByG_S_PrevAndNext(session, mbCategory, groupId,
4429 status, orderByComparator, false);
4430
4431 return array;
4432 }
4433 catch (Exception e) {
4434 throw processException(e);
4435 }
4436 finally {
4437 closeSession(session);
4438 }
4439 }
4440
4441 protected MBCategory getByG_S_PrevAndNext(Session session,
4442 MBCategory mbCategory, long groupId, int status,
4443 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
4444 StringBundler query = null;
4445
4446 if (orderByComparator != null) {
4447 query = new StringBundler(6 +
4448 (orderByComparator.getOrderByFields().length * 6));
4449 }
4450 else {
4451 query = new StringBundler(3);
4452 }
4453
4454 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
4455
4456 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4457
4458 query.append(_FINDER_COLUMN_G_S_STATUS_2);
4459
4460 if (orderByComparator != null) {
4461 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4462
4463 if (orderByConditionFields.length > 0) {
4464 query.append(WHERE_AND);
4465 }
4466
4467 for (int i = 0; i < orderByConditionFields.length; i++) {
4468 query.append(_ORDER_BY_ENTITY_ALIAS);
4469 query.append(orderByConditionFields[i]);
4470
4471 if ((i + 1) < orderByConditionFields.length) {
4472 if (orderByComparator.isAscending() ^ previous) {
4473 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4474 }
4475 else {
4476 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4477 }
4478 }
4479 else {
4480 if (orderByComparator.isAscending() ^ previous) {
4481 query.append(WHERE_GREATER_THAN);
4482 }
4483 else {
4484 query.append(WHERE_LESSER_THAN);
4485 }
4486 }
4487 }
4488
4489 query.append(ORDER_BY_CLAUSE);
4490
4491 String[] orderByFields = orderByComparator.getOrderByFields();
4492
4493 for (int i = 0; i < orderByFields.length; i++) {
4494 query.append(_ORDER_BY_ENTITY_ALIAS);
4495 query.append(orderByFields[i]);
4496
4497 if ((i + 1) < orderByFields.length) {
4498 if (orderByComparator.isAscending() ^ previous) {
4499 query.append(ORDER_BY_ASC_HAS_NEXT);
4500 }
4501 else {
4502 query.append(ORDER_BY_DESC_HAS_NEXT);
4503 }
4504 }
4505 else {
4506 if (orderByComparator.isAscending() ^ previous) {
4507 query.append(ORDER_BY_ASC);
4508 }
4509 else {
4510 query.append(ORDER_BY_DESC);
4511 }
4512 }
4513 }
4514 }
4515 else {
4516 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
4517 }
4518
4519 String sql = query.toString();
4520
4521 Query q = session.createQuery(sql);
4522
4523 q.setFirstResult(0);
4524 q.setMaxResults(2);
4525
4526 QueryPos qPos = QueryPos.getInstance(q);
4527
4528 qPos.add(groupId);
4529
4530 qPos.add(status);
4531
4532 if (orderByComparator != null) {
4533 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
4534
4535 for (Object value : values) {
4536 qPos.add(value);
4537 }
4538 }
4539
4540 List<MBCategory> list = q.list();
4541
4542 if (list.size() == 2) {
4543 return list.get(1);
4544 }
4545 else {
4546 return null;
4547 }
4548 }
4549
4550
4557 @Override
4558 public List<MBCategory> filterFindByG_S(long groupId, int status) {
4559 return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4560 QueryUtil.ALL_POS, null);
4561 }
4562
4563
4576 @Override
4577 public List<MBCategory> filterFindByG_S(long groupId, int status,
4578 int start, int end) {
4579 return filterFindByG_S(groupId, status, start, end, null);
4580 }
4581
4582
4596 @Override
4597 public List<MBCategory> filterFindByG_S(long groupId, int status,
4598 int start, int end, OrderByComparator<MBCategory> orderByComparator) {
4599 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4600 return findByG_S(groupId, status, start, end, orderByComparator);
4601 }
4602
4603 StringBundler query = null;
4604
4605 if (orderByComparator != null) {
4606 query = new StringBundler(4 +
4607 (orderByComparator.getOrderByFields().length * 3));
4608 }
4609 else {
4610 query = new StringBundler(4);
4611 }
4612
4613 if (getDB().isSupportsInlineDistinct()) {
4614 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
4615 }
4616 else {
4617 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4618 }
4619
4620 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4621
4622 query.append(_FINDER_COLUMN_G_S_STATUS_2);
4623
4624 if (!getDB().isSupportsInlineDistinct()) {
4625 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4626 }
4627
4628 if (orderByComparator != null) {
4629 if (getDB().isSupportsInlineDistinct()) {
4630 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4631 orderByComparator, true);
4632 }
4633 else {
4634 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4635 orderByComparator, true);
4636 }
4637 }
4638 else {
4639 if (getDB().isSupportsInlineDistinct()) {
4640 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
4641 }
4642 else {
4643 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
4644 }
4645 }
4646
4647 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4648 MBCategory.class.getName(),
4649 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4650
4651 Session session = null;
4652
4653 try {
4654 session = openSession();
4655
4656 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4657
4658 if (getDB().isSupportsInlineDistinct()) {
4659 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
4660 }
4661 else {
4662 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
4663 }
4664
4665 QueryPos qPos = QueryPos.getInstance(q);
4666
4667 qPos.add(groupId);
4668
4669 qPos.add(status);
4670
4671 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
4672 }
4673 catch (Exception e) {
4674 throw processException(e);
4675 }
4676 finally {
4677 closeSession(session);
4678 }
4679 }
4680
4681
4691 @Override
4692 public MBCategory[] filterFindByG_S_PrevAndNext(long categoryId,
4693 long groupId, int status,
4694 OrderByComparator<MBCategory> orderByComparator)
4695 throws NoSuchCategoryException {
4696 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4697 return findByG_S_PrevAndNext(categoryId, groupId, status,
4698 orderByComparator);
4699 }
4700
4701 MBCategory mbCategory = findByPrimaryKey(categoryId);
4702
4703 Session session = null;
4704
4705 try {
4706 session = openSession();
4707
4708 MBCategory[] array = new MBCategoryImpl[3];
4709
4710 array[0] = filterGetByG_S_PrevAndNext(session, mbCategory, groupId,
4711 status, orderByComparator, true);
4712
4713 array[1] = mbCategory;
4714
4715 array[2] = filterGetByG_S_PrevAndNext(session, mbCategory, groupId,
4716 status, orderByComparator, false);
4717
4718 return array;
4719 }
4720 catch (Exception e) {
4721 throw processException(e);
4722 }
4723 finally {
4724 closeSession(session);
4725 }
4726 }
4727
4728 protected MBCategory filterGetByG_S_PrevAndNext(Session session,
4729 MBCategory mbCategory, long groupId, int status,
4730 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
4731 StringBundler query = null;
4732
4733 if (orderByComparator != null) {
4734 query = new StringBundler(6 +
4735 (orderByComparator.getOrderByFields().length * 6));
4736 }
4737 else {
4738 query = new StringBundler(3);
4739 }
4740
4741 if (getDB().isSupportsInlineDistinct()) {
4742 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
4743 }
4744 else {
4745 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4746 }
4747
4748 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4749
4750 query.append(_FINDER_COLUMN_G_S_STATUS_2);
4751
4752 if (!getDB().isSupportsInlineDistinct()) {
4753 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4754 }
4755
4756 if (orderByComparator != null) {
4757 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4758
4759 if (orderByConditionFields.length > 0) {
4760 query.append(WHERE_AND);
4761 }
4762
4763 for (int i = 0; i < orderByConditionFields.length; i++) {
4764 if (getDB().isSupportsInlineDistinct()) {
4765 query.append(_ORDER_BY_ENTITY_ALIAS);
4766 }
4767 else {
4768 query.append(_ORDER_BY_ENTITY_TABLE);
4769 }
4770
4771 query.append(orderByConditionFields[i]);
4772
4773 if ((i + 1) < orderByConditionFields.length) {
4774 if (orderByComparator.isAscending() ^ previous) {
4775 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4776 }
4777 else {
4778 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4779 }
4780 }
4781 else {
4782 if (orderByComparator.isAscending() ^ previous) {
4783 query.append(WHERE_GREATER_THAN);
4784 }
4785 else {
4786 query.append(WHERE_LESSER_THAN);
4787 }
4788 }
4789 }
4790
4791 query.append(ORDER_BY_CLAUSE);
4792
4793 String[] orderByFields = orderByComparator.getOrderByFields();
4794
4795 for (int i = 0; i < orderByFields.length; i++) {
4796 if (getDB().isSupportsInlineDistinct()) {
4797 query.append(_ORDER_BY_ENTITY_ALIAS);
4798 }
4799 else {
4800 query.append(_ORDER_BY_ENTITY_TABLE);
4801 }
4802
4803 query.append(orderByFields[i]);
4804
4805 if ((i + 1) < orderByFields.length) {
4806 if (orderByComparator.isAscending() ^ previous) {
4807 query.append(ORDER_BY_ASC_HAS_NEXT);
4808 }
4809 else {
4810 query.append(ORDER_BY_DESC_HAS_NEXT);
4811 }
4812 }
4813 else {
4814 if (orderByComparator.isAscending() ^ previous) {
4815 query.append(ORDER_BY_ASC);
4816 }
4817 else {
4818 query.append(ORDER_BY_DESC);
4819 }
4820 }
4821 }
4822 }
4823 else {
4824 if (getDB().isSupportsInlineDistinct()) {
4825 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
4826 }
4827 else {
4828 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
4829 }
4830 }
4831
4832 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4833 MBCategory.class.getName(),
4834 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4835
4836 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4837
4838 q.setFirstResult(0);
4839 q.setMaxResults(2);
4840
4841 if (getDB().isSupportsInlineDistinct()) {
4842 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
4843 }
4844 else {
4845 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
4846 }
4847
4848 QueryPos qPos = QueryPos.getInstance(q);
4849
4850 qPos.add(groupId);
4851
4852 qPos.add(status);
4853
4854 if (orderByComparator != null) {
4855 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
4856
4857 for (Object value : values) {
4858 qPos.add(value);
4859 }
4860 }
4861
4862 List<MBCategory> list = q.list();
4863
4864 if (list.size() == 2) {
4865 return list.get(1);
4866 }
4867 else {
4868 return null;
4869 }
4870 }
4871
4872
4878 @Override
4879 public void removeByG_S(long groupId, int status) {
4880 for (MBCategory mbCategory : findByG_S(groupId, status,
4881 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4882 remove(mbCategory);
4883 }
4884 }
4885
4886
4893 @Override
4894 public int countByG_S(long groupId, int status) {
4895 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4896
4897 Object[] finderArgs = new Object[] { groupId, status };
4898
4899 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4900 this);
4901
4902 if (count == null) {
4903 StringBundler query = new StringBundler(3);
4904
4905 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
4906
4907 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4908
4909 query.append(_FINDER_COLUMN_G_S_STATUS_2);
4910
4911 String sql = query.toString();
4912
4913 Session session = null;
4914
4915 try {
4916 session = openSession();
4917
4918 Query q = session.createQuery(sql);
4919
4920 QueryPos qPos = QueryPos.getInstance(q);
4921
4922 qPos.add(groupId);
4923
4924 qPos.add(status);
4925
4926 count = (Long)q.uniqueResult();
4927
4928 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4929 }
4930 catch (Exception e) {
4931 FinderCacheUtil.removeResult(finderPath, finderArgs);
4932
4933 throw processException(e);
4934 }
4935 finally {
4936 closeSession(session);
4937 }
4938 }
4939
4940 return count.intValue();
4941 }
4942
4943
4950 @Override
4951 public int filterCountByG_S(long groupId, int status) {
4952 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4953 return countByG_S(groupId, status);
4954 }
4955
4956 StringBundler query = new StringBundler(3);
4957
4958 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
4959
4960 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4961
4962 query.append(_FINDER_COLUMN_G_S_STATUS_2);
4963
4964 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4965 MBCategory.class.getName(),
4966 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4967
4968 Session session = null;
4969
4970 try {
4971 session = openSession();
4972
4973 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4974
4975 q.addScalar(COUNT_COLUMN_NAME,
4976 com.liferay.portal.kernel.dao.orm.Type.LONG);
4977
4978 QueryPos qPos = QueryPos.getInstance(q);
4979
4980 qPos.add(groupId);
4981
4982 qPos.add(status);
4983
4984 Long count = (Long)q.uniqueResult();
4985
4986 return count.intValue();
4987 }
4988 catch (Exception e) {
4989 throw processException(e);
4990 }
4991 finally {
4992 closeSession(session);
4993 }
4994 }
4995
4996 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "mbCategory.groupId = ? AND ";
4997 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbCategory.status = ?";
4998 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
4999 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
5000 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
5001 new String[] {
5002 Long.class.getName(), Integer.class.getName(),
5003
5004 Integer.class.getName(), Integer.class.getName(),
5005 OrderByComparator.class.getName()
5006 });
5007 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
5008 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
5009 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
5010 new String[] { Long.class.getName(), Integer.class.getName() },
5011 MBCategoryModelImpl.COMPANYID_COLUMN_BITMASK |
5012 MBCategoryModelImpl.STATUS_COLUMN_BITMASK |
5013 MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
5014 MBCategoryModelImpl.NAME_COLUMN_BITMASK);
5015 public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
5016 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5017 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
5018 new String[] { Long.class.getName(), Integer.class.getName() });
5019
5020
5027 @Override
5028 public List<MBCategory> findByC_S(long companyId, int status) {
5029 return findByC_S(companyId, status, QueryUtil.ALL_POS,
5030 QueryUtil.ALL_POS, null);
5031 }
5032
5033
5046 @Override
5047 public List<MBCategory> findByC_S(long companyId, int status, int start,
5048 int end) {
5049 return findByC_S(companyId, status, start, end, null);
5050 }
5051
5052
5066 @Override
5067 public List<MBCategory> findByC_S(long companyId, int status, int start,
5068 int end, OrderByComparator<MBCategory> orderByComparator) {
5069 boolean pagination = true;
5070 FinderPath finderPath = null;
5071 Object[] finderArgs = null;
5072
5073 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5074 (orderByComparator == null)) {
5075 pagination = false;
5076 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
5077 finderArgs = new Object[] { companyId, status };
5078 }
5079 else {
5080 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
5081 finderArgs = new Object[] {
5082 companyId, status,
5083
5084 start, end, orderByComparator
5085 };
5086 }
5087
5088 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
5089 finderArgs, this);
5090
5091 if ((list != null) && !list.isEmpty()) {
5092 for (MBCategory mbCategory : list) {
5093 if ((companyId != mbCategory.getCompanyId()) ||
5094 (status != mbCategory.getStatus())) {
5095 list = null;
5096
5097 break;
5098 }
5099 }
5100 }
5101
5102 if (list == null) {
5103 StringBundler query = null;
5104
5105 if (orderByComparator != null) {
5106 query = new StringBundler(4 +
5107 (orderByComparator.getOrderByFields().length * 3));
5108 }
5109 else {
5110 query = new StringBundler(4);
5111 }
5112
5113 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
5114
5115 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
5116
5117 query.append(_FINDER_COLUMN_C_S_STATUS_2);
5118
5119 if (orderByComparator != null) {
5120 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5121 orderByComparator);
5122 }
5123 else
5124 if (pagination) {
5125 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
5126 }
5127
5128 String sql = query.toString();
5129
5130 Session session = null;
5131
5132 try {
5133 session = openSession();
5134
5135 Query q = session.createQuery(sql);
5136
5137 QueryPos qPos = QueryPos.getInstance(q);
5138
5139 qPos.add(companyId);
5140
5141 qPos.add(status);
5142
5143 if (!pagination) {
5144 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
5145 start, end, false);
5146
5147 Collections.sort(list);
5148
5149 list = Collections.unmodifiableList(list);
5150 }
5151 else {
5152 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
5153 start, end);
5154 }
5155
5156 cacheResult(list);
5157
5158 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5159 }
5160 catch (Exception e) {
5161 FinderCacheUtil.removeResult(finderPath, finderArgs);
5162
5163 throw processException(e);
5164 }
5165 finally {
5166 closeSession(session);
5167 }
5168 }
5169
5170 return list;
5171 }
5172
5173
5182 @Override
5183 public MBCategory findByC_S_First(long companyId, int status,
5184 OrderByComparator<MBCategory> orderByComparator)
5185 throws NoSuchCategoryException {
5186 MBCategory mbCategory = fetchByC_S_First(companyId, status,
5187 orderByComparator);
5188
5189 if (mbCategory != null) {
5190 return mbCategory;
5191 }
5192
5193 StringBundler msg = new StringBundler(6);
5194
5195 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5196
5197 msg.append("companyId=");
5198 msg.append(companyId);
5199
5200 msg.append(", status=");
5201 msg.append(status);
5202
5203 msg.append(StringPool.CLOSE_CURLY_BRACE);
5204
5205 throw new NoSuchCategoryException(msg.toString());
5206 }
5207
5208
5216 @Override
5217 public MBCategory fetchByC_S_First(long companyId, int status,
5218 OrderByComparator<MBCategory> orderByComparator) {
5219 List<MBCategory> list = findByC_S(companyId, status, 0, 1,
5220 orderByComparator);
5221
5222 if (!list.isEmpty()) {
5223 return list.get(0);
5224 }
5225
5226 return null;
5227 }
5228
5229
5238 @Override
5239 public MBCategory findByC_S_Last(long companyId, int status,
5240 OrderByComparator<MBCategory> orderByComparator)
5241 throws NoSuchCategoryException {
5242 MBCategory mbCategory = fetchByC_S_Last(companyId, status,
5243 orderByComparator);
5244
5245 if (mbCategory != null) {
5246 return mbCategory;
5247 }
5248
5249 StringBundler msg = new StringBundler(6);
5250
5251 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5252
5253 msg.append("companyId=");
5254 msg.append(companyId);
5255
5256 msg.append(", status=");
5257 msg.append(status);
5258
5259 msg.append(StringPool.CLOSE_CURLY_BRACE);
5260
5261 throw new NoSuchCategoryException(msg.toString());
5262 }
5263
5264
5272 @Override
5273 public MBCategory fetchByC_S_Last(long companyId, int status,
5274 OrderByComparator<MBCategory> orderByComparator) {
5275 int count = countByC_S(companyId, status);
5276
5277 if (count == 0) {
5278 return null;
5279 }
5280
5281 List<MBCategory> list = findByC_S(companyId, status, count - 1, count,
5282 orderByComparator);
5283
5284 if (!list.isEmpty()) {
5285 return list.get(0);
5286 }
5287
5288 return null;
5289 }
5290
5291
5301 @Override
5302 public MBCategory[] findByC_S_PrevAndNext(long categoryId, long companyId,
5303 int status, OrderByComparator<MBCategory> orderByComparator)
5304 throws NoSuchCategoryException {
5305 MBCategory mbCategory = findByPrimaryKey(categoryId);
5306
5307 Session session = null;
5308
5309 try {
5310 session = openSession();
5311
5312 MBCategory[] array = new MBCategoryImpl[3];
5313
5314 array[0] = getByC_S_PrevAndNext(session, mbCategory, companyId,
5315 status, orderByComparator, true);
5316
5317 array[1] = mbCategory;
5318
5319 array[2] = getByC_S_PrevAndNext(session, mbCategory, companyId,
5320 status, orderByComparator, false);
5321
5322 return array;
5323 }
5324 catch (Exception e) {
5325 throw processException(e);
5326 }
5327 finally {
5328 closeSession(session);
5329 }
5330 }
5331
5332 protected MBCategory getByC_S_PrevAndNext(Session session,
5333 MBCategory mbCategory, long companyId, int status,
5334 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
5335 StringBundler query = null;
5336
5337 if (orderByComparator != null) {
5338 query = new StringBundler(6 +
5339 (orderByComparator.getOrderByFields().length * 6));
5340 }
5341 else {
5342 query = new StringBundler(3);
5343 }
5344
5345 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
5346
5347 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
5348
5349 query.append(_FINDER_COLUMN_C_S_STATUS_2);
5350
5351 if (orderByComparator != null) {
5352 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5353
5354 if (orderByConditionFields.length > 0) {
5355 query.append(WHERE_AND);
5356 }
5357
5358 for (int i = 0; i < orderByConditionFields.length; i++) {
5359 query.append(_ORDER_BY_ENTITY_ALIAS);
5360 query.append(orderByConditionFields[i]);
5361
5362 if ((i + 1) < orderByConditionFields.length) {
5363 if (orderByComparator.isAscending() ^ previous) {
5364 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5365 }
5366 else {
5367 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5368 }
5369 }
5370 else {
5371 if (orderByComparator.isAscending() ^ previous) {
5372 query.append(WHERE_GREATER_THAN);
5373 }
5374 else {
5375 query.append(WHERE_LESSER_THAN);
5376 }
5377 }
5378 }
5379
5380 query.append(ORDER_BY_CLAUSE);
5381
5382 String[] orderByFields = orderByComparator.getOrderByFields();
5383
5384 for (int i = 0; i < orderByFields.length; i++) {
5385 query.append(_ORDER_BY_ENTITY_ALIAS);
5386 query.append(orderByFields[i]);
5387
5388 if ((i + 1) < orderByFields.length) {
5389 if (orderByComparator.isAscending() ^ previous) {
5390 query.append(ORDER_BY_ASC_HAS_NEXT);
5391 }
5392 else {
5393 query.append(ORDER_BY_DESC_HAS_NEXT);
5394 }
5395 }
5396 else {
5397 if (orderByComparator.isAscending() ^ previous) {
5398 query.append(ORDER_BY_ASC);
5399 }
5400 else {
5401 query.append(ORDER_BY_DESC);
5402 }
5403 }
5404 }
5405 }
5406 else {
5407 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
5408 }
5409
5410 String sql = query.toString();
5411
5412 Query q = session.createQuery(sql);
5413
5414 q.setFirstResult(0);
5415 q.setMaxResults(2);
5416
5417 QueryPos qPos = QueryPos.getInstance(q);
5418
5419 qPos.add(companyId);
5420
5421 qPos.add(status);
5422
5423 if (orderByComparator != null) {
5424 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
5425
5426 for (Object value : values) {
5427 qPos.add(value);
5428 }
5429 }
5430
5431 List<MBCategory> list = q.list();
5432
5433 if (list.size() == 2) {
5434 return list.get(1);
5435 }
5436 else {
5437 return null;
5438 }
5439 }
5440
5441
5447 @Override
5448 public void removeByC_S(long companyId, int status) {
5449 for (MBCategory mbCategory : findByC_S(companyId, status,
5450 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5451 remove(mbCategory);
5452 }
5453 }
5454
5455
5462 @Override
5463 public int countByC_S(long companyId, int status) {
5464 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
5465
5466 Object[] finderArgs = new Object[] { companyId, status };
5467
5468 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5469 this);
5470
5471 if (count == null) {
5472 StringBundler query = new StringBundler(3);
5473
5474 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
5475
5476 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
5477
5478 query.append(_FINDER_COLUMN_C_S_STATUS_2);
5479
5480 String sql = query.toString();
5481
5482 Session session = null;
5483
5484 try {
5485 session = openSession();
5486
5487 Query q = session.createQuery(sql);
5488
5489 QueryPos qPos = QueryPos.getInstance(q);
5490
5491 qPos.add(companyId);
5492
5493 qPos.add(status);
5494
5495 count = (Long)q.uniqueResult();
5496
5497 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5498 }
5499 catch (Exception e) {
5500 FinderCacheUtil.removeResult(finderPath, finderArgs);
5501
5502 throw processException(e);
5503 }
5504 finally {
5505 closeSession(session);
5506 }
5507 }
5508
5509 return count.intValue();
5510 }
5511
5512 private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "mbCategory.companyId = ? AND ";
5513 private static final String _FINDER_COLUMN_C_S_STATUS_2 = "mbCategory.status = ?";
5514 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
5515 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
5516 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByNotC_G_P",
5517 new String[] {
5518 Long.class.getName(), Long.class.getName(), Long.class.getName(),
5519
5520 Integer.class.getName(), Integer.class.getName(),
5521 OrderByComparator.class.getName()
5522 });
5523 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P =
5524 new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
5525 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5526 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByNotC_G_P",
5527 new String[] {
5528 Long.class.getName(), Long.class.getName(), Long.class.getName()
5529 });
5530
5531
5539 @Override
5540 public List<MBCategory> findByNotC_G_P(long categoryId, long groupId,
5541 long parentCategoryId) {
5542 return findByNotC_G_P(categoryId, groupId, parentCategoryId,
5543 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5544 }
5545
5546
5560 @Override
5561 public List<MBCategory> findByNotC_G_P(long categoryId, long groupId,
5562 long parentCategoryId, int start, int end) {
5563 return findByNotC_G_P(categoryId, groupId, parentCategoryId, start,
5564 end, null);
5565 }
5566
5567
5582 @Override
5583 public List<MBCategory> findByNotC_G_P(long categoryId, long groupId,
5584 long parentCategoryId, int start, int end,
5585 OrderByComparator<MBCategory> orderByComparator) {
5586 boolean pagination = true;
5587 FinderPath finderPath = null;
5588 Object[] finderArgs = null;
5589
5590 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P;
5591 finderArgs = new Object[] {
5592 categoryId, groupId, parentCategoryId,
5593
5594 start, end, orderByComparator
5595 };
5596
5597 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
5598 finderArgs, this);
5599
5600 if ((list != null) && !list.isEmpty()) {
5601 for (MBCategory mbCategory : list) {
5602 if ((categoryId == mbCategory.getCategoryId()) ||
5603 (groupId != mbCategory.getGroupId()) ||
5604 (parentCategoryId != mbCategory.getParentCategoryId())) {
5605 list = null;
5606
5607 break;
5608 }
5609 }
5610 }
5611
5612 if (list == null) {
5613 StringBundler query = null;
5614
5615 if (orderByComparator != null) {
5616 query = new StringBundler(5 +
5617 (orderByComparator.getOrderByFields().length * 3));
5618 }
5619 else {
5620 query = new StringBundler(5);
5621 }
5622
5623 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
5624
5625 query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_2);
5626
5627 query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2);
5628
5629 query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_2);
5630
5631 if (orderByComparator != null) {
5632 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5633 orderByComparator);
5634 }
5635 else
5636 if (pagination) {
5637 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
5638 }
5639
5640 String sql = query.toString();
5641
5642 Session session = null;
5643
5644 try {
5645 session = openSession();
5646
5647 Query q = session.createQuery(sql);
5648
5649 QueryPos qPos = QueryPos.getInstance(q);
5650
5651 qPos.add(categoryId);
5652
5653 qPos.add(groupId);
5654
5655 qPos.add(parentCategoryId);
5656
5657 if (!pagination) {
5658 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
5659 start, end, false);
5660
5661 Collections.sort(list);
5662
5663 list = Collections.unmodifiableList(list);
5664 }
5665 else {
5666 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
5667 start, end);
5668 }
5669
5670 cacheResult(list);
5671
5672 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5673 }
5674 catch (Exception e) {
5675 FinderCacheUtil.removeResult(finderPath, finderArgs);
5676
5677 throw processException(e);
5678 }
5679 finally {
5680 closeSession(session);
5681 }
5682 }
5683
5684 return list;
5685 }
5686
5687
5697 @Override
5698 public MBCategory findByNotC_G_P_First(long categoryId, long groupId,
5699 long parentCategoryId, OrderByComparator<MBCategory> orderByComparator)
5700 throws NoSuchCategoryException {
5701 MBCategory mbCategory = fetchByNotC_G_P_First(categoryId, groupId,
5702 parentCategoryId, orderByComparator);
5703
5704 if (mbCategory != null) {
5705 return mbCategory;
5706 }
5707
5708 StringBundler msg = new StringBundler(8);
5709
5710 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5711
5712 msg.append("categoryId=");
5713 msg.append(categoryId);
5714
5715 msg.append(", groupId=");
5716 msg.append(groupId);
5717
5718 msg.append(", parentCategoryId=");
5719 msg.append(parentCategoryId);
5720
5721 msg.append(StringPool.CLOSE_CURLY_BRACE);
5722
5723 throw new NoSuchCategoryException(msg.toString());
5724 }
5725
5726
5735 @Override
5736 public MBCategory fetchByNotC_G_P_First(long categoryId, long groupId,
5737 long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) {
5738 List<MBCategory> list = findByNotC_G_P(categoryId, groupId,
5739 parentCategoryId, 0, 1, orderByComparator);
5740
5741 if (!list.isEmpty()) {
5742 return list.get(0);
5743 }
5744
5745 return null;
5746 }
5747
5748
5758 @Override
5759 public MBCategory findByNotC_G_P_Last(long categoryId, long groupId,
5760 long parentCategoryId, OrderByComparator<MBCategory> orderByComparator)
5761 throws NoSuchCategoryException {
5762 MBCategory mbCategory = fetchByNotC_G_P_Last(categoryId, groupId,
5763 parentCategoryId, orderByComparator);
5764
5765 if (mbCategory != null) {
5766 return mbCategory;
5767 }
5768
5769 StringBundler msg = new StringBundler(8);
5770
5771 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5772
5773 msg.append("categoryId=");
5774 msg.append(categoryId);
5775
5776 msg.append(", groupId=");
5777 msg.append(groupId);
5778
5779 msg.append(", parentCategoryId=");
5780 msg.append(parentCategoryId);
5781
5782 msg.append(StringPool.CLOSE_CURLY_BRACE);
5783
5784 throw new NoSuchCategoryException(msg.toString());
5785 }
5786
5787
5796 @Override
5797 public MBCategory fetchByNotC_G_P_Last(long categoryId, long groupId,
5798 long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) {
5799 int count = countByNotC_G_P(categoryId, groupId, parentCategoryId);
5800
5801 if (count == 0) {
5802 return null;
5803 }
5804
5805 List<MBCategory> list = findByNotC_G_P(categoryId, groupId,
5806 parentCategoryId, count - 1, count, orderByComparator);
5807
5808 if (!list.isEmpty()) {
5809 return list.get(0);
5810 }
5811
5812 return null;
5813 }
5814
5815
5823 @Override
5824 public List<MBCategory> filterFindByNotC_G_P(long categoryId, long groupId,
5825 long parentCategoryId) {
5826 return filterFindByNotC_G_P(categoryId, groupId, parentCategoryId,
5827 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5828 }
5829
5830
5844 @Override
5845 public List<MBCategory> filterFindByNotC_G_P(long categoryId, long groupId,
5846 long parentCategoryId, int start, int end) {
5847 return filterFindByNotC_G_P(categoryId, groupId, parentCategoryId,
5848 start, end, null);
5849 }
5850
5851
5866 @Override
5867 public List<MBCategory> filterFindByNotC_G_P(long categoryId, long groupId,
5868 long parentCategoryId, int start, int end,
5869 OrderByComparator<MBCategory> orderByComparator) {
5870 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5871 return findByNotC_G_P(categoryId, groupId, parentCategoryId, start,
5872 end, orderByComparator);
5873 }
5874
5875 StringBundler query = null;
5876
5877 if (orderByComparator != null) {
5878 query = new StringBundler(5 +
5879 (orderByComparator.getOrderByFields().length * 3));
5880 }
5881 else {
5882 query = new StringBundler(5);
5883 }
5884
5885 if (getDB().isSupportsInlineDistinct()) {
5886 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
5887 }
5888 else {
5889 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
5890 }
5891
5892 query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_2);
5893
5894 query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2);
5895
5896 query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_2);
5897
5898 if (!getDB().isSupportsInlineDistinct()) {
5899 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
5900 }
5901
5902 if (orderByComparator != null) {
5903 if (getDB().isSupportsInlineDistinct()) {
5904 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5905 orderByComparator, true);
5906 }
5907 else {
5908 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5909 orderByComparator, true);
5910 }
5911 }
5912 else {
5913 if (getDB().isSupportsInlineDistinct()) {
5914 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
5915 }
5916 else {
5917 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
5918 }
5919 }
5920
5921 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5922 MBCategory.class.getName(),
5923 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5924
5925 Session session = null;
5926
5927 try {
5928 session = openSession();
5929
5930 SQLQuery q = session.createSynchronizedSQLQuery(sql);
5931
5932 if (getDB().isSupportsInlineDistinct()) {
5933 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
5934 }
5935 else {
5936 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
5937 }
5938
5939 QueryPos qPos = QueryPos.getInstance(q);
5940
5941 qPos.add(categoryId);
5942
5943 qPos.add(groupId);
5944
5945 qPos.add(parentCategoryId);
5946
5947 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
5948 }
5949 catch (Exception e) {
5950 throw processException(e);
5951 }
5952 finally {
5953 closeSession(session);
5954 }
5955 }
5956
5957
5965 @Override
5966 public List<MBCategory> filterFindByNotC_G_P(long[] categoryIds,
5967 long groupId, long[] parentCategoryIds) {
5968 return filterFindByNotC_G_P(categoryIds, groupId, parentCategoryIds,
5969 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5970 }
5971
5972
5986 @Override
5987 public List<MBCategory> filterFindByNotC_G_P(long[] categoryIds,
5988 long groupId, long[] parentCategoryIds, int start, int end) {
5989 return filterFindByNotC_G_P(categoryIds, groupId, parentCategoryIds,
5990 start, end, null);
5991 }
5992
5993
6008 @Override
6009 public List<MBCategory> filterFindByNotC_G_P(long[] categoryIds,
6010 long groupId, long[] parentCategoryIds, int start, int end,
6011 OrderByComparator<MBCategory> orderByComparator) {
6012 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6013 return findByNotC_G_P(categoryIds, groupId, parentCategoryIds,
6014 start, end, orderByComparator);
6015 }
6016
6017 if (categoryIds == null) {
6018 categoryIds = new long[0];
6019 }
6020 else {
6021 categoryIds = ArrayUtil.unique(categoryIds);
6022 }
6023
6024 if (parentCategoryIds == null) {
6025 parentCategoryIds = new long[0];
6026 }
6027 else {
6028 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
6029 }
6030
6031 StringBundler query = new StringBundler();
6032
6033 if (getDB().isSupportsInlineDistinct()) {
6034 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
6035 }
6036 else {
6037 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6038 }
6039
6040 if (categoryIds.length > 0) {
6041 query.append(StringPool.OPEN_PARENTHESIS);
6042
6043 query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_7);
6044
6045 query.append(StringUtil.merge(categoryIds));
6046
6047 query.append(StringPool.CLOSE_PARENTHESIS);
6048
6049 query.append(StringPool.CLOSE_PARENTHESIS);
6050
6051 query.append(WHERE_AND);
6052 }
6053
6054 query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2);
6055
6056 if (parentCategoryIds.length > 0) {
6057 query.append(StringPool.OPEN_PARENTHESIS);
6058
6059 query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_7);
6060
6061 query.append(StringUtil.merge(parentCategoryIds));
6062
6063 query.append(StringPool.CLOSE_PARENTHESIS);
6064
6065 query.append(StringPool.CLOSE_PARENTHESIS);
6066 }
6067
6068 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
6069 query.index() - 1);
6070
6071 if (!getDB().isSupportsInlineDistinct()) {
6072 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6073 }
6074
6075 if (orderByComparator != null) {
6076 if (getDB().isSupportsInlineDistinct()) {
6077 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6078 orderByComparator, true);
6079 }
6080 else {
6081 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6082 orderByComparator, true);
6083 }
6084 }
6085 else {
6086 if (getDB().isSupportsInlineDistinct()) {
6087 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
6088 }
6089 else {
6090 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
6091 }
6092 }
6093
6094 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6095 MBCategory.class.getName(),
6096 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6097
6098 Session session = null;
6099
6100 try {
6101 session = openSession();
6102
6103 SQLQuery q = session.createSynchronizedSQLQuery(sql);
6104
6105 if (getDB().isSupportsInlineDistinct()) {
6106 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
6107 }
6108 else {
6109 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
6110 }
6111
6112 QueryPos qPos = QueryPos.getInstance(q);
6113
6114 qPos.add(groupId);
6115
6116 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
6117 }
6118 catch (Exception e) {
6119 throw processException(e);
6120 }
6121 finally {
6122 closeSession(session);
6123 }
6124 }
6125
6126
6138 @Override
6139 public List<MBCategory> findByNotC_G_P(long[] categoryIds, long groupId,
6140 long[] parentCategoryIds) {
6141 return findByNotC_G_P(categoryIds, groupId, parentCategoryIds,
6142 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6143 }
6144
6145
6159 @Override
6160 public List<MBCategory> findByNotC_G_P(long[] categoryIds, long groupId,
6161 long[] parentCategoryIds, int start, int end) {
6162 return findByNotC_G_P(categoryIds, groupId, parentCategoryIds, start,
6163 end, null);
6164 }
6165
6166
6181 @Override
6182 public List<MBCategory> findByNotC_G_P(long[] categoryIds, long groupId,
6183 long[] parentCategoryIds, int start, int end,
6184 OrderByComparator<MBCategory> orderByComparator) {
6185 if (categoryIds == null) {
6186 categoryIds = new long[0];
6187 }
6188 else {
6189 categoryIds = ArrayUtil.unique(categoryIds);
6190 }
6191
6192 if (parentCategoryIds == null) {
6193 parentCategoryIds = new long[0];
6194 }
6195 else {
6196 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
6197 }
6198
6199 if ((categoryIds.length == 1) && (parentCategoryIds.length == 1)) {
6200 return findByNotC_G_P(categoryIds[0], groupId,
6201 parentCategoryIds[0], start, end, orderByComparator);
6202 }
6203
6204 boolean pagination = true;
6205 Object[] finderArgs = null;
6206
6207 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6208 (orderByComparator == null)) {
6209 pagination = false;
6210 finderArgs = new Object[] {
6211 StringUtil.merge(categoryIds), groupId,
6212 StringUtil.merge(parentCategoryIds)
6213 };
6214 }
6215 else {
6216 finderArgs = new Object[] {
6217 StringUtil.merge(categoryIds), groupId,
6218 StringUtil.merge(parentCategoryIds),
6219
6220 start, end, orderByComparator
6221 };
6222 }
6223
6224 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P,
6225 finderArgs, this);
6226
6227 if ((list != null) && !list.isEmpty()) {
6228 for (MBCategory mbCategory : list) {
6229 if (!ArrayUtil.contains(categoryIds, mbCategory.getCategoryId()) ||
6230 (groupId != mbCategory.getGroupId()) ||
6231 !ArrayUtil.contains(parentCategoryIds,
6232 mbCategory.getParentCategoryId())) {
6233 list = null;
6234
6235 break;
6236 }
6237 }
6238 }
6239
6240 if (list == null) {
6241 StringBundler query = new StringBundler();
6242
6243 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
6244
6245 if (categoryIds.length > 0) {
6246 query.append(StringPool.OPEN_PARENTHESIS);
6247
6248 query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_7);
6249
6250 query.append(StringUtil.merge(categoryIds));
6251
6252 query.append(StringPool.CLOSE_PARENTHESIS);
6253
6254 query.append(StringPool.CLOSE_PARENTHESIS);
6255
6256 query.append(WHERE_AND);
6257 }
6258
6259 query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2);
6260
6261 if (parentCategoryIds.length > 0) {
6262 query.append(StringPool.OPEN_PARENTHESIS);
6263
6264 query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_7);
6265
6266 query.append(StringUtil.merge(parentCategoryIds));
6267
6268 query.append(StringPool.CLOSE_PARENTHESIS);
6269
6270 query.append(StringPool.CLOSE_PARENTHESIS);
6271 }
6272
6273 query.setStringAt(removeConjunction(query.stringAt(query.index() -
6274 1)), query.index() - 1);
6275
6276 if (orderByComparator != null) {
6277 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6278 orderByComparator);
6279 }
6280 else
6281 if (pagination) {
6282 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
6283 }
6284
6285 String sql = query.toString();
6286
6287 Session session = null;
6288
6289 try {
6290 session = openSession();
6291
6292 Query q = session.createQuery(sql);
6293
6294 QueryPos qPos = QueryPos.getInstance(q);
6295
6296 qPos.add(groupId);
6297
6298 if (!pagination) {
6299 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
6300 start, end, false);
6301
6302 Collections.sort(list);
6303
6304 list = Collections.unmodifiableList(list);
6305 }
6306 else {
6307 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
6308 start, end);
6309 }
6310
6311 cacheResult(list);
6312
6313 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P,
6314 finderArgs, list);
6315 }
6316 catch (Exception e) {
6317 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P,
6318 finderArgs);
6319
6320 throw processException(e);
6321 }
6322 finally {
6323 closeSession(session);
6324 }
6325 }
6326
6327 return list;
6328 }
6329
6330
6337 @Override
6338 public void removeByNotC_G_P(long categoryId, long groupId,
6339 long parentCategoryId) {
6340 for (MBCategory mbCategory : findByNotC_G_P(categoryId, groupId,
6341 parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6342 remove(mbCategory);
6343 }
6344 }
6345
6346
6354 @Override
6355 public int countByNotC_G_P(long categoryId, long groupId,
6356 long parentCategoryId) {
6357 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P;
6358
6359 Object[] finderArgs = new Object[] { categoryId, groupId, parentCategoryId };
6360
6361 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6362 this);
6363
6364 if (count == null) {
6365 StringBundler query = new StringBundler(4);
6366
6367 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
6368
6369 query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_2);
6370
6371 query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2);
6372
6373 query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_2);
6374
6375 String sql = query.toString();
6376
6377 Session session = null;
6378
6379 try {
6380 session = openSession();
6381
6382 Query q = session.createQuery(sql);
6383
6384 QueryPos qPos = QueryPos.getInstance(q);
6385
6386 qPos.add(categoryId);
6387
6388 qPos.add(groupId);
6389
6390 qPos.add(parentCategoryId);
6391
6392 count = (Long)q.uniqueResult();
6393
6394 FinderCacheUtil.putResult(finderPath, finderArgs, count);
6395 }
6396 catch (Exception e) {
6397 FinderCacheUtil.removeResult(finderPath, finderArgs);
6398
6399 throw processException(e);
6400 }
6401 finally {
6402 closeSession(session);
6403 }
6404 }
6405
6406 return count.intValue();
6407 }
6408
6409
6417 @Override
6418 public int countByNotC_G_P(long[] categoryIds, long groupId,
6419 long[] parentCategoryIds) {
6420 if (categoryIds == null) {
6421 categoryIds = new long[0];
6422 }
6423 else {
6424 categoryIds = ArrayUtil.unique(categoryIds);
6425 }
6426
6427 if (parentCategoryIds == null) {
6428 parentCategoryIds = new long[0];
6429 }
6430 else {
6431 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
6432 }
6433
6434 Object[] finderArgs = new Object[] {
6435 StringUtil.merge(categoryIds), groupId,
6436 StringUtil.merge(parentCategoryIds)
6437 };
6438
6439 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P,
6440 finderArgs, this);
6441
6442 if (count == null) {
6443 StringBundler query = new StringBundler();
6444
6445 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
6446
6447 if (categoryIds.length > 0) {
6448 query.append(StringPool.OPEN_PARENTHESIS);
6449
6450 query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_7);
6451
6452 query.append(StringUtil.merge(categoryIds));
6453
6454 query.append(StringPool.CLOSE_PARENTHESIS);
6455
6456 query.append(StringPool.CLOSE_PARENTHESIS);
6457
6458 query.append(WHERE_AND);
6459 }
6460
6461 query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2);
6462
6463 if (parentCategoryIds.length > 0) {
6464 query.append(StringPool.OPEN_PARENTHESIS);
6465
6466 query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_7);
6467
6468 query.append(StringUtil.merge(parentCategoryIds));
6469
6470 query.append(StringPool.CLOSE_PARENTHESIS);
6471
6472 query.append(StringPool.CLOSE_PARENTHESIS);
6473 }
6474
6475 query.setStringAt(removeConjunction(query.stringAt(query.index() -
6476 1)), query.index() - 1);
6477
6478 String sql = query.toString();
6479
6480 Session session = null;
6481
6482 try {
6483 session = openSession();
6484
6485 Query q = session.createQuery(sql);
6486
6487 QueryPos qPos = QueryPos.getInstance(q);
6488
6489 qPos.add(groupId);
6490
6491 count = (Long)q.uniqueResult();
6492
6493 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P,
6494 finderArgs, count);
6495 }
6496 catch (Exception e) {
6497 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P,
6498 finderArgs);
6499
6500 throw processException(e);
6501 }
6502 finally {
6503 closeSession(session);
6504 }
6505 }
6506
6507 return count.intValue();
6508 }
6509
6510
6518 @Override
6519 public int filterCountByNotC_G_P(long categoryId, long groupId,
6520 long parentCategoryId) {
6521 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6522 return countByNotC_G_P(categoryId, groupId, parentCategoryId);
6523 }
6524
6525 StringBundler query = new StringBundler(4);
6526
6527 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
6528
6529 query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_2);
6530
6531 query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2);
6532
6533 query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_2);
6534
6535 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6536 MBCategory.class.getName(),
6537 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6538
6539 Session session = null;
6540
6541 try {
6542 session = openSession();
6543
6544 SQLQuery q = session.createSynchronizedSQLQuery(sql);
6545
6546 q.addScalar(COUNT_COLUMN_NAME,
6547 com.liferay.portal.kernel.dao.orm.Type.LONG);
6548
6549 QueryPos qPos = QueryPos.getInstance(q);
6550
6551 qPos.add(categoryId);
6552
6553 qPos.add(groupId);
6554
6555 qPos.add(parentCategoryId);
6556
6557 Long count = (Long)q.uniqueResult();
6558
6559 return count.intValue();
6560 }
6561 catch (Exception e) {
6562 throw processException(e);
6563 }
6564 finally {
6565 closeSession(session);
6566 }
6567 }
6568
6569
6577 @Override
6578 public int filterCountByNotC_G_P(long[] categoryIds, long groupId,
6579 long[] parentCategoryIds) {
6580 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6581 return countByNotC_G_P(categoryIds, groupId, parentCategoryIds);
6582 }
6583
6584 if (categoryIds == null) {
6585 categoryIds = new long[0];
6586 }
6587 else {
6588 categoryIds = ArrayUtil.unique(categoryIds);
6589 }
6590
6591 if (parentCategoryIds == null) {
6592 parentCategoryIds = new long[0];
6593 }
6594 else {
6595 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
6596 }
6597
6598 StringBundler query = new StringBundler();
6599
6600 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
6601
6602 if (categoryIds.length > 0) {
6603 query.append(StringPool.OPEN_PARENTHESIS);
6604
6605 query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_7);
6606
6607 query.append(StringUtil.merge(categoryIds));
6608
6609 query.append(StringPool.CLOSE_PARENTHESIS);
6610
6611 query.append(StringPool.CLOSE_PARENTHESIS);
6612
6613 query.append(WHERE_AND);
6614 }
6615
6616 query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2);
6617
6618 if (parentCategoryIds.length > 0) {
6619 query.append(StringPool.OPEN_PARENTHESIS);
6620
6621 query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_7);
6622
6623 query.append(StringUtil.merge(parentCategoryIds));
6624
6625 query.append(StringPool.CLOSE_PARENTHESIS);
6626
6627 query.append(StringPool.CLOSE_PARENTHESIS);
6628 }
6629
6630 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
6631 query.index() - 1);
6632
6633 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6634 MBCategory.class.getName(),
6635 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6636
6637 Session session = null;
6638
6639 try {
6640 session = openSession();
6641
6642 SQLQuery q = session.createSynchronizedSQLQuery(sql);
6643
6644 q.addScalar(COUNT_COLUMN_NAME,
6645 com.liferay.portal.kernel.dao.orm.Type.LONG);
6646
6647 QueryPos qPos = QueryPos.getInstance(q);
6648
6649 qPos.add(groupId);
6650
6651 Long count = (Long)q.uniqueResult();
6652
6653 return count.intValue();
6654 }
6655 catch (Exception e) {
6656 throw processException(e);
6657 }
6658 finally {
6659 closeSession(session);
6660 }
6661 }
6662
6663 private static final String _FINDER_COLUMN_NOTC_G_P_CATEGORYID_2 = "mbCategory.categoryId != ? AND ";
6664 private static final String _FINDER_COLUMN_NOTC_G_P_CATEGORYID_7 = "mbCategory.categoryId NOT IN (";
6665 private static final String _FINDER_COLUMN_NOTC_G_P_GROUPID_2 = "mbCategory.groupId = ? AND ";
6666 private static final String _FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_2 = "mbCategory.parentCategoryId = ?";
6667 private static final String _FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_7 = "mbCategory.parentCategoryId IN (";
6668 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
6669 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
6670 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_S",
6671 new String[] {
6672 Long.class.getName(), Long.class.getName(),
6673 Integer.class.getName(),
6674
6675 Integer.class.getName(), Integer.class.getName(),
6676 OrderByComparator.class.getName()
6677 });
6678 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
6679 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
6680 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_S",
6681 new String[] {
6682 Long.class.getName(), Long.class.getName(),
6683 Integer.class.getName()
6684 },
6685 MBCategoryModelImpl.GROUPID_COLUMN_BITMASK |
6686 MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
6687 MBCategoryModelImpl.STATUS_COLUMN_BITMASK |
6688 MBCategoryModelImpl.NAME_COLUMN_BITMASK);
6689 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
6690 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6691 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_S",
6692 new String[] {
6693 Long.class.getName(), Long.class.getName(),
6694 Integer.class.getName()
6695 });
6696 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
6697 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6698 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_P_S",
6699 new String[] {
6700 Long.class.getName(), Long.class.getName(),
6701 Integer.class.getName()
6702 });
6703
6704
6712 @Override
6713 public List<MBCategory> findByG_P_S(long groupId, long parentCategoryId,
6714 int status) {
6715 return findByG_P_S(groupId, parentCategoryId, status,
6716 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6717 }
6718
6719
6733 @Override
6734 public List<MBCategory> findByG_P_S(long groupId, long parentCategoryId,
6735 int status, int start, int end) {
6736 return findByG_P_S(groupId, parentCategoryId, status, start, end, null);
6737 }
6738
6739
6754 @Override
6755 public List<MBCategory> findByG_P_S(long groupId, long parentCategoryId,
6756 int status, int start, int end,
6757 OrderByComparator<MBCategory> orderByComparator) {
6758 boolean pagination = true;
6759 FinderPath finderPath = null;
6760 Object[] finderArgs = null;
6761
6762 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6763 (orderByComparator == null)) {
6764 pagination = false;
6765 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S;
6766 finderArgs = new Object[] { groupId, parentCategoryId, status };
6767 }
6768 else {
6769 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S;
6770 finderArgs = new Object[] {
6771 groupId, parentCategoryId, status,
6772
6773 start, end, orderByComparator
6774 };
6775 }
6776
6777 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
6778 finderArgs, this);
6779
6780 if ((list != null) && !list.isEmpty()) {
6781 for (MBCategory mbCategory : list) {
6782 if ((groupId != mbCategory.getGroupId()) ||
6783 (parentCategoryId != mbCategory.getParentCategoryId()) ||
6784 (status != mbCategory.getStatus())) {
6785 list = null;
6786
6787 break;
6788 }
6789 }
6790 }
6791
6792 if (list == null) {
6793 StringBundler query = null;
6794
6795 if (orderByComparator != null) {
6796 query = new StringBundler(5 +
6797 (orderByComparator.getOrderByFields().length * 3));
6798 }
6799 else {
6800 query = new StringBundler(5);
6801 }
6802
6803 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
6804
6805 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
6806
6807 query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2);
6808
6809 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
6810
6811 if (orderByComparator != null) {
6812 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6813 orderByComparator);
6814 }
6815 else
6816 if (pagination) {
6817 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
6818 }
6819
6820 String sql = query.toString();
6821
6822 Session session = null;
6823
6824 try {
6825 session = openSession();
6826
6827 Query q = session.createQuery(sql);
6828
6829 QueryPos qPos = QueryPos.getInstance(q);
6830
6831 qPos.add(groupId);
6832
6833 qPos.add(parentCategoryId);
6834
6835 qPos.add(status);
6836
6837 if (!pagination) {
6838 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
6839 start, end, false);
6840
6841 Collections.sort(list);
6842
6843 list = Collections.unmodifiableList(list);
6844 }
6845 else {
6846 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
6847 start, end);
6848 }
6849
6850 cacheResult(list);
6851
6852 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6853 }
6854 catch (Exception e) {
6855 FinderCacheUtil.removeResult(finderPath, finderArgs);
6856
6857 throw processException(e);
6858 }
6859 finally {
6860 closeSession(session);
6861 }
6862 }
6863
6864 return list;
6865 }
6866
6867
6877 @Override
6878 public MBCategory findByG_P_S_First(long groupId, long parentCategoryId,
6879 int status, OrderByComparator<MBCategory> orderByComparator)
6880 throws NoSuchCategoryException {
6881 MBCategory mbCategory = fetchByG_P_S_First(groupId, parentCategoryId,
6882 status, orderByComparator);
6883
6884 if (mbCategory != null) {
6885 return mbCategory;
6886 }
6887
6888 StringBundler msg = new StringBundler(8);
6889
6890 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6891
6892 msg.append("groupId=");
6893 msg.append(groupId);
6894
6895 msg.append(", parentCategoryId=");
6896 msg.append(parentCategoryId);
6897
6898 msg.append(", status=");
6899 msg.append(status);
6900
6901 msg.append(StringPool.CLOSE_CURLY_BRACE);
6902
6903 throw new NoSuchCategoryException(msg.toString());
6904 }
6905
6906
6915 @Override
6916 public MBCategory fetchByG_P_S_First(long groupId, long parentCategoryId,
6917 int status, OrderByComparator<MBCategory> orderByComparator) {
6918 List<MBCategory> list = findByG_P_S(groupId, parentCategoryId, status,
6919 0, 1, orderByComparator);
6920
6921 if (!list.isEmpty()) {
6922 return list.get(0);
6923 }
6924
6925 return null;
6926 }
6927
6928
6938 @Override
6939 public MBCategory findByG_P_S_Last(long groupId, long parentCategoryId,
6940 int status, OrderByComparator<MBCategory> orderByComparator)
6941 throws NoSuchCategoryException {
6942 MBCategory mbCategory = fetchByG_P_S_Last(groupId, parentCategoryId,
6943 status, orderByComparator);
6944
6945 if (mbCategory != null) {
6946 return mbCategory;
6947 }
6948
6949 StringBundler msg = new StringBundler(8);
6950
6951 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6952
6953 msg.append("groupId=");
6954 msg.append(groupId);
6955
6956 msg.append(", parentCategoryId=");
6957 msg.append(parentCategoryId);
6958
6959 msg.append(", status=");
6960 msg.append(status);
6961
6962 msg.append(StringPool.CLOSE_CURLY_BRACE);
6963
6964 throw new NoSuchCategoryException(msg.toString());
6965 }
6966
6967
6976 @Override
6977 public MBCategory fetchByG_P_S_Last(long groupId, long parentCategoryId,
6978 int status, OrderByComparator<MBCategory> orderByComparator) {
6979 int count = countByG_P_S(groupId, parentCategoryId, status);
6980
6981 if (count == 0) {
6982 return null;
6983 }
6984
6985 List<MBCategory> list = findByG_P_S(groupId, parentCategoryId, status,
6986 count - 1, count, orderByComparator);
6987
6988 if (!list.isEmpty()) {
6989 return list.get(0);
6990 }
6991
6992 return null;
6993 }
6994
6995
7006 @Override
7007 public MBCategory[] findByG_P_S_PrevAndNext(long categoryId, long groupId,
7008 long parentCategoryId, int status,
7009 OrderByComparator<MBCategory> orderByComparator)
7010 throws NoSuchCategoryException {
7011 MBCategory mbCategory = findByPrimaryKey(categoryId);
7012
7013 Session session = null;
7014
7015 try {
7016 session = openSession();
7017
7018 MBCategory[] array = new MBCategoryImpl[3];
7019
7020 array[0] = getByG_P_S_PrevAndNext(session, mbCategory, groupId,
7021 parentCategoryId, status, orderByComparator, true);
7022
7023 array[1] = mbCategory;
7024
7025 array[2] = getByG_P_S_PrevAndNext(session, mbCategory, groupId,
7026 parentCategoryId, status, orderByComparator, false);
7027
7028 return array;
7029 }
7030 catch (Exception e) {
7031 throw processException(e);
7032 }
7033 finally {
7034 closeSession(session);
7035 }
7036 }
7037
7038 protected MBCategory getByG_P_S_PrevAndNext(Session session,
7039 MBCategory mbCategory, long groupId, long parentCategoryId, int status,
7040 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
7041 StringBundler query = null;
7042
7043 if (orderByComparator != null) {
7044 query = new StringBundler(6 +
7045 (orderByComparator.getOrderByFields().length * 6));
7046 }
7047 else {
7048 query = new StringBundler(3);
7049 }
7050
7051 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
7052
7053 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
7054
7055 query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2);
7056
7057 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
7058
7059 if (orderByComparator != null) {
7060 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7061
7062 if (orderByConditionFields.length > 0) {
7063 query.append(WHERE_AND);
7064 }
7065
7066 for (int i = 0; i < orderByConditionFields.length; i++) {
7067 query.append(_ORDER_BY_ENTITY_ALIAS);
7068 query.append(orderByConditionFields[i]);
7069
7070 if ((i + 1) < orderByConditionFields.length) {
7071 if (orderByComparator.isAscending() ^ previous) {
7072 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7073 }
7074 else {
7075 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7076 }
7077 }
7078 else {
7079 if (orderByComparator.isAscending() ^ previous) {
7080 query.append(WHERE_GREATER_THAN);
7081 }
7082 else {
7083 query.append(WHERE_LESSER_THAN);
7084 }
7085 }
7086 }
7087
7088 query.append(ORDER_BY_CLAUSE);
7089
7090 String[] orderByFields = orderByComparator.getOrderByFields();
7091
7092 for (int i = 0; i < orderByFields.length; i++) {
7093 query.append(_ORDER_BY_ENTITY_ALIAS);
7094 query.append(orderByFields[i]);
7095
7096 if ((i + 1) < orderByFields.length) {
7097 if (orderByComparator.isAscending() ^ previous) {
7098 query.append(ORDER_BY_ASC_HAS_NEXT);
7099 }
7100 else {
7101 query.append(ORDER_BY_DESC_HAS_NEXT);
7102 }
7103 }
7104 else {
7105 if (orderByComparator.isAscending() ^ previous) {
7106 query.append(ORDER_BY_ASC);
7107 }
7108 else {
7109 query.append(ORDER_BY_DESC);
7110 }
7111 }
7112 }
7113 }
7114 else {
7115 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
7116 }
7117
7118 String sql = query.toString();
7119
7120 Query q = session.createQuery(sql);
7121
7122 q.setFirstResult(0);
7123 q.setMaxResults(2);
7124
7125 QueryPos qPos = QueryPos.getInstance(q);
7126
7127 qPos.add(groupId);
7128
7129 qPos.add(parentCategoryId);
7130
7131 qPos.add(status);
7132
7133 if (orderByComparator != null) {
7134 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
7135
7136 for (Object value : values) {
7137 qPos.add(value);
7138 }
7139 }
7140
7141 List<MBCategory> list = q.list();
7142
7143 if (list.size() == 2) {
7144 return list.get(1);
7145 }
7146 else {
7147 return null;
7148 }
7149 }
7150
7151
7159 @Override
7160 public List<MBCategory> filterFindByG_P_S(long groupId,
7161 long parentCategoryId, int status) {
7162 return filterFindByG_P_S(groupId, parentCategoryId, status,
7163 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7164 }
7165
7166
7180 @Override
7181 public List<MBCategory> filterFindByG_P_S(long groupId,
7182 long parentCategoryId, int status, int start, int end) {
7183 return filterFindByG_P_S(groupId, parentCategoryId, status, start, end,
7184 null);
7185 }
7186
7187
7202 @Override
7203 public List<MBCategory> filterFindByG_P_S(long groupId,
7204 long parentCategoryId, int status, int start, int end,
7205 OrderByComparator<MBCategory> orderByComparator) {
7206 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7207 return findByG_P_S(groupId, parentCategoryId, status, start, end,
7208 orderByComparator);
7209 }
7210
7211 StringBundler query = null;
7212
7213 if (orderByComparator != null) {
7214 query = new StringBundler(5 +
7215 (orderByComparator.getOrderByFields().length * 3));
7216 }
7217 else {
7218 query = new StringBundler(5);
7219 }
7220
7221 if (getDB().isSupportsInlineDistinct()) {
7222 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
7223 }
7224 else {
7225 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7226 }
7227
7228 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
7229
7230 query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2);
7231
7232 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
7233
7234 if (!getDB().isSupportsInlineDistinct()) {
7235 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7236 }
7237
7238 if (orderByComparator != null) {
7239 if (getDB().isSupportsInlineDistinct()) {
7240 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7241 orderByComparator, true);
7242 }
7243 else {
7244 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7245 orderByComparator, true);
7246 }
7247 }
7248 else {
7249 if (getDB().isSupportsInlineDistinct()) {
7250 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
7251 }
7252 else {
7253 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
7254 }
7255 }
7256
7257 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7258 MBCategory.class.getName(),
7259 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7260
7261 Session session = null;
7262
7263 try {
7264 session = openSession();
7265
7266 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7267
7268 if (getDB().isSupportsInlineDistinct()) {
7269 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
7270 }
7271 else {
7272 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
7273 }
7274
7275 QueryPos qPos = QueryPos.getInstance(q);
7276
7277 qPos.add(groupId);
7278
7279 qPos.add(parentCategoryId);
7280
7281 qPos.add(status);
7282
7283 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
7284 }
7285 catch (Exception e) {
7286 throw processException(e);
7287 }
7288 finally {
7289 closeSession(session);
7290 }
7291 }
7292
7293
7304 @Override
7305 public MBCategory[] filterFindByG_P_S_PrevAndNext(long categoryId,
7306 long groupId, long parentCategoryId, int status,
7307 OrderByComparator<MBCategory> orderByComparator)
7308 throws NoSuchCategoryException {
7309 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7310 return findByG_P_S_PrevAndNext(categoryId, groupId,
7311 parentCategoryId, status, orderByComparator);
7312 }
7313
7314 MBCategory mbCategory = findByPrimaryKey(categoryId);
7315
7316 Session session = null;
7317
7318 try {
7319 session = openSession();
7320
7321 MBCategory[] array = new MBCategoryImpl[3];
7322
7323 array[0] = filterGetByG_P_S_PrevAndNext(session, mbCategory,
7324 groupId, parentCategoryId, status, orderByComparator, true);
7325
7326 array[1] = mbCategory;
7327
7328 array[2] = filterGetByG_P_S_PrevAndNext(session, mbCategory,
7329 groupId, parentCategoryId, status, orderByComparator, false);
7330
7331 return array;
7332 }
7333 catch (Exception e) {
7334 throw processException(e);
7335 }
7336 finally {
7337 closeSession(session);
7338 }
7339 }
7340
7341 protected MBCategory filterGetByG_P_S_PrevAndNext(Session session,
7342 MBCategory mbCategory, long groupId, long parentCategoryId, int status,
7343 OrderByComparator<MBCategory> orderByComparator, boolean previous) {
7344 StringBundler query = null;
7345
7346 if (orderByComparator != null) {
7347 query = new StringBundler(6 +
7348 (orderByComparator.getOrderByFields().length * 6));
7349 }
7350 else {
7351 query = new StringBundler(3);
7352 }
7353
7354 if (getDB().isSupportsInlineDistinct()) {
7355 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
7356 }
7357 else {
7358 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7359 }
7360
7361 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
7362
7363 query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2);
7364
7365 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
7366
7367 if (!getDB().isSupportsInlineDistinct()) {
7368 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7369 }
7370
7371 if (orderByComparator != null) {
7372 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7373
7374 if (orderByConditionFields.length > 0) {
7375 query.append(WHERE_AND);
7376 }
7377
7378 for (int i = 0; i < orderByConditionFields.length; i++) {
7379 if (getDB().isSupportsInlineDistinct()) {
7380 query.append(_ORDER_BY_ENTITY_ALIAS);
7381 }
7382 else {
7383 query.append(_ORDER_BY_ENTITY_TABLE);
7384 }
7385
7386 query.append(orderByConditionFields[i]);
7387
7388 if ((i + 1) < orderByConditionFields.length) {
7389 if (orderByComparator.isAscending() ^ previous) {
7390 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7391 }
7392 else {
7393 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7394 }
7395 }
7396 else {
7397 if (orderByComparator.isAscending() ^ previous) {
7398 query.append(WHERE_GREATER_THAN);
7399 }
7400 else {
7401 query.append(WHERE_LESSER_THAN);
7402 }
7403 }
7404 }
7405
7406 query.append(ORDER_BY_CLAUSE);
7407
7408 String[] orderByFields = orderByComparator.getOrderByFields();
7409
7410 for (int i = 0; i < orderByFields.length; i++) {
7411 if (getDB().isSupportsInlineDistinct()) {
7412 query.append(_ORDER_BY_ENTITY_ALIAS);
7413 }
7414 else {
7415 query.append(_ORDER_BY_ENTITY_TABLE);
7416 }
7417
7418 query.append(orderByFields[i]);
7419
7420 if ((i + 1) < orderByFields.length) {
7421 if (orderByComparator.isAscending() ^ previous) {
7422 query.append(ORDER_BY_ASC_HAS_NEXT);
7423 }
7424 else {
7425 query.append(ORDER_BY_DESC_HAS_NEXT);
7426 }
7427 }
7428 else {
7429 if (orderByComparator.isAscending() ^ previous) {
7430 query.append(ORDER_BY_ASC);
7431 }
7432 else {
7433 query.append(ORDER_BY_DESC);
7434 }
7435 }
7436 }
7437 }
7438 else {
7439 if (getDB().isSupportsInlineDistinct()) {
7440 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
7441 }
7442 else {
7443 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
7444 }
7445 }
7446
7447 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7448 MBCategory.class.getName(),
7449 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7450
7451 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7452
7453 q.setFirstResult(0);
7454 q.setMaxResults(2);
7455
7456 if (getDB().isSupportsInlineDistinct()) {
7457 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
7458 }
7459 else {
7460 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
7461 }
7462
7463 QueryPos qPos = QueryPos.getInstance(q);
7464
7465 qPos.add(groupId);
7466
7467 qPos.add(parentCategoryId);
7468
7469 qPos.add(status);
7470
7471 if (orderByComparator != null) {
7472 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
7473
7474 for (Object value : values) {
7475 qPos.add(value);
7476 }
7477 }
7478
7479 List<MBCategory> list = q.list();
7480
7481 if (list.size() == 2) {
7482 return list.get(1);
7483 }
7484 else {
7485 return null;
7486 }
7487 }
7488
7489
7497 @Override
7498 public List<MBCategory> filterFindByG_P_S(long groupId,
7499 long[] parentCategoryIds, int status) {
7500 return filterFindByG_P_S(groupId, parentCategoryIds, status,
7501 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7502 }
7503
7504
7518 @Override
7519 public List<MBCategory> filterFindByG_P_S(long groupId,
7520 long[] parentCategoryIds, int status, int start, int end) {
7521 return filterFindByG_P_S(groupId, parentCategoryIds, status, start,
7522 end, null);
7523 }
7524
7525
7540 @Override
7541 public List<MBCategory> filterFindByG_P_S(long groupId,
7542 long[] parentCategoryIds, int status, int start, int end,
7543 OrderByComparator<MBCategory> orderByComparator) {
7544 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7545 return findByG_P_S(groupId, parentCategoryIds, status, start, end,
7546 orderByComparator);
7547 }
7548
7549 if (parentCategoryIds == null) {
7550 parentCategoryIds = new long[0];
7551 }
7552 else {
7553 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
7554 }
7555
7556 StringBundler query = new StringBundler();
7557
7558 if (getDB().isSupportsInlineDistinct()) {
7559 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
7560 }
7561 else {
7562 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7563 }
7564
7565 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
7566
7567 if (parentCategoryIds.length > 0) {
7568 query.append(StringPool.OPEN_PARENTHESIS);
7569
7570 query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_7);
7571
7572 query.append(StringUtil.merge(parentCategoryIds));
7573
7574 query.append(StringPool.CLOSE_PARENTHESIS);
7575
7576 query.append(StringPool.CLOSE_PARENTHESIS);
7577
7578 query.append(WHERE_AND);
7579 }
7580
7581 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
7582
7583 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
7584 query.index() - 1);
7585
7586 if (!getDB().isSupportsInlineDistinct()) {
7587 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7588 }
7589
7590 if (orderByComparator != null) {
7591 if (getDB().isSupportsInlineDistinct()) {
7592 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7593 orderByComparator, true);
7594 }
7595 else {
7596 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7597 orderByComparator, true);
7598 }
7599 }
7600 else {
7601 if (getDB().isSupportsInlineDistinct()) {
7602 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
7603 }
7604 else {
7605 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
7606 }
7607 }
7608
7609 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7610 MBCategory.class.getName(),
7611 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7612
7613 Session session = null;
7614
7615 try {
7616 session = openSession();
7617
7618 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7619
7620 if (getDB().isSupportsInlineDistinct()) {
7621 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
7622 }
7623 else {
7624 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
7625 }
7626
7627 QueryPos qPos = QueryPos.getInstance(q);
7628
7629 qPos.add(groupId);
7630
7631 qPos.add(status);
7632
7633 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
7634 }
7635 catch (Exception e) {
7636 throw processException(e);
7637 }
7638 finally {
7639 closeSession(session);
7640 }
7641 }
7642
7643
7655 @Override
7656 public List<MBCategory> findByG_P_S(long groupId, long[] parentCategoryIds,
7657 int status) {
7658 return findByG_P_S(groupId, parentCategoryIds, status,
7659 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7660 }
7661
7662
7676 @Override
7677 public List<MBCategory> findByG_P_S(long groupId, long[] parentCategoryIds,
7678 int status, int start, int end) {
7679 return findByG_P_S(groupId, parentCategoryIds, status, start, end, null);
7680 }
7681
7682
7697 @Override
7698 public List<MBCategory> findByG_P_S(long groupId, long[] parentCategoryIds,
7699 int status, int start, int end,
7700 OrderByComparator<MBCategory> orderByComparator) {
7701 if (parentCategoryIds == null) {
7702 parentCategoryIds = new long[0];
7703 }
7704 else {
7705 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
7706 }
7707
7708 if (parentCategoryIds.length == 1) {
7709 return findByG_P_S(groupId, parentCategoryIds[0], status, start,
7710 end, orderByComparator);
7711 }
7712
7713 boolean pagination = true;
7714 Object[] finderArgs = null;
7715
7716 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7717 (orderByComparator == null)) {
7718 pagination = false;
7719 finderArgs = new Object[] {
7720 groupId, StringUtil.merge(parentCategoryIds), status
7721 };
7722 }
7723 else {
7724 finderArgs = new Object[] {
7725 groupId, StringUtil.merge(parentCategoryIds), status,
7726
7727 start, end, orderByComparator
7728 };
7729 }
7730
7731 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S,
7732 finderArgs, this);
7733
7734 if ((list != null) && !list.isEmpty()) {
7735 for (MBCategory mbCategory : list) {
7736 if ((groupId != mbCategory.getGroupId()) ||
7737 !ArrayUtil.contains(parentCategoryIds,
7738 mbCategory.getParentCategoryId()) ||
7739 (status != mbCategory.getStatus())) {
7740 list = null;
7741
7742 break;
7743 }
7744 }
7745 }
7746
7747 if (list == null) {
7748 StringBundler query = new StringBundler();
7749
7750 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
7751
7752 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
7753
7754 if (parentCategoryIds.length > 0) {
7755 query.append(StringPool.OPEN_PARENTHESIS);
7756
7757 query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_7);
7758
7759 query.append(StringUtil.merge(parentCategoryIds));
7760
7761 query.append(StringPool.CLOSE_PARENTHESIS);
7762
7763 query.append(StringPool.CLOSE_PARENTHESIS);
7764
7765 query.append(WHERE_AND);
7766 }
7767
7768 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
7769
7770 query.setStringAt(removeConjunction(query.stringAt(query.index() -
7771 1)), query.index() - 1);
7772
7773 if (orderByComparator != null) {
7774 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7775 orderByComparator);
7776 }
7777 else
7778 if (pagination) {
7779 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
7780 }
7781
7782 String sql = query.toString();
7783
7784 Session session = null;
7785
7786 try {
7787 session = openSession();
7788
7789 Query q = session.createQuery(sql);
7790
7791 QueryPos qPos = QueryPos.getInstance(q);
7792
7793 qPos.add(groupId);
7794
7795 qPos.add(status);
7796
7797 if (!pagination) {
7798 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
7799 start, end, false);
7800
7801 Collections.sort(list);
7802
7803 list = Collections.unmodifiableList(list);
7804 }
7805 else {
7806 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
7807 start, end);
7808 }
7809
7810 cacheResult(list);
7811
7812 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S,
7813 finderArgs, list);
7814 }
7815 catch (Exception e) {
7816 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S,
7817 finderArgs);
7818
7819 throw processException(e);
7820 }
7821 finally {
7822 closeSession(session);
7823 }
7824 }
7825
7826 return list;
7827 }
7828
7829
7836 @Override
7837 public void removeByG_P_S(long groupId, long parentCategoryId, int status) {
7838 for (MBCategory mbCategory : findByG_P_S(groupId, parentCategoryId,
7839 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7840 remove(mbCategory);
7841 }
7842 }
7843
7844
7852 @Override
7853 public int countByG_P_S(long groupId, long parentCategoryId, int status) {
7854 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_S;
7855
7856 Object[] finderArgs = new Object[] { groupId, parentCategoryId, status };
7857
7858 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7859 this);
7860
7861 if (count == null) {
7862 StringBundler query = new StringBundler(4);
7863
7864 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
7865
7866 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
7867
7868 query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2);
7869
7870 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
7871
7872 String sql = query.toString();
7873
7874 Session session = null;
7875
7876 try {
7877 session = openSession();
7878
7879 Query q = session.createQuery(sql);
7880
7881 QueryPos qPos = QueryPos.getInstance(q);
7882
7883 qPos.add(groupId);
7884
7885 qPos.add(parentCategoryId);
7886
7887 qPos.add(status);
7888
7889 count = (Long)q.uniqueResult();
7890
7891 FinderCacheUtil.putResult(finderPath, finderArgs, count);
7892 }
7893 catch (Exception e) {
7894 FinderCacheUtil.removeResult(finderPath, finderArgs);
7895
7896 throw processException(e);
7897 }
7898 finally {
7899 closeSession(session);
7900 }
7901 }
7902
7903 return count.intValue();
7904 }
7905
7906
7914 @Override
7915 public int countByG_P_S(long groupId, long[] parentCategoryIds, int status) {
7916 if (parentCategoryIds == null) {
7917 parentCategoryIds = new long[0];
7918 }
7919 else {
7920 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
7921 }
7922
7923 Object[] finderArgs = new Object[] {
7924 groupId, StringUtil.merge(parentCategoryIds), status
7925 };
7926
7927 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S,
7928 finderArgs, this);
7929
7930 if (count == null) {
7931 StringBundler query = new StringBundler();
7932
7933 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
7934
7935 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
7936
7937 if (parentCategoryIds.length > 0) {
7938 query.append(StringPool.OPEN_PARENTHESIS);
7939
7940 query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_7);
7941
7942 query.append(StringUtil.merge(parentCategoryIds));
7943
7944 query.append(StringPool.CLOSE_PARENTHESIS);
7945
7946 query.append(StringPool.CLOSE_PARENTHESIS);
7947
7948 query.append(WHERE_AND);
7949 }
7950
7951 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
7952
7953 query.setStringAt(removeConjunction(query.stringAt(query.index() -
7954 1)), query.index() - 1);
7955
7956 String sql = query.toString();
7957
7958 Session session = null;
7959
7960 try {
7961 session = openSession();
7962
7963 Query q = session.createQuery(sql);
7964
7965 QueryPos qPos = QueryPos.getInstance(q);
7966
7967 qPos.add(groupId);
7968
7969 qPos.add(status);
7970
7971 count = (Long)q.uniqueResult();
7972
7973 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S,
7974 finderArgs, count);
7975 }
7976 catch (Exception e) {
7977 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S,
7978 finderArgs);
7979
7980 throw processException(e);
7981 }
7982 finally {
7983 closeSession(session);
7984 }
7985 }
7986
7987 return count.intValue();
7988 }
7989
7990
7998 @Override
7999 public int filterCountByG_P_S(long groupId, long parentCategoryId,
8000 int status) {
8001 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8002 return countByG_P_S(groupId, parentCategoryId, status);
8003 }
8004
8005 StringBundler query = new StringBundler(4);
8006
8007 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
8008
8009 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
8010
8011 query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2);
8012
8013 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
8014
8015 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8016 MBCategory.class.getName(),
8017 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8018
8019 Session session = null;
8020
8021 try {
8022 session = openSession();
8023
8024 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8025
8026 q.addScalar(COUNT_COLUMN_NAME,
8027 com.liferay.portal.kernel.dao.orm.Type.LONG);
8028
8029 QueryPos qPos = QueryPos.getInstance(q);
8030
8031 qPos.add(groupId);
8032
8033 qPos.add(parentCategoryId);
8034
8035 qPos.add(status);
8036
8037 Long count = (Long)q.uniqueResult();
8038
8039 return count.intValue();
8040 }
8041 catch (Exception e) {
8042 throw processException(e);
8043 }
8044 finally {
8045 closeSession(session);
8046 }
8047 }
8048
8049
8057 @Override
8058 public int filterCountByG_P_S(long groupId, long[] parentCategoryIds,
8059 int status) {
8060 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8061 return countByG_P_S(groupId, parentCategoryIds, status);
8062 }
8063
8064 if (parentCategoryIds == null) {
8065 parentCategoryIds = new long[0];
8066 }
8067 else {
8068 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
8069 }
8070
8071 StringBundler query = new StringBundler();
8072
8073 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
8074
8075 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
8076
8077 if (parentCategoryIds.length > 0) {
8078 query.append(StringPool.OPEN_PARENTHESIS);
8079
8080 query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_7);
8081
8082 query.append(StringUtil.merge(parentCategoryIds));
8083
8084 query.append(StringPool.CLOSE_PARENTHESIS);
8085
8086 query.append(StringPool.CLOSE_PARENTHESIS);
8087
8088 query.append(WHERE_AND);
8089 }
8090
8091 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
8092
8093 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8094 query.index() - 1);
8095
8096 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8097 MBCategory.class.getName(),
8098 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8099
8100 Session session = null;
8101
8102 try {
8103 session = openSession();
8104
8105 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8106
8107 q.addScalar(COUNT_COLUMN_NAME,
8108 com.liferay.portal.kernel.dao.orm.Type.LONG);
8109
8110 QueryPos qPos = QueryPos.getInstance(q);
8111
8112 qPos.add(groupId);
8113
8114 qPos.add(status);
8115
8116 Long count = (Long)q.uniqueResult();
8117
8118 return count.intValue();
8119 }
8120 catch (Exception e) {
8121 throw processException(e);
8122 }
8123 finally {
8124 closeSession(session);
8125 }
8126 }
8127
8128 private static final String _FINDER_COLUMN_G_P_S_GROUPID_2 = "mbCategory.groupId = ? AND ";
8129 private static final String _FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2 = "mbCategory.parentCategoryId = ? AND ";
8130 private static final String _FINDER_COLUMN_G_P_S_PARENTCATEGORYID_7 = "mbCategory.parentCategoryId IN (";
8131 private static final String _FINDER_COLUMN_G_P_S_STATUS_2 = "mbCategory.status = ?";
8132 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P_S =
8133 new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
8134 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
8135 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByNotC_G_P_S",
8136 new String[] {
8137 Long.class.getName(), Long.class.getName(), Long.class.getName(),
8138 Integer.class.getName(),
8139
8140 Integer.class.getName(), Integer.class.getName(),
8141 OrderByComparator.class.getName()
8142 });
8143 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P_S =
8144 new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
8145 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8146 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByNotC_G_P_S",
8147 new String[] {
8148 Long.class.getName(), Long.class.getName(), Long.class.getName(),
8149 Integer.class.getName()
8150 });
8151
8152
8161 @Override
8162 public List<MBCategory> findByNotC_G_P_S(long categoryId, long groupId,
8163 long parentCategoryId, int status) {
8164 return findByNotC_G_P_S(categoryId, groupId, parentCategoryId, status,
8165 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8166 }
8167
8168
8183 @Override
8184 public List<MBCategory> findByNotC_G_P_S(long categoryId, long groupId,
8185 long parentCategoryId, int status, int start, int end) {
8186 return findByNotC_G_P_S(categoryId, groupId, parentCategoryId, status,
8187 start, end, null);
8188 }
8189
8190
8206 @Override
8207 public List<MBCategory> findByNotC_G_P_S(long categoryId, long groupId,
8208 long parentCategoryId, int status, int start, int end,
8209 OrderByComparator<MBCategory> orderByComparator) {
8210 boolean pagination = true;
8211 FinderPath finderPath = null;
8212 Object[] finderArgs = null;
8213
8214 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P_S;
8215 finderArgs = new Object[] {
8216 categoryId, groupId, parentCategoryId, status,
8217
8218 start, end, orderByComparator
8219 };
8220
8221 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
8222 finderArgs, this);
8223
8224 if ((list != null) && !list.isEmpty()) {
8225 for (MBCategory mbCategory : list) {
8226 if ((categoryId == mbCategory.getCategoryId()) ||
8227 (groupId != mbCategory.getGroupId()) ||
8228 (parentCategoryId != mbCategory.getParentCategoryId()) ||
8229 (status != mbCategory.getStatus())) {
8230 list = null;
8231
8232 break;
8233 }
8234 }
8235 }
8236
8237 if (list == null) {
8238 StringBundler query = null;
8239
8240 if (orderByComparator != null) {
8241 query = new StringBundler(6 +
8242 (orderByComparator.getOrderByFields().length * 3));
8243 }
8244 else {
8245 query = new StringBundler(6);
8246 }
8247
8248 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
8249
8250 query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_2);
8251
8252 query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2);
8253
8254 query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_2);
8255
8256 query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2);
8257
8258 if (orderByComparator != null) {
8259 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8260 orderByComparator);
8261 }
8262 else
8263 if (pagination) {
8264 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
8265 }
8266
8267 String sql = query.toString();
8268
8269 Session session = null;
8270
8271 try {
8272 session = openSession();
8273
8274 Query q = session.createQuery(sql);
8275
8276 QueryPos qPos = QueryPos.getInstance(q);
8277
8278 qPos.add(categoryId);
8279
8280 qPos.add(groupId);
8281
8282 qPos.add(parentCategoryId);
8283
8284 qPos.add(status);
8285
8286 if (!pagination) {
8287 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
8288 start, end, false);
8289
8290 Collections.sort(list);
8291
8292 list = Collections.unmodifiableList(list);
8293 }
8294 else {
8295 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
8296 start, end);
8297 }
8298
8299 cacheResult(list);
8300
8301 FinderCacheUtil.putResult(finderPath, finderArgs, list);
8302 }
8303 catch (Exception e) {
8304 FinderCacheUtil.removeResult(finderPath, finderArgs);
8305
8306 throw processException(e);
8307 }
8308 finally {
8309 closeSession(session);
8310 }
8311 }
8312
8313 return list;
8314 }
8315
8316
8327 @Override
8328 public MBCategory findByNotC_G_P_S_First(long categoryId, long groupId,
8329 long parentCategoryId, int status,
8330 OrderByComparator<MBCategory> orderByComparator)
8331 throws NoSuchCategoryException {
8332 MBCategory mbCategory = fetchByNotC_G_P_S_First(categoryId, groupId,
8333 parentCategoryId, status, orderByComparator);
8334
8335 if (mbCategory != null) {
8336 return mbCategory;
8337 }
8338
8339 StringBundler msg = new StringBundler(10);
8340
8341 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8342
8343 msg.append("categoryId=");
8344 msg.append(categoryId);
8345
8346 msg.append(", groupId=");
8347 msg.append(groupId);
8348
8349 msg.append(", parentCategoryId=");
8350 msg.append(parentCategoryId);
8351
8352 msg.append(", status=");
8353 msg.append(status);
8354
8355 msg.append(StringPool.CLOSE_CURLY_BRACE);
8356
8357 throw new NoSuchCategoryException(msg.toString());
8358 }
8359
8360
8370 @Override
8371 public MBCategory fetchByNotC_G_P_S_First(long categoryId, long groupId,
8372 long parentCategoryId, int status,
8373 OrderByComparator<MBCategory> orderByComparator) {
8374 List<MBCategory> list = findByNotC_G_P_S(categoryId, groupId,
8375 parentCategoryId, status, 0, 1, orderByComparator);
8376
8377 if (!list.isEmpty()) {
8378 return list.get(0);
8379 }
8380
8381 return null;
8382 }
8383
8384
8395 @Override
8396 public MBCategory findByNotC_G_P_S_Last(long categoryId, long groupId,
8397 long parentCategoryId, int status,
8398 OrderByComparator<MBCategory> orderByComparator)
8399 throws NoSuchCategoryException {
8400 MBCategory mbCategory = fetchByNotC_G_P_S_Last(categoryId, groupId,
8401 parentCategoryId, status, orderByComparator);
8402
8403 if (mbCategory != null) {
8404 return mbCategory;
8405 }
8406
8407 StringBundler msg = new StringBundler(10);
8408
8409 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8410
8411 msg.append("categoryId=");
8412 msg.append(categoryId);
8413
8414 msg.append(", groupId=");
8415 msg.append(groupId);
8416
8417 msg.append(", parentCategoryId=");
8418 msg.append(parentCategoryId);
8419
8420 msg.append(", status=");
8421 msg.append(status);
8422
8423 msg.append(StringPool.CLOSE_CURLY_BRACE);
8424
8425 throw new NoSuchCategoryException(msg.toString());
8426 }
8427
8428
8438 @Override
8439 public MBCategory fetchByNotC_G_P_S_Last(long categoryId, long groupId,
8440 long parentCategoryId, int status,
8441 OrderByComparator<MBCategory> orderByComparator) {
8442 int count = countByNotC_G_P_S(categoryId, groupId, parentCategoryId,
8443 status);
8444
8445 if (count == 0) {
8446 return null;
8447 }
8448
8449 List<MBCategory> list = findByNotC_G_P_S(categoryId, groupId,
8450 parentCategoryId, status, count - 1, count, orderByComparator);
8451
8452 if (!list.isEmpty()) {
8453 return list.get(0);
8454 }
8455
8456 return null;
8457 }
8458
8459
8468 @Override
8469 public List<MBCategory> filterFindByNotC_G_P_S(long categoryId,
8470 long groupId, long parentCategoryId, int status) {
8471 return filterFindByNotC_G_P_S(categoryId, groupId, parentCategoryId,
8472 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8473 }
8474
8475
8490 @Override
8491 public List<MBCategory> filterFindByNotC_G_P_S(long categoryId,
8492 long groupId, long parentCategoryId, int status, int start, int end) {
8493 return filterFindByNotC_G_P_S(categoryId, groupId, parentCategoryId,
8494 status, start, end, null);
8495 }
8496
8497
8513 @Override
8514 public List<MBCategory> filterFindByNotC_G_P_S(long categoryId,
8515 long groupId, long parentCategoryId, int status, int start, int end,
8516 OrderByComparator<MBCategory> orderByComparator) {
8517 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8518 return findByNotC_G_P_S(categoryId, groupId, parentCategoryId,
8519 status, start, end, orderByComparator);
8520 }
8521
8522 StringBundler query = null;
8523
8524 if (orderByComparator != null) {
8525 query = new StringBundler(6 +
8526 (orderByComparator.getOrderByFields().length * 3));
8527 }
8528 else {
8529 query = new StringBundler(6);
8530 }
8531
8532 if (getDB().isSupportsInlineDistinct()) {
8533 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
8534 }
8535 else {
8536 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8537 }
8538
8539 query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_2);
8540
8541 query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2);
8542
8543 query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_2);
8544
8545 query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2);
8546
8547 if (!getDB().isSupportsInlineDistinct()) {
8548 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8549 }
8550
8551 if (orderByComparator != null) {
8552 if (getDB().isSupportsInlineDistinct()) {
8553 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8554 orderByComparator, true);
8555 }
8556 else {
8557 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8558 orderByComparator, true);
8559 }
8560 }
8561 else {
8562 if (getDB().isSupportsInlineDistinct()) {
8563 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
8564 }
8565 else {
8566 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
8567 }
8568 }
8569
8570 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8571 MBCategory.class.getName(),
8572 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8573
8574 Session session = null;
8575
8576 try {
8577 session = openSession();
8578
8579 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8580
8581 if (getDB().isSupportsInlineDistinct()) {
8582 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
8583 }
8584 else {
8585 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
8586 }
8587
8588 QueryPos qPos = QueryPos.getInstance(q);
8589
8590 qPos.add(categoryId);
8591
8592 qPos.add(groupId);
8593
8594 qPos.add(parentCategoryId);
8595
8596 qPos.add(status);
8597
8598 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
8599 }
8600 catch (Exception e) {
8601 throw processException(e);
8602 }
8603 finally {
8604 closeSession(session);
8605 }
8606 }
8607
8608
8617 @Override
8618 public List<MBCategory> filterFindByNotC_G_P_S(long[] categoryIds,
8619 long groupId, long[] parentCategoryIds, int status) {
8620 return filterFindByNotC_G_P_S(categoryIds, groupId, parentCategoryIds,
8621 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8622 }
8623
8624
8639 @Override
8640 public List<MBCategory> filterFindByNotC_G_P_S(long[] categoryIds,
8641 long groupId, long[] parentCategoryIds, int status, int start, int end) {
8642 return filterFindByNotC_G_P_S(categoryIds, groupId, parentCategoryIds,
8643 status, start, end, null);
8644 }
8645
8646
8662 @Override
8663 public List<MBCategory> filterFindByNotC_G_P_S(long[] categoryIds,
8664 long groupId, long[] parentCategoryIds, int status, int start, int end,
8665 OrderByComparator<MBCategory> orderByComparator) {
8666 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8667 return findByNotC_G_P_S(categoryIds, groupId, parentCategoryIds,
8668 status, start, end, orderByComparator);
8669 }
8670
8671 if (categoryIds == null) {
8672 categoryIds = new long[0];
8673 }
8674 else {
8675 categoryIds = ArrayUtil.unique(categoryIds);
8676 }
8677
8678 if (parentCategoryIds == null) {
8679 parentCategoryIds = new long[0];
8680 }
8681 else {
8682 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
8683 }
8684
8685 StringBundler query = new StringBundler();
8686
8687 if (getDB().isSupportsInlineDistinct()) {
8688 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
8689 }
8690 else {
8691 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8692 }
8693
8694 if (categoryIds.length > 0) {
8695 query.append(StringPool.OPEN_PARENTHESIS);
8696
8697 query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_7);
8698
8699 query.append(StringUtil.merge(categoryIds));
8700
8701 query.append(StringPool.CLOSE_PARENTHESIS);
8702
8703 query.append(StringPool.CLOSE_PARENTHESIS);
8704
8705 query.append(WHERE_AND);
8706 }
8707
8708 query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2);
8709
8710 if (parentCategoryIds.length > 0) {
8711 query.append(StringPool.OPEN_PARENTHESIS);
8712
8713 query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_7);
8714
8715 query.append(StringUtil.merge(parentCategoryIds));
8716
8717 query.append(StringPool.CLOSE_PARENTHESIS);
8718
8719 query.append(StringPool.CLOSE_PARENTHESIS);
8720
8721 query.append(WHERE_AND);
8722 }
8723
8724 query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2);
8725
8726 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8727 query.index() - 1);
8728
8729 if (!getDB().isSupportsInlineDistinct()) {
8730 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8731 }
8732
8733 if (orderByComparator != null) {
8734 if (getDB().isSupportsInlineDistinct()) {
8735 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8736 orderByComparator, true);
8737 }
8738 else {
8739 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8740 orderByComparator, true);
8741 }
8742 }
8743 else {
8744 if (getDB().isSupportsInlineDistinct()) {
8745 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
8746 }
8747 else {
8748 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
8749 }
8750 }
8751
8752 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8753 MBCategory.class.getName(),
8754 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8755
8756 Session session = null;
8757
8758 try {
8759 session = openSession();
8760
8761 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8762
8763 if (getDB().isSupportsInlineDistinct()) {
8764 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
8765 }
8766 else {
8767 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
8768 }
8769
8770 QueryPos qPos = QueryPos.getInstance(q);
8771
8772 qPos.add(groupId);
8773
8774 qPos.add(status);
8775
8776 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
8777 }
8778 catch (Exception e) {
8779 throw processException(e);
8780 }
8781 finally {
8782 closeSession(session);
8783 }
8784 }
8785
8786
8799 @Override
8800 public List<MBCategory> findByNotC_G_P_S(long[] categoryIds, long groupId,
8801 long[] parentCategoryIds, int status) {
8802 return findByNotC_G_P_S(categoryIds, groupId, parentCategoryIds,
8803 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8804 }
8805
8806
8821 @Override
8822 public List<MBCategory> findByNotC_G_P_S(long[] categoryIds, long groupId,
8823 long[] parentCategoryIds, int status, int start, int end) {
8824 return findByNotC_G_P_S(categoryIds, groupId, parentCategoryIds,
8825 status, start, end, null);
8826 }
8827
8828
8844 @Override
8845 public List<MBCategory> findByNotC_G_P_S(long[] categoryIds, long groupId,
8846 long[] parentCategoryIds, int status, int start, int end,
8847 OrderByComparator<MBCategory> orderByComparator) {
8848 if (categoryIds == null) {
8849 categoryIds = new long[0];
8850 }
8851 else {
8852 categoryIds = ArrayUtil.unique(categoryIds);
8853 }
8854
8855 if (parentCategoryIds == null) {
8856 parentCategoryIds = new long[0];
8857 }
8858 else {
8859 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
8860 }
8861
8862 if ((categoryIds.length == 1) && (parentCategoryIds.length == 1)) {
8863 return findByNotC_G_P_S(categoryIds[0], groupId,
8864 parentCategoryIds[0], status, start, end, orderByComparator);
8865 }
8866
8867 boolean pagination = true;
8868 Object[] finderArgs = null;
8869
8870 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8871 (orderByComparator == null)) {
8872 pagination = false;
8873 finderArgs = new Object[] {
8874 StringUtil.merge(categoryIds), groupId,
8875 StringUtil.merge(parentCategoryIds), status
8876 };
8877 }
8878 else {
8879 finderArgs = new Object[] {
8880 StringUtil.merge(categoryIds), groupId,
8881 StringUtil.merge(parentCategoryIds), status,
8882
8883 start, end, orderByComparator
8884 };
8885 }
8886
8887 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P_S,
8888 finderArgs, this);
8889
8890 if ((list != null) && !list.isEmpty()) {
8891 for (MBCategory mbCategory : list) {
8892 if (!ArrayUtil.contains(categoryIds, mbCategory.getCategoryId()) ||
8893 (groupId != mbCategory.getGroupId()) ||
8894 !ArrayUtil.contains(parentCategoryIds,
8895 mbCategory.getParentCategoryId()) ||
8896 (status != mbCategory.getStatus())) {
8897 list = null;
8898
8899 break;
8900 }
8901 }
8902 }
8903
8904 if (list == null) {
8905 StringBundler query = new StringBundler();
8906
8907 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
8908
8909 if (categoryIds.length > 0) {
8910 query.append(StringPool.OPEN_PARENTHESIS);
8911
8912 query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_7);
8913
8914 query.append(StringUtil.merge(categoryIds));
8915
8916 query.append(StringPool.CLOSE_PARENTHESIS);
8917
8918 query.append(StringPool.CLOSE_PARENTHESIS);
8919
8920 query.append(WHERE_AND);
8921 }
8922
8923 query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2);
8924
8925 if (parentCategoryIds.length > 0) {
8926 query.append(StringPool.OPEN_PARENTHESIS);
8927
8928 query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_7);
8929
8930 query.append(StringUtil.merge(parentCategoryIds));
8931
8932 query.append(StringPool.CLOSE_PARENTHESIS);
8933
8934 query.append(StringPool.CLOSE_PARENTHESIS);
8935
8936 query.append(WHERE_AND);
8937 }
8938
8939 query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2);
8940
8941 query.setStringAt(removeConjunction(query.stringAt(query.index() -
8942 1)), query.index() - 1);
8943
8944 if (orderByComparator != null) {
8945 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8946 orderByComparator);
8947 }
8948 else
8949 if (pagination) {
8950 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
8951 }
8952
8953 String sql = query.toString();
8954
8955 Session session = null;
8956
8957 try {
8958 session = openSession();
8959
8960 Query q = session.createQuery(sql);
8961
8962 QueryPos qPos = QueryPos.getInstance(q);
8963
8964 qPos.add(groupId);
8965
8966 qPos.add(status);
8967
8968 if (!pagination) {
8969 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
8970 start, end, false);
8971
8972 Collections.sort(list);
8973
8974 list = Collections.unmodifiableList(list);
8975 }
8976 else {
8977 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
8978 start, end);
8979 }
8980
8981 cacheResult(list);
8982
8983 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P_S,
8984 finderArgs, list);
8985 }
8986 catch (Exception e) {
8987 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P_S,
8988 finderArgs);
8989
8990 throw processException(e);
8991 }
8992 finally {
8993 closeSession(session);
8994 }
8995 }
8996
8997 return list;
8998 }
8999
9000
9008 @Override
9009 public void removeByNotC_G_P_S(long categoryId, long groupId,
9010 long parentCategoryId, int status) {
9011 for (MBCategory mbCategory : findByNotC_G_P_S(categoryId, groupId,
9012 parentCategoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
9013 null)) {
9014 remove(mbCategory);
9015 }
9016 }
9017
9018
9027 @Override
9028 public int countByNotC_G_P_S(long categoryId, long groupId,
9029 long parentCategoryId, int status) {
9030 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P_S;
9031
9032 Object[] finderArgs = new Object[] {
9033 categoryId, groupId, parentCategoryId, status
9034 };
9035
9036 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9037 this);
9038
9039 if (count == null) {
9040 StringBundler query = new StringBundler(5);
9041
9042 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
9043
9044 query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_2);
9045
9046 query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2);
9047
9048 query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_2);
9049
9050 query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2);
9051
9052 String sql = query.toString();
9053
9054 Session session = null;
9055
9056 try {
9057 session = openSession();
9058
9059 Query q = session.createQuery(sql);
9060
9061 QueryPos qPos = QueryPos.getInstance(q);
9062
9063 qPos.add(categoryId);
9064
9065 qPos.add(groupId);
9066
9067 qPos.add(parentCategoryId);
9068
9069 qPos.add(status);
9070
9071 count = (Long)q.uniqueResult();
9072
9073 FinderCacheUtil.putResult(finderPath, finderArgs, count);
9074 }
9075 catch (Exception e) {
9076 FinderCacheUtil.removeResult(finderPath, finderArgs);
9077
9078 throw processException(e);
9079 }
9080 finally {
9081 closeSession(session);
9082 }
9083 }
9084
9085 return count.intValue();
9086 }
9087
9088
9097 @Override
9098 public int countByNotC_G_P_S(long[] categoryIds, long groupId,
9099 long[] parentCategoryIds, int status) {
9100 if (categoryIds == null) {
9101 categoryIds = new long[0];
9102 }
9103 else {
9104 categoryIds = ArrayUtil.unique(categoryIds);
9105 }
9106
9107 if (parentCategoryIds == null) {
9108 parentCategoryIds = new long[0];
9109 }
9110 else {
9111 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
9112 }
9113
9114 Object[] finderArgs = new Object[] {
9115 StringUtil.merge(categoryIds), groupId,
9116 StringUtil.merge(parentCategoryIds), status
9117 };
9118
9119 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P_S,
9120 finderArgs, this);
9121
9122 if (count == null) {
9123 StringBundler query = new StringBundler();
9124
9125 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
9126
9127 if (categoryIds.length > 0) {
9128 query.append(StringPool.OPEN_PARENTHESIS);
9129
9130 query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_7);
9131
9132 query.append(StringUtil.merge(categoryIds));
9133
9134 query.append(StringPool.CLOSE_PARENTHESIS);
9135
9136 query.append(StringPool.CLOSE_PARENTHESIS);
9137
9138 query.append(WHERE_AND);
9139 }
9140
9141 query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2);
9142
9143 if (parentCategoryIds.length > 0) {
9144 query.append(StringPool.OPEN_PARENTHESIS);
9145
9146 query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_7);
9147
9148 query.append(StringUtil.merge(parentCategoryIds));
9149
9150 query.append(StringPool.CLOSE_PARENTHESIS);
9151
9152 query.append(StringPool.CLOSE_PARENTHESIS);
9153
9154 query.append(WHERE_AND);
9155 }
9156
9157 query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2);
9158
9159 query.setStringAt(removeConjunction(query.stringAt(query.index() -
9160 1)), query.index() - 1);
9161
9162 String sql = query.toString();
9163
9164 Session session = null;
9165
9166 try {
9167 session = openSession();
9168
9169 Query q = session.createQuery(sql);
9170
9171 QueryPos qPos = QueryPos.getInstance(q);
9172
9173 qPos.add(groupId);
9174
9175 qPos.add(status);
9176
9177 count = (Long)q.uniqueResult();
9178
9179 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P_S,
9180 finderArgs, count);
9181 }
9182 catch (Exception e) {
9183 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P_S,
9184 finderArgs);
9185
9186 throw processException(e);
9187 }
9188 finally {
9189 closeSession(session);
9190 }
9191 }
9192
9193 return count.intValue();
9194 }
9195
9196
9205 @Override
9206 public int filterCountByNotC_G_P_S(long categoryId, long groupId,
9207 long parentCategoryId, int status) {
9208 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9209 return countByNotC_G_P_S(categoryId, groupId, parentCategoryId,
9210 status);
9211 }
9212
9213 StringBundler query = new StringBundler(5);
9214
9215 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
9216
9217 query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_2);
9218
9219 query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2);
9220
9221 query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_2);
9222
9223 query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2);
9224
9225 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9226 MBCategory.class.getName(),
9227 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9228
9229 Session session = null;
9230
9231 try {
9232 session = openSession();
9233
9234 SQLQuery q = session.createSynchronizedSQLQuery(sql);
9235
9236 q.addScalar(COUNT_COLUMN_NAME,
9237 com.liferay.portal.kernel.dao.orm.Type.LONG);
9238
9239 QueryPos qPos = QueryPos.getInstance(q);
9240
9241 qPos.add(categoryId);
9242
9243 qPos.add(groupId);
9244
9245 qPos.add(parentCategoryId);
9246
9247 qPos.add(status);
9248
9249 Long count = (Long)q.uniqueResult();
9250
9251 return count.intValue();
9252 }
9253 catch (Exception e) {
9254 throw processException(e);
9255 }
9256 finally {
9257 closeSession(session);
9258 }
9259 }
9260
9261
9270 @Override
9271 public int filterCountByNotC_G_P_S(long[] categoryIds, long groupId,
9272 long[] parentCategoryIds, int status) {
9273 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9274 return countByNotC_G_P_S(categoryIds, groupId, parentCategoryIds,
9275 status);
9276 }
9277
9278 if (categoryIds == null) {
9279 categoryIds = new long[0];
9280 }
9281 else {
9282 categoryIds = ArrayUtil.unique(categoryIds);
9283 }
9284
9285 if (parentCategoryIds == null) {
9286 parentCategoryIds = new long[0];
9287 }
9288 else {
9289 parentCategoryIds = ArrayUtil.unique(parentCategoryIds);
9290 }
9291
9292 StringBundler query = new StringBundler();
9293
9294 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
9295
9296 if (categoryIds.length > 0) {
9297 query.append(StringPool.OPEN_PARENTHESIS);
9298
9299 query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_7);
9300
9301 query.append(StringUtil.merge(categoryIds));
9302
9303 query.append(StringPool.CLOSE_PARENTHESIS);
9304
9305 query.append(StringPool.CLOSE_PARENTHESIS);
9306
9307 query.append(WHERE_AND);
9308 }
9309
9310 query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2);
9311
9312 if (parentCategoryIds.length > 0) {
9313 query.append(StringPool.OPEN_PARENTHESIS);
9314
9315 query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_7);
9316
9317 query.append(StringUtil.merge(parentCategoryIds));
9318
9319 query.append(StringPool.CLOSE_PARENTHESIS);
9320
9321 query.append(StringPool.CLOSE_PARENTHESIS);
9322
9323 query.append(WHERE_AND);
9324 }
9325
9326 query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2);
9327
9328 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
9329 query.index() - 1);
9330
9331 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9332 MBCategory.class.getName(),
9333 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9334
9335 Session session = null;
9336
9337 try {
9338 session = openSession();
9339
9340 SQLQuery q = session.createSynchronizedSQLQuery(sql);
9341
9342 q.addScalar(COUNT_COLUMN_NAME,
9343 com.liferay.portal.kernel.dao.orm.Type.LONG);
9344
9345 QueryPos qPos = QueryPos.getInstance(q);
9346
9347 qPos.add(groupId);
9348
9349 qPos.add(status);
9350
9351 Long count = (Long)q.uniqueResult();
9352
9353 return count.intValue();
9354 }
9355 catch (Exception e) {
9356 throw processException(e);
9357 }
9358 finally {
9359 closeSession(session);
9360 }
9361 }
9362
9363 private static final String _FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_2 = "mbCategory.categoryId != ? AND ";
9364 private static final String _FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_7 = "mbCategory.categoryId NOT IN (";
9365 private static final String _FINDER_COLUMN_NOTC_G_P_S_GROUPID_2 = "mbCategory.groupId = ? AND ";
9366 private static final String _FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_2 = "mbCategory.parentCategoryId = ? AND ";
9367 private static final String _FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_7 = "mbCategory.parentCategoryId IN (";
9368 private static final String _FINDER_COLUMN_NOTC_G_P_S_STATUS_2 = "mbCategory.status = ?";
9369
9370 public MBCategoryPersistenceImpl() {
9371 setModelClass(MBCategory.class);
9372 }
9373
9374
9379 @Override
9380 public void cacheResult(MBCategory mbCategory) {
9381 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
9382 MBCategoryImpl.class, mbCategory.getPrimaryKey(), mbCategory);
9383
9384 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
9385 new Object[] { mbCategory.getUuid(), mbCategory.getGroupId() },
9386 mbCategory);
9387
9388 mbCategory.resetOriginalValues();
9389 }
9390
9391
9396 @Override
9397 public void cacheResult(List<MBCategory> mbCategories) {
9398 for (MBCategory mbCategory : mbCategories) {
9399 if (EntityCacheUtil.getResult(
9400 MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
9401 MBCategoryImpl.class, mbCategory.getPrimaryKey()) == null) {
9402 cacheResult(mbCategory);
9403 }
9404 else {
9405 mbCategory.resetOriginalValues();
9406 }
9407 }
9408 }
9409
9410
9417 @Override
9418 public void clearCache() {
9419 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
9420 CacheRegistryUtil.clear(MBCategoryImpl.class.getName());
9421 }
9422
9423 EntityCacheUtil.clearCache(MBCategoryImpl.class);
9424
9425 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
9426 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
9427 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9428 }
9429
9430
9437 @Override
9438 public void clearCache(MBCategory mbCategory) {
9439 EntityCacheUtil.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
9440 MBCategoryImpl.class, mbCategory.getPrimaryKey());
9441
9442 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
9443 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9444
9445 clearUniqueFindersCache(mbCategory);
9446 }
9447
9448 @Override
9449 public void clearCache(List<MBCategory> mbCategories) {
9450 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
9451 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9452
9453 for (MBCategory mbCategory : mbCategories) {
9454 EntityCacheUtil.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
9455 MBCategoryImpl.class, mbCategory.getPrimaryKey());
9456
9457 clearUniqueFindersCache(mbCategory);
9458 }
9459 }
9460
9461 protected void cacheUniqueFindersCache(MBCategory mbCategory) {
9462 if (mbCategory.isNew()) {
9463 Object[] args = new Object[] {
9464 mbCategory.getUuid(), mbCategory.getGroupId()
9465 };
9466
9467 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
9468 Long.valueOf(1));
9469 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
9470 mbCategory);
9471 }
9472 else {
9473 MBCategoryModelImpl mbCategoryModelImpl = (MBCategoryModelImpl)mbCategory;
9474
9475 if ((mbCategoryModelImpl.getColumnBitmask() &
9476 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
9477 Object[] args = new Object[] {
9478 mbCategory.getUuid(), mbCategory.getGroupId()
9479 };
9480
9481 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
9482 Long.valueOf(1));
9483 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
9484 mbCategory);
9485 }
9486 }
9487 }
9488
9489 protected void clearUniqueFindersCache(MBCategory mbCategory) {
9490 MBCategoryModelImpl mbCategoryModelImpl = (MBCategoryModelImpl)mbCategory;
9491
9492 Object[] args = new Object[] {
9493 mbCategory.getUuid(), mbCategory.getGroupId()
9494 };
9495
9496 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
9497 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
9498
9499 if ((mbCategoryModelImpl.getColumnBitmask() &
9500 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
9501 args = new Object[] {
9502 mbCategoryModelImpl.getOriginalUuid(),
9503 mbCategoryModelImpl.getOriginalGroupId()
9504 };
9505
9506 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
9507 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
9508 }
9509 }
9510
9511
9517 @Override
9518 public MBCategory create(long categoryId) {
9519 MBCategory mbCategory = new MBCategoryImpl();
9520
9521 mbCategory.setNew(true);
9522 mbCategory.setPrimaryKey(categoryId);
9523
9524 String uuid = PortalUUIDUtil.generate();
9525
9526 mbCategory.setUuid(uuid);
9527
9528 return mbCategory;
9529 }
9530
9531
9538 @Override
9539 public MBCategory remove(long categoryId) throws NoSuchCategoryException {
9540 return remove((Serializable)categoryId);
9541 }
9542
9543
9550 @Override
9551 public MBCategory remove(Serializable primaryKey)
9552 throws NoSuchCategoryException {
9553 Session session = null;
9554
9555 try {
9556 session = openSession();
9557
9558 MBCategory mbCategory = (MBCategory)session.get(MBCategoryImpl.class,
9559 primaryKey);
9560
9561 if (mbCategory == null) {
9562 if (_log.isWarnEnabled()) {
9563 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
9564 }
9565
9566 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
9567 primaryKey);
9568 }
9569
9570 return remove(mbCategory);
9571 }
9572 catch (NoSuchCategoryException nsee) {
9573 throw nsee;
9574 }
9575 catch (Exception e) {
9576 throw processException(e);
9577 }
9578 finally {
9579 closeSession(session);
9580 }
9581 }
9582
9583 @Override
9584 protected MBCategory removeImpl(MBCategory mbCategory) {
9585 mbCategory = toUnwrappedModel(mbCategory);
9586
9587 Session session = null;
9588
9589 try {
9590 session = openSession();
9591
9592 if (!session.contains(mbCategory)) {
9593 mbCategory = (MBCategory)session.get(MBCategoryImpl.class,
9594 mbCategory.getPrimaryKeyObj());
9595 }
9596
9597 if (mbCategory != null) {
9598 session.delete(mbCategory);
9599 }
9600 }
9601 catch (Exception e) {
9602 throw processException(e);
9603 }
9604 finally {
9605 closeSession(session);
9606 }
9607
9608 if (mbCategory != null) {
9609 clearCache(mbCategory);
9610 }
9611
9612 return mbCategory;
9613 }
9614
9615 @Override
9616 public MBCategory updateImpl(
9617 com.liferay.portlet.messageboards.model.MBCategory mbCategory) {
9618 mbCategory = toUnwrappedModel(mbCategory);
9619
9620 boolean isNew = mbCategory.isNew();
9621
9622 MBCategoryModelImpl mbCategoryModelImpl = (MBCategoryModelImpl)mbCategory;
9623
9624 if (Validator.isNull(mbCategory.getUuid())) {
9625 String uuid = PortalUUIDUtil.generate();
9626
9627 mbCategory.setUuid(uuid);
9628 }
9629
9630 Session session = null;
9631
9632 try {
9633 session = openSession();
9634
9635 if (mbCategory.isNew()) {
9636 session.save(mbCategory);
9637
9638 mbCategory.setNew(false);
9639 }
9640 else {
9641 session.merge(mbCategory);
9642 }
9643 }
9644 catch (Exception e) {
9645 throw processException(e);
9646 }
9647 finally {
9648 closeSession(session);
9649 }
9650
9651 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
9652
9653 if (isNew || !MBCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
9654 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9655 }
9656
9657 else {
9658 if ((mbCategoryModelImpl.getColumnBitmask() &
9659 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
9660 Object[] args = new Object[] {
9661 mbCategoryModelImpl.getOriginalUuid()
9662 };
9663
9664 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
9665 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
9666 args);
9667
9668 args = new Object[] { mbCategoryModelImpl.getUuid() };
9669
9670 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
9671 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
9672 args);
9673 }
9674
9675 if ((mbCategoryModelImpl.getColumnBitmask() &
9676 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
9677 Object[] args = new Object[] {
9678 mbCategoryModelImpl.getOriginalUuid(),
9679 mbCategoryModelImpl.getOriginalCompanyId()
9680 };
9681
9682 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
9683 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
9684 args);
9685
9686 args = new Object[] {
9687 mbCategoryModelImpl.getUuid(),
9688 mbCategoryModelImpl.getCompanyId()
9689 };
9690
9691 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
9692 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
9693 args);
9694 }
9695
9696 if ((mbCategoryModelImpl.getColumnBitmask() &
9697 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
9698 Object[] args = new Object[] {
9699 mbCategoryModelImpl.getOriginalGroupId()
9700 };
9701
9702 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
9703 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
9704 args);
9705
9706 args = new Object[] { mbCategoryModelImpl.getGroupId() };
9707
9708 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
9709 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
9710 args);
9711 }
9712
9713 if ((mbCategoryModelImpl.getColumnBitmask() &
9714 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
9715 Object[] args = new Object[] {
9716 mbCategoryModelImpl.getOriginalCompanyId()
9717 };
9718
9719 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
9720 args);
9721 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
9722 args);
9723
9724 args = new Object[] { mbCategoryModelImpl.getCompanyId() };
9725
9726 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
9727 args);
9728 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
9729 args);
9730 }
9731
9732 if ((mbCategoryModelImpl.getColumnBitmask() &
9733 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
9734 Object[] args = new Object[] {
9735 mbCategoryModelImpl.getOriginalGroupId(),
9736 mbCategoryModelImpl.getOriginalParentCategoryId()
9737 };
9738
9739 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
9740 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
9741 args);
9742
9743 args = new Object[] {
9744 mbCategoryModelImpl.getGroupId(),
9745 mbCategoryModelImpl.getParentCategoryId()
9746 };
9747
9748 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
9749 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
9750 args);
9751 }
9752
9753 if ((mbCategoryModelImpl.getColumnBitmask() &
9754 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
9755 Object[] args = new Object[] {
9756 mbCategoryModelImpl.getOriginalGroupId(),
9757 mbCategoryModelImpl.getOriginalStatus()
9758 };
9759
9760 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
9761 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
9762 args);
9763
9764 args = new Object[] {
9765 mbCategoryModelImpl.getGroupId(),
9766 mbCategoryModelImpl.getStatus()
9767 };
9768
9769 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
9770 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
9771 args);
9772 }
9773
9774 if ((mbCategoryModelImpl.getColumnBitmask() &
9775 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
9776 Object[] args = new Object[] {
9777 mbCategoryModelImpl.getOriginalCompanyId(),
9778 mbCategoryModelImpl.getOriginalStatus()
9779 };
9780
9781 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
9782 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
9783 args);
9784
9785 args = new Object[] {
9786 mbCategoryModelImpl.getCompanyId(),
9787 mbCategoryModelImpl.getStatus()
9788 };
9789
9790 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
9791 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
9792 args);
9793 }
9794
9795 if ((mbCategoryModelImpl.getColumnBitmask() &
9796 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S.getColumnBitmask()) != 0) {
9797 Object[] args = new Object[] {
9798 mbCategoryModelImpl.getOriginalGroupId(),
9799 mbCategoryModelImpl.getOriginalParentCategoryId(),
9800 mbCategoryModelImpl.getOriginalStatus()
9801 };
9802
9803 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_S, args);
9804 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S,
9805 args);
9806
9807 args = new Object[] {
9808 mbCategoryModelImpl.getGroupId(),
9809 mbCategoryModelImpl.getParentCategoryId(),
9810 mbCategoryModelImpl.getStatus()
9811 };
9812
9813 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_S, args);
9814 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S,
9815 args);
9816 }
9817 }
9818
9819 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
9820 MBCategoryImpl.class, mbCategory.getPrimaryKey(), mbCategory, false);
9821
9822 clearUniqueFindersCache(mbCategory);
9823 cacheUniqueFindersCache(mbCategory);
9824
9825 mbCategory.resetOriginalValues();
9826
9827 return mbCategory;
9828 }
9829
9830 protected MBCategory toUnwrappedModel(MBCategory mbCategory) {
9831 if (mbCategory instanceof MBCategoryImpl) {
9832 return mbCategory;
9833 }
9834
9835 MBCategoryImpl mbCategoryImpl = new MBCategoryImpl();
9836
9837 mbCategoryImpl.setNew(mbCategory.isNew());
9838 mbCategoryImpl.setPrimaryKey(mbCategory.getPrimaryKey());
9839
9840 mbCategoryImpl.setUuid(mbCategory.getUuid());
9841 mbCategoryImpl.setCategoryId(mbCategory.getCategoryId());
9842 mbCategoryImpl.setGroupId(mbCategory.getGroupId());
9843 mbCategoryImpl.setCompanyId(mbCategory.getCompanyId());
9844 mbCategoryImpl.setUserId(mbCategory.getUserId());
9845 mbCategoryImpl.setUserName(mbCategory.getUserName());
9846 mbCategoryImpl.setCreateDate(mbCategory.getCreateDate());
9847 mbCategoryImpl.setModifiedDate(mbCategory.getModifiedDate());
9848 mbCategoryImpl.setParentCategoryId(mbCategory.getParentCategoryId());
9849 mbCategoryImpl.setName(mbCategory.getName());
9850 mbCategoryImpl.setDescription(mbCategory.getDescription());
9851 mbCategoryImpl.setDisplayStyle(mbCategory.getDisplayStyle());
9852 mbCategoryImpl.setThreadCount(mbCategory.getThreadCount());
9853 mbCategoryImpl.setMessageCount(mbCategory.getMessageCount());
9854 mbCategoryImpl.setLastPostDate(mbCategory.getLastPostDate());
9855 mbCategoryImpl.setStatus(mbCategory.getStatus());
9856 mbCategoryImpl.setStatusByUserId(mbCategory.getStatusByUserId());
9857 mbCategoryImpl.setStatusByUserName(mbCategory.getStatusByUserName());
9858 mbCategoryImpl.setStatusDate(mbCategory.getStatusDate());
9859
9860 return mbCategoryImpl;
9861 }
9862
9863
9870 @Override
9871 public MBCategory findByPrimaryKey(Serializable primaryKey)
9872 throws NoSuchCategoryException {
9873 MBCategory mbCategory = fetchByPrimaryKey(primaryKey);
9874
9875 if (mbCategory == null) {
9876 if (_log.isWarnEnabled()) {
9877 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
9878 }
9879
9880 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
9881 primaryKey);
9882 }
9883
9884 return mbCategory;
9885 }
9886
9887
9894 @Override
9895 public MBCategory findByPrimaryKey(long categoryId)
9896 throws NoSuchCategoryException {
9897 return findByPrimaryKey((Serializable)categoryId);
9898 }
9899
9900
9906 @Override
9907 public MBCategory fetchByPrimaryKey(Serializable primaryKey) {
9908 MBCategory mbCategory = (MBCategory)EntityCacheUtil.getResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
9909 MBCategoryImpl.class, primaryKey);
9910
9911 if (mbCategory == _nullMBCategory) {
9912 return null;
9913 }
9914
9915 if (mbCategory == null) {
9916 Session session = null;
9917
9918 try {
9919 session = openSession();
9920
9921 mbCategory = (MBCategory)session.get(MBCategoryImpl.class,
9922 primaryKey);
9923
9924 if (mbCategory != null) {
9925 cacheResult(mbCategory);
9926 }
9927 else {
9928 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
9929 MBCategoryImpl.class, primaryKey, _nullMBCategory);
9930 }
9931 }
9932 catch (Exception e) {
9933 EntityCacheUtil.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
9934 MBCategoryImpl.class, primaryKey);
9935
9936 throw processException(e);
9937 }
9938 finally {
9939 closeSession(session);
9940 }
9941 }
9942
9943 return mbCategory;
9944 }
9945
9946
9952 @Override
9953 public MBCategory fetchByPrimaryKey(long categoryId) {
9954 return fetchByPrimaryKey((Serializable)categoryId);
9955 }
9956
9957 @Override
9958 public Map<Serializable, MBCategory> fetchByPrimaryKeys(
9959 Set<Serializable> primaryKeys) {
9960 if (primaryKeys.isEmpty()) {
9961 return Collections.emptyMap();
9962 }
9963
9964 Map<Serializable, MBCategory> map = new HashMap<Serializable, MBCategory>();
9965
9966 if (primaryKeys.size() == 1) {
9967 Iterator<Serializable> iterator = primaryKeys.iterator();
9968
9969 Serializable primaryKey = iterator.next();
9970
9971 MBCategory mbCategory = fetchByPrimaryKey(primaryKey);
9972
9973 if (mbCategory != null) {
9974 map.put(primaryKey, mbCategory);
9975 }
9976
9977 return map;
9978 }
9979
9980 Set<Serializable> uncachedPrimaryKeys = null;
9981
9982 for (Serializable primaryKey : primaryKeys) {
9983 MBCategory mbCategory = (MBCategory)EntityCacheUtil.getResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
9984 MBCategoryImpl.class, primaryKey);
9985
9986 if (mbCategory == null) {
9987 if (uncachedPrimaryKeys == null) {
9988 uncachedPrimaryKeys = new HashSet<Serializable>();
9989 }
9990
9991 uncachedPrimaryKeys.add(primaryKey);
9992 }
9993 else {
9994 map.put(primaryKey, mbCategory);
9995 }
9996 }
9997
9998 if (uncachedPrimaryKeys == null) {
9999 return map;
10000 }
10001
10002 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
10003 1);
10004
10005 query.append(_SQL_SELECT_MBCATEGORY_WHERE_PKS_IN);
10006
10007 for (Serializable primaryKey : uncachedPrimaryKeys) {
10008 query.append(String.valueOf(primaryKey));
10009
10010 query.append(StringPool.COMMA);
10011 }
10012
10013 query.setIndex(query.index() - 1);
10014
10015 query.append(StringPool.CLOSE_PARENTHESIS);
10016
10017 String sql = query.toString();
10018
10019 Session session = null;
10020
10021 try {
10022 session = openSession();
10023
10024 Query q = session.createQuery(sql);
10025
10026 for (MBCategory mbCategory : (List<MBCategory>)q.list()) {
10027 map.put(mbCategory.getPrimaryKeyObj(), mbCategory);
10028
10029 cacheResult(mbCategory);
10030
10031 uncachedPrimaryKeys.remove(mbCategory.getPrimaryKeyObj());
10032 }
10033
10034 for (Serializable primaryKey : uncachedPrimaryKeys) {
10035 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
10036 MBCategoryImpl.class, primaryKey, _nullMBCategory);
10037 }
10038 }
10039 catch (Exception e) {
10040 throw processException(e);
10041 }
10042 finally {
10043 closeSession(session);
10044 }
10045
10046 return map;
10047 }
10048
10049
10054 @Override
10055 public List<MBCategory> findAll() {
10056 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10057 }
10058
10059
10070 @Override
10071 public List<MBCategory> findAll(int start, int end) {
10072 return findAll(start, end, null);
10073 }
10074
10075
10087 @Override
10088 public List<MBCategory> findAll(int start, int end,
10089 OrderByComparator<MBCategory> orderByComparator) {
10090 boolean pagination = true;
10091 FinderPath finderPath = null;
10092 Object[] finderArgs = null;
10093
10094 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10095 (orderByComparator == null)) {
10096 pagination = false;
10097 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
10098 finderArgs = FINDER_ARGS_EMPTY;
10099 }
10100 else {
10101 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
10102 finderArgs = new Object[] { start, end, orderByComparator };
10103 }
10104
10105 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
10106 finderArgs, this);
10107
10108 if (list == null) {
10109 StringBundler query = null;
10110 String sql = null;
10111
10112 if (orderByComparator != null) {
10113 query = new StringBundler(2 +
10114 (orderByComparator.getOrderByFields().length * 3));
10115
10116 query.append(_SQL_SELECT_MBCATEGORY);
10117
10118 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10119 orderByComparator);
10120
10121 sql = query.toString();
10122 }
10123 else {
10124 sql = _SQL_SELECT_MBCATEGORY;
10125
10126 if (pagination) {
10127 sql = sql.concat(MBCategoryModelImpl.ORDER_BY_JPQL);
10128 }
10129 }
10130
10131 Session session = null;
10132
10133 try {
10134 session = openSession();
10135
10136 Query q = session.createQuery(sql);
10137
10138 if (!pagination) {
10139 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
10140 start, end, false);
10141
10142 Collections.sort(list);
10143
10144 list = Collections.unmodifiableList(list);
10145 }
10146 else {
10147 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
10148 start, end);
10149 }
10150
10151 cacheResult(list);
10152
10153 FinderCacheUtil.putResult(finderPath, finderArgs, list);
10154 }
10155 catch (Exception e) {
10156 FinderCacheUtil.removeResult(finderPath, finderArgs);
10157
10158 throw processException(e);
10159 }
10160 finally {
10161 closeSession(session);
10162 }
10163 }
10164
10165 return list;
10166 }
10167
10168
10172 @Override
10173 public void removeAll() {
10174 for (MBCategory mbCategory : findAll()) {
10175 remove(mbCategory);
10176 }
10177 }
10178
10179
10184 @Override
10185 public int countAll() {
10186 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
10187 FINDER_ARGS_EMPTY, this);
10188
10189 if (count == null) {
10190 Session session = null;
10191
10192 try {
10193 session = openSession();
10194
10195 Query q = session.createQuery(_SQL_COUNT_MBCATEGORY);
10196
10197 count = (Long)q.uniqueResult();
10198
10199 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
10200 FINDER_ARGS_EMPTY, count);
10201 }
10202 catch (Exception e) {
10203 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
10204 FINDER_ARGS_EMPTY);
10205
10206 throw processException(e);
10207 }
10208 finally {
10209 closeSession(session);
10210 }
10211 }
10212
10213 return count.intValue();
10214 }
10215
10216 @Override
10217 protected Set<String> getBadColumnNames() {
10218 return _badColumnNames;
10219 }
10220
10221
10224 public void afterPropertiesSet() {
10225 }
10226
10227 public void destroy() {
10228 EntityCacheUtil.removeCache(MBCategoryImpl.class.getName());
10229 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
10230 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10231 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10232 }
10233
10234 private static final String _SQL_SELECT_MBCATEGORY = "SELECT mbCategory FROM MBCategory mbCategory";
10235 private static final String _SQL_SELECT_MBCATEGORY_WHERE_PKS_IN = "SELECT mbCategory FROM MBCategory mbCategory WHERE categoryId IN (";
10236 private static final String _SQL_SELECT_MBCATEGORY_WHERE = "SELECT mbCategory FROM MBCategory mbCategory WHERE ";
10237 private static final String _SQL_COUNT_MBCATEGORY = "SELECT COUNT(mbCategory) FROM MBCategory mbCategory";
10238 private static final String _SQL_COUNT_MBCATEGORY_WHERE = "SELECT COUNT(mbCategory) FROM MBCategory mbCategory WHERE ";
10239 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mbCategory.categoryId";
10240 private static final String _FILTER_SQL_SELECT_MBCATEGORY_WHERE = "SELECT DISTINCT {mbCategory.*} FROM MBCategory mbCategory WHERE ";
10241 private static final String _FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
10242 "SELECT {MBCategory.*} FROM (SELECT DISTINCT mbCategory.categoryId FROM MBCategory mbCategory WHERE ";
10243 private static final String _FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
10244 ") TEMP_TABLE INNER JOIN MBCategory ON TEMP_TABLE.categoryId = MBCategory.categoryId";
10245 private static final String _FILTER_SQL_COUNT_MBCATEGORY_WHERE = "SELECT COUNT(DISTINCT mbCategory.categoryId) AS COUNT_VALUE FROM MBCategory mbCategory WHERE ";
10246 private static final String _FILTER_ENTITY_ALIAS = "mbCategory";
10247 private static final String _FILTER_ENTITY_TABLE = "MBCategory";
10248 private static final String _ORDER_BY_ENTITY_ALIAS = "mbCategory.";
10249 private static final String _ORDER_BY_ENTITY_TABLE = "MBCategory.";
10250 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBCategory exists with the primary key ";
10251 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBCategory exists with the key {";
10252 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
10253 private static final Log _log = LogFactoryUtil.getLog(MBCategoryPersistenceImpl.class);
10254 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
10255 "uuid"
10256 });
10257 private static final MBCategory _nullMBCategory = new MBCategoryImpl() {
10258 @Override
10259 public Object clone() {
10260 return this;
10261 }
10262
10263 @Override
10264 public CacheModel<MBCategory> toCacheModel() {
10265 return _nullMBCategoryCacheModel;
10266 }
10267 };
10268
10269 private static final CacheModel<MBCategory> _nullMBCategoryCacheModel = new CacheModel<MBCategory>() {
10270 @Override
10271 public MBCategory toEntityModel() {
10272 return _nullMBCategory;
10273 }
10274 };
10275 }