001
014
015 package com.liferay.portlet.asset.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.asset.kernel.exception.NoSuchCategoryException;
020 import com.liferay.asset.kernel.model.AssetCategory;
021 import com.liferay.asset.kernel.service.persistence.AssetCategoryPersistence;
022 import com.liferay.asset.kernel.service.persistence.AssetEntryPersistence;
023
024 import com.liferay.portal.kernel.bean.BeanReference;
025 import com.liferay.portal.kernel.dao.orm.EntityCache;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCache;
028 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
029 import com.liferay.portal.kernel.dao.orm.FinderPath;
030 import com.liferay.portal.kernel.dao.orm.Query;
031 import com.liferay.portal.kernel.dao.orm.QueryPos;
032 import com.liferay.portal.kernel.dao.orm.QueryUtil;
033 import com.liferay.portal.kernel.dao.orm.SQLQuery;
034 import com.liferay.portal.kernel.dao.orm.Session;
035 import com.liferay.portal.kernel.exception.SystemException;
036 import com.liferay.portal.kernel.log.Log;
037 import com.liferay.portal.kernel.log.LogFactoryUtil;
038 import com.liferay.portal.kernel.model.CacheModel;
039 import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
040 import com.liferay.portal.kernel.service.ServiceContext;
041 import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
042 import com.liferay.portal.kernel.service.persistence.CompanyProvider;
043 import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
044 import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
045 import com.liferay.portal.kernel.service.persistence.impl.NestedSetsTreeManager;
046 import com.liferay.portal.kernel.service.persistence.impl.PersistenceNestedSetsTreeManager;
047 import com.liferay.portal.kernel.service.persistence.impl.TableMapper;
048 import com.liferay.portal.kernel.service.persistence.impl.TableMapperFactory;
049 import com.liferay.portal.kernel.util.ArrayUtil;
050 import com.liferay.portal.kernel.util.CharPool;
051 import com.liferay.portal.kernel.util.OrderByComparator;
052 import com.liferay.portal.kernel.util.SetUtil;
053 import com.liferay.portal.kernel.util.StringBundler;
054 import com.liferay.portal.kernel.util.StringPool;
055 import com.liferay.portal.kernel.util.StringUtil;
056 import com.liferay.portal.kernel.util.Validator;
057 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
058
059 import com.liferay.portlet.asset.model.impl.AssetCategoryImpl;
060 import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl;
061
062 import java.io.Serializable;
063
064 import java.util.Arrays;
065 import java.util.Collections;
066 import java.util.Date;
067 import java.util.HashMap;
068 import java.util.HashSet;
069 import java.util.Iterator;
070 import java.util.List;
071 import java.util.Map;
072 import java.util.Objects;
073 import java.util.Set;
074
075
087 @ProviderType
088 public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
089 implements AssetCategoryPersistence {
090
095 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
096 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
097 ".List1";
098 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
099 ".List2";
100 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
101 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
102 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
103 "findAll", new String[0]);
104 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
105 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
106 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
107 "findAll", new String[0]);
108 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
109 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
111 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
112 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
113 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countAncestors",
114 new String[] {
115 Long.class.getName(), Long.class.getName(), Long.class.getName()
116 });
117 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS =
118 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
119 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
120 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countDescendants",
121 new String[] {
122 Long.class.getName(), Long.class.getName(), Long.class.getName()
123 });
124 public static final FinderPath FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
125 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
126 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
127 "getAncestors",
128 new String[] {
129 Long.class.getName(), Long.class.getName(), Long.class.getName()
130 });
131 public static final FinderPath FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
132 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
133 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
134 "getDescendants",
135 new String[] {
136 Long.class.getName(), Long.class.getName(), Long.class.getName()
137 });
138 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
139 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
140 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
141 "findByUuid",
142 new String[] {
143 String.class.getName(),
144
145 Integer.class.getName(), Integer.class.getName(),
146 OrderByComparator.class.getName()
147 });
148 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
149 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
150 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
151 "findByUuid", new String[] { String.class.getName() },
152 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
153 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
154 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
155 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
156 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
157 new String[] { String.class.getName() });
158
159
165 @Override
166 public List<AssetCategory> findByUuid(String uuid) {
167 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
168 }
169
170
182 @Override
183 public List<AssetCategory> findByUuid(String uuid, int start, int end) {
184 return findByUuid(uuid, start, end, null);
185 }
186
187
200 @Override
201 public List<AssetCategory> findByUuid(String uuid, int start, int end,
202 OrderByComparator<AssetCategory> orderByComparator) {
203 return findByUuid(uuid, start, end, orderByComparator, true);
204 }
205
206
220 @Override
221 public List<AssetCategory> findByUuid(String uuid, int start, int end,
222 OrderByComparator<AssetCategory> orderByComparator,
223 boolean retrieveFromCache) {
224 boolean pagination = true;
225 FinderPath finderPath = null;
226 Object[] finderArgs = null;
227
228 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
229 (orderByComparator == null)) {
230 pagination = false;
231 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
232 finderArgs = new Object[] { uuid };
233 }
234 else {
235 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
236 finderArgs = new Object[] { uuid, start, end, orderByComparator };
237 }
238
239 List<AssetCategory> list = null;
240
241 if (retrieveFromCache) {
242 list = (List<AssetCategory>)finderCache.getResult(finderPath,
243 finderArgs, this);
244
245 if ((list != null) && !list.isEmpty()) {
246 for (AssetCategory assetCategory : list) {
247 if (!Objects.equals(uuid, assetCategory.getUuid())) {
248 list = null;
249
250 break;
251 }
252 }
253 }
254 }
255
256 if (list == null) {
257 StringBundler query = null;
258
259 if (orderByComparator != null) {
260 query = new StringBundler(3 +
261 (orderByComparator.getOrderByFields().length * 2));
262 }
263 else {
264 query = new StringBundler(3);
265 }
266
267 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
268
269 boolean bindUuid = false;
270
271 if (uuid == null) {
272 query.append(_FINDER_COLUMN_UUID_UUID_1);
273 }
274 else if (uuid.equals(StringPool.BLANK)) {
275 query.append(_FINDER_COLUMN_UUID_UUID_3);
276 }
277 else {
278 bindUuid = true;
279
280 query.append(_FINDER_COLUMN_UUID_UUID_2);
281 }
282
283 if (orderByComparator != null) {
284 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
285 orderByComparator);
286 }
287 else
288 if (pagination) {
289 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
290 }
291
292 String sql = query.toString();
293
294 Session session = null;
295
296 try {
297 session = openSession();
298
299 Query q = session.createQuery(sql);
300
301 QueryPos qPos = QueryPos.getInstance(q);
302
303 if (bindUuid) {
304 qPos.add(uuid);
305 }
306
307 if (!pagination) {
308 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
309 start, end, false);
310
311 Collections.sort(list);
312
313 list = Collections.unmodifiableList(list);
314 }
315 else {
316 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
317 start, end);
318 }
319
320 cacheResult(list);
321
322 finderCache.putResult(finderPath, finderArgs, list);
323 }
324 catch (Exception e) {
325 finderCache.removeResult(finderPath, finderArgs);
326
327 throw processException(e);
328 }
329 finally {
330 closeSession(session);
331 }
332 }
333
334 return list;
335 }
336
337
345 @Override
346 public AssetCategory findByUuid_First(String uuid,
347 OrderByComparator<AssetCategory> orderByComparator)
348 throws NoSuchCategoryException {
349 AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator);
350
351 if (assetCategory != null) {
352 return assetCategory;
353 }
354
355 StringBundler msg = new StringBundler(4);
356
357 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
358
359 msg.append("uuid=");
360 msg.append(uuid);
361
362 msg.append(StringPool.CLOSE_CURLY_BRACE);
363
364 throw new NoSuchCategoryException(msg.toString());
365 }
366
367
374 @Override
375 public AssetCategory fetchByUuid_First(String uuid,
376 OrderByComparator<AssetCategory> orderByComparator) {
377 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
378
379 if (!list.isEmpty()) {
380 return list.get(0);
381 }
382
383 return null;
384 }
385
386
394 @Override
395 public AssetCategory findByUuid_Last(String uuid,
396 OrderByComparator<AssetCategory> orderByComparator)
397 throws NoSuchCategoryException {
398 AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator);
399
400 if (assetCategory != null) {
401 return assetCategory;
402 }
403
404 StringBundler msg = new StringBundler(4);
405
406 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
407
408 msg.append("uuid=");
409 msg.append(uuid);
410
411 msg.append(StringPool.CLOSE_CURLY_BRACE);
412
413 throw new NoSuchCategoryException(msg.toString());
414 }
415
416
423 @Override
424 public AssetCategory fetchByUuid_Last(String uuid,
425 OrderByComparator<AssetCategory> orderByComparator) {
426 int count = countByUuid(uuid);
427
428 if (count == 0) {
429 return null;
430 }
431
432 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
433 orderByComparator);
434
435 if (!list.isEmpty()) {
436 return list.get(0);
437 }
438
439 return null;
440 }
441
442
451 @Override
452 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
453 OrderByComparator<AssetCategory> orderByComparator)
454 throws NoSuchCategoryException {
455 AssetCategory assetCategory = findByPrimaryKey(categoryId);
456
457 Session session = null;
458
459 try {
460 session = openSession();
461
462 AssetCategory[] array = new AssetCategoryImpl[3];
463
464 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
465 orderByComparator, true);
466
467 array[1] = assetCategory;
468
469 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
470 orderByComparator, false);
471
472 return array;
473 }
474 catch (Exception e) {
475 throw processException(e);
476 }
477 finally {
478 closeSession(session);
479 }
480 }
481
482 protected AssetCategory getByUuid_PrevAndNext(Session session,
483 AssetCategory assetCategory, String uuid,
484 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
485 StringBundler query = null;
486
487 if (orderByComparator != null) {
488 query = new StringBundler(4 +
489 (orderByComparator.getOrderByConditionFields().length * 3) +
490 (orderByComparator.getOrderByFields().length * 3));
491 }
492 else {
493 query = new StringBundler(3);
494 }
495
496 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
497
498 boolean bindUuid = false;
499
500 if (uuid == null) {
501 query.append(_FINDER_COLUMN_UUID_UUID_1);
502 }
503 else if (uuid.equals(StringPool.BLANK)) {
504 query.append(_FINDER_COLUMN_UUID_UUID_3);
505 }
506 else {
507 bindUuid = true;
508
509 query.append(_FINDER_COLUMN_UUID_UUID_2);
510 }
511
512 if (orderByComparator != null) {
513 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
514
515 if (orderByConditionFields.length > 0) {
516 query.append(WHERE_AND);
517 }
518
519 for (int i = 0; i < orderByConditionFields.length; i++) {
520 query.append(_ORDER_BY_ENTITY_ALIAS);
521 query.append(orderByConditionFields[i]);
522
523 if ((i + 1) < orderByConditionFields.length) {
524 if (orderByComparator.isAscending() ^ previous) {
525 query.append(WHERE_GREATER_THAN_HAS_NEXT);
526 }
527 else {
528 query.append(WHERE_LESSER_THAN_HAS_NEXT);
529 }
530 }
531 else {
532 if (orderByComparator.isAscending() ^ previous) {
533 query.append(WHERE_GREATER_THAN);
534 }
535 else {
536 query.append(WHERE_LESSER_THAN);
537 }
538 }
539 }
540
541 query.append(ORDER_BY_CLAUSE);
542
543 String[] orderByFields = orderByComparator.getOrderByFields();
544
545 for (int i = 0; i < orderByFields.length; i++) {
546 query.append(_ORDER_BY_ENTITY_ALIAS);
547 query.append(orderByFields[i]);
548
549 if ((i + 1) < orderByFields.length) {
550 if (orderByComparator.isAscending() ^ previous) {
551 query.append(ORDER_BY_ASC_HAS_NEXT);
552 }
553 else {
554 query.append(ORDER_BY_DESC_HAS_NEXT);
555 }
556 }
557 else {
558 if (orderByComparator.isAscending() ^ previous) {
559 query.append(ORDER_BY_ASC);
560 }
561 else {
562 query.append(ORDER_BY_DESC);
563 }
564 }
565 }
566 }
567 else {
568 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
569 }
570
571 String sql = query.toString();
572
573 Query q = session.createQuery(sql);
574
575 q.setFirstResult(0);
576 q.setMaxResults(2);
577
578 QueryPos qPos = QueryPos.getInstance(q);
579
580 if (bindUuid) {
581 qPos.add(uuid);
582 }
583
584 if (orderByComparator != null) {
585 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
586
587 for (Object value : values) {
588 qPos.add(value);
589 }
590 }
591
592 List<AssetCategory> list = q.list();
593
594 if (list.size() == 2) {
595 return list.get(1);
596 }
597 else {
598 return null;
599 }
600 }
601
602
607 @Override
608 public void removeByUuid(String uuid) {
609 for (AssetCategory assetCategory : findByUuid(uuid, QueryUtil.ALL_POS,
610 QueryUtil.ALL_POS, null)) {
611 remove(assetCategory);
612 }
613 }
614
615
621 @Override
622 public int countByUuid(String uuid) {
623 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
624
625 Object[] finderArgs = new Object[] { uuid };
626
627 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
628
629 if (count == null) {
630 StringBundler query = new StringBundler(2);
631
632 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
633
634 boolean bindUuid = false;
635
636 if (uuid == null) {
637 query.append(_FINDER_COLUMN_UUID_UUID_1);
638 }
639 else if (uuid.equals(StringPool.BLANK)) {
640 query.append(_FINDER_COLUMN_UUID_UUID_3);
641 }
642 else {
643 bindUuid = true;
644
645 query.append(_FINDER_COLUMN_UUID_UUID_2);
646 }
647
648 String sql = query.toString();
649
650 Session session = null;
651
652 try {
653 session = openSession();
654
655 Query q = session.createQuery(sql);
656
657 QueryPos qPos = QueryPos.getInstance(q);
658
659 if (bindUuid) {
660 qPos.add(uuid);
661 }
662
663 count = (Long)q.uniqueResult();
664
665 finderCache.putResult(finderPath, finderArgs, count);
666 }
667 catch (Exception e) {
668 finderCache.removeResult(finderPath, finderArgs);
669
670 throw processException(e);
671 }
672 finally {
673 closeSession(session);
674 }
675 }
676
677 return count.intValue();
678 }
679
680 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
681 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
682 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '')";
683 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
684 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
685 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
686 new String[] { String.class.getName(), Long.class.getName() },
687 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
688 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
689 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
690 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
691 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
692 new String[] { String.class.getName(), Long.class.getName() });
693
694
702 @Override
703 public AssetCategory findByUUID_G(String uuid, long groupId)
704 throws NoSuchCategoryException {
705 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
706
707 if (assetCategory == null) {
708 StringBundler msg = new StringBundler(6);
709
710 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
711
712 msg.append("uuid=");
713 msg.append(uuid);
714
715 msg.append(", groupId=");
716 msg.append(groupId);
717
718 msg.append(StringPool.CLOSE_CURLY_BRACE);
719
720 if (_log.isDebugEnabled()) {
721 _log.debug(msg.toString());
722 }
723
724 throw new NoSuchCategoryException(msg.toString());
725 }
726
727 return assetCategory;
728 }
729
730
737 @Override
738 public AssetCategory fetchByUUID_G(String uuid, long groupId) {
739 return fetchByUUID_G(uuid, groupId, true);
740 }
741
742
750 @Override
751 public AssetCategory fetchByUUID_G(String uuid, long groupId,
752 boolean retrieveFromCache) {
753 Object[] finderArgs = new Object[] { uuid, groupId };
754
755 Object result = null;
756
757 if (retrieveFromCache) {
758 result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
759 finderArgs, this);
760 }
761
762 if (result instanceof AssetCategory) {
763 AssetCategory assetCategory = (AssetCategory)result;
764
765 if (!Objects.equals(uuid, assetCategory.getUuid()) ||
766 (groupId != assetCategory.getGroupId())) {
767 result = null;
768 }
769 }
770
771 if (result == null) {
772 StringBundler query = new StringBundler(4);
773
774 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
775
776 boolean bindUuid = false;
777
778 if (uuid == null) {
779 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
780 }
781 else if (uuid.equals(StringPool.BLANK)) {
782 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
783 }
784 else {
785 bindUuid = true;
786
787 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
788 }
789
790 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
791
792 String sql = query.toString();
793
794 Session session = null;
795
796 try {
797 session = openSession();
798
799 Query q = session.createQuery(sql);
800
801 QueryPos qPos = QueryPos.getInstance(q);
802
803 if (bindUuid) {
804 qPos.add(uuid);
805 }
806
807 qPos.add(groupId);
808
809 List<AssetCategory> list = q.list();
810
811 if (list.isEmpty()) {
812 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
813 finderArgs, list);
814 }
815 else {
816 AssetCategory assetCategory = list.get(0);
817
818 result = assetCategory;
819
820 cacheResult(assetCategory);
821
822 if ((assetCategory.getUuid() == null) ||
823 !assetCategory.getUuid().equals(uuid) ||
824 (assetCategory.getGroupId() != groupId)) {
825 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
826 finderArgs, assetCategory);
827 }
828 }
829 }
830 catch (Exception e) {
831 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
832
833 throw processException(e);
834 }
835 finally {
836 closeSession(session);
837 }
838 }
839
840 if (result instanceof List<?>) {
841 return null;
842 }
843 else {
844 return (AssetCategory)result;
845 }
846 }
847
848
855 @Override
856 public AssetCategory removeByUUID_G(String uuid, long groupId)
857 throws NoSuchCategoryException {
858 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
859
860 return remove(assetCategory);
861 }
862
863
870 @Override
871 public int countByUUID_G(String uuid, long groupId) {
872 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
873
874 Object[] finderArgs = new Object[] { uuid, groupId };
875
876 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
877
878 if (count == null) {
879 StringBundler query = new StringBundler(3);
880
881 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
882
883 boolean bindUuid = false;
884
885 if (uuid == null) {
886 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
887 }
888 else if (uuid.equals(StringPool.BLANK)) {
889 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
890 }
891 else {
892 bindUuid = true;
893
894 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
895 }
896
897 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
898
899 String sql = query.toString();
900
901 Session session = null;
902
903 try {
904 session = openSession();
905
906 Query q = session.createQuery(sql);
907
908 QueryPos qPos = QueryPos.getInstance(q);
909
910 if (bindUuid) {
911 qPos.add(uuid);
912 }
913
914 qPos.add(groupId);
915
916 count = (Long)q.uniqueResult();
917
918 finderCache.putResult(finderPath, finderArgs, count);
919 }
920 catch (Exception e) {
921 finderCache.removeResult(finderPath, finderArgs);
922
923 throw processException(e);
924 }
925 finally {
926 closeSession(session);
927 }
928 }
929
930 return count.intValue();
931 }
932
933 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
934 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
935 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
936 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
937 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
938 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
939 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
940 "findByUuid_C",
941 new String[] {
942 String.class.getName(), Long.class.getName(),
943
944 Integer.class.getName(), Integer.class.getName(),
945 OrderByComparator.class.getName()
946 });
947 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
948 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
949 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
950 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
951 "findByUuid_C",
952 new String[] { String.class.getName(), Long.class.getName() },
953 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
954 AssetCategoryModelImpl.COMPANYID_COLUMN_BITMASK |
955 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
956 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
957 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
958 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
959 new String[] { String.class.getName(), Long.class.getName() });
960
961
968 @Override
969 public List<AssetCategory> findByUuid_C(String uuid, long companyId) {
970 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
971 QueryUtil.ALL_POS, null);
972 }
973
974
987 @Override
988 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
989 int start, int end) {
990 return findByUuid_C(uuid, companyId, start, end, null);
991 }
992
993
1007 @Override
1008 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
1009 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
1010 return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
1011 }
1012
1013
1028 @Override
1029 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
1030 int start, int end, OrderByComparator<AssetCategory> orderByComparator,
1031 boolean retrieveFromCache) {
1032 boolean pagination = true;
1033 FinderPath finderPath = null;
1034 Object[] finderArgs = null;
1035
1036 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1037 (orderByComparator == null)) {
1038 pagination = false;
1039 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1040 finderArgs = new Object[] { uuid, companyId };
1041 }
1042 else {
1043 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1044 finderArgs = new Object[] {
1045 uuid, companyId,
1046
1047 start, end, orderByComparator
1048 };
1049 }
1050
1051 List<AssetCategory> list = null;
1052
1053 if (retrieveFromCache) {
1054 list = (List<AssetCategory>)finderCache.getResult(finderPath,
1055 finderArgs, this);
1056
1057 if ((list != null) && !list.isEmpty()) {
1058 for (AssetCategory assetCategory : list) {
1059 if (!Objects.equals(uuid, assetCategory.getUuid()) ||
1060 (companyId != assetCategory.getCompanyId())) {
1061 list = null;
1062
1063 break;
1064 }
1065 }
1066 }
1067 }
1068
1069 if (list == null) {
1070 StringBundler query = null;
1071
1072 if (orderByComparator != null) {
1073 query = new StringBundler(4 +
1074 (orderByComparator.getOrderByFields().length * 2));
1075 }
1076 else {
1077 query = new StringBundler(4);
1078 }
1079
1080 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1081
1082 boolean bindUuid = false;
1083
1084 if (uuid == null) {
1085 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1086 }
1087 else if (uuid.equals(StringPool.BLANK)) {
1088 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1089 }
1090 else {
1091 bindUuid = true;
1092
1093 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1094 }
1095
1096 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1097
1098 if (orderByComparator != null) {
1099 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1100 orderByComparator);
1101 }
1102 else
1103 if (pagination) {
1104 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1105 }
1106
1107 String sql = query.toString();
1108
1109 Session session = null;
1110
1111 try {
1112 session = openSession();
1113
1114 Query q = session.createQuery(sql);
1115
1116 QueryPos qPos = QueryPos.getInstance(q);
1117
1118 if (bindUuid) {
1119 qPos.add(uuid);
1120 }
1121
1122 qPos.add(companyId);
1123
1124 if (!pagination) {
1125 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1126 start, end, false);
1127
1128 Collections.sort(list);
1129
1130 list = Collections.unmodifiableList(list);
1131 }
1132 else {
1133 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1134 start, end);
1135 }
1136
1137 cacheResult(list);
1138
1139 finderCache.putResult(finderPath, finderArgs, list);
1140 }
1141 catch (Exception e) {
1142 finderCache.removeResult(finderPath, finderArgs);
1143
1144 throw processException(e);
1145 }
1146 finally {
1147 closeSession(session);
1148 }
1149 }
1150
1151 return list;
1152 }
1153
1154
1163 @Override
1164 public AssetCategory findByUuid_C_First(String uuid, long companyId,
1165 OrderByComparator<AssetCategory> orderByComparator)
1166 throws NoSuchCategoryException {
1167 AssetCategory assetCategory = fetchByUuid_C_First(uuid, companyId,
1168 orderByComparator);
1169
1170 if (assetCategory != null) {
1171 return assetCategory;
1172 }
1173
1174 StringBundler msg = new StringBundler(6);
1175
1176 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1177
1178 msg.append("uuid=");
1179 msg.append(uuid);
1180
1181 msg.append(", companyId=");
1182 msg.append(companyId);
1183
1184 msg.append(StringPool.CLOSE_CURLY_BRACE);
1185
1186 throw new NoSuchCategoryException(msg.toString());
1187 }
1188
1189
1197 @Override
1198 public AssetCategory fetchByUuid_C_First(String uuid, long companyId,
1199 OrderByComparator<AssetCategory> orderByComparator) {
1200 List<AssetCategory> list = findByUuid_C(uuid, companyId, 0, 1,
1201 orderByComparator);
1202
1203 if (!list.isEmpty()) {
1204 return list.get(0);
1205 }
1206
1207 return null;
1208 }
1209
1210
1219 @Override
1220 public AssetCategory findByUuid_C_Last(String uuid, long companyId,
1221 OrderByComparator<AssetCategory> orderByComparator)
1222 throws NoSuchCategoryException {
1223 AssetCategory assetCategory = fetchByUuid_C_Last(uuid, companyId,
1224 orderByComparator);
1225
1226 if (assetCategory != null) {
1227 return assetCategory;
1228 }
1229
1230 StringBundler msg = new StringBundler(6);
1231
1232 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1233
1234 msg.append("uuid=");
1235 msg.append(uuid);
1236
1237 msg.append(", companyId=");
1238 msg.append(companyId);
1239
1240 msg.append(StringPool.CLOSE_CURLY_BRACE);
1241
1242 throw new NoSuchCategoryException(msg.toString());
1243 }
1244
1245
1253 @Override
1254 public AssetCategory fetchByUuid_C_Last(String uuid, long companyId,
1255 OrderByComparator<AssetCategory> orderByComparator) {
1256 int count = countByUuid_C(uuid, companyId);
1257
1258 if (count == 0) {
1259 return null;
1260 }
1261
1262 List<AssetCategory> list = findByUuid_C(uuid, companyId, count - 1,
1263 count, orderByComparator);
1264
1265 if (!list.isEmpty()) {
1266 return list.get(0);
1267 }
1268
1269 return null;
1270 }
1271
1272
1282 @Override
1283 public AssetCategory[] findByUuid_C_PrevAndNext(long categoryId,
1284 String uuid, long companyId,
1285 OrderByComparator<AssetCategory> orderByComparator)
1286 throws NoSuchCategoryException {
1287 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1288
1289 Session session = null;
1290
1291 try {
1292 session = openSession();
1293
1294 AssetCategory[] array = new AssetCategoryImpl[3];
1295
1296 array[0] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1297 companyId, orderByComparator, true);
1298
1299 array[1] = assetCategory;
1300
1301 array[2] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1302 companyId, orderByComparator, false);
1303
1304 return array;
1305 }
1306 catch (Exception e) {
1307 throw processException(e);
1308 }
1309 finally {
1310 closeSession(session);
1311 }
1312 }
1313
1314 protected AssetCategory getByUuid_C_PrevAndNext(Session session,
1315 AssetCategory assetCategory, String uuid, long companyId,
1316 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
1317 StringBundler query = null;
1318
1319 if (orderByComparator != null) {
1320 query = new StringBundler(5 +
1321 (orderByComparator.getOrderByConditionFields().length * 3) +
1322 (orderByComparator.getOrderByFields().length * 3));
1323 }
1324 else {
1325 query = new StringBundler(4);
1326 }
1327
1328 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1329
1330 boolean bindUuid = false;
1331
1332 if (uuid == null) {
1333 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1334 }
1335 else if (uuid.equals(StringPool.BLANK)) {
1336 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1337 }
1338 else {
1339 bindUuid = true;
1340
1341 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1342 }
1343
1344 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1345
1346 if (orderByComparator != null) {
1347 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1348
1349 if (orderByConditionFields.length > 0) {
1350 query.append(WHERE_AND);
1351 }
1352
1353 for (int i = 0; i < orderByConditionFields.length; i++) {
1354 query.append(_ORDER_BY_ENTITY_ALIAS);
1355 query.append(orderByConditionFields[i]);
1356
1357 if ((i + 1) < orderByConditionFields.length) {
1358 if (orderByComparator.isAscending() ^ previous) {
1359 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1360 }
1361 else {
1362 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1363 }
1364 }
1365 else {
1366 if (orderByComparator.isAscending() ^ previous) {
1367 query.append(WHERE_GREATER_THAN);
1368 }
1369 else {
1370 query.append(WHERE_LESSER_THAN);
1371 }
1372 }
1373 }
1374
1375 query.append(ORDER_BY_CLAUSE);
1376
1377 String[] orderByFields = orderByComparator.getOrderByFields();
1378
1379 for (int i = 0; i < orderByFields.length; i++) {
1380 query.append(_ORDER_BY_ENTITY_ALIAS);
1381 query.append(orderByFields[i]);
1382
1383 if ((i + 1) < orderByFields.length) {
1384 if (orderByComparator.isAscending() ^ previous) {
1385 query.append(ORDER_BY_ASC_HAS_NEXT);
1386 }
1387 else {
1388 query.append(ORDER_BY_DESC_HAS_NEXT);
1389 }
1390 }
1391 else {
1392 if (orderByComparator.isAscending() ^ previous) {
1393 query.append(ORDER_BY_ASC);
1394 }
1395 else {
1396 query.append(ORDER_BY_DESC);
1397 }
1398 }
1399 }
1400 }
1401 else {
1402 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1403 }
1404
1405 String sql = query.toString();
1406
1407 Query q = session.createQuery(sql);
1408
1409 q.setFirstResult(0);
1410 q.setMaxResults(2);
1411
1412 QueryPos qPos = QueryPos.getInstance(q);
1413
1414 if (bindUuid) {
1415 qPos.add(uuid);
1416 }
1417
1418 qPos.add(companyId);
1419
1420 if (orderByComparator != null) {
1421 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1422
1423 for (Object value : values) {
1424 qPos.add(value);
1425 }
1426 }
1427
1428 List<AssetCategory> list = q.list();
1429
1430 if (list.size() == 2) {
1431 return list.get(1);
1432 }
1433 else {
1434 return null;
1435 }
1436 }
1437
1438
1444 @Override
1445 public void removeByUuid_C(String uuid, long companyId) {
1446 for (AssetCategory assetCategory : findByUuid_C(uuid, companyId,
1447 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1448 remove(assetCategory);
1449 }
1450 }
1451
1452
1459 @Override
1460 public int countByUuid_C(String uuid, long companyId) {
1461 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1462
1463 Object[] finderArgs = new Object[] { uuid, companyId };
1464
1465 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1466
1467 if (count == null) {
1468 StringBundler query = new StringBundler(3);
1469
1470 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
1471
1472 boolean bindUuid = false;
1473
1474 if (uuid == null) {
1475 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1476 }
1477 else if (uuid.equals(StringPool.BLANK)) {
1478 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1479 }
1480 else {
1481 bindUuid = true;
1482
1483 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1484 }
1485
1486 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1487
1488 String sql = query.toString();
1489
1490 Session session = null;
1491
1492 try {
1493 session = openSession();
1494
1495 Query q = session.createQuery(sql);
1496
1497 QueryPos qPos = QueryPos.getInstance(q);
1498
1499 if (bindUuid) {
1500 qPos.add(uuid);
1501 }
1502
1503 qPos.add(companyId);
1504
1505 count = (Long)q.uniqueResult();
1506
1507 finderCache.putResult(finderPath, finderArgs, count);
1508 }
1509 catch (Exception e) {
1510 finderCache.removeResult(finderPath, finderArgs);
1511
1512 throw processException(e);
1513 }
1514 finally {
1515 closeSession(session);
1516 }
1517 }
1518
1519 return count.intValue();
1520 }
1521
1522 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetCategory.uuid IS NULL AND ";
1523 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetCategory.uuid = ? AND ";
1524 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
1525 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetCategory.companyId = ?";
1526 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1527 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
1528 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1529 "findByGroupId",
1530 new String[] {
1531 Long.class.getName(),
1532
1533 Integer.class.getName(), Integer.class.getName(),
1534 OrderByComparator.class.getName()
1535 });
1536 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1537 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1538 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
1539 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1540 "findByGroupId", new String[] { Long.class.getName() },
1541 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
1542 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
1543 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1544 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1545 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1546 new String[] { Long.class.getName() });
1547
1548
1554 @Override
1555 public List<AssetCategory> findByGroupId(long groupId) {
1556 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1557 }
1558
1559
1571 @Override
1572 public List<AssetCategory> findByGroupId(long groupId, int start, int end) {
1573 return findByGroupId(groupId, start, end, null);
1574 }
1575
1576
1589 @Override
1590 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1591 OrderByComparator<AssetCategory> orderByComparator) {
1592 return findByGroupId(groupId, start, end, orderByComparator, true);
1593 }
1594
1595
1609 @Override
1610 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1611 OrderByComparator<AssetCategory> orderByComparator,
1612 boolean retrieveFromCache) {
1613 boolean pagination = true;
1614 FinderPath finderPath = null;
1615 Object[] finderArgs = null;
1616
1617 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1618 (orderByComparator == null)) {
1619 pagination = false;
1620 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1621 finderArgs = new Object[] { groupId };
1622 }
1623 else {
1624 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1625 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1626 }
1627
1628 List<AssetCategory> list = null;
1629
1630 if (retrieveFromCache) {
1631 list = (List<AssetCategory>)finderCache.getResult(finderPath,
1632 finderArgs, this);
1633
1634 if ((list != null) && !list.isEmpty()) {
1635 for (AssetCategory assetCategory : list) {
1636 if ((groupId != assetCategory.getGroupId())) {
1637 list = null;
1638
1639 break;
1640 }
1641 }
1642 }
1643 }
1644
1645 if (list == null) {
1646 StringBundler query = null;
1647
1648 if (orderByComparator != null) {
1649 query = new StringBundler(3 +
1650 (orderByComparator.getOrderByFields().length * 2));
1651 }
1652 else {
1653 query = new StringBundler(3);
1654 }
1655
1656 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1657
1658 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1659
1660 if (orderByComparator != null) {
1661 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1662 orderByComparator);
1663 }
1664 else
1665 if (pagination) {
1666 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1667 }
1668
1669 String sql = query.toString();
1670
1671 Session session = null;
1672
1673 try {
1674 session = openSession();
1675
1676 Query q = session.createQuery(sql);
1677
1678 QueryPos qPos = QueryPos.getInstance(q);
1679
1680 qPos.add(groupId);
1681
1682 if (!pagination) {
1683 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1684 start, end, false);
1685
1686 Collections.sort(list);
1687
1688 list = Collections.unmodifiableList(list);
1689 }
1690 else {
1691 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1692 start, end);
1693 }
1694
1695 cacheResult(list);
1696
1697 finderCache.putResult(finderPath, finderArgs, list);
1698 }
1699 catch (Exception e) {
1700 finderCache.removeResult(finderPath, finderArgs);
1701
1702 throw processException(e);
1703 }
1704 finally {
1705 closeSession(session);
1706 }
1707 }
1708
1709 return list;
1710 }
1711
1712
1720 @Override
1721 public AssetCategory findByGroupId_First(long groupId,
1722 OrderByComparator<AssetCategory> orderByComparator)
1723 throws NoSuchCategoryException {
1724 AssetCategory assetCategory = fetchByGroupId_First(groupId,
1725 orderByComparator);
1726
1727 if (assetCategory != null) {
1728 return assetCategory;
1729 }
1730
1731 StringBundler msg = new StringBundler(4);
1732
1733 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1734
1735 msg.append("groupId=");
1736 msg.append(groupId);
1737
1738 msg.append(StringPool.CLOSE_CURLY_BRACE);
1739
1740 throw new NoSuchCategoryException(msg.toString());
1741 }
1742
1743
1750 @Override
1751 public AssetCategory fetchByGroupId_First(long groupId,
1752 OrderByComparator<AssetCategory> orderByComparator) {
1753 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1754 orderByComparator);
1755
1756 if (!list.isEmpty()) {
1757 return list.get(0);
1758 }
1759
1760 return null;
1761 }
1762
1763
1771 @Override
1772 public AssetCategory findByGroupId_Last(long groupId,
1773 OrderByComparator<AssetCategory> orderByComparator)
1774 throws NoSuchCategoryException {
1775 AssetCategory assetCategory = fetchByGroupId_Last(groupId,
1776 orderByComparator);
1777
1778 if (assetCategory != null) {
1779 return assetCategory;
1780 }
1781
1782 StringBundler msg = new StringBundler(4);
1783
1784 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1785
1786 msg.append("groupId=");
1787 msg.append(groupId);
1788
1789 msg.append(StringPool.CLOSE_CURLY_BRACE);
1790
1791 throw new NoSuchCategoryException(msg.toString());
1792 }
1793
1794
1801 @Override
1802 public AssetCategory fetchByGroupId_Last(long groupId,
1803 OrderByComparator<AssetCategory> orderByComparator) {
1804 int count = countByGroupId(groupId);
1805
1806 if (count == 0) {
1807 return null;
1808 }
1809
1810 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1811 orderByComparator);
1812
1813 if (!list.isEmpty()) {
1814 return list.get(0);
1815 }
1816
1817 return null;
1818 }
1819
1820
1829 @Override
1830 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1831 long groupId, OrderByComparator<AssetCategory> orderByComparator)
1832 throws NoSuchCategoryException {
1833 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1834
1835 Session session = null;
1836
1837 try {
1838 session = openSession();
1839
1840 AssetCategory[] array = new AssetCategoryImpl[3];
1841
1842 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1843 groupId, orderByComparator, true);
1844
1845 array[1] = assetCategory;
1846
1847 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1848 groupId, orderByComparator, false);
1849
1850 return array;
1851 }
1852 catch (Exception e) {
1853 throw processException(e);
1854 }
1855 finally {
1856 closeSession(session);
1857 }
1858 }
1859
1860 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1861 AssetCategory assetCategory, long groupId,
1862 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
1863 StringBundler query = null;
1864
1865 if (orderByComparator != null) {
1866 query = new StringBundler(4 +
1867 (orderByComparator.getOrderByConditionFields().length * 3) +
1868 (orderByComparator.getOrderByFields().length * 3));
1869 }
1870 else {
1871 query = new StringBundler(3);
1872 }
1873
1874 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1875
1876 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1877
1878 if (orderByComparator != null) {
1879 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1880
1881 if (orderByConditionFields.length > 0) {
1882 query.append(WHERE_AND);
1883 }
1884
1885 for (int i = 0; i < orderByConditionFields.length; i++) {
1886 query.append(_ORDER_BY_ENTITY_ALIAS);
1887 query.append(orderByConditionFields[i]);
1888
1889 if ((i + 1) < orderByConditionFields.length) {
1890 if (orderByComparator.isAscending() ^ previous) {
1891 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1892 }
1893 else {
1894 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1895 }
1896 }
1897 else {
1898 if (orderByComparator.isAscending() ^ previous) {
1899 query.append(WHERE_GREATER_THAN);
1900 }
1901 else {
1902 query.append(WHERE_LESSER_THAN);
1903 }
1904 }
1905 }
1906
1907 query.append(ORDER_BY_CLAUSE);
1908
1909 String[] orderByFields = orderByComparator.getOrderByFields();
1910
1911 for (int i = 0; i < orderByFields.length; i++) {
1912 query.append(_ORDER_BY_ENTITY_ALIAS);
1913 query.append(orderByFields[i]);
1914
1915 if ((i + 1) < orderByFields.length) {
1916 if (orderByComparator.isAscending() ^ previous) {
1917 query.append(ORDER_BY_ASC_HAS_NEXT);
1918 }
1919 else {
1920 query.append(ORDER_BY_DESC_HAS_NEXT);
1921 }
1922 }
1923 else {
1924 if (orderByComparator.isAscending() ^ previous) {
1925 query.append(ORDER_BY_ASC);
1926 }
1927 else {
1928 query.append(ORDER_BY_DESC);
1929 }
1930 }
1931 }
1932 }
1933 else {
1934 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1935 }
1936
1937 String sql = query.toString();
1938
1939 Query q = session.createQuery(sql);
1940
1941 q.setFirstResult(0);
1942 q.setMaxResults(2);
1943
1944 QueryPos qPos = QueryPos.getInstance(q);
1945
1946 qPos.add(groupId);
1947
1948 if (orderByComparator != null) {
1949 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1950
1951 for (Object value : values) {
1952 qPos.add(value);
1953 }
1954 }
1955
1956 List<AssetCategory> list = q.list();
1957
1958 if (list.size() == 2) {
1959 return list.get(1);
1960 }
1961 else {
1962 return null;
1963 }
1964 }
1965
1966
1972 @Override
1973 public List<AssetCategory> filterFindByGroupId(long groupId) {
1974 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1975 QueryUtil.ALL_POS, null);
1976 }
1977
1978
1990 @Override
1991 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1992 int end) {
1993 return filterFindByGroupId(groupId, start, end, null);
1994 }
1995
1996
2009 @Override
2010 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
2011 int end, OrderByComparator<AssetCategory> orderByComparator) {
2012 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2013 return findByGroupId(groupId, start, end, orderByComparator);
2014 }
2015
2016 StringBundler query = null;
2017
2018 if (orderByComparator != null) {
2019 query = new StringBundler(3 +
2020 (orderByComparator.getOrderByFields().length * 2));
2021 }
2022 else {
2023 query = new StringBundler(4);
2024 }
2025
2026 if (getDB().isSupportsInlineDistinct()) {
2027 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2028 }
2029 else {
2030 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2031 }
2032
2033 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2034
2035 if (!getDB().isSupportsInlineDistinct()) {
2036 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2037 }
2038
2039 if (orderByComparator != null) {
2040 if (getDB().isSupportsInlineDistinct()) {
2041 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2042 orderByComparator, true);
2043 }
2044 else {
2045 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2046 orderByComparator, true);
2047 }
2048 }
2049 else {
2050 if (getDB().isSupportsInlineDistinct()) {
2051 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2052 }
2053 else {
2054 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2055 }
2056 }
2057
2058 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2059 AssetCategory.class.getName(),
2060 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2061
2062 Session session = null;
2063
2064 try {
2065 session = openSession();
2066
2067 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2068
2069 if (getDB().isSupportsInlineDistinct()) {
2070 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2071 }
2072 else {
2073 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2074 }
2075
2076 QueryPos qPos = QueryPos.getInstance(q);
2077
2078 qPos.add(groupId);
2079
2080 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
2081 end);
2082 }
2083 catch (Exception e) {
2084 throw processException(e);
2085 }
2086 finally {
2087 closeSession(session);
2088 }
2089 }
2090
2091
2100 @Override
2101 public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
2102 long groupId, OrderByComparator<AssetCategory> orderByComparator)
2103 throws NoSuchCategoryException {
2104 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2105 return findByGroupId_PrevAndNext(categoryId, groupId,
2106 orderByComparator);
2107 }
2108
2109 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2110
2111 Session session = null;
2112
2113 try {
2114 session = openSession();
2115
2116 AssetCategory[] array = new AssetCategoryImpl[3];
2117
2118 array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2119 groupId, orderByComparator, true);
2120
2121 array[1] = assetCategory;
2122
2123 array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2124 groupId, orderByComparator, false);
2125
2126 return array;
2127 }
2128 catch (Exception e) {
2129 throw processException(e);
2130 }
2131 finally {
2132 closeSession(session);
2133 }
2134 }
2135
2136 protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
2137 AssetCategory assetCategory, long groupId,
2138 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
2139 StringBundler query = null;
2140
2141 if (orderByComparator != null) {
2142 query = new StringBundler(5 +
2143 (orderByComparator.getOrderByConditionFields().length * 3) +
2144 (orderByComparator.getOrderByFields().length * 3));
2145 }
2146 else {
2147 query = new StringBundler(4);
2148 }
2149
2150 if (getDB().isSupportsInlineDistinct()) {
2151 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2152 }
2153 else {
2154 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2155 }
2156
2157 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2158
2159 if (!getDB().isSupportsInlineDistinct()) {
2160 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2161 }
2162
2163 if (orderByComparator != null) {
2164 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2165
2166 if (orderByConditionFields.length > 0) {
2167 query.append(WHERE_AND);
2168 }
2169
2170 for (int i = 0; i < orderByConditionFields.length; i++) {
2171 if (getDB().isSupportsInlineDistinct()) {
2172 query.append(_ORDER_BY_ENTITY_ALIAS);
2173 }
2174 else {
2175 query.append(_ORDER_BY_ENTITY_TABLE);
2176 }
2177
2178 query.append(orderByConditionFields[i]);
2179
2180 if ((i + 1) < orderByConditionFields.length) {
2181 if (orderByComparator.isAscending() ^ previous) {
2182 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2183 }
2184 else {
2185 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2186 }
2187 }
2188 else {
2189 if (orderByComparator.isAscending() ^ previous) {
2190 query.append(WHERE_GREATER_THAN);
2191 }
2192 else {
2193 query.append(WHERE_LESSER_THAN);
2194 }
2195 }
2196 }
2197
2198 query.append(ORDER_BY_CLAUSE);
2199
2200 String[] orderByFields = orderByComparator.getOrderByFields();
2201
2202 for (int i = 0; i < orderByFields.length; i++) {
2203 if (getDB().isSupportsInlineDistinct()) {
2204 query.append(_ORDER_BY_ENTITY_ALIAS);
2205 }
2206 else {
2207 query.append(_ORDER_BY_ENTITY_TABLE);
2208 }
2209
2210 query.append(orderByFields[i]);
2211
2212 if ((i + 1) < orderByFields.length) {
2213 if (orderByComparator.isAscending() ^ previous) {
2214 query.append(ORDER_BY_ASC_HAS_NEXT);
2215 }
2216 else {
2217 query.append(ORDER_BY_DESC_HAS_NEXT);
2218 }
2219 }
2220 else {
2221 if (orderByComparator.isAscending() ^ previous) {
2222 query.append(ORDER_BY_ASC);
2223 }
2224 else {
2225 query.append(ORDER_BY_DESC);
2226 }
2227 }
2228 }
2229 }
2230 else {
2231 if (getDB().isSupportsInlineDistinct()) {
2232 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2233 }
2234 else {
2235 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2236 }
2237 }
2238
2239 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2240 AssetCategory.class.getName(),
2241 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2242
2243 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2244
2245 q.setFirstResult(0);
2246 q.setMaxResults(2);
2247
2248 if (getDB().isSupportsInlineDistinct()) {
2249 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2250 }
2251 else {
2252 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2253 }
2254
2255 QueryPos qPos = QueryPos.getInstance(q);
2256
2257 qPos.add(groupId);
2258
2259 if (orderByComparator != null) {
2260 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2261
2262 for (Object value : values) {
2263 qPos.add(value);
2264 }
2265 }
2266
2267 List<AssetCategory> list = q.list();
2268
2269 if (list.size() == 2) {
2270 return list.get(1);
2271 }
2272 else {
2273 return null;
2274 }
2275 }
2276
2277
2282 @Override
2283 public void removeByGroupId(long groupId) {
2284 for (AssetCategory assetCategory : findByGroupId(groupId,
2285 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2286 remove(assetCategory);
2287 }
2288 }
2289
2290
2296 @Override
2297 public int countByGroupId(long groupId) {
2298 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2299
2300 Object[] finderArgs = new Object[] { groupId };
2301
2302 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2303
2304 if (count == null) {
2305 StringBundler query = new StringBundler(2);
2306
2307 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2308
2309 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2310
2311 String sql = query.toString();
2312
2313 Session session = null;
2314
2315 try {
2316 session = openSession();
2317
2318 Query q = session.createQuery(sql);
2319
2320 QueryPos qPos = QueryPos.getInstance(q);
2321
2322 qPos.add(groupId);
2323
2324 count = (Long)q.uniqueResult();
2325
2326 finderCache.putResult(finderPath, finderArgs, count);
2327 }
2328 catch (Exception e) {
2329 finderCache.removeResult(finderPath, finderArgs);
2330
2331 throw processException(e);
2332 }
2333 finally {
2334 closeSession(session);
2335 }
2336 }
2337
2338 return count.intValue();
2339 }
2340
2341
2347 @Override
2348 public int filterCountByGroupId(long groupId) {
2349 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2350 return countByGroupId(groupId);
2351 }
2352
2353 StringBundler query = new StringBundler(2);
2354
2355 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
2356
2357 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2358
2359 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2360 AssetCategory.class.getName(),
2361 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2362
2363 Session session = null;
2364
2365 try {
2366 session = openSession();
2367
2368 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2369
2370 q.addScalar(COUNT_COLUMN_NAME,
2371 com.liferay.portal.kernel.dao.orm.Type.LONG);
2372
2373 QueryPos qPos = QueryPos.getInstance(q);
2374
2375 qPos.add(groupId);
2376
2377 Long count = (Long)q.uniqueResult();
2378
2379 return count.intValue();
2380 }
2381 catch (Exception e) {
2382 throw processException(e);
2383 }
2384 finally {
2385 closeSession(session);
2386 }
2387 }
2388
2389 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
2390 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
2391 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2392 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2393 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2394 "findByParentCategoryId",
2395 new String[] {
2396 Long.class.getName(),
2397
2398 Integer.class.getName(), Integer.class.getName(),
2399 OrderByComparator.class.getName()
2400 });
2401 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
2402 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2403 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2404 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2405 "findByParentCategoryId", new String[] { Long.class.getName() },
2406 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
2407 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2408 public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2409 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2410 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2411 "countByParentCategoryId", new String[] { Long.class.getName() });
2412
2413
2419 @Override
2420 public List<AssetCategory> findByParentCategoryId(long parentCategoryId) {
2421 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2422 QueryUtil.ALL_POS, null);
2423 }
2424
2425
2437 @Override
2438 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2439 int start, int end) {
2440 return findByParentCategoryId(parentCategoryId, start, end, null);
2441 }
2442
2443
2456 @Override
2457 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2458 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
2459 return findByParentCategoryId(parentCategoryId, start, end,
2460 orderByComparator, true);
2461 }
2462
2463
2477 @Override
2478 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2479 int start, int end, OrderByComparator<AssetCategory> orderByComparator,
2480 boolean retrieveFromCache) {
2481 boolean pagination = true;
2482 FinderPath finderPath = null;
2483 Object[] finderArgs = null;
2484
2485 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2486 (orderByComparator == null)) {
2487 pagination = false;
2488 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2489 finderArgs = new Object[] { parentCategoryId };
2490 }
2491 else {
2492 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2493 finderArgs = new Object[] {
2494 parentCategoryId,
2495
2496 start, end, orderByComparator
2497 };
2498 }
2499
2500 List<AssetCategory> list = null;
2501
2502 if (retrieveFromCache) {
2503 list = (List<AssetCategory>)finderCache.getResult(finderPath,
2504 finderArgs, this);
2505
2506 if ((list != null) && !list.isEmpty()) {
2507 for (AssetCategory assetCategory : list) {
2508 if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2509 list = null;
2510
2511 break;
2512 }
2513 }
2514 }
2515 }
2516
2517 if (list == null) {
2518 StringBundler query = null;
2519
2520 if (orderByComparator != null) {
2521 query = new StringBundler(3 +
2522 (orderByComparator.getOrderByFields().length * 2));
2523 }
2524 else {
2525 query = new StringBundler(3);
2526 }
2527
2528 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2529
2530 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2531
2532 if (orderByComparator != null) {
2533 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2534 orderByComparator);
2535 }
2536 else
2537 if (pagination) {
2538 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2539 }
2540
2541 String sql = query.toString();
2542
2543 Session session = null;
2544
2545 try {
2546 session = openSession();
2547
2548 Query q = session.createQuery(sql);
2549
2550 QueryPos qPos = QueryPos.getInstance(q);
2551
2552 qPos.add(parentCategoryId);
2553
2554 if (!pagination) {
2555 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2556 start, end, false);
2557
2558 Collections.sort(list);
2559
2560 list = Collections.unmodifiableList(list);
2561 }
2562 else {
2563 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2564 start, end);
2565 }
2566
2567 cacheResult(list);
2568
2569 finderCache.putResult(finderPath, finderArgs, list);
2570 }
2571 catch (Exception e) {
2572 finderCache.removeResult(finderPath, finderArgs);
2573
2574 throw processException(e);
2575 }
2576 finally {
2577 closeSession(session);
2578 }
2579 }
2580
2581 return list;
2582 }
2583
2584
2592 @Override
2593 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2594 OrderByComparator<AssetCategory> orderByComparator)
2595 throws NoSuchCategoryException {
2596 AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId,
2597 orderByComparator);
2598
2599 if (assetCategory != null) {
2600 return assetCategory;
2601 }
2602
2603 StringBundler msg = new StringBundler(4);
2604
2605 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2606
2607 msg.append("parentCategoryId=");
2608 msg.append(parentCategoryId);
2609
2610 msg.append(StringPool.CLOSE_CURLY_BRACE);
2611
2612 throw new NoSuchCategoryException(msg.toString());
2613 }
2614
2615
2622 @Override
2623 public AssetCategory fetchByParentCategoryId_First(long parentCategoryId,
2624 OrderByComparator<AssetCategory> orderByComparator) {
2625 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2626 1, orderByComparator);
2627
2628 if (!list.isEmpty()) {
2629 return list.get(0);
2630 }
2631
2632 return null;
2633 }
2634
2635
2643 @Override
2644 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2645 OrderByComparator<AssetCategory> orderByComparator)
2646 throws NoSuchCategoryException {
2647 AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId,
2648 orderByComparator);
2649
2650 if (assetCategory != null) {
2651 return assetCategory;
2652 }
2653
2654 StringBundler msg = new StringBundler(4);
2655
2656 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2657
2658 msg.append("parentCategoryId=");
2659 msg.append(parentCategoryId);
2660
2661 msg.append(StringPool.CLOSE_CURLY_BRACE);
2662
2663 throw new NoSuchCategoryException(msg.toString());
2664 }
2665
2666
2673 @Override
2674 public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId,
2675 OrderByComparator<AssetCategory> orderByComparator) {
2676 int count = countByParentCategoryId(parentCategoryId);
2677
2678 if (count == 0) {
2679 return null;
2680 }
2681
2682 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2683 count - 1, count, orderByComparator);
2684
2685 if (!list.isEmpty()) {
2686 return list.get(0);
2687 }
2688
2689 return null;
2690 }
2691
2692
2701 @Override
2702 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2703 long parentCategoryId,
2704 OrderByComparator<AssetCategory> orderByComparator)
2705 throws NoSuchCategoryException {
2706 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2707
2708 Session session = null;
2709
2710 try {
2711 session = openSession();
2712
2713 AssetCategory[] array = new AssetCategoryImpl[3];
2714
2715 array[0] = getByParentCategoryId_PrevAndNext(session,
2716 assetCategory, parentCategoryId, orderByComparator, true);
2717
2718 array[1] = assetCategory;
2719
2720 array[2] = getByParentCategoryId_PrevAndNext(session,
2721 assetCategory, parentCategoryId, orderByComparator, false);
2722
2723 return array;
2724 }
2725 catch (Exception e) {
2726 throw processException(e);
2727 }
2728 finally {
2729 closeSession(session);
2730 }
2731 }
2732
2733 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2734 AssetCategory assetCategory, long parentCategoryId,
2735 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
2736 StringBundler query = null;
2737
2738 if (orderByComparator != null) {
2739 query = new StringBundler(4 +
2740 (orderByComparator.getOrderByConditionFields().length * 3) +
2741 (orderByComparator.getOrderByFields().length * 3));
2742 }
2743 else {
2744 query = new StringBundler(3);
2745 }
2746
2747 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2748
2749 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2750
2751 if (orderByComparator != null) {
2752 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2753
2754 if (orderByConditionFields.length > 0) {
2755 query.append(WHERE_AND);
2756 }
2757
2758 for (int i = 0; i < orderByConditionFields.length; i++) {
2759 query.append(_ORDER_BY_ENTITY_ALIAS);
2760 query.append(orderByConditionFields[i]);
2761
2762 if ((i + 1) < orderByConditionFields.length) {
2763 if (orderByComparator.isAscending() ^ previous) {
2764 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2765 }
2766 else {
2767 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2768 }
2769 }
2770 else {
2771 if (orderByComparator.isAscending() ^ previous) {
2772 query.append(WHERE_GREATER_THAN);
2773 }
2774 else {
2775 query.append(WHERE_LESSER_THAN);
2776 }
2777 }
2778 }
2779
2780 query.append(ORDER_BY_CLAUSE);
2781
2782 String[] orderByFields = orderByComparator.getOrderByFields();
2783
2784 for (int i = 0; i < orderByFields.length; i++) {
2785 query.append(_ORDER_BY_ENTITY_ALIAS);
2786 query.append(orderByFields[i]);
2787
2788 if ((i + 1) < orderByFields.length) {
2789 if (orderByComparator.isAscending() ^ previous) {
2790 query.append(ORDER_BY_ASC_HAS_NEXT);
2791 }
2792 else {
2793 query.append(ORDER_BY_DESC_HAS_NEXT);
2794 }
2795 }
2796 else {
2797 if (orderByComparator.isAscending() ^ previous) {
2798 query.append(ORDER_BY_ASC);
2799 }
2800 else {
2801 query.append(ORDER_BY_DESC);
2802 }
2803 }
2804 }
2805 }
2806 else {
2807 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2808 }
2809
2810 String sql = query.toString();
2811
2812 Query q = session.createQuery(sql);
2813
2814 q.setFirstResult(0);
2815 q.setMaxResults(2);
2816
2817 QueryPos qPos = QueryPos.getInstance(q);
2818
2819 qPos.add(parentCategoryId);
2820
2821 if (orderByComparator != null) {
2822 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2823
2824 for (Object value : values) {
2825 qPos.add(value);
2826 }
2827 }
2828
2829 List<AssetCategory> list = q.list();
2830
2831 if (list.size() == 2) {
2832 return list.get(1);
2833 }
2834 else {
2835 return null;
2836 }
2837 }
2838
2839
2844 @Override
2845 public void removeByParentCategoryId(long parentCategoryId) {
2846 for (AssetCategory assetCategory : findByParentCategoryId(
2847 parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2848 remove(assetCategory);
2849 }
2850 }
2851
2852
2858 @Override
2859 public int countByParentCategoryId(long parentCategoryId) {
2860 FinderPath finderPath = FINDER_PATH_COUNT_BY_PARENTCATEGORYID;
2861
2862 Object[] finderArgs = new Object[] { parentCategoryId };
2863
2864 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2865
2866 if (count == null) {
2867 StringBundler query = new StringBundler(2);
2868
2869 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2870
2871 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2872
2873 String sql = query.toString();
2874
2875 Session session = null;
2876
2877 try {
2878 session = openSession();
2879
2880 Query q = session.createQuery(sql);
2881
2882 QueryPos qPos = QueryPos.getInstance(q);
2883
2884 qPos.add(parentCategoryId);
2885
2886 count = (Long)q.uniqueResult();
2887
2888 finderCache.putResult(finderPath, finderArgs, count);
2889 }
2890 catch (Exception e) {
2891 finderCache.removeResult(finderPath, finderArgs);
2892
2893 throw processException(e);
2894 }
2895 finally {
2896 closeSession(session);
2897 }
2898 }
2899
2900 return count.intValue();
2901 }
2902
2903 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
2904 "assetCategory.parentCategoryId = ?";
2905 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
2906 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2907 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2908 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2909 "findByVocabularyId",
2910 new String[] {
2911 Long.class.getName(),
2912
2913 Integer.class.getName(), Integer.class.getName(),
2914 OrderByComparator.class.getName()
2915 });
2916 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID =
2917 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2918 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2919 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2920 "findByVocabularyId", new String[] { Long.class.getName() },
2921 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
2922 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2923 public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2924 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2925 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
2926 new String[] { Long.class.getName() });
2927
2928
2934 @Override
2935 public List<AssetCategory> findByVocabularyId(long vocabularyId) {
2936 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2937 QueryUtil.ALL_POS, null);
2938 }
2939
2940
2952 @Override
2953 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2954 int end) {
2955 return findByVocabularyId(vocabularyId, start, end, null);
2956 }
2957
2958
2971 @Override
2972 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2973 int end, OrderByComparator<AssetCategory> orderByComparator) {
2974 return findByVocabularyId(vocabularyId, start, end, orderByComparator,
2975 true);
2976 }
2977
2978
2992 @Override
2993 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2994 int end, OrderByComparator<AssetCategory> orderByComparator,
2995 boolean retrieveFromCache) {
2996 boolean pagination = true;
2997 FinderPath finderPath = null;
2998 Object[] finderArgs = null;
2999
3000 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3001 (orderByComparator == null)) {
3002 pagination = false;
3003 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
3004 finderArgs = new Object[] { vocabularyId };
3005 }
3006 else {
3007 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
3008 finderArgs = new Object[] {
3009 vocabularyId,
3010
3011 start, end, orderByComparator
3012 };
3013 }
3014
3015 List<AssetCategory> list = null;
3016
3017 if (retrieveFromCache) {
3018 list = (List<AssetCategory>)finderCache.getResult(finderPath,
3019 finderArgs, this);
3020
3021 if ((list != null) && !list.isEmpty()) {
3022 for (AssetCategory assetCategory : list) {
3023 if ((vocabularyId != assetCategory.getVocabularyId())) {
3024 list = null;
3025
3026 break;
3027 }
3028 }
3029 }
3030 }
3031
3032 if (list == null) {
3033 StringBundler query = null;
3034
3035 if (orderByComparator != null) {
3036 query = new StringBundler(3 +
3037 (orderByComparator.getOrderByFields().length * 2));
3038 }
3039 else {
3040 query = new StringBundler(3);
3041 }
3042
3043 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3044
3045 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3046
3047 if (orderByComparator != null) {
3048 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3049 orderByComparator);
3050 }
3051 else
3052 if (pagination) {
3053 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3054 }
3055
3056 String sql = query.toString();
3057
3058 Session session = null;
3059
3060 try {
3061 session = openSession();
3062
3063 Query q = session.createQuery(sql);
3064
3065 QueryPos qPos = QueryPos.getInstance(q);
3066
3067 qPos.add(vocabularyId);
3068
3069 if (!pagination) {
3070 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3071 start, end, false);
3072
3073 Collections.sort(list);
3074
3075 list = Collections.unmodifiableList(list);
3076 }
3077 else {
3078 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3079 start, end);
3080 }
3081
3082 cacheResult(list);
3083
3084 finderCache.putResult(finderPath, finderArgs, list);
3085 }
3086 catch (Exception e) {
3087 finderCache.removeResult(finderPath, finderArgs);
3088
3089 throw processException(e);
3090 }
3091 finally {
3092 closeSession(session);
3093 }
3094 }
3095
3096 return list;
3097 }
3098
3099
3107 @Override
3108 public AssetCategory findByVocabularyId_First(long vocabularyId,
3109 OrderByComparator<AssetCategory> orderByComparator)
3110 throws NoSuchCategoryException {
3111 AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId,
3112 orderByComparator);
3113
3114 if (assetCategory != null) {
3115 return assetCategory;
3116 }
3117
3118 StringBundler msg = new StringBundler(4);
3119
3120 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3121
3122 msg.append("vocabularyId=");
3123 msg.append(vocabularyId);
3124
3125 msg.append(StringPool.CLOSE_CURLY_BRACE);
3126
3127 throw new NoSuchCategoryException(msg.toString());
3128 }
3129
3130
3137 @Override
3138 public AssetCategory fetchByVocabularyId_First(long vocabularyId,
3139 OrderByComparator<AssetCategory> orderByComparator) {
3140 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
3141 orderByComparator);
3142
3143 if (!list.isEmpty()) {
3144 return list.get(0);
3145 }
3146
3147 return null;
3148 }
3149
3150
3158 @Override
3159 public AssetCategory findByVocabularyId_Last(long vocabularyId,
3160 OrderByComparator<AssetCategory> orderByComparator)
3161 throws NoSuchCategoryException {
3162 AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId,
3163 orderByComparator);
3164
3165 if (assetCategory != null) {
3166 return assetCategory;
3167 }
3168
3169 StringBundler msg = new StringBundler(4);
3170
3171 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3172
3173 msg.append("vocabularyId=");
3174 msg.append(vocabularyId);
3175
3176 msg.append(StringPool.CLOSE_CURLY_BRACE);
3177
3178 throw new NoSuchCategoryException(msg.toString());
3179 }
3180
3181
3188 @Override
3189 public AssetCategory fetchByVocabularyId_Last(long vocabularyId,
3190 OrderByComparator<AssetCategory> orderByComparator) {
3191 int count = countByVocabularyId(vocabularyId);
3192
3193 if (count == 0) {
3194 return null;
3195 }
3196
3197 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
3198 count, orderByComparator);
3199
3200 if (!list.isEmpty()) {
3201 return list.get(0);
3202 }
3203
3204 return null;
3205 }
3206
3207
3216 @Override
3217 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
3218 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
3219 throws NoSuchCategoryException {
3220 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3221
3222 Session session = null;
3223
3224 try {
3225 session = openSession();
3226
3227 AssetCategory[] array = new AssetCategoryImpl[3];
3228
3229 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
3230 vocabularyId, orderByComparator, true);
3231
3232 array[1] = assetCategory;
3233
3234 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
3235 vocabularyId, orderByComparator, false);
3236
3237 return array;
3238 }
3239 catch (Exception e) {
3240 throw processException(e);
3241 }
3242 finally {
3243 closeSession(session);
3244 }
3245 }
3246
3247 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
3248 AssetCategory assetCategory, long vocabularyId,
3249 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
3250 StringBundler query = null;
3251
3252 if (orderByComparator != null) {
3253 query = new StringBundler(4 +
3254 (orderByComparator.getOrderByConditionFields().length * 3) +
3255 (orderByComparator.getOrderByFields().length * 3));
3256 }
3257 else {
3258 query = new StringBundler(3);
3259 }
3260
3261 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3262
3263 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3264
3265 if (orderByComparator != null) {
3266 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3267
3268 if (orderByConditionFields.length > 0) {
3269 query.append(WHERE_AND);
3270 }
3271
3272 for (int i = 0; i < orderByConditionFields.length; i++) {
3273 query.append(_ORDER_BY_ENTITY_ALIAS);
3274 query.append(orderByConditionFields[i]);
3275
3276 if ((i + 1) < orderByConditionFields.length) {
3277 if (orderByComparator.isAscending() ^ previous) {
3278 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3279 }
3280 else {
3281 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3282 }
3283 }
3284 else {
3285 if (orderByComparator.isAscending() ^ previous) {
3286 query.append(WHERE_GREATER_THAN);
3287 }
3288 else {
3289 query.append(WHERE_LESSER_THAN);
3290 }
3291 }
3292 }
3293
3294 query.append(ORDER_BY_CLAUSE);
3295
3296 String[] orderByFields = orderByComparator.getOrderByFields();
3297
3298 for (int i = 0; i < orderByFields.length; i++) {
3299 query.append(_ORDER_BY_ENTITY_ALIAS);
3300 query.append(orderByFields[i]);
3301
3302 if ((i + 1) < orderByFields.length) {
3303 if (orderByComparator.isAscending() ^ previous) {
3304 query.append(ORDER_BY_ASC_HAS_NEXT);
3305 }
3306 else {
3307 query.append(ORDER_BY_DESC_HAS_NEXT);
3308 }
3309 }
3310 else {
3311 if (orderByComparator.isAscending() ^ previous) {
3312 query.append(ORDER_BY_ASC);
3313 }
3314 else {
3315 query.append(ORDER_BY_DESC);
3316 }
3317 }
3318 }
3319 }
3320 else {
3321 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3322 }
3323
3324 String sql = query.toString();
3325
3326 Query q = session.createQuery(sql);
3327
3328 q.setFirstResult(0);
3329 q.setMaxResults(2);
3330
3331 QueryPos qPos = QueryPos.getInstance(q);
3332
3333 qPos.add(vocabularyId);
3334
3335 if (orderByComparator != null) {
3336 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3337
3338 for (Object value : values) {
3339 qPos.add(value);
3340 }
3341 }
3342
3343 List<AssetCategory> list = q.list();
3344
3345 if (list.size() == 2) {
3346 return list.get(1);
3347 }
3348 else {
3349 return null;
3350 }
3351 }
3352
3353
3358 @Override
3359 public void removeByVocabularyId(long vocabularyId) {
3360 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId,
3361 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3362 remove(assetCategory);
3363 }
3364 }
3365
3366
3372 @Override
3373 public int countByVocabularyId(long vocabularyId) {
3374 FinderPath finderPath = FINDER_PATH_COUNT_BY_VOCABULARYID;
3375
3376 Object[] finderArgs = new Object[] { vocabularyId };
3377
3378 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3379
3380 if (count == null) {
3381 StringBundler query = new StringBundler(2);
3382
3383 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3384
3385 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3386
3387 String sql = query.toString();
3388
3389 Session session = null;
3390
3391 try {
3392 session = openSession();
3393
3394 Query q = session.createQuery(sql);
3395
3396 QueryPos qPos = QueryPos.getInstance(q);
3397
3398 qPos.add(vocabularyId);
3399
3400 count = (Long)q.uniqueResult();
3401
3402 finderCache.putResult(finderPath, finderArgs, count);
3403 }
3404 catch (Exception e) {
3405 finderCache.removeResult(finderPath, finderArgs);
3406
3407 throw processException(e);
3408 }
3409 finally {
3410 closeSession(session);
3411 }
3412 }
3413
3414 return count.intValue();
3415 }
3416
3417 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
3418 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3419 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3420 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3421 "findByG_V",
3422 new String[] {
3423 Long.class.getName(), Long.class.getName(),
3424
3425 Integer.class.getName(), Integer.class.getName(),
3426 OrderByComparator.class.getName()
3427 });
3428 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3429 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3430 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
3431 "findByG_V",
3432 new String[] { Long.class.getName(), Long.class.getName() },
3433 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
3434 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
3435 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
3436 public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3437 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3438 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
3439 new String[] { Long.class.getName(), Long.class.getName() });
3440 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3441 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3442 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_V",
3443 new String[] { Long.class.getName(), Long.class.getName() });
3444
3445
3452 @Override
3453 public List<AssetCategory> findByG_V(long groupId, long vocabularyId) {
3454 return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3455 QueryUtil.ALL_POS, null);
3456 }
3457
3458
3471 @Override
3472 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3473 int start, int end) {
3474 return findByG_V(groupId, vocabularyId, start, end, null);
3475 }
3476
3477
3491 @Override
3492 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3493 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
3494 return findByG_V(groupId, vocabularyId, start, end, orderByComparator,
3495 true);
3496 }
3497
3498
3513 @Override
3514 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3515 int start, int end, OrderByComparator<AssetCategory> orderByComparator,
3516 boolean retrieveFromCache) {
3517 boolean pagination = true;
3518 FinderPath finderPath = null;
3519 Object[] finderArgs = null;
3520
3521 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3522 (orderByComparator == null)) {
3523 pagination = false;
3524 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
3525 finderArgs = new Object[] { groupId, vocabularyId };
3526 }
3527 else {
3528 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3529 finderArgs = new Object[] {
3530 groupId, vocabularyId,
3531
3532 start, end, orderByComparator
3533 };
3534 }
3535
3536 List<AssetCategory> list = null;
3537
3538 if (retrieveFromCache) {
3539 list = (List<AssetCategory>)finderCache.getResult(finderPath,
3540 finderArgs, this);
3541
3542 if ((list != null) && !list.isEmpty()) {
3543 for (AssetCategory assetCategory : list) {
3544 if ((groupId != assetCategory.getGroupId()) ||
3545 (vocabularyId != assetCategory.getVocabularyId())) {
3546 list = null;
3547
3548 break;
3549 }
3550 }
3551 }
3552 }
3553
3554 if (list == null) {
3555 StringBundler query = null;
3556
3557 if (orderByComparator != null) {
3558 query = new StringBundler(4 +
3559 (orderByComparator.getOrderByFields().length * 2));
3560 }
3561 else {
3562 query = new StringBundler(4);
3563 }
3564
3565 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3566
3567 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3568
3569 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3570
3571 if (orderByComparator != null) {
3572 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3573 orderByComparator);
3574 }
3575 else
3576 if (pagination) {
3577 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3578 }
3579
3580 String sql = query.toString();
3581
3582 Session session = null;
3583
3584 try {
3585 session = openSession();
3586
3587 Query q = session.createQuery(sql);
3588
3589 QueryPos qPos = QueryPos.getInstance(q);
3590
3591 qPos.add(groupId);
3592
3593 qPos.add(vocabularyId);
3594
3595 if (!pagination) {
3596 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3597 start, end, false);
3598
3599 Collections.sort(list);
3600
3601 list = Collections.unmodifiableList(list);
3602 }
3603 else {
3604 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3605 start, end);
3606 }
3607
3608 cacheResult(list);
3609
3610 finderCache.putResult(finderPath, finderArgs, list);
3611 }
3612 catch (Exception e) {
3613 finderCache.removeResult(finderPath, finderArgs);
3614
3615 throw processException(e);
3616 }
3617 finally {
3618 closeSession(session);
3619 }
3620 }
3621
3622 return list;
3623 }
3624
3625
3634 @Override
3635 public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3636 OrderByComparator<AssetCategory> orderByComparator)
3637 throws NoSuchCategoryException {
3638 AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId,
3639 orderByComparator);
3640
3641 if (assetCategory != null) {
3642 return assetCategory;
3643 }
3644
3645 StringBundler msg = new StringBundler(6);
3646
3647 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3648
3649 msg.append("groupId=");
3650 msg.append(groupId);
3651
3652 msg.append(", vocabularyId=");
3653 msg.append(vocabularyId);
3654
3655 msg.append(StringPool.CLOSE_CURLY_BRACE);
3656
3657 throw new NoSuchCategoryException(msg.toString());
3658 }
3659
3660
3668 @Override
3669 public AssetCategory fetchByG_V_First(long groupId, long vocabularyId,
3670 OrderByComparator<AssetCategory> orderByComparator) {
3671 List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3672 orderByComparator);
3673
3674 if (!list.isEmpty()) {
3675 return list.get(0);
3676 }
3677
3678 return null;
3679 }
3680
3681
3690 @Override
3691 public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3692 OrderByComparator<AssetCategory> orderByComparator)
3693 throws NoSuchCategoryException {
3694 AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId,
3695 orderByComparator);
3696
3697 if (assetCategory != null) {
3698 return assetCategory;
3699 }
3700
3701 StringBundler msg = new StringBundler(6);
3702
3703 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3704
3705 msg.append("groupId=");
3706 msg.append(groupId);
3707
3708 msg.append(", vocabularyId=");
3709 msg.append(vocabularyId);
3710
3711 msg.append(StringPool.CLOSE_CURLY_BRACE);
3712
3713 throw new NoSuchCategoryException(msg.toString());
3714 }
3715
3716
3724 @Override
3725 public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId,
3726 OrderByComparator<AssetCategory> orderByComparator) {
3727 int count = countByG_V(groupId, vocabularyId);
3728
3729 if (count == 0) {
3730 return null;
3731 }
3732
3733 List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3734 count, orderByComparator);
3735
3736 if (!list.isEmpty()) {
3737 return list.get(0);
3738 }
3739
3740 return null;
3741 }
3742
3743
3753 @Override
3754 public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3755 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
3756 throws NoSuchCategoryException {
3757 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3758
3759 Session session = null;
3760
3761 try {
3762 session = openSession();
3763
3764 AssetCategory[] array = new AssetCategoryImpl[3];
3765
3766 array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3767 vocabularyId, orderByComparator, true);
3768
3769 array[1] = assetCategory;
3770
3771 array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3772 vocabularyId, orderByComparator, false);
3773
3774 return array;
3775 }
3776 catch (Exception e) {
3777 throw processException(e);
3778 }
3779 finally {
3780 closeSession(session);
3781 }
3782 }
3783
3784 protected AssetCategory getByG_V_PrevAndNext(Session session,
3785 AssetCategory assetCategory, long groupId, long vocabularyId,
3786 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
3787 StringBundler query = null;
3788
3789 if (orderByComparator != null) {
3790 query = new StringBundler(5 +
3791 (orderByComparator.getOrderByConditionFields().length * 3) +
3792 (orderByComparator.getOrderByFields().length * 3));
3793 }
3794 else {
3795 query = new StringBundler(4);
3796 }
3797
3798 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3799
3800 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3801
3802 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3803
3804 if (orderByComparator != null) {
3805 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3806
3807 if (orderByConditionFields.length > 0) {
3808 query.append(WHERE_AND);
3809 }
3810
3811 for (int i = 0; i < orderByConditionFields.length; i++) {
3812 query.append(_ORDER_BY_ENTITY_ALIAS);
3813 query.append(orderByConditionFields[i]);
3814
3815 if ((i + 1) < orderByConditionFields.length) {
3816 if (orderByComparator.isAscending() ^ previous) {
3817 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3818 }
3819 else {
3820 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3821 }
3822 }
3823 else {
3824 if (orderByComparator.isAscending() ^ previous) {
3825 query.append(WHERE_GREATER_THAN);
3826 }
3827 else {
3828 query.append(WHERE_LESSER_THAN);
3829 }
3830 }
3831 }
3832
3833 query.append(ORDER_BY_CLAUSE);
3834
3835 String[] orderByFields = orderByComparator.getOrderByFields();
3836
3837 for (int i = 0; i < orderByFields.length; i++) {
3838 query.append(_ORDER_BY_ENTITY_ALIAS);
3839 query.append(orderByFields[i]);
3840
3841 if ((i + 1) < orderByFields.length) {
3842 if (orderByComparator.isAscending() ^ previous) {
3843 query.append(ORDER_BY_ASC_HAS_NEXT);
3844 }
3845 else {
3846 query.append(ORDER_BY_DESC_HAS_NEXT);
3847 }
3848 }
3849 else {
3850 if (orderByComparator.isAscending() ^ previous) {
3851 query.append(ORDER_BY_ASC);
3852 }
3853 else {
3854 query.append(ORDER_BY_DESC);
3855 }
3856 }
3857 }
3858 }
3859 else {
3860 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3861 }
3862
3863 String sql = query.toString();
3864
3865 Query q = session.createQuery(sql);
3866
3867 q.setFirstResult(0);
3868 q.setMaxResults(2);
3869
3870 QueryPos qPos = QueryPos.getInstance(q);
3871
3872 qPos.add(groupId);
3873
3874 qPos.add(vocabularyId);
3875
3876 if (orderByComparator != null) {
3877 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3878
3879 for (Object value : values) {
3880 qPos.add(value);
3881 }
3882 }
3883
3884 List<AssetCategory> list = q.list();
3885
3886 if (list.size() == 2) {
3887 return list.get(1);
3888 }
3889 else {
3890 return null;
3891 }
3892 }
3893
3894
3901 @Override
3902 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId) {
3903 return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3904 QueryUtil.ALL_POS, null);
3905 }
3906
3907
3920 @Override
3921 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3922 int start, int end) {
3923 return filterFindByG_V(groupId, vocabularyId, start, end, null);
3924 }
3925
3926
3940 @Override
3941 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3942 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
3943 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3944 return findByG_V(groupId, vocabularyId, start, end,
3945 orderByComparator);
3946 }
3947
3948 StringBundler query = null;
3949
3950 if (orderByComparator != null) {
3951 query = new StringBundler(4 +
3952 (orderByComparator.getOrderByFields().length * 2));
3953 }
3954 else {
3955 query = new StringBundler(5);
3956 }
3957
3958 if (getDB().isSupportsInlineDistinct()) {
3959 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3960 }
3961 else {
3962 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3963 }
3964
3965 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3966
3967 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3968
3969 if (!getDB().isSupportsInlineDistinct()) {
3970 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3971 }
3972
3973 if (orderByComparator != null) {
3974 if (getDB().isSupportsInlineDistinct()) {
3975 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3976 orderByComparator, true);
3977 }
3978 else {
3979 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3980 orderByComparator, true);
3981 }
3982 }
3983 else {
3984 if (getDB().isSupportsInlineDistinct()) {
3985 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3986 }
3987 else {
3988 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3989 }
3990 }
3991
3992 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3993 AssetCategory.class.getName(),
3994 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3995
3996 Session session = null;
3997
3998 try {
3999 session = openSession();
4000
4001 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4002
4003 if (getDB().isSupportsInlineDistinct()) {
4004 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4005 }
4006 else {
4007 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4008 }
4009
4010 QueryPos qPos = QueryPos.getInstance(q);
4011
4012 qPos.add(groupId);
4013
4014 qPos.add(vocabularyId);
4015
4016 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
4017 end);
4018 }
4019 catch (Exception e) {
4020 throw processException(e);
4021 }
4022 finally {
4023 closeSession(session);
4024 }
4025 }
4026
4027
4037 @Override
4038 public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
4039 long groupId, long vocabularyId,
4040 OrderByComparator<AssetCategory> orderByComparator)
4041 throws NoSuchCategoryException {
4042 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4043 return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
4044 orderByComparator);
4045 }
4046
4047 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4048
4049 Session session = null;
4050
4051 try {
4052 session = openSession();
4053
4054 AssetCategory[] array = new AssetCategoryImpl[3];
4055
4056 array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
4057 groupId, vocabularyId, orderByComparator, true);
4058
4059 array[1] = assetCategory;
4060
4061 array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
4062 groupId, vocabularyId, orderByComparator, false);
4063
4064 return array;
4065 }
4066 catch (Exception e) {
4067 throw processException(e);
4068 }
4069 finally {
4070 closeSession(session);
4071 }
4072 }
4073
4074 protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
4075 AssetCategory assetCategory, long groupId, long vocabularyId,
4076 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
4077 StringBundler query = null;
4078
4079 if (orderByComparator != null) {
4080 query = new StringBundler(6 +
4081 (orderByComparator.getOrderByConditionFields().length * 3) +
4082 (orderByComparator.getOrderByFields().length * 3));
4083 }
4084 else {
4085 query = new StringBundler(5);
4086 }
4087
4088 if (getDB().isSupportsInlineDistinct()) {
4089 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
4090 }
4091 else {
4092 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4093 }
4094
4095 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4096
4097 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4098
4099 if (!getDB().isSupportsInlineDistinct()) {
4100 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4101 }
4102
4103 if (orderByComparator != null) {
4104 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4105
4106 if (orderByConditionFields.length > 0) {
4107 query.append(WHERE_AND);
4108 }
4109
4110 for (int i = 0; i < orderByConditionFields.length; i++) {
4111 if (getDB().isSupportsInlineDistinct()) {
4112 query.append(_ORDER_BY_ENTITY_ALIAS);
4113 }
4114 else {
4115 query.append(_ORDER_BY_ENTITY_TABLE);
4116 }
4117
4118 query.append(orderByConditionFields[i]);
4119
4120 if ((i + 1) < orderByConditionFields.length) {
4121 if (orderByComparator.isAscending() ^ previous) {
4122 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4123 }
4124 else {
4125 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4126 }
4127 }
4128 else {
4129 if (orderByComparator.isAscending() ^ previous) {
4130 query.append(WHERE_GREATER_THAN);
4131 }
4132 else {
4133 query.append(WHERE_LESSER_THAN);
4134 }
4135 }
4136 }
4137
4138 query.append(ORDER_BY_CLAUSE);
4139
4140 String[] orderByFields = orderByComparator.getOrderByFields();
4141
4142 for (int i = 0; i < orderByFields.length; i++) {
4143 if (getDB().isSupportsInlineDistinct()) {
4144 query.append(_ORDER_BY_ENTITY_ALIAS);
4145 }
4146 else {
4147 query.append(_ORDER_BY_ENTITY_TABLE);
4148 }
4149
4150 query.append(orderByFields[i]);
4151
4152 if ((i + 1) < orderByFields.length) {
4153 if (orderByComparator.isAscending() ^ previous) {
4154 query.append(ORDER_BY_ASC_HAS_NEXT);
4155 }
4156 else {
4157 query.append(ORDER_BY_DESC_HAS_NEXT);
4158 }
4159 }
4160 else {
4161 if (orderByComparator.isAscending() ^ previous) {
4162 query.append(ORDER_BY_ASC);
4163 }
4164 else {
4165 query.append(ORDER_BY_DESC);
4166 }
4167 }
4168 }
4169 }
4170 else {
4171 if (getDB().isSupportsInlineDistinct()) {
4172 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4173 }
4174 else {
4175 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4176 }
4177 }
4178
4179 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4180 AssetCategory.class.getName(),
4181 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4182
4183 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4184
4185 q.setFirstResult(0);
4186 q.setMaxResults(2);
4187
4188 if (getDB().isSupportsInlineDistinct()) {
4189 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4190 }
4191 else {
4192 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4193 }
4194
4195 QueryPos qPos = QueryPos.getInstance(q);
4196
4197 qPos.add(groupId);
4198
4199 qPos.add(vocabularyId);
4200
4201 if (orderByComparator != null) {
4202 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4203
4204 for (Object value : values) {
4205 qPos.add(value);
4206 }
4207 }
4208
4209 List<AssetCategory> list = q.list();
4210
4211 if (list.size() == 2) {
4212 return list.get(1);
4213 }
4214 else {
4215 return null;
4216 }
4217 }
4218
4219
4226 @Override
4227 public List<AssetCategory> filterFindByG_V(long groupId,
4228 long[] vocabularyIds) {
4229 return filterFindByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4230 QueryUtil.ALL_POS, null);
4231 }
4232
4233
4246 @Override
4247 public List<AssetCategory> filterFindByG_V(long groupId,
4248 long[] vocabularyIds, int start, int end) {
4249 return filterFindByG_V(groupId, vocabularyIds, start, end, null);
4250 }
4251
4252
4266 @Override
4267 public List<AssetCategory> filterFindByG_V(long groupId,
4268 long[] vocabularyIds, int start, int end,
4269 OrderByComparator<AssetCategory> orderByComparator) {
4270 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4271 return findByG_V(groupId, vocabularyIds, start, end,
4272 orderByComparator);
4273 }
4274
4275 if (vocabularyIds == null) {
4276 vocabularyIds = new long[0];
4277 }
4278 else if (vocabularyIds.length > 1) {
4279 vocabularyIds = ArrayUtil.unique(vocabularyIds);
4280
4281 Arrays.sort(vocabularyIds);
4282 }
4283
4284 StringBundler query = new StringBundler();
4285
4286 if (getDB().isSupportsInlineDistinct()) {
4287 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
4288 }
4289 else {
4290 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4291 }
4292
4293 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4294
4295 if (vocabularyIds.length > 0) {
4296 query.append(StringPool.OPEN_PARENTHESIS);
4297
4298 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7);
4299
4300 query.append(StringUtil.merge(vocabularyIds));
4301
4302 query.append(StringPool.CLOSE_PARENTHESIS);
4303
4304 query.append(StringPool.CLOSE_PARENTHESIS);
4305 }
4306
4307 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
4308 query.index() - 1);
4309
4310 if (!getDB().isSupportsInlineDistinct()) {
4311 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4312 }
4313
4314 if (orderByComparator != null) {
4315 if (getDB().isSupportsInlineDistinct()) {
4316 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4317 orderByComparator, true);
4318 }
4319 else {
4320 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4321 orderByComparator, true);
4322 }
4323 }
4324 else {
4325 if (getDB().isSupportsInlineDistinct()) {
4326 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4327 }
4328 else {
4329 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4330 }
4331 }
4332
4333 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4334 AssetCategory.class.getName(),
4335 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4336
4337 Session session = null;
4338
4339 try {
4340 session = openSession();
4341
4342 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4343
4344 if (getDB().isSupportsInlineDistinct()) {
4345 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4346 }
4347 else {
4348 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4349 }
4350
4351 QueryPos qPos = QueryPos.getInstance(q);
4352
4353 qPos.add(groupId);
4354
4355 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
4356 end);
4357 }
4358 catch (Exception e) {
4359 throw processException(e);
4360 }
4361 finally {
4362 closeSession(session);
4363 }
4364 }
4365
4366
4377 @Override
4378 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds) {
4379 return findByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4380 QueryUtil.ALL_POS, null);
4381 }
4382
4383
4396 @Override
4397 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4398 int start, int end) {
4399 return findByG_V(groupId, vocabularyIds, start, end, null);
4400 }
4401
4402
4416 @Override
4417 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4418 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
4419 return findByG_V(groupId, vocabularyIds, start, end, orderByComparator,
4420 true);
4421 }
4422
4423
4438 @Override
4439 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4440 int start, int end, OrderByComparator<AssetCategory> orderByComparator,
4441 boolean retrieveFromCache) {
4442 if (vocabularyIds == null) {
4443 vocabularyIds = new long[0];
4444 }
4445 else if (vocabularyIds.length > 1) {
4446 vocabularyIds = ArrayUtil.unique(vocabularyIds);
4447
4448 Arrays.sort(vocabularyIds);
4449 }
4450
4451 if (vocabularyIds.length == 1) {
4452 return findByG_V(groupId, vocabularyIds[0], start, end,
4453 orderByComparator);
4454 }
4455
4456 boolean pagination = true;
4457 Object[] finderArgs = null;
4458
4459 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4460 (orderByComparator == null)) {
4461 pagination = false;
4462 finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds) };
4463 }
4464 else {
4465 finderArgs = new Object[] {
4466 groupId, StringUtil.merge(vocabularyIds),
4467
4468 start, end, orderByComparator
4469 };
4470 }
4471
4472 List<AssetCategory> list = null;
4473
4474 if (retrieveFromCache) {
4475 list = (List<AssetCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4476 finderArgs, this);
4477
4478 if ((list != null) && !list.isEmpty()) {
4479 for (AssetCategory assetCategory : list) {
4480 if ((groupId != assetCategory.getGroupId()) ||
4481 !ArrayUtil.contains(vocabularyIds,
4482 assetCategory.getVocabularyId())) {
4483 list = null;
4484
4485 break;
4486 }
4487 }
4488 }
4489 }
4490
4491 if (list == null) {
4492 StringBundler query = new StringBundler();
4493
4494 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4495
4496 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4497
4498 if (vocabularyIds.length > 0) {
4499 query.append(StringPool.OPEN_PARENTHESIS);
4500
4501 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7);
4502
4503 query.append(StringUtil.merge(vocabularyIds));
4504
4505 query.append(StringPool.CLOSE_PARENTHESIS);
4506
4507 query.append(StringPool.CLOSE_PARENTHESIS);
4508 }
4509
4510 query.setStringAt(removeConjunction(query.stringAt(query.index() -
4511 1)), query.index() - 1);
4512
4513 if (orderByComparator != null) {
4514 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4515 orderByComparator);
4516 }
4517 else
4518 if (pagination) {
4519 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4520 }
4521
4522 String sql = query.toString();
4523
4524 Session session = null;
4525
4526 try {
4527 session = openSession();
4528
4529 Query q = session.createQuery(sql);
4530
4531 QueryPos qPos = QueryPos.getInstance(q);
4532
4533 qPos.add(groupId);
4534
4535 if (!pagination) {
4536 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4537 start, end, false);
4538
4539 Collections.sort(list);
4540
4541 list = Collections.unmodifiableList(list);
4542 }
4543 else {
4544 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4545 start, end);
4546 }
4547
4548 cacheResult(list);
4549
4550 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4551 finderArgs, list);
4552 }
4553 catch (Exception e) {
4554 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4555 finderArgs);
4556
4557 throw processException(e);
4558 }
4559 finally {
4560 closeSession(session);
4561 }
4562 }
4563
4564 return list;
4565 }
4566
4567
4573 @Override
4574 public void removeByG_V(long groupId, long vocabularyId) {
4575 for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId,
4576 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4577 remove(assetCategory);
4578 }
4579 }
4580
4581
4588 @Override
4589 public int countByG_V(long groupId, long vocabularyId) {
4590 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_V;
4591
4592 Object[] finderArgs = new Object[] { groupId, vocabularyId };
4593
4594 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4595
4596 if (count == null) {
4597 StringBundler query = new StringBundler(3);
4598
4599 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4600
4601 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4602
4603 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4604
4605 String sql = query.toString();
4606
4607 Session session = null;
4608
4609 try {
4610 session = openSession();
4611
4612 Query q = session.createQuery(sql);
4613
4614 QueryPos qPos = QueryPos.getInstance(q);
4615
4616 qPos.add(groupId);
4617
4618 qPos.add(vocabularyId);
4619
4620 count = (Long)q.uniqueResult();
4621
4622 finderCache.putResult(finderPath, finderArgs, count);
4623 }
4624 catch (Exception e) {
4625 finderCache.removeResult(finderPath, finderArgs);
4626
4627 throw processException(e);
4628 }
4629 finally {
4630 closeSession(session);
4631 }
4632 }
4633
4634 return count.intValue();
4635 }
4636
4637
4644 @Override
4645 public int countByG_V(long groupId, long[] vocabularyIds) {
4646 if (vocabularyIds == null) {
4647 vocabularyIds = new long[0];
4648 }
4649 else if (vocabularyIds.length > 1) {
4650 vocabularyIds = ArrayUtil.unique(vocabularyIds);
4651
4652 Arrays.sort(vocabularyIds);
4653 }
4654
4655 Object[] finderArgs = new Object[] {
4656 groupId, StringUtil.merge(vocabularyIds)
4657 };
4658
4659 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4660 finderArgs, this);
4661
4662 if (count == null) {
4663 StringBundler query = new StringBundler();
4664
4665 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4666
4667 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4668
4669 if (vocabularyIds.length > 0) {
4670 query.append(StringPool.OPEN_PARENTHESIS);
4671
4672 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7);
4673
4674 query.append(StringUtil.merge(vocabularyIds));
4675
4676 query.append(StringPool.CLOSE_PARENTHESIS);
4677
4678 query.append(StringPool.CLOSE_PARENTHESIS);
4679 }
4680
4681 query.setStringAt(removeConjunction(query.stringAt(query.index() -
4682 1)), query.index() - 1);
4683
4684 String sql = query.toString();
4685
4686 Session session = null;
4687
4688 try {
4689 session = openSession();
4690
4691 Query q = session.createQuery(sql);
4692
4693 QueryPos qPos = QueryPos.getInstance(q);
4694
4695 qPos.add(groupId);
4696
4697 count = (Long)q.uniqueResult();
4698
4699 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4700 finderArgs, count);
4701 }
4702 catch (Exception e) {
4703 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4704 finderArgs);
4705
4706 throw processException(e);
4707 }
4708 finally {
4709 closeSession(session);
4710 }
4711 }
4712
4713 return count.intValue();
4714 }
4715
4716
4723 @Override
4724 public int filterCountByG_V(long groupId, long vocabularyId) {
4725 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4726 return countByG_V(groupId, vocabularyId);
4727 }
4728
4729 StringBundler query = new StringBundler(3);
4730
4731 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4732
4733 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4734
4735 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4736
4737 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4738 AssetCategory.class.getName(),
4739 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4740
4741 Session session = null;
4742
4743 try {
4744 session = openSession();
4745
4746 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4747
4748 q.addScalar(COUNT_COLUMN_NAME,
4749 com.liferay.portal.kernel.dao.orm.Type.LONG);
4750
4751 QueryPos qPos = QueryPos.getInstance(q);
4752
4753 qPos.add(groupId);
4754
4755 qPos.add(vocabularyId);
4756
4757 Long count = (Long)q.uniqueResult();
4758
4759 return count.intValue();
4760 }
4761 catch (Exception e) {
4762 throw processException(e);
4763 }
4764 finally {
4765 closeSession(session);
4766 }
4767 }
4768
4769
4776 @Override
4777 public int filterCountByG_V(long groupId, long[] vocabularyIds) {
4778 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4779 return countByG_V(groupId, vocabularyIds);
4780 }
4781
4782 if (vocabularyIds == null) {
4783 vocabularyIds = new long[0];
4784 }
4785 else if (vocabularyIds.length > 1) {
4786 vocabularyIds = ArrayUtil.unique(vocabularyIds);
4787
4788 Arrays.sort(vocabularyIds);
4789 }
4790
4791 StringBundler query = new StringBundler();
4792
4793 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4794
4795 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4796
4797 if (vocabularyIds.length > 0) {
4798 query.append(StringPool.OPEN_PARENTHESIS);
4799
4800 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7);
4801
4802 query.append(StringUtil.merge(vocabularyIds));
4803
4804 query.append(StringPool.CLOSE_PARENTHESIS);
4805
4806 query.append(StringPool.CLOSE_PARENTHESIS);
4807 }
4808
4809 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
4810 query.index() - 1);
4811
4812 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4813 AssetCategory.class.getName(),
4814 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4815
4816 Session session = null;
4817
4818 try {
4819 session = openSession();
4820
4821 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4822
4823 q.addScalar(COUNT_COLUMN_NAME,
4824 com.liferay.portal.kernel.dao.orm.Type.LONG);
4825
4826 QueryPos qPos = QueryPos.getInstance(q);
4827
4828 qPos.add(groupId);
4829
4830 Long count = (Long)q.uniqueResult();
4831
4832 return count.intValue();
4833 }
4834 catch (Exception e) {
4835 throw processException(e);
4836 }
4837 finally {
4838 closeSession(session);
4839 }
4840 }
4841
4842 private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
4843 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
4844 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_7 = "assetCategory.vocabularyId IN (";
4845 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4846 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4847 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4848 "findByP_N",
4849 new String[] {
4850 Long.class.getName(), String.class.getName(),
4851
4852 Integer.class.getName(), Integer.class.getName(),
4853 OrderByComparator.class.getName()
4854 });
4855 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4856 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4857 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
4858 "findByP_N",
4859 new String[] { Long.class.getName(), String.class.getName() },
4860 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
4861 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
4862 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4863 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4864 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
4865 new String[] { Long.class.getName(), String.class.getName() });
4866
4867
4874 @Override
4875 public List<AssetCategory> findByP_N(long parentCategoryId, String name) {
4876 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
4877 QueryUtil.ALL_POS, null);
4878 }
4879
4880
4893 @Override
4894 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4895 int start, int end) {
4896 return findByP_N(parentCategoryId, name, start, end, null);
4897 }
4898
4899
4913 @Override
4914 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4915 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
4916 return findByP_N(parentCategoryId, name, start, end, orderByComparator,
4917 true);
4918 }
4919
4920
4935 @Override
4936 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4937 int start, int end, OrderByComparator<AssetCategory> orderByComparator,
4938 boolean retrieveFromCache) {
4939 boolean pagination = true;
4940 FinderPath finderPath = null;
4941 Object[] finderArgs = null;
4942
4943 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4944 (orderByComparator == null)) {
4945 pagination = false;
4946 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
4947 finderArgs = new Object[] { parentCategoryId, name };
4948 }
4949 else {
4950 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
4951 finderArgs = new Object[] {
4952 parentCategoryId, name,
4953
4954 start, end, orderByComparator
4955 };
4956 }
4957
4958 List<AssetCategory> list = null;
4959
4960 if (retrieveFromCache) {
4961 list = (List<AssetCategory>)finderCache.getResult(finderPath,
4962 finderArgs, this);
4963
4964 if ((list != null) && !list.isEmpty()) {
4965 for (AssetCategory assetCategory : list) {
4966 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4967 !Objects.equals(name, assetCategory.getName())) {
4968 list = null;
4969
4970 break;
4971 }
4972 }
4973 }
4974 }
4975
4976 if (list == null) {
4977 StringBundler query = null;
4978
4979 if (orderByComparator != null) {
4980 query = new StringBundler(4 +
4981 (orderByComparator.getOrderByFields().length * 2));
4982 }
4983 else {
4984 query = new StringBundler(4);
4985 }
4986
4987 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4988
4989 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4990
4991 boolean bindName = false;
4992
4993 if (name == null) {
4994 query.append(_FINDER_COLUMN_P_N_NAME_1);
4995 }
4996 else if (name.equals(StringPool.BLANK)) {
4997 query.append(_FINDER_COLUMN_P_N_NAME_3);
4998 }
4999 else {
5000 bindName = true;
5001
5002 query.append(_FINDER_COLUMN_P_N_NAME_2);
5003 }
5004
5005 if (orderByComparator != null) {
5006 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5007 orderByComparator);
5008 }
5009 else
5010 if (pagination) {
5011 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5012 }
5013
5014 String sql = query.toString();
5015
5016 Session session = null;
5017
5018 try {
5019 session = openSession();
5020
5021 Query q = session.createQuery(sql);
5022
5023 QueryPos qPos = QueryPos.getInstance(q);
5024
5025 qPos.add(parentCategoryId);
5026
5027 if (bindName) {
5028 qPos.add(name);
5029 }
5030
5031 if (!pagination) {
5032 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5033 start, end, false);
5034
5035 Collections.sort(list);
5036
5037 list = Collections.unmodifiableList(list);
5038 }
5039 else {
5040 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5041 start, end);
5042 }
5043
5044 cacheResult(list);
5045
5046 finderCache.putResult(finderPath, finderArgs, list);
5047 }
5048 catch (Exception e) {
5049 finderCache.removeResult(finderPath, finderArgs);
5050
5051 throw processException(e);
5052 }
5053 finally {
5054 closeSession(session);
5055 }
5056 }
5057
5058 return list;
5059 }
5060
5061
5070 @Override
5071 public AssetCategory findByP_N_First(long parentCategoryId, String name,
5072 OrderByComparator<AssetCategory> orderByComparator)
5073 throws NoSuchCategoryException {
5074 AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name,
5075 orderByComparator);
5076
5077 if (assetCategory != null) {
5078 return assetCategory;
5079 }
5080
5081 StringBundler msg = new StringBundler(6);
5082
5083 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5084
5085 msg.append("parentCategoryId=");
5086 msg.append(parentCategoryId);
5087
5088 msg.append(", name=");
5089 msg.append(name);
5090
5091 msg.append(StringPool.CLOSE_CURLY_BRACE);
5092
5093 throw new NoSuchCategoryException(msg.toString());
5094 }
5095
5096
5104 @Override
5105 public AssetCategory fetchByP_N_First(long parentCategoryId, String name,
5106 OrderByComparator<AssetCategory> orderByComparator) {
5107 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
5108 orderByComparator);
5109
5110 if (!list.isEmpty()) {
5111 return list.get(0);
5112 }
5113
5114 return null;
5115 }
5116
5117
5126 @Override
5127 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
5128 OrderByComparator<AssetCategory> orderByComparator)
5129 throws NoSuchCategoryException {
5130 AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name,
5131 orderByComparator);
5132
5133 if (assetCategory != null) {
5134 return assetCategory;
5135 }
5136
5137 StringBundler msg = new StringBundler(6);
5138
5139 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5140
5141 msg.append("parentCategoryId=");
5142 msg.append(parentCategoryId);
5143
5144 msg.append(", name=");
5145 msg.append(name);
5146
5147 msg.append(StringPool.CLOSE_CURLY_BRACE);
5148
5149 throw new NoSuchCategoryException(msg.toString());
5150 }
5151
5152
5160 @Override
5161 public AssetCategory fetchByP_N_Last(long parentCategoryId, String name,
5162 OrderByComparator<AssetCategory> orderByComparator) {
5163 int count = countByP_N(parentCategoryId, name);
5164
5165 if (count == 0) {
5166 return null;
5167 }
5168
5169 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
5170 count, orderByComparator);
5171
5172 if (!list.isEmpty()) {
5173 return list.get(0);
5174 }
5175
5176 return null;
5177 }
5178
5179
5189 @Override
5190 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
5191 long parentCategoryId, String name,
5192 OrderByComparator<AssetCategory> orderByComparator)
5193 throws NoSuchCategoryException {
5194 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5195
5196 Session session = null;
5197
5198 try {
5199 session = openSession();
5200
5201 AssetCategory[] array = new AssetCategoryImpl[3];
5202
5203 array[0] = getByP_N_PrevAndNext(session, assetCategory,
5204 parentCategoryId, name, orderByComparator, true);
5205
5206 array[1] = assetCategory;
5207
5208 array[2] = getByP_N_PrevAndNext(session, assetCategory,
5209 parentCategoryId, name, orderByComparator, false);
5210
5211 return array;
5212 }
5213 catch (Exception e) {
5214 throw processException(e);
5215 }
5216 finally {
5217 closeSession(session);
5218 }
5219 }
5220
5221 protected AssetCategory getByP_N_PrevAndNext(Session session,
5222 AssetCategory assetCategory, long parentCategoryId, String name,
5223 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
5224 StringBundler query = null;
5225
5226 if (orderByComparator != null) {
5227 query = new StringBundler(5 +
5228 (orderByComparator.getOrderByConditionFields().length * 3) +
5229 (orderByComparator.getOrderByFields().length * 3));
5230 }
5231 else {
5232 query = new StringBundler(4);
5233 }
5234
5235 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5236
5237 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5238
5239 boolean bindName = false;
5240
5241 if (name == null) {
5242 query.append(_FINDER_COLUMN_P_N_NAME_1);
5243 }
5244 else if (name.equals(StringPool.BLANK)) {
5245 query.append(_FINDER_COLUMN_P_N_NAME_3);
5246 }
5247 else {
5248 bindName = true;
5249
5250 query.append(_FINDER_COLUMN_P_N_NAME_2);
5251 }
5252
5253 if (orderByComparator != null) {
5254 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5255
5256 if (orderByConditionFields.length > 0) {
5257 query.append(WHERE_AND);
5258 }
5259
5260 for (int i = 0; i < orderByConditionFields.length; i++) {
5261 query.append(_ORDER_BY_ENTITY_ALIAS);
5262 query.append(orderByConditionFields[i]);
5263
5264 if ((i + 1) < orderByConditionFields.length) {
5265 if (orderByComparator.isAscending() ^ previous) {
5266 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5267 }
5268 else {
5269 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5270 }
5271 }
5272 else {
5273 if (orderByComparator.isAscending() ^ previous) {
5274 query.append(WHERE_GREATER_THAN);
5275 }
5276 else {
5277 query.append(WHERE_LESSER_THAN);
5278 }
5279 }
5280 }
5281
5282 query.append(ORDER_BY_CLAUSE);
5283
5284 String[] orderByFields = orderByComparator.getOrderByFields();
5285
5286 for (int i = 0; i < orderByFields.length; i++) {
5287 query.append(_ORDER_BY_ENTITY_ALIAS);
5288 query.append(orderByFields[i]);
5289
5290 if ((i + 1) < orderByFields.length) {
5291 if (orderByComparator.isAscending() ^ previous) {
5292 query.append(ORDER_BY_ASC_HAS_NEXT);
5293 }
5294 else {
5295 query.append(ORDER_BY_DESC_HAS_NEXT);
5296 }
5297 }
5298 else {
5299 if (orderByComparator.isAscending() ^ previous) {
5300 query.append(ORDER_BY_ASC);
5301 }
5302 else {
5303 query.append(ORDER_BY_DESC);
5304 }
5305 }
5306 }
5307 }
5308 else {
5309 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5310 }
5311
5312 String sql = query.toString();
5313
5314 Query q = session.createQuery(sql);
5315
5316 q.setFirstResult(0);
5317 q.setMaxResults(2);
5318
5319 QueryPos qPos = QueryPos.getInstance(q);
5320
5321 qPos.add(parentCategoryId);
5322
5323 if (bindName) {
5324 qPos.add(name);
5325 }
5326
5327 if (orderByComparator != null) {
5328 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5329
5330 for (Object value : values) {
5331 qPos.add(value);
5332 }
5333 }
5334
5335 List<AssetCategory> list = q.list();
5336
5337 if (list.size() == 2) {
5338 return list.get(1);
5339 }
5340 else {
5341 return null;
5342 }
5343 }
5344
5345
5351 @Override
5352 public void removeByP_N(long parentCategoryId, String name) {
5353 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name,
5354 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5355 remove(assetCategory);
5356 }
5357 }
5358
5359
5366 @Override
5367 public int countByP_N(long parentCategoryId, String name) {
5368 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N;
5369
5370 Object[] finderArgs = new Object[] { parentCategoryId, name };
5371
5372 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5373
5374 if (count == null) {
5375 StringBundler query = new StringBundler(3);
5376
5377 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5378
5379 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5380
5381 boolean bindName = false;
5382
5383 if (name == null) {
5384 query.append(_FINDER_COLUMN_P_N_NAME_1);
5385 }
5386 else if (name.equals(StringPool.BLANK)) {
5387 query.append(_FINDER_COLUMN_P_N_NAME_3);
5388 }
5389 else {
5390 bindName = true;
5391
5392 query.append(_FINDER_COLUMN_P_N_NAME_2);
5393 }
5394
5395 String sql = query.toString();
5396
5397 Session session = null;
5398
5399 try {
5400 session = openSession();
5401
5402 Query q = session.createQuery(sql);
5403
5404 QueryPos qPos = QueryPos.getInstance(q);
5405
5406 qPos.add(parentCategoryId);
5407
5408 if (bindName) {
5409 qPos.add(name);
5410 }
5411
5412 count = (Long)q.uniqueResult();
5413
5414 finderCache.putResult(finderPath, finderArgs, count);
5415 }
5416 catch (Exception e) {
5417 finderCache.removeResult(finderPath, finderArgs);
5418
5419 throw processException(e);
5420 }
5421 finally {
5422 closeSession(session);
5423 }
5424 }
5425
5426 return count.intValue();
5427 }
5428
5429 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5430 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
5431 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
5432 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '')";
5433 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5434 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5435 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5436 "findByP_V",
5437 new String[] {
5438 Long.class.getName(), Long.class.getName(),
5439
5440 Integer.class.getName(), Integer.class.getName(),
5441 OrderByComparator.class.getName()
5442 });
5443 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5444 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5445 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5446 "findByP_V",
5447 new String[] { Long.class.getName(), Long.class.getName() },
5448 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
5449 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
5450 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
5451 public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5452 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5453 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
5454 new String[] { Long.class.getName(), Long.class.getName() });
5455
5456
5463 @Override
5464 public List<AssetCategory> findByP_V(long parentCategoryId,
5465 long vocabularyId) {
5466 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
5467 QueryUtil.ALL_POS, null);
5468 }
5469
5470
5483 @Override
5484 public List<AssetCategory> findByP_V(long parentCategoryId,
5485 long vocabularyId, int start, int end) {
5486 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
5487 }
5488
5489
5503 @Override
5504 public List<AssetCategory> findByP_V(long parentCategoryId,
5505 long vocabularyId, int start, int end,
5506 OrderByComparator<AssetCategory> orderByComparator) {
5507 return findByP_V(parentCategoryId, vocabularyId, start, end,
5508 orderByComparator, true);
5509 }
5510
5511
5526 @Override
5527 public List<AssetCategory> findByP_V(long parentCategoryId,
5528 long vocabularyId, int start, int end,
5529 OrderByComparator<AssetCategory> orderByComparator,
5530 boolean retrieveFromCache) {
5531 boolean pagination = true;
5532 FinderPath finderPath = null;
5533 Object[] finderArgs = null;
5534
5535 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5536 (orderByComparator == null)) {
5537 pagination = false;
5538 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
5539 finderArgs = new Object[] { parentCategoryId, vocabularyId };
5540 }
5541 else {
5542 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
5543 finderArgs = new Object[] {
5544 parentCategoryId, vocabularyId,
5545
5546 start, end, orderByComparator
5547 };
5548 }
5549
5550 List<AssetCategory> list = null;
5551
5552 if (retrieveFromCache) {
5553 list = (List<AssetCategory>)finderCache.getResult(finderPath,
5554 finderArgs, this);
5555
5556 if ((list != null) && !list.isEmpty()) {
5557 for (AssetCategory assetCategory : list) {
5558 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
5559 (vocabularyId != assetCategory.getVocabularyId())) {
5560 list = null;
5561
5562 break;
5563 }
5564 }
5565 }
5566 }
5567
5568 if (list == null) {
5569 StringBundler query = null;
5570
5571 if (orderByComparator != null) {
5572 query = new StringBundler(4 +
5573 (orderByComparator.getOrderByFields().length * 2));
5574 }
5575 else {
5576 query = new StringBundler(4);
5577 }
5578
5579 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5580
5581 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5582
5583 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5584
5585 if (orderByComparator != null) {
5586 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5587 orderByComparator);
5588 }
5589 else
5590 if (pagination) {
5591 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5592 }
5593
5594 String sql = query.toString();
5595
5596 Session session = null;
5597
5598 try {
5599 session = openSession();
5600
5601 Query q = session.createQuery(sql);
5602
5603 QueryPos qPos = QueryPos.getInstance(q);
5604
5605 qPos.add(parentCategoryId);
5606
5607 qPos.add(vocabularyId);
5608
5609 if (!pagination) {
5610 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5611 start, end, false);
5612
5613 Collections.sort(list);
5614
5615 list = Collections.unmodifiableList(list);
5616 }
5617 else {
5618 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5619 start, end);
5620 }
5621
5622 cacheResult(list);
5623
5624 finderCache.putResult(finderPath, finderArgs, list);
5625 }
5626 catch (Exception e) {
5627 finderCache.removeResult(finderPath, finderArgs);
5628
5629 throw processException(e);
5630 }
5631 finally {
5632 closeSession(session);
5633 }
5634 }
5635
5636 return list;
5637 }
5638
5639
5648 @Override
5649 public AssetCategory findByP_V_First(long parentCategoryId,
5650 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
5651 throws NoSuchCategoryException {
5652 AssetCategory assetCategory = fetchByP_V_First(parentCategoryId,
5653 vocabularyId, orderByComparator);
5654
5655 if (assetCategory != null) {
5656 return assetCategory;
5657 }
5658
5659 StringBundler msg = new StringBundler(6);
5660
5661 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5662
5663 msg.append("parentCategoryId=");
5664 msg.append(parentCategoryId);
5665
5666 msg.append(", vocabularyId=");
5667 msg.append(vocabularyId);
5668
5669 msg.append(StringPool.CLOSE_CURLY_BRACE);
5670
5671 throw new NoSuchCategoryException(msg.toString());
5672 }
5673
5674
5682 @Override
5683 public AssetCategory fetchByP_V_First(long parentCategoryId,
5684 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) {
5685 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
5686 1, orderByComparator);
5687
5688 if (!list.isEmpty()) {
5689 return list.get(0);
5690 }
5691
5692 return null;
5693 }
5694
5695
5704 @Override
5705 public AssetCategory findByP_V_Last(long parentCategoryId,
5706 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
5707 throws NoSuchCategoryException {
5708 AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId,
5709 vocabularyId, orderByComparator);
5710
5711 if (assetCategory != null) {
5712 return assetCategory;
5713 }
5714
5715 StringBundler msg = new StringBundler(6);
5716
5717 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5718
5719 msg.append("parentCategoryId=");
5720 msg.append(parentCategoryId);
5721
5722 msg.append(", vocabularyId=");
5723 msg.append(vocabularyId);
5724
5725 msg.append(StringPool.CLOSE_CURLY_BRACE);
5726
5727 throw new NoSuchCategoryException(msg.toString());
5728 }
5729
5730
5738 @Override
5739 public AssetCategory fetchByP_V_Last(long parentCategoryId,
5740 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) {
5741 int count = countByP_V(parentCategoryId, vocabularyId);
5742
5743 if (count == 0) {
5744 return null;
5745 }
5746
5747 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
5748 count - 1, count, orderByComparator);
5749
5750 if (!list.isEmpty()) {
5751 return list.get(0);
5752 }
5753
5754 return null;
5755 }
5756
5757
5767 @Override
5768 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
5769 long parentCategoryId, long vocabularyId,
5770 OrderByComparator<AssetCategory> orderByComparator)
5771 throws NoSuchCategoryException {
5772 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5773
5774 Session session = null;
5775
5776 try {
5777 session = openSession();
5778
5779 AssetCategory[] array = new AssetCategoryImpl[3];
5780
5781 array[0] = getByP_V_PrevAndNext(session, assetCategory,
5782 parentCategoryId, vocabularyId, orderByComparator, true);
5783
5784 array[1] = assetCategory;
5785
5786 array[2] = getByP_V_PrevAndNext(session, assetCategory,
5787 parentCategoryId, vocabularyId, orderByComparator, false);
5788
5789 return array;
5790 }
5791 catch (Exception e) {
5792 throw processException(e);
5793 }
5794 finally {
5795 closeSession(session);
5796 }
5797 }
5798
5799 protected AssetCategory getByP_V_PrevAndNext(Session session,
5800 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
5801 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
5802 StringBundler query = null;
5803
5804 if (orderByComparator != null) {
5805 query = new StringBundler(5 +
5806 (orderByComparator.getOrderByConditionFields().length * 3) +
5807 (orderByComparator.getOrderByFields().length * 3));
5808 }
5809 else {
5810 query = new StringBundler(4);
5811 }
5812
5813 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5814
5815 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5816
5817 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5818
5819 if (orderByComparator != null) {
5820 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5821
5822 if (orderByConditionFields.length > 0) {
5823 query.append(WHERE_AND);
5824 }
5825
5826 for (int i = 0; i < orderByConditionFields.length; i++) {
5827 query.append(_ORDER_BY_ENTITY_ALIAS);
5828 query.append(orderByConditionFields[i]);
5829
5830 if ((i + 1) < orderByConditionFields.length) {
5831 if (orderByComparator.isAscending() ^ previous) {
5832 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5833 }
5834 else {
5835 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5836 }
5837 }
5838 else {
5839 if (orderByComparator.isAscending() ^ previous) {
5840 query.append(WHERE_GREATER_THAN);
5841 }
5842 else {
5843 query.append(WHERE_LESSER_THAN);
5844 }
5845 }
5846 }
5847
5848 query.append(ORDER_BY_CLAUSE);
5849
5850 String[] orderByFields = orderByComparator.getOrderByFields();
5851
5852 for (int i = 0; i < orderByFields.length; i++) {
5853 query.append(_ORDER_BY_ENTITY_ALIAS);
5854 query.append(orderByFields[i]);
5855
5856 if ((i + 1) < orderByFields.length) {
5857 if (orderByComparator.isAscending() ^ previous) {
5858 query.append(ORDER_BY_ASC_HAS_NEXT);
5859 }
5860 else {
5861 query.append(ORDER_BY_DESC_HAS_NEXT);
5862 }
5863 }
5864 else {
5865 if (orderByComparator.isAscending() ^ previous) {
5866 query.append(ORDER_BY_ASC);
5867 }
5868 else {
5869 query.append(ORDER_BY_DESC);
5870 }
5871 }
5872 }
5873 }
5874 else {
5875 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5876 }
5877
5878 String sql = query.toString();
5879
5880 Query q = session.createQuery(sql);
5881
5882 q.setFirstResult(0);
5883 q.setMaxResults(2);
5884
5885 QueryPos qPos = QueryPos.getInstance(q);
5886
5887 qPos.add(parentCategoryId);
5888
5889 qPos.add(vocabularyId);
5890
5891 if (orderByComparator != null) {
5892 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5893
5894 for (Object value : values) {
5895 qPos.add(value);
5896 }
5897 }
5898
5899 List<AssetCategory> list = q.list();
5900
5901 if (list.size() == 2) {
5902 return list.get(1);
5903 }
5904 else {
5905 return null;
5906 }
5907 }
5908
5909
5915 @Override
5916 public void removeByP_V(long parentCategoryId, long vocabularyId) {
5917 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
5918 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5919 remove(assetCategory);
5920 }
5921 }
5922
5923
5930 @Override
5931 public int countByP_V(long parentCategoryId, long vocabularyId) {
5932 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_V;
5933
5934 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
5935
5936 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5937
5938 if (count == null) {
5939 StringBundler query = new StringBundler(3);
5940
5941 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5942
5943 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5944
5945 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5946
5947 String sql = query.toString();
5948
5949 Session session = null;
5950
5951 try {
5952 session = openSession();
5953
5954 Query q = session.createQuery(sql);
5955
5956 QueryPos qPos = QueryPos.getInstance(q);
5957
5958 qPos.add(parentCategoryId);
5959
5960 qPos.add(vocabularyId);
5961
5962 count = (Long)q.uniqueResult();
5963
5964 finderCache.putResult(finderPath, finderArgs, count);
5965 }
5966 catch (Exception e) {
5967 finderCache.removeResult(finderPath, finderArgs);
5968
5969 throw processException(e);
5970 }
5971 finally {
5972 closeSession(session);
5973 }
5974 }
5975
5976 return count.intValue();
5977 }
5978
5979 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5980 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5981 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5982 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5983 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5984 "findByN_V",
5985 new String[] {
5986 String.class.getName(), Long.class.getName(),
5987
5988 Integer.class.getName(), Integer.class.getName(),
5989 OrderByComparator.class.getName()
5990 });
5991 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5992 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5993 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5994 "findByN_V",
5995 new String[] { String.class.getName(), Long.class.getName() },
5996 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
5997 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
5998 public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5999 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6000 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
6001 new String[] { String.class.getName(), Long.class.getName() });
6002
6003
6010 @Override
6011 public List<AssetCategory> findByN_V(String name, long vocabularyId) {
6012 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
6013 QueryUtil.ALL_POS, null);
6014 }
6015
6016
6029 @Override
6030 public List<AssetCategory> findByN_V(String name, long vocabularyId,
6031 int start, int end) {
6032 return findByN_V(name, vocabularyId, start, end, null);
6033 }
6034
6035
6049 @Override
6050 public List<AssetCategory> findByN_V(String name, long vocabularyId,
6051 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
6052 return findByN_V(name, vocabularyId, start, end, orderByComparator, true);
6053 }
6054
6055
6070 @Override
6071 public List<AssetCategory> findByN_V(String name, long vocabularyId,
6072 int start, int end, OrderByComparator<AssetCategory> orderByComparator,
6073 boolean retrieveFromCache) {
6074 boolean pagination = true;
6075 FinderPath finderPath = null;
6076 Object[] finderArgs = null;
6077
6078 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6079 (orderByComparator == null)) {
6080 pagination = false;
6081 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
6082 finderArgs = new Object[] { name, vocabularyId };
6083 }
6084 else {
6085 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
6086 finderArgs = new Object[] {
6087 name, vocabularyId,
6088
6089 start, end, orderByComparator
6090 };
6091 }
6092
6093 List<AssetCategory> list = null;
6094
6095 if (retrieveFromCache) {
6096 list = (List<AssetCategory>)finderCache.getResult(finderPath,
6097 finderArgs, this);
6098
6099 if ((list != null) && !list.isEmpty()) {
6100 for (AssetCategory assetCategory : list) {
6101 if (!Objects.equals(name, assetCategory.getName()) ||
6102 (vocabularyId != assetCategory.getVocabularyId())) {
6103 list = null;
6104
6105 break;
6106 }
6107 }
6108 }
6109 }
6110
6111 if (list == null) {
6112 StringBundler query = null;
6113
6114 if (orderByComparator != null) {
6115 query = new StringBundler(4 +
6116 (orderByComparator.getOrderByFields().length * 2));
6117 }
6118 else {
6119 query = new StringBundler(4);
6120 }
6121
6122 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6123
6124 boolean bindName = false;
6125
6126 if (name == null) {
6127 query.append(_FINDER_COLUMN_N_V_NAME_1);
6128 }
6129 else if (name.equals(StringPool.BLANK)) {
6130 query.append(_FINDER_COLUMN_N_V_NAME_3);
6131 }
6132 else {
6133 bindName = true;
6134
6135 query.append(_FINDER_COLUMN_N_V_NAME_2);
6136 }
6137
6138 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6139
6140 if (orderByComparator != null) {
6141 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6142 orderByComparator);
6143 }
6144 else
6145 if (pagination) {
6146 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6147 }
6148
6149 String sql = query.toString();
6150
6151 Session session = null;
6152
6153 try {
6154 session = openSession();
6155
6156 Query q = session.createQuery(sql);
6157
6158 QueryPos qPos = QueryPos.getInstance(q);
6159
6160 if (bindName) {
6161 qPos.add(name);
6162 }
6163
6164 qPos.add(vocabularyId);
6165
6166 if (!pagination) {
6167 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6168 start, end, false);
6169
6170 Collections.sort(list);
6171
6172 list = Collections.unmodifiableList(list);
6173 }
6174 else {
6175 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6176 start, end);
6177 }
6178
6179 cacheResult(list);
6180
6181 finderCache.putResult(finderPath, finderArgs, list);
6182 }
6183 catch (Exception e) {
6184 finderCache.removeResult(finderPath, finderArgs);
6185
6186 throw processException(e);
6187 }
6188 finally {
6189 closeSession(session);
6190 }
6191 }
6192
6193 return list;
6194 }
6195
6196
6205 @Override
6206 public AssetCategory findByN_V_First(String name, long vocabularyId,
6207 OrderByComparator<AssetCategory> orderByComparator)
6208 throws NoSuchCategoryException {
6209 AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId,
6210 orderByComparator);
6211
6212 if (assetCategory != null) {
6213 return assetCategory;
6214 }
6215
6216 StringBundler msg = new StringBundler(6);
6217
6218 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6219
6220 msg.append("name=");
6221 msg.append(name);
6222
6223 msg.append(", vocabularyId=");
6224 msg.append(vocabularyId);
6225
6226 msg.append(StringPool.CLOSE_CURLY_BRACE);
6227
6228 throw new NoSuchCategoryException(msg.toString());
6229 }
6230
6231
6239 @Override
6240 public AssetCategory fetchByN_V_First(String name, long vocabularyId,
6241 OrderByComparator<AssetCategory> orderByComparator) {
6242 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
6243 orderByComparator);
6244
6245 if (!list.isEmpty()) {
6246 return list.get(0);
6247 }
6248
6249 return null;
6250 }
6251
6252
6261 @Override
6262 public AssetCategory findByN_V_Last(String name, long vocabularyId,
6263 OrderByComparator<AssetCategory> orderByComparator)
6264 throws NoSuchCategoryException {
6265 AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId,
6266 orderByComparator);
6267
6268 if (assetCategory != null) {
6269 return assetCategory;
6270 }
6271
6272 StringBundler msg = new StringBundler(6);
6273
6274 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6275
6276 msg.append("name=");
6277 msg.append(name);
6278
6279 msg.append(", vocabularyId=");
6280 msg.append(vocabularyId);
6281
6282 msg.append(StringPool.CLOSE_CURLY_BRACE);
6283
6284 throw new NoSuchCategoryException(msg.toString());
6285 }
6286
6287
6295 @Override
6296 public AssetCategory fetchByN_V_Last(String name, long vocabularyId,
6297 OrderByComparator<AssetCategory> orderByComparator) {
6298 int count = countByN_V(name, vocabularyId);
6299
6300 if (count == 0) {
6301 return null;
6302 }
6303
6304 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
6305 count, orderByComparator);
6306
6307 if (!list.isEmpty()) {
6308 return list.get(0);
6309 }
6310
6311 return null;
6312 }
6313
6314
6324 @Override
6325 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
6326 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
6327 throws NoSuchCategoryException {
6328 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6329
6330 Session session = null;
6331
6332 try {
6333 session = openSession();
6334
6335 AssetCategory[] array = new AssetCategoryImpl[3];
6336
6337 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
6338 vocabularyId, orderByComparator, true);
6339
6340 array[1] = assetCategory;
6341
6342 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
6343 vocabularyId, orderByComparator, false);
6344
6345 return array;
6346 }
6347 catch (Exception e) {
6348 throw processException(e);
6349 }
6350 finally {
6351 closeSession(session);
6352 }
6353 }
6354
6355 protected AssetCategory getByN_V_PrevAndNext(Session session,
6356 AssetCategory assetCategory, String name, long vocabularyId,
6357 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
6358 StringBundler query = null;
6359
6360 if (orderByComparator != null) {
6361 query = new StringBundler(5 +
6362 (orderByComparator.getOrderByConditionFields().length * 3) +
6363 (orderByComparator.getOrderByFields().length * 3));
6364 }
6365 else {
6366 query = new StringBundler(4);
6367 }
6368
6369 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6370
6371 boolean bindName = false;
6372
6373 if (name == null) {
6374 query.append(_FINDER_COLUMN_N_V_NAME_1);
6375 }
6376 else if (name.equals(StringPool.BLANK)) {
6377 query.append(_FINDER_COLUMN_N_V_NAME_3);
6378 }
6379 else {
6380 bindName = true;
6381
6382 query.append(_FINDER_COLUMN_N_V_NAME_2);
6383 }
6384
6385 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6386
6387 if (orderByComparator != null) {
6388 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6389
6390 if (orderByConditionFields.length > 0) {
6391 query.append(WHERE_AND);
6392 }
6393
6394 for (int i = 0; i < orderByConditionFields.length; i++) {
6395 query.append(_ORDER_BY_ENTITY_ALIAS);
6396 query.append(orderByConditionFields[i]);
6397
6398 if ((i + 1) < orderByConditionFields.length) {
6399 if (orderByComparator.isAscending() ^ previous) {
6400 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6401 }
6402 else {
6403 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6404 }
6405 }
6406 else {
6407 if (orderByComparator.isAscending() ^ previous) {
6408 query.append(WHERE_GREATER_THAN);
6409 }
6410 else {
6411 query.append(WHERE_LESSER_THAN);
6412 }
6413 }
6414 }
6415
6416 query.append(ORDER_BY_CLAUSE);
6417
6418 String[] orderByFields = orderByComparator.getOrderByFields();
6419
6420 for (int i = 0; i < orderByFields.length; i++) {
6421 query.append(_ORDER_BY_ENTITY_ALIAS);
6422 query.append(orderByFields[i]);
6423
6424 if ((i + 1) < orderByFields.length) {
6425 if (orderByComparator.isAscending() ^ previous) {
6426 query.append(ORDER_BY_ASC_HAS_NEXT);
6427 }
6428 else {
6429 query.append(ORDER_BY_DESC_HAS_NEXT);
6430 }
6431 }
6432 else {
6433 if (orderByComparator.isAscending() ^ previous) {
6434 query.append(ORDER_BY_ASC);
6435 }
6436 else {
6437 query.append(ORDER_BY_DESC);
6438 }
6439 }
6440 }
6441 }
6442 else {
6443 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6444 }
6445
6446 String sql = query.toString();
6447
6448 Query q = session.createQuery(sql);
6449
6450 q.setFirstResult(0);
6451 q.setMaxResults(2);
6452
6453 QueryPos qPos = QueryPos.getInstance(q);
6454
6455 if (bindName) {
6456 qPos.add(name);
6457 }
6458
6459 qPos.add(vocabularyId);
6460
6461 if (orderByComparator != null) {
6462 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6463
6464 for (Object value : values) {
6465 qPos.add(value);
6466 }
6467 }
6468
6469 List<AssetCategory> list = q.list();
6470
6471 if (list.size() == 2) {
6472 return list.get(1);
6473 }
6474 else {
6475 return null;
6476 }
6477 }
6478
6479
6485 @Override
6486 public void removeByN_V(String name, long vocabularyId) {
6487 for (AssetCategory assetCategory : findByN_V(name, vocabularyId,
6488 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6489 remove(assetCategory);
6490 }
6491 }
6492
6493
6500 @Override
6501 public int countByN_V(String name, long vocabularyId) {
6502 FinderPath finderPath = FINDER_PATH_COUNT_BY_N_V;
6503
6504 Object[] finderArgs = new Object[] { name, vocabularyId };
6505
6506 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6507
6508 if (count == null) {
6509 StringBundler query = new StringBundler(3);
6510
6511 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6512
6513 boolean bindName = false;
6514
6515 if (name == null) {
6516 query.append(_FINDER_COLUMN_N_V_NAME_1);
6517 }
6518 else if (name.equals(StringPool.BLANK)) {
6519 query.append(_FINDER_COLUMN_N_V_NAME_3);
6520 }
6521 else {
6522 bindName = true;
6523
6524 query.append(_FINDER_COLUMN_N_V_NAME_2);
6525 }
6526
6527 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6528
6529 String sql = query.toString();
6530
6531 Session session = null;
6532
6533 try {
6534 session = openSession();
6535
6536 Query q = session.createQuery(sql);
6537
6538 QueryPos qPos = QueryPos.getInstance(q);
6539
6540 if (bindName) {
6541 qPos.add(name);
6542 }
6543
6544 qPos.add(vocabularyId);
6545
6546 count = (Long)q.uniqueResult();
6547
6548 finderCache.putResult(finderPath, finderArgs, count);
6549 }
6550 catch (Exception e) {
6551 finderCache.removeResult(finderPath, finderArgs);
6552
6553 throw processException(e);
6554 }
6555 finally {
6556 closeSession(session);
6557 }
6558 }
6559
6560 return count.intValue();
6561 }
6562
6563 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
6564 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
6565 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
6566 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6567 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6568 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6569 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6570 "findByG_P_V",
6571 new String[] {
6572 Long.class.getName(), Long.class.getName(), Long.class.getName(),
6573
6574 Integer.class.getName(), Integer.class.getName(),
6575 OrderByComparator.class.getName()
6576 });
6577 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6578 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6579 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
6580 "findByG_P_V",
6581 new String[] {
6582 Long.class.getName(), Long.class.getName(), Long.class.getName()
6583 },
6584 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
6585 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
6586 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
6587 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
6588 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6589 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6590 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_V",
6591 new String[] {
6592 Long.class.getName(), Long.class.getName(), Long.class.getName()
6593 });
6594
6595
6603 @Override
6604 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6605 long vocabularyId) {
6606 return findByG_P_V(groupId, parentCategoryId, vocabularyId,
6607 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6608 }
6609
6610
6624 @Override
6625 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6626 long vocabularyId, int start, int end) {
6627 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end,
6628 null);
6629 }
6630
6631
6646 @Override
6647 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6648 long vocabularyId, int start, int end,
6649 OrderByComparator<AssetCategory> orderByComparator) {
6650 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end,
6651 orderByComparator, true);
6652 }
6653
6654
6670 @Override
6671 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6672 long vocabularyId, int start, int end,
6673 OrderByComparator<AssetCategory> orderByComparator,
6674 boolean retrieveFromCache) {
6675 boolean pagination = true;
6676 FinderPath finderPath = null;
6677 Object[] finderArgs = null;
6678
6679 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6680 (orderByComparator == null)) {
6681 pagination = false;
6682 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V;
6683 finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId };
6684 }
6685 else {
6686 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V;
6687 finderArgs = new Object[] {
6688 groupId, parentCategoryId, vocabularyId,
6689
6690 start, end, orderByComparator
6691 };
6692 }
6693
6694 List<AssetCategory> list = null;
6695
6696 if (retrieveFromCache) {
6697 list = (List<AssetCategory>)finderCache.getResult(finderPath,
6698 finderArgs, this);
6699
6700 if ((list != null) && !list.isEmpty()) {
6701 for (AssetCategory assetCategory : list) {
6702 if ((groupId != assetCategory.getGroupId()) ||
6703 (parentCategoryId != assetCategory.getParentCategoryId()) ||
6704 (vocabularyId != assetCategory.getVocabularyId())) {
6705 list = null;
6706
6707 break;
6708 }
6709 }
6710 }
6711 }
6712
6713 if (list == null) {
6714 StringBundler query = null;
6715
6716 if (orderByComparator != null) {
6717 query = new StringBundler(5 +
6718 (orderByComparator.getOrderByFields().length * 2));
6719 }
6720 else {
6721 query = new StringBundler(5);
6722 }
6723
6724 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6725
6726 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6727
6728 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6729
6730 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6731
6732 if (orderByComparator != null) {
6733 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6734 orderByComparator);
6735 }
6736 else
6737 if (pagination) {
6738 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6739 }
6740
6741 String sql = query.toString();
6742
6743 Session session = null;
6744
6745 try {
6746 session = openSession();
6747
6748 Query q = session.createQuery(sql);
6749
6750 QueryPos qPos = QueryPos.getInstance(q);
6751
6752 qPos.add(groupId);
6753
6754 qPos.add(parentCategoryId);
6755
6756 qPos.add(vocabularyId);
6757
6758 if (!pagination) {
6759 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6760 start, end, false);
6761
6762 Collections.sort(list);
6763
6764 list = Collections.unmodifiableList(list);
6765 }
6766 else {
6767 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6768 start, end);
6769 }
6770
6771 cacheResult(list);
6772
6773 finderCache.putResult(finderPath, finderArgs, list);
6774 }
6775 catch (Exception e) {
6776 finderCache.removeResult(finderPath, finderArgs);
6777
6778 throw processException(e);
6779 }
6780 finally {
6781 closeSession(session);
6782 }
6783 }
6784
6785 return list;
6786 }
6787
6788
6798 @Override
6799 public AssetCategory findByG_P_V_First(long groupId, long parentCategoryId,
6800 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
6801 throws NoSuchCategoryException {
6802 AssetCategory assetCategory = fetchByG_P_V_First(groupId,
6803 parentCategoryId, vocabularyId, orderByComparator);
6804
6805 if (assetCategory != null) {
6806 return assetCategory;
6807 }
6808
6809 StringBundler msg = new StringBundler(8);
6810
6811 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6812
6813 msg.append("groupId=");
6814 msg.append(groupId);
6815
6816 msg.append(", parentCategoryId=");
6817 msg.append(parentCategoryId);
6818
6819 msg.append(", vocabularyId=");
6820 msg.append(vocabularyId);
6821
6822 msg.append(StringPool.CLOSE_CURLY_BRACE);
6823
6824 throw new NoSuchCategoryException(msg.toString());
6825 }
6826
6827
6836 @Override
6837 public AssetCategory fetchByG_P_V_First(long groupId,
6838 long parentCategoryId, long vocabularyId,
6839 OrderByComparator<AssetCategory> orderByComparator) {
6840 List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6841 vocabularyId, 0, 1, orderByComparator);
6842
6843 if (!list.isEmpty()) {
6844 return list.get(0);
6845 }
6846
6847 return null;
6848 }
6849
6850
6860 @Override
6861 public AssetCategory findByG_P_V_Last(long groupId, long parentCategoryId,
6862 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
6863 throws NoSuchCategoryException {
6864 AssetCategory assetCategory = fetchByG_P_V_Last(groupId,
6865 parentCategoryId, vocabularyId, orderByComparator);
6866
6867 if (assetCategory != null) {
6868 return assetCategory;
6869 }
6870
6871 StringBundler msg = new StringBundler(8);
6872
6873 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6874
6875 msg.append("groupId=");
6876 msg.append(groupId);
6877
6878 msg.append(", parentCategoryId=");
6879 msg.append(parentCategoryId);
6880
6881 msg.append(", vocabularyId=");
6882 msg.append(vocabularyId);
6883
6884 msg.append(StringPool.CLOSE_CURLY_BRACE);
6885
6886 throw new NoSuchCategoryException(msg.toString());
6887 }
6888
6889
6898 @Override
6899 public AssetCategory fetchByG_P_V_Last(long groupId, long parentCategoryId,
6900 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) {
6901 int count = countByG_P_V(groupId, parentCategoryId, vocabularyId);
6902
6903 if (count == 0) {
6904 return null;
6905 }
6906
6907 List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6908 vocabularyId, count - 1, count, orderByComparator);
6909
6910 if (!list.isEmpty()) {
6911 return list.get(0);
6912 }
6913
6914 return null;
6915 }
6916
6917
6928 @Override
6929 public AssetCategory[] findByG_P_V_PrevAndNext(long categoryId,
6930 long groupId, long parentCategoryId, long vocabularyId,
6931 OrderByComparator<AssetCategory> orderByComparator)
6932 throws NoSuchCategoryException {
6933 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6934
6935 Session session = null;
6936
6937 try {
6938 session = openSession();
6939
6940 AssetCategory[] array = new AssetCategoryImpl[3];
6941
6942 array[0] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6943 parentCategoryId, vocabularyId, orderByComparator, true);
6944
6945 array[1] = assetCategory;
6946
6947 array[2] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6948 parentCategoryId, vocabularyId, orderByComparator, false);
6949
6950 return array;
6951 }
6952 catch (Exception e) {
6953 throw processException(e);
6954 }
6955 finally {
6956 closeSession(session);
6957 }
6958 }
6959
6960 protected AssetCategory getByG_P_V_PrevAndNext(Session session,
6961 AssetCategory assetCategory, long groupId, long parentCategoryId,
6962 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator,
6963 boolean previous) {
6964 StringBundler query = null;
6965
6966 if (orderByComparator != null) {
6967 query = new StringBundler(6 +
6968 (orderByComparator.getOrderByConditionFields().length * 3) +
6969 (orderByComparator.getOrderByFields().length * 3));
6970 }
6971 else {
6972 query = new StringBundler(5);
6973 }
6974
6975 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6976
6977 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6978
6979 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6980
6981 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6982
6983 if (orderByComparator != null) {
6984 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6985
6986 if (orderByConditionFields.length > 0) {
6987 query.append(WHERE_AND);
6988 }
6989
6990 for (int i = 0; i < orderByConditionFields.length; i++) {
6991 query.append(_ORDER_BY_ENTITY_ALIAS);
6992 query.append(orderByConditionFields[i]);
6993
6994 if ((i + 1) < orderByConditionFields.length) {
6995 if (orderByComparator.isAscending() ^ previous) {
6996 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6997 }
6998 else {
6999 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7000 }
7001 }
7002 else {
7003 if (orderByComparator.isAscending() ^ previous) {
7004 query.append(WHERE_GREATER_THAN);
7005 }
7006 else {
7007 query.append(WHERE_LESSER_THAN);
7008 }
7009 }
7010 }
7011
7012 query.append(ORDER_BY_CLAUSE);
7013
7014 String[] orderByFields = orderByComparator.getOrderByFields();
7015
7016 for (int i = 0; i < orderByFields.length; i++) {
7017 query.append(_ORDER_BY_ENTITY_ALIAS);
7018 query.append(orderByFields[i]);
7019
7020 if ((i + 1) < orderByFields.length) {
7021 if (orderByComparator.isAscending() ^ previous) {
7022 query.append(ORDER_BY_ASC_HAS_NEXT);
7023 }
7024 else {
7025 query.append(ORDER_BY_DESC_HAS_NEXT);
7026 }
7027 }
7028 else {
7029 if (orderByComparator.isAscending() ^ previous) {
7030 query.append(ORDER_BY_ASC);
7031 }
7032 else {
7033 query.append(ORDER_BY_DESC);
7034 }
7035 }
7036 }
7037 }
7038 else {
7039 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7040 }
7041
7042 String sql = query.toString();
7043
7044 Query q = session.createQuery(sql);
7045
7046 q.setFirstResult(0);
7047 q.setMaxResults(2);
7048
7049 QueryPos qPos = QueryPos.getInstance(q);
7050
7051 qPos.add(groupId);
7052
7053 qPos.add(parentCategoryId);
7054
7055 qPos.add(vocabularyId);
7056
7057 if (orderByComparator != null) {
7058 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7059
7060 for (Object value : values) {
7061 qPos.add(value);
7062 }
7063 }
7064
7065 List<AssetCategory> list = q.list();
7066
7067 if (list.size() == 2) {
7068 return list.get(1);
7069 }
7070 else {
7071 return null;
7072 }
7073 }
7074
7075
7083 @Override
7084 public List<AssetCategory> filterFindByG_P_V(long groupId,
7085 long parentCategoryId, long vocabularyId) {
7086 return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
7087 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7088 }
7089
7090
7104 @Override
7105 public List<AssetCategory> filterFindByG_P_V(long groupId,
7106 long parentCategoryId, long vocabularyId, int start, int end) {
7107 return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
7108 start, end, null);
7109 }
7110
7111
7126 @Override
7127 public List<AssetCategory> filterFindByG_P_V(long groupId,
7128 long parentCategoryId, long vocabularyId, int start, int end,
7129 OrderByComparator<AssetCategory> orderByComparator) {
7130 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7131 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start,
7132 end, orderByComparator);
7133 }
7134
7135 StringBundler query = null;
7136
7137 if (orderByComparator != null) {
7138 query = new StringBundler(5 +
7139 (orderByComparator.getOrderByFields().length * 2));
7140 }
7141 else {
7142 query = new StringBundler(6);
7143 }
7144
7145 if (getDB().isSupportsInlineDistinct()) {
7146 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7147 }
7148 else {
7149 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7150 }
7151
7152 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7153
7154 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7155
7156 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7157
7158 if (!getDB().isSupportsInlineDistinct()) {
7159 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7160 }
7161
7162 if (orderByComparator != null) {
7163 if (getDB().isSupportsInlineDistinct()) {
7164 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7165 orderByComparator, true);
7166 }
7167 else {
7168 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7169 orderByComparator, true);
7170 }
7171 }
7172 else {
7173 if (getDB().isSupportsInlineDistinct()) {
7174 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7175 }
7176 else {
7177 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7178 }
7179 }
7180
7181 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7182 AssetCategory.class.getName(),
7183 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7184
7185 Session session = null;
7186
7187 try {
7188 session = openSession();
7189
7190 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7191
7192 if (getDB().isSupportsInlineDistinct()) {
7193 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7194 }
7195 else {
7196 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7197 }
7198
7199 QueryPos qPos = QueryPos.getInstance(q);
7200
7201 qPos.add(groupId);
7202
7203 qPos.add(parentCategoryId);
7204
7205 qPos.add(vocabularyId);
7206
7207 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
7208 end);
7209 }
7210 catch (Exception e) {
7211 throw processException(e);
7212 }
7213 finally {
7214 closeSession(session);
7215 }
7216 }
7217
7218
7229 @Override
7230 public AssetCategory[] filterFindByG_P_V_PrevAndNext(long categoryId,
7231 long groupId, long parentCategoryId, long vocabularyId,
7232 OrderByComparator<AssetCategory> orderByComparator)
7233 throws NoSuchCategoryException {
7234 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7235 return findByG_P_V_PrevAndNext(categoryId, groupId,
7236 parentCategoryId, vocabularyId, orderByComparator);
7237 }
7238
7239 AssetCategory assetCategory = findByPrimaryKey(categoryId);
7240
7241 Session session = null;
7242
7243 try {
7244 session = openSession();
7245
7246 AssetCategory[] array = new AssetCategoryImpl[3];
7247
7248 array[0] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
7249 groupId, parentCategoryId, vocabularyId, orderByComparator,
7250 true);
7251
7252 array[1] = assetCategory;
7253
7254 array[2] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
7255 groupId, parentCategoryId, vocabularyId, orderByComparator,
7256 false);
7257
7258 return array;
7259 }
7260 catch (Exception e) {
7261 throw processException(e);
7262 }
7263 finally {
7264 closeSession(session);
7265 }
7266 }
7267
7268 protected AssetCategory filterGetByG_P_V_PrevAndNext(Session session,
7269 AssetCategory assetCategory, long groupId, long parentCategoryId,
7270 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator,
7271 boolean previous) {
7272 StringBundler query = null;
7273
7274 if (orderByComparator != null) {
7275 query = new StringBundler(7 +
7276 (orderByComparator.getOrderByConditionFields().length * 3) +
7277 (orderByComparator.getOrderByFields().length * 3));
7278 }
7279 else {
7280 query = new StringBundler(6);
7281 }
7282
7283 if (getDB().isSupportsInlineDistinct()) {
7284 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7285 }
7286 else {
7287 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7288 }
7289
7290 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7291
7292 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7293
7294 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7295
7296 if (!getDB().isSupportsInlineDistinct()) {
7297 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7298 }
7299
7300 if (orderByComparator != null) {
7301 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7302
7303 if (orderByConditionFields.length > 0) {
7304 query.append(WHERE_AND);
7305 }
7306
7307 for (int i = 0; i < orderByConditionFields.length; i++) {
7308 if (getDB().isSupportsInlineDistinct()) {
7309 query.append(_ORDER_BY_ENTITY_ALIAS);
7310 }
7311 else {
7312 query.append(_ORDER_BY_ENTITY_TABLE);
7313 }
7314
7315 query.append(orderByConditionFields[i]);
7316
7317 if ((i + 1) < orderByConditionFields.length) {
7318 if (orderByComparator.isAscending() ^ previous) {
7319 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7320 }
7321 else {
7322 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7323 }
7324 }
7325 else {
7326 if (orderByComparator.isAscending() ^ previous) {
7327 query.append(WHERE_GREATER_THAN);
7328 }
7329 else {
7330 query.append(WHERE_LESSER_THAN);
7331 }
7332 }
7333 }
7334
7335 query.append(ORDER_BY_CLAUSE);
7336
7337 String[] orderByFields = orderByComparator.getOrderByFields();
7338
7339 for (int i = 0; i < orderByFields.length; i++) {
7340 if (getDB().isSupportsInlineDistinct()) {
7341 query.append(_ORDER_BY_ENTITY_ALIAS);
7342 }
7343 else {
7344 query.append(_ORDER_BY_ENTITY_TABLE);
7345 }
7346
7347 query.append(orderByFields[i]);
7348
7349 if ((i + 1) < orderByFields.length) {
7350 if (orderByComparator.isAscending() ^ previous) {
7351 query.append(ORDER_BY_ASC_HAS_NEXT);
7352 }
7353 else {
7354 query.append(ORDER_BY_DESC_HAS_NEXT);
7355 }
7356 }
7357 else {
7358 if (orderByComparator.isAscending() ^ previous) {
7359 query.append(ORDER_BY_ASC);
7360 }
7361 else {
7362 query.append(ORDER_BY_DESC);
7363 }
7364 }
7365 }
7366 }
7367 else {
7368 if (getDB().isSupportsInlineDistinct()) {
7369 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7370 }
7371 else {
7372 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7373 }
7374 }
7375
7376 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7377 AssetCategory.class.getName(),
7378 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7379
7380 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7381
7382 q.setFirstResult(0);
7383 q.setMaxResults(2);
7384
7385 if (getDB().isSupportsInlineDistinct()) {
7386 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7387 }
7388 else {
7389 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7390 }
7391
7392 QueryPos qPos = QueryPos.getInstance(q);
7393
7394 qPos.add(groupId);
7395
7396 qPos.add(parentCategoryId);
7397
7398 qPos.add(vocabularyId);
7399
7400 if (orderByComparator != null) {
7401 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7402
7403 for (Object value : values) {
7404 qPos.add(value);
7405 }
7406 }
7407
7408 List<AssetCategory> list = q.list();
7409
7410 if (list.size() == 2) {
7411 return list.get(1);
7412 }
7413 else {
7414 return null;
7415 }
7416 }
7417
7418
7425 @Override
7426 public void removeByG_P_V(long groupId, long parentCategoryId,
7427 long vocabularyId) {
7428 for (AssetCategory assetCategory : findByG_P_V(groupId,
7429 parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
7430 QueryUtil.ALL_POS, null)) {
7431 remove(assetCategory);
7432 }
7433 }
7434
7435
7443 @Override
7444 public int countByG_P_V(long groupId, long parentCategoryId,
7445 long vocabularyId) {
7446 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_V;
7447
7448 Object[] finderArgs = new Object[] {
7449 groupId, parentCategoryId, vocabularyId
7450 };
7451
7452 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7453
7454 if (count == null) {
7455 StringBundler query = new StringBundler(4);
7456
7457 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7458
7459 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7460
7461 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7462
7463 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7464
7465 String sql = query.toString();
7466
7467 Session session = null;
7468
7469 try {
7470 session = openSession();
7471
7472 Query q = session.createQuery(sql);
7473
7474 QueryPos qPos = QueryPos.getInstance(q);
7475
7476 qPos.add(groupId);
7477
7478 qPos.add(parentCategoryId);
7479
7480 qPos.add(vocabularyId);
7481
7482 count = (Long)q.uniqueResult();
7483
7484 finderCache.putResult(finderPath, finderArgs, count);
7485 }
7486 catch (Exception e) {
7487 finderCache.removeResult(finderPath, finderArgs);
7488
7489 throw processException(e);
7490 }
7491 finally {
7492 closeSession(session);
7493 }
7494 }
7495
7496 return count.intValue();
7497 }
7498
7499
7507 @Override
7508 public int filterCountByG_P_V(long groupId, long parentCategoryId,
7509 long vocabularyId) {
7510 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7511 return countByG_P_V(groupId, parentCategoryId, vocabularyId);
7512 }
7513
7514 StringBundler query = new StringBundler(4);
7515
7516 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
7517
7518 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7519
7520 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7521
7522 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7523
7524 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7525 AssetCategory.class.getName(),
7526 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7527
7528 Session session = null;
7529
7530 try {
7531 session = openSession();
7532
7533 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7534
7535 q.addScalar(COUNT_COLUMN_NAME,
7536 com.liferay.portal.kernel.dao.orm.Type.LONG);
7537
7538 QueryPos qPos = QueryPos.getInstance(q);
7539
7540 qPos.add(groupId);
7541
7542 qPos.add(parentCategoryId);
7543
7544 qPos.add(vocabularyId);
7545
7546 Long count = (Long)q.uniqueResult();
7547
7548 return count.intValue();
7549 }
7550 catch (Exception e) {
7551 throw processException(e);
7552 }
7553 finally {
7554 closeSession(session);
7555 }
7556 }
7557
7558 private static final String _FINDER_COLUMN_G_P_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
7559 private static final String _FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
7560 private static final String _FINDER_COLUMN_G_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7561 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V =
7562 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7563 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
7564 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7565 "findByG_LikeN_V",
7566 new String[] {
7567 Long.class.getName(), String.class.getName(),
7568 Long.class.getName(),
7569
7570 Integer.class.getName(), Integer.class.getName(),
7571 OrderByComparator.class.getName()
7572 });
7573 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V =
7574 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7575 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7576 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LikeN_V",
7577 new String[] {
7578 Long.class.getName(), String.class.getName(),
7579 Long.class.getName()
7580 });
7581
7582
7590 @Override
7591 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7592 long vocabularyId) {
7593 return findByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS,
7594 QueryUtil.ALL_POS, null);
7595 }
7596
7597
7611 @Override
7612 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7613 long vocabularyId, int start, int end) {
7614 return findByG_LikeN_V(groupId, name, vocabularyId, start, end, null);
7615 }
7616
7617
7632 @Override
7633 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7634 long vocabularyId, int start, int end,
7635 OrderByComparator<AssetCategory> orderByComparator) {
7636 return findByG_LikeN_V(groupId, name, vocabularyId, start, end,
7637 orderByComparator, true);
7638 }
7639
7640
7656 @Override
7657 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7658 long vocabularyId, int start, int end,
7659 OrderByComparator<AssetCategory> orderByComparator,
7660 boolean retrieveFromCache) {
7661 boolean pagination = true;
7662 FinderPath finderPath = null;
7663 Object[] finderArgs = null;
7664
7665 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V;
7666 finderArgs = new Object[] {
7667 groupId, name, vocabularyId,
7668
7669 start, end, orderByComparator
7670 };
7671
7672 List<AssetCategory> list = null;
7673
7674 if (retrieveFromCache) {
7675 list = (List<AssetCategory>)finderCache.getResult(finderPath,
7676 finderArgs, this);
7677
7678 if ((list != null) && !list.isEmpty()) {
7679 for (AssetCategory assetCategory : list) {
7680 if ((groupId != assetCategory.getGroupId()) ||
7681 !StringUtil.wildcardMatches(
7682 assetCategory.getName(), name,
7683 CharPool.UNDERLINE, CharPool.PERCENT,
7684 CharPool.BACK_SLASH, false) ||
7685 (vocabularyId != assetCategory.getVocabularyId())) {
7686 list = null;
7687
7688 break;
7689 }
7690 }
7691 }
7692 }
7693
7694 if (list == null) {
7695 StringBundler query = null;
7696
7697 if (orderByComparator != null) {
7698 query = new StringBundler(5 +
7699 (orderByComparator.getOrderByFields().length * 2));
7700 }
7701 else {
7702 query = new StringBundler(5);
7703 }
7704
7705 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7706
7707 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7708
7709 boolean bindName = false;
7710
7711 if (name == null) {
7712 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7713 }
7714 else if (name.equals(StringPool.BLANK)) {
7715 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7716 }
7717 else {
7718 bindName = true;
7719
7720 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7721 }
7722
7723 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7724
7725 if (orderByComparator != null) {
7726 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7727 orderByComparator);
7728 }
7729 else
7730 if (pagination) {
7731 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7732 }
7733
7734 String sql = query.toString();
7735
7736 Session session = null;
7737
7738 try {
7739 session = openSession();
7740
7741 Query q = session.createQuery(sql);
7742
7743 QueryPos qPos = QueryPos.getInstance(q);
7744
7745 qPos.add(groupId);
7746
7747 if (bindName) {
7748 qPos.add(StringUtil.toLowerCase(name));
7749 }
7750
7751 qPos.add(vocabularyId);
7752
7753 if (!pagination) {
7754 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7755 start, end, false);
7756
7757 Collections.sort(list);
7758
7759 list = Collections.unmodifiableList(list);
7760 }
7761 else {
7762 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7763 start, end);
7764 }
7765
7766 cacheResult(list);
7767
7768 finderCache.putResult(finderPath, finderArgs, list);
7769 }
7770 catch (Exception e) {
7771 finderCache.removeResult(finderPath, finderArgs);
7772
7773 throw processException(e);
7774 }
7775 finally {
7776 closeSession(session);
7777 }
7778 }
7779
7780 return list;
7781 }
7782
7783
7793 @Override
7794 public AssetCategory findByG_LikeN_V_First(long groupId, String name,
7795 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
7796 throws NoSuchCategoryException {
7797 AssetCategory assetCategory = fetchByG_LikeN_V_First(groupId, name,
7798 vocabularyId, orderByComparator);
7799
7800 if (assetCategory != null) {
7801 return assetCategory;
7802 }
7803
7804 StringBundler msg = new StringBundler(8);
7805
7806 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7807
7808 msg.append("groupId=");
7809 msg.append(groupId);
7810
7811 msg.append(", name=");
7812 msg.append(name);
7813
7814 msg.append(", vocabularyId=");
7815 msg.append(vocabularyId);
7816
7817 msg.append(StringPool.CLOSE_CURLY_BRACE);
7818
7819 throw new NoSuchCategoryException(msg.toString());
7820 }
7821
7822
7831 @Override
7832 public AssetCategory fetchByG_LikeN_V_First(long groupId, String name,
7833 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) {
7834 List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7835 0, 1, orderByComparator);
7836
7837 if (!list.isEmpty()) {
7838 return list.get(0);
7839 }
7840
7841 return null;
7842 }
7843
7844
7854 @Override
7855 public AssetCategory findByG_LikeN_V_Last(long groupId, String name,
7856 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
7857 throws NoSuchCategoryException {
7858 AssetCategory assetCategory = fetchByG_LikeN_V_Last(groupId, name,
7859 vocabularyId, orderByComparator);
7860
7861 if (assetCategory != null) {
7862 return assetCategory;
7863 }
7864
7865 StringBundler msg = new StringBundler(8);
7866
7867 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7868
7869 msg.append("groupId=");
7870 msg.append(groupId);
7871
7872 msg.append(", name=");
7873 msg.append(name);
7874
7875 msg.append(", vocabularyId=");
7876 msg.append(vocabularyId);
7877
7878 msg.append(StringPool.CLOSE_CURLY_BRACE);
7879
7880 throw new NoSuchCategoryException(msg.toString());
7881 }
7882
7883
7892 @Override
7893 public AssetCategory fetchByG_LikeN_V_Last(long groupId, String name,
7894 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) {
7895 int count = countByG_LikeN_V(groupId, name, vocabularyId);
7896
7897 if (count == 0) {
7898 return null;
7899 }
7900
7901 List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7902 count - 1, count, orderByComparator);
7903
7904 if (!list.isEmpty()) {
7905 return list.get(0);
7906 }
7907
7908 return null;
7909 }
7910
7911
7922 @Override
7923 public AssetCategory[] findByG_LikeN_V_PrevAndNext(long categoryId,
7924 long groupId, String name, long vocabularyId,
7925 OrderByComparator<AssetCategory> orderByComparator)
7926 throws NoSuchCategoryException {
7927 AssetCategory assetCategory = findByPrimaryKey(categoryId);
7928
7929 Session session = null;
7930
7931 try {
7932 session = openSession();
7933
7934 AssetCategory[] array = new AssetCategoryImpl[3];
7935
7936 array[0] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7937 groupId, name, vocabularyId, orderByComparator, true);
7938
7939 array[1] = assetCategory;
7940
7941 array[2] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7942 groupId, name, vocabularyId, orderByComparator, false);
7943
7944 return array;
7945 }
7946 catch (Exception e) {
7947 throw processException(e);
7948 }
7949 finally {
7950 closeSession(session);
7951 }
7952 }
7953
7954 protected AssetCategory getByG_LikeN_V_PrevAndNext(Session session,
7955 AssetCategory assetCategory, long groupId, String name,
7956 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator,
7957 boolean previous) {
7958 StringBundler query = null;
7959
7960 if (orderByComparator != null) {
7961 query = new StringBundler(6 +
7962 (orderByComparator.getOrderByConditionFields().length * 3) +
7963 (orderByComparator.getOrderByFields().length * 3));
7964 }
7965 else {
7966 query = new StringBundler(5);
7967 }
7968
7969 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7970
7971 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7972
7973 boolean bindName = false;
7974
7975 if (name == null) {
7976 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7977 }
7978 else if (name.equals(StringPool.BLANK)) {
7979 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7980 }
7981 else {
7982 bindName = true;
7983
7984 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7985 }
7986
7987 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7988
7989 if (orderByComparator != null) {
7990 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7991
7992 if (orderByConditionFields.length > 0) {
7993 query.append(WHERE_AND);
7994 }
7995
7996 for (int i = 0; i < orderByConditionFields.length; i++) {
7997 query.append(_ORDER_BY_ENTITY_ALIAS);
7998 query.append(orderByConditionFields[i]);
7999
8000 if ((i + 1) < orderByConditionFields.length) {
8001 if (orderByComparator.isAscending() ^ previous) {
8002 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8003 }
8004 else {
8005 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8006 }
8007 }
8008 else {
8009 if (orderByComparator.isAscending() ^ previous) {
8010 query.append(WHERE_GREATER_THAN);
8011 }
8012 else {
8013 query.append(WHERE_LESSER_THAN);
8014 }
8015 }
8016 }
8017
8018 query.append(ORDER_BY_CLAUSE);
8019
8020 String[] orderByFields = orderByComparator.getOrderByFields();
8021
8022 for (int i = 0; i < orderByFields.length; i++) {
8023 query.append(_ORDER_BY_ENTITY_ALIAS);
8024 query.append(orderByFields[i]);
8025
8026 if ((i + 1) < orderByFields.length) {
8027 if (orderByComparator.isAscending() ^ previous) {
8028 query.append(ORDER_BY_ASC_HAS_NEXT);
8029 }
8030 else {
8031 query.append(ORDER_BY_DESC_HAS_NEXT);
8032 }
8033 }
8034 else {
8035 if (orderByComparator.isAscending() ^ previous) {
8036 query.append(ORDER_BY_ASC);
8037 }
8038 else {
8039 query.append(ORDER_BY_DESC);
8040 }
8041 }
8042 }
8043 }
8044 else {
8045 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8046 }
8047
8048 String sql = query.toString();
8049
8050 Query q = session.createQuery(sql);
8051
8052 q.setFirstResult(0);
8053 q.setMaxResults(2);
8054
8055 QueryPos qPos = QueryPos.getInstance(q);
8056
8057 qPos.add(groupId);
8058
8059 if (bindName) {
8060 qPos.add(StringUtil.toLowerCase(name));
8061 }
8062
8063 qPos.add(vocabularyId);
8064
8065 if (orderByComparator != null) {
8066 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
8067
8068 for (Object value : values) {
8069 qPos.add(value);
8070 }
8071 }
8072
8073 List<AssetCategory> list = q.list();
8074
8075 if (list.size() == 2) {
8076 return list.get(1);
8077 }
8078 else {
8079 return null;
8080 }
8081 }
8082
8083
8091 @Override
8092 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8093 long vocabularyId) {
8094 return filterFindByG_LikeN_V(groupId, name, vocabularyId,
8095 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8096 }
8097
8098
8112 @Override
8113 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8114 long vocabularyId, int start, int end) {
8115 return filterFindByG_LikeN_V(groupId, name, vocabularyId, start, end,
8116 null);
8117 }
8118
8119
8134 @Override
8135 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8136 long vocabularyId, int start, int end,
8137 OrderByComparator<AssetCategory> orderByComparator) {
8138 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8139 return findByG_LikeN_V(groupId, name, vocabularyId, start, end,
8140 orderByComparator);
8141 }
8142
8143 StringBundler query = null;
8144
8145 if (orderByComparator != null) {
8146 query = new StringBundler(5 +
8147 (orderByComparator.getOrderByFields().length * 2));
8148 }
8149 else {
8150 query = new StringBundler(6);
8151 }
8152
8153 if (getDB().isSupportsInlineDistinct()) {
8154 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8155 }
8156 else {
8157 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8158 }
8159
8160 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8161
8162 boolean bindName = false;
8163
8164 if (name == null) {
8165 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8166 }
8167 else if (name.equals(StringPool.BLANK)) {
8168 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8169 }
8170 else {
8171 bindName = true;
8172
8173 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8174 }
8175
8176 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8177
8178 if (!getDB().isSupportsInlineDistinct()) {
8179 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8180 }
8181
8182 if (orderByComparator != null) {
8183 if (getDB().isSupportsInlineDistinct()) {
8184 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8185 orderByComparator, true);
8186 }
8187 else {
8188 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8189 orderByComparator, true);
8190 }
8191 }
8192 else {
8193 if (getDB().isSupportsInlineDistinct()) {
8194 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8195 }
8196 else {
8197 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8198 }
8199 }
8200
8201 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8202 AssetCategory.class.getName(),
8203 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8204
8205 Session session = null;
8206
8207 try {
8208 session = openSession();
8209
8210 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8211
8212 if (getDB().isSupportsInlineDistinct()) {
8213 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8214 }
8215 else {
8216 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8217 }
8218
8219 QueryPos qPos = QueryPos.getInstance(q);
8220
8221 qPos.add(groupId);
8222
8223 if (bindName) {
8224 qPos.add(StringUtil.toLowerCase(name));
8225 }
8226
8227 qPos.add(vocabularyId);
8228
8229 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8230 end);
8231 }
8232 catch (Exception e) {
8233 throw processException(e);
8234 }
8235 finally {
8236 closeSession(session);
8237 }
8238 }
8239
8240
8251 @Override
8252 public AssetCategory[] filterFindByG_LikeN_V_PrevAndNext(long categoryId,
8253 long groupId, String name, long vocabularyId,
8254 OrderByComparator<AssetCategory> orderByComparator)
8255 throws NoSuchCategoryException {
8256 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8257 return findByG_LikeN_V_PrevAndNext(categoryId, groupId, name,
8258 vocabularyId, orderByComparator);
8259 }
8260
8261 AssetCategory assetCategory = findByPrimaryKey(categoryId);
8262
8263 Session session = null;
8264
8265 try {
8266 session = openSession();
8267
8268 AssetCategory[] array = new AssetCategoryImpl[3];
8269
8270 array[0] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
8271 groupId, name, vocabularyId, orderByComparator, true);
8272
8273 array[1] = assetCategory;
8274
8275 array[2] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
8276 groupId, name, vocabularyId, orderByComparator, false);
8277
8278 return array;
8279 }
8280 catch (Exception e) {
8281 throw processException(e);
8282 }
8283 finally {
8284 closeSession(session);
8285 }
8286 }
8287
8288 protected AssetCategory filterGetByG_LikeN_V_PrevAndNext(Session session,
8289 AssetCategory assetCategory, long groupId, String name,
8290 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator,
8291 boolean previous) {
8292 StringBundler query = null;
8293
8294 if (orderByComparator != null) {
8295 query = new StringBundler(7 +
8296 (orderByComparator.getOrderByConditionFields().length * 3) +
8297 (orderByComparator.getOrderByFields().length * 3));
8298 }
8299 else {
8300 query = new StringBundler(6);
8301 }
8302
8303 if (getDB().isSupportsInlineDistinct()) {
8304 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8305 }
8306 else {
8307 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8308 }
8309
8310 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8311
8312 boolean bindName = false;
8313
8314 if (name == null) {
8315 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8316 }
8317 else if (name.equals(StringPool.BLANK)) {
8318 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8319 }
8320 else {
8321 bindName = true;
8322
8323 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8324 }
8325
8326 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8327
8328 if (!getDB().isSupportsInlineDistinct()) {
8329 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8330 }
8331
8332 if (orderByComparator != null) {
8333 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8334
8335 if (orderByConditionFields.length > 0) {
8336 query.append(WHERE_AND);
8337 }
8338
8339 for (int i = 0; i < orderByConditionFields.length; i++) {
8340 if (getDB().isSupportsInlineDistinct()) {
8341 query.append(_ORDER_BY_ENTITY_ALIAS);
8342 }
8343 else {
8344 query.append(_ORDER_BY_ENTITY_TABLE);
8345 }
8346
8347 query.append(orderByConditionFields[i]);
8348
8349 if ((i + 1) < orderByConditionFields.length) {
8350 if (orderByComparator.isAscending() ^ previous) {
8351 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8352 }
8353 else {
8354 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8355 }
8356 }
8357 else {
8358 if (orderByComparator.isAscending() ^ previous) {
8359 query.append(WHERE_GREATER_THAN);
8360 }
8361 else {
8362 query.append(WHERE_LESSER_THAN);
8363 }
8364 }
8365 }
8366
8367 query.append(ORDER_BY_CLAUSE);
8368
8369 String[] orderByFields = orderByComparator.getOrderByFields();
8370
8371 for (int i = 0; i < orderByFields.length; i++) {
8372 if (getDB().isSupportsInlineDistinct()) {
8373 query.append(_ORDER_BY_ENTITY_ALIAS);
8374 }
8375 else {
8376 query.append(_ORDER_BY_ENTITY_TABLE);
8377 }
8378
8379 query.append(orderByFields[i]);
8380
8381 if ((i + 1) < orderByFields.length) {
8382 if (orderByComparator.isAscending() ^ previous) {
8383 query.append(ORDER_BY_ASC_HAS_NEXT);
8384 }
8385 else {
8386 query.append(ORDER_BY_DESC_HAS_NEXT);
8387 }
8388 }
8389 else {
8390 if (orderByComparator.isAscending() ^ previous) {
8391 query.append(ORDER_BY_ASC);
8392 }
8393 else {
8394 query.append(ORDER_BY_DESC);
8395 }
8396 }
8397 }
8398 }
8399 else {
8400 if (getDB().isSupportsInlineDistinct()) {
8401 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8402 }
8403 else {
8404 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8405 }
8406 }
8407
8408 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8409 AssetCategory.class.getName(),
8410 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8411
8412 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8413
8414 q.setFirstResult(0);
8415 q.setMaxResults(2);
8416
8417 if (getDB().isSupportsInlineDistinct()) {
8418 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8419 }
8420 else {
8421 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8422 }
8423
8424 QueryPos qPos = QueryPos.getInstance(q);
8425
8426 qPos.add(groupId);
8427
8428 if (bindName) {
8429 qPos.add(StringUtil.toLowerCase(name));
8430 }
8431
8432 qPos.add(vocabularyId);
8433
8434 if (orderByComparator != null) {
8435 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
8436
8437 for (Object value : values) {
8438 qPos.add(value);
8439 }
8440 }
8441
8442 List<AssetCategory> list = q.list();
8443
8444 if (list.size() == 2) {
8445 return list.get(1);
8446 }
8447 else {
8448 return null;
8449 }
8450 }
8451
8452
8460 @Override
8461 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8462 long[] vocabularyIds) {
8463 return filterFindByG_LikeN_V(groupId, name, vocabularyIds,
8464 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8465 }
8466
8467
8481 @Override
8482 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8483 long[] vocabularyIds, int start, int end) {
8484 return filterFindByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8485 null);
8486 }
8487
8488
8503 @Override
8504 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8505 long[] vocabularyIds, int start, int end,
8506 OrderByComparator<AssetCategory> orderByComparator) {
8507 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8508 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8509 orderByComparator);
8510 }
8511
8512 if (vocabularyIds == null) {
8513 vocabularyIds = new long[0];
8514 }
8515 else if (vocabularyIds.length > 1) {
8516 vocabularyIds = ArrayUtil.unique(vocabularyIds);
8517
8518 Arrays.sort(vocabularyIds);
8519 }
8520
8521 StringBundler query = new StringBundler();
8522
8523 if (getDB().isSupportsInlineDistinct()) {
8524 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8525 }
8526 else {
8527 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8528 }
8529
8530 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8531
8532 boolean bindName = false;
8533
8534 if (name == null) {
8535 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8536 }
8537 else if (name.equals(StringPool.BLANK)) {
8538 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8539 }
8540 else {
8541 bindName = true;
8542
8543 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8544 }
8545
8546 if (vocabularyIds.length > 0) {
8547 query.append(StringPool.OPEN_PARENTHESIS);
8548
8549 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7);
8550
8551 query.append(StringUtil.merge(vocabularyIds));
8552
8553 query.append(StringPool.CLOSE_PARENTHESIS);
8554
8555 query.append(StringPool.CLOSE_PARENTHESIS);
8556 }
8557
8558 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8559 query.index() - 1);
8560
8561 if (!getDB().isSupportsInlineDistinct()) {
8562 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8563 }
8564
8565 if (orderByComparator != null) {
8566 if (getDB().isSupportsInlineDistinct()) {
8567 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8568 orderByComparator, true);
8569 }
8570 else {
8571 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8572 orderByComparator, true);
8573 }
8574 }
8575 else {
8576 if (getDB().isSupportsInlineDistinct()) {
8577 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8578 }
8579 else {
8580 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8581 }
8582 }
8583
8584 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8585 AssetCategory.class.getName(),
8586 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8587
8588 Session session = null;
8589
8590 try {
8591 session = openSession();
8592
8593 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8594
8595 if (getDB().isSupportsInlineDistinct()) {
8596 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8597 }
8598 else {
8599 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8600 }
8601
8602 QueryPos qPos = QueryPos.getInstance(q);
8603
8604 qPos.add(groupId);
8605
8606 if (bindName) {
8607 qPos.add(StringUtil.toLowerCase(name));
8608 }
8609
8610 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8611 end);
8612 }
8613 catch (Exception e) {
8614 throw processException(e);
8615 }
8616 finally {
8617 closeSession(session);
8618 }
8619 }
8620
8621
8633 @Override
8634 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8635 long[] vocabularyIds) {
8636 return findByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS,
8637 QueryUtil.ALL_POS, null);
8638 }
8639
8640
8654 @Override
8655 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8656 long[] vocabularyIds, int start, int end) {
8657 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, null);
8658 }
8659
8660
8675 @Override
8676 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8677 long[] vocabularyIds, int start, int end,
8678 OrderByComparator<AssetCategory> orderByComparator) {
8679 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8680 orderByComparator, true);
8681 }
8682
8683
8699 @Override
8700 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8701 long[] vocabularyIds, int start, int end,
8702 OrderByComparator<AssetCategory> orderByComparator,
8703 boolean retrieveFromCache) {
8704 if (vocabularyIds == null) {
8705 vocabularyIds = new long[0];
8706 }
8707 else if (vocabularyIds.length > 1) {
8708 vocabularyIds = ArrayUtil.unique(vocabularyIds);
8709
8710 Arrays.sort(vocabularyIds);
8711 }
8712
8713 if (vocabularyIds.length == 1) {
8714 return findByG_LikeN_V(groupId, name, vocabularyIds[0], start, end,
8715 orderByComparator);
8716 }
8717
8718 boolean pagination = true;
8719 Object[] finderArgs = null;
8720
8721 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8722 (orderByComparator == null)) {
8723 pagination = false;
8724 finderArgs = new Object[] {
8725 groupId, name, StringUtil.merge(vocabularyIds)
8726 };
8727 }
8728 else {
8729 finderArgs = new Object[] {
8730 groupId, name, StringUtil.merge(vocabularyIds),
8731
8732 start, end, orderByComparator
8733 };
8734 }
8735
8736 List<AssetCategory> list = null;
8737
8738 if (retrieveFromCache) {
8739 list = (List<AssetCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8740 finderArgs, this);
8741
8742 if ((list != null) && !list.isEmpty()) {
8743 for (AssetCategory assetCategory : list) {
8744 if ((groupId != assetCategory.getGroupId()) ||
8745 !StringUtil.wildcardMatches(
8746 assetCategory.getName(), name,
8747 CharPool.UNDERLINE, CharPool.PERCENT,
8748 CharPool.BACK_SLASH, false) ||
8749 !ArrayUtil.contains(vocabularyIds,
8750 assetCategory.getVocabularyId())) {
8751 list = null;
8752
8753 break;
8754 }
8755 }
8756 }
8757 }
8758
8759 if (list == null) {
8760 StringBundler query = new StringBundler();
8761
8762 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
8763
8764 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8765
8766 boolean bindName = false;
8767
8768 if (name == null) {
8769 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8770 }
8771 else if (name.equals(StringPool.BLANK)) {
8772 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8773 }
8774 else {
8775 bindName = true;
8776
8777 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8778 }
8779
8780 if (vocabularyIds.length > 0) {
8781 query.append(StringPool.OPEN_PARENTHESIS);
8782
8783 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7);
8784
8785 query.append(StringUtil.merge(vocabularyIds));
8786
8787 query.append(StringPool.CLOSE_PARENTHESIS);
8788
8789 query.append(StringPool.CLOSE_PARENTHESIS);
8790 }
8791
8792 query.setStringAt(removeConjunction(query.stringAt(query.index() -
8793 1)), query.index() - 1);
8794
8795 if (orderByComparator != null) {
8796 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8797 orderByComparator);
8798 }
8799 else
8800 if (pagination) {
8801 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8802 }
8803
8804 String sql = query.toString();
8805
8806 Session session = null;
8807
8808 try {
8809 session = openSession();
8810
8811 Query q = session.createQuery(sql);
8812
8813 QueryPos qPos = QueryPos.getInstance(q);
8814
8815 qPos.add(groupId);
8816
8817 if (bindName) {
8818 qPos.add(StringUtil.toLowerCase(name));
8819 }
8820
8821 if (!pagination) {
8822 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8823 start, end, false);
8824
8825 Collections.sort(list);
8826
8827 list = Collections.unmodifiableList(list);
8828 }
8829 else {
8830 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8831 start, end);
8832 }
8833
8834 cacheResult(list);
8835
8836 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8837 finderArgs, list);
8838 }
8839 catch (Exception e) {
8840 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8841 finderArgs);
8842
8843 throw processException(e);
8844 }
8845 finally {
8846 closeSession(session);
8847 }
8848 }
8849
8850 return list;
8851 }
8852
8853
8860 @Override
8861 public void removeByG_LikeN_V(long groupId, String name, long vocabularyId) {
8862 for (AssetCategory assetCategory : findByG_LikeN_V(groupId, name,
8863 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8864 remove(assetCategory);
8865 }
8866 }
8867
8868
8876 @Override
8877 public int countByG_LikeN_V(long groupId, String name, long vocabularyId) {
8878 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V;
8879
8880 Object[] finderArgs = new Object[] { groupId, name, vocabularyId };
8881
8882 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8883
8884 if (count == null) {
8885 StringBundler query = new StringBundler(4);
8886
8887 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8888
8889 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8890
8891 boolean bindName = false;
8892
8893 if (name == null) {
8894 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8895 }
8896 else if (name.equals(StringPool.BLANK)) {
8897 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8898 }
8899 else {
8900 bindName = true;
8901
8902 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8903 }
8904
8905 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8906
8907 String sql = query.toString();
8908
8909 Session session = null;
8910
8911 try {
8912 session = openSession();
8913
8914 Query q = session.createQuery(sql);
8915
8916 QueryPos qPos = QueryPos.getInstance(q);
8917
8918 qPos.add(groupId);
8919
8920 if (bindName) {
8921 qPos.add(StringUtil.toLowerCase(name));
8922 }
8923
8924 qPos.add(vocabularyId);
8925
8926 count = (Long)q.uniqueResult();
8927
8928 finderCache.putResult(finderPath, finderArgs, count);
8929 }
8930 catch (Exception e) {
8931 finderCache.removeResult(finderPath, finderArgs);
8932
8933 throw processException(e);
8934 }
8935 finally {
8936 closeSession(session);
8937 }
8938 }
8939
8940 return count.intValue();
8941 }
8942
8943
8951 @Override
8952 public int countByG_LikeN_V(long groupId, String name, long[] vocabularyIds) {
8953 if (vocabularyIds == null) {
8954 vocabularyIds = new long[0];
8955 }
8956 else if (vocabularyIds.length > 1) {
8957 vocabularyIds = ArrayUtil.unique(vocabularyIds);
8958
8959 Arrays.sort(vocabularyIds);
8960 }
8961
8962 Object[] finderArgs = new Object[] {
8963 groupId, name, StringUtil.merge(vocabularyIds)
8964 };
8965
8966 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8967 finderArgs, this);
8968
8969 if (count == null) {
8970 StringBundler query = new StringBundler();
8971
8972 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8973
8974 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8975
8976 boolean bindName = false;
8977
8978 if (name == null) {
8979 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8980 }
8981 else if (name.equals(StringPool.BLANK)) {
8982 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8983 }
8984 else {
8985 bindName = true;
8986
8987 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8988 }
8989
8990 if (vocabularyIds.length > 0) {
8991 query.append(StringPool.OPEN_PARENTHESIS);
8992
8993 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7);
8994
8995 query.append(StringUtil.merge(vocabularyIds));
8996
8997 query.append(StringPool.CLOSE_PARENTHESIS);
8998
8999 query.append(StringPool.CLOSE_PARENTHESIS);
9000 }
9001
9002 query.setStringAt(removeConjunction(query.stringAt(query.index() -
9003 1)), query.index() - 1);
9004
9005 String sql = query.toString();
9006
9007 Session session = null;
9008
9009 try {
9010 session = openSession();
9011
9012 Query q = session.createQuery(sql);
9013
9014 QueryPos qPos = QueryPos.getInstance(q);
9015
9016 qPos.add(groupId);
9017
9018 if (bindName) {
9019 qPos.add(StringUtil.toLowerCase(name));
9020 }
9021
9022 count = (Long)q.uniqueResult();
9023
9024 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
9025 finderArgs, count);
9026 }
9027 catch (Exception e) {
9028 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
9029 finderArgs);
9030
9031 throw processException(e);
9032 }
9033 finally {
9034 closeSession(session);
9035 }
9036 }
9037
9038 return count.intValue();
9039 }
9040
9041
9049 @Override
9050 public int filterCountByG_LikeN_V(long groupId, String name,
9051 long vocabularyId) {
9052 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9053 return countByG_LikeN_V(groupId, name, vocabularyId);
9054 }
9055
9056 StringBundler query = new StringBundler(4);
9057
9058 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9059
9060 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
9061
9062 boolean bindName = false;
9063
9064 if (name == null) {
9065 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
9066 }
9067 else if (name.equals(StringPool.BLANK)) {
9068 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
9069 }
9070 else {
9071 bindName = true;
9072
9073 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
9074 }
9075
9076 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
9077
9078 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9079 AssetCategory.class.getName(),
9080 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9081
9082 Session session = null;
9083
9084 try {
9085 session = openSession();
9086
9087 SQLQuery q = session.createSynchronizedSQLQuery(sql);
9088
9089 q.addScalar(COUNT_COLUMN_NAME,
9090 com.liferay.portal.kernel.dao.orm.Type.LONG);
9091
9092 QueryPos qPos = QueryPos.getInstance(q);
9093
9094 qPos.add(groupId);
9095
9096 if (bindName) {
9097 qPos.add(StringUtil.toLowerCase(name));
9098 }
9099
9100 qPos.add(vocabularyId);
9101
9102 Long count = (Long)q.uniqueResult();
9103
9104 return count.intValue();
9105 }
9106 catch (Exception e) {
9107 throw processException(e);
9108 }
9109 finally {
9110 closeSession(session);
9111 }
9112 }
9113
9114
9122 @Override
9123 public int filterCountByG_LikeN_V(long groupId, String name,
9124 long[] vocabularyIds) {
9125 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9126 return countByG_LikeN_V(groupId, name, vocabularyIds);
9127 }
9128
9129 if (vocabularyIds == null) {
9130 vocabularyIds = new long[0];
9131 }
9132 else if (vocabularyIds.length > 1) {
9133 vocabularyIds = ArrayUtil.unique(vocabularyIds);
9134
9135 Arrays.sort(vocabularyIds);
9136 }
9137
9138 StringBundler query = new StringBundler();
9139
9140 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9141
9142 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
9143
9144 boolean bindName = false;
9145
9146 if (name == null) {
9147 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
9148 }
9149 else if (name.equals(StringPool.BLANK)) {
9150 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
9151 }
9152 else {
9153 bindName = true;
9154
9155 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
9156 }
9157
9158 if (vocabularyIds.length > 0) {
9159 query.append(StringPool.OPEN_PARENTHESIS);
9160
9161 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7);
9162
9163 query.append(StringUtil.merge(vocabularyIds));
9164
9165 query.append(StringPool.CLOSE_PARENTHESIS);
9166
9167 query.append(StringPool.CLOSE_PARENTHESIS);
9168 }
9169
9170 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
9171 query.index() - 1);
9172
9173 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9174 AssetCategory.class.getName(),
9175 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9176
9177 Session session = null;
9178
9179 try {
9180 session = openSession();
9181
9182 SQLQuery q = session.createSynchronizedSQLQuery(sql);
9183
9184 q.addScalar(COUNT_COLUMN_NAME,
9185 com.liferay.portal.kernel.dao.orm.Type.LONG);
9186
9187 QueryPos qPos = QueryPos.getInstance(q);
9188
9189 qPos.add(groupId);
9190
9191 if (bindName) {
9192 qPos.add(StringUtil.toLowerCase(name));
9193 }
9194
9195 Long count = (Long)q.uniqueResult();
9196
9197 return count.intValue();
9198 }
9199 catch (Exception e) {
9200 throw processException(e);
9201 }
9202 finally {
9203 closeSession(session);
9204 }
9205 }
9206
9207 private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
9208 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_1 = "assetCategory.name IS NULL AND ";
9209 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_2 = "lower(assetCategory.name) LIKE ? AND ";
9210 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name LIKE '') AND ";
9211 private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9212 private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7 = "assetCategory.vocabularyId IN (";
9213 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9214 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9215 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
9216 new String[] {
9217 Long.class.getName(), String.class.getName(),
9218 Long.class.getName()
9219 },
9220 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9221 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9222 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9223 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9224 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9225 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
9226 new String[] {
9227 Long.class.getName(), String.class.getName(),
9228 Long.class.getName()
9229 });
9230
9231
9240 @Override
9241 public AssetCategory findByP_N_V(long parentCategoryId, String name,
9242 long vocabularyId) throws NoSuchCategoryException {
9243 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
9244 vocabularyId);
9245
9246 if (assetCategory == null) {
9247 StringBundler msg = new StringBundler(8);
9248
9249 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9250
9251 msg.append("parentCategoryId=");
9252 msg.append(parentCategoryId);
9253
9254 msg.append(", name=");
9255 msg.append(name);
9256
9257 msg.append(", vocabularyId=");
9258 msg.append(vocabularyId);
9259
9260 msg.append(StringPool.CLOSE_CURLY_BRACE);
9261
9262 if (_log.isDebugEnabled()) {
9263 _log.debug(msg.toString());
9264 }
9265
9266 throw new NoSuchCategoryException(msg.toString());
9267 }
9268
9269 return assetCategory;
9270 }
9271
9272
9280 @Override
9281 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
9282 long vocabularyId) {
9283 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
9284 }
9285
9286
9295 @Override
9296 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
9297 long vocabularyId, boolean retrieveFromCache) {
9298 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9299
9300 Object result = null;
9301
9302 if (retrieveFromCache) {
9303 result = finderCache.getResult(FINDER_PATH_FETCH_BY_P_N_V,
9304 finderArgs, this);
9305 }
9306
9307 if (result instanceof AssetCategory) {
9308 AssetCategory assetCategory = (AssetCategory)result;
9309
9310 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
9311 !Objects.equals(name, assetCategory.getName()) ||
9312 (vocabularyId != assetCategory.getVocabularyId())) {
9313 result = null;
9314 }
9315 }
9316
9317 if (result == null) {
9318 StringBundler query = new StringBundler(5);
9319
9320 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9321
9322 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9323
9324 boolean bindName = false;
9325
9326 if (name == null) {
9327 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9328 }
9329 else if (name.equals(StringPool.BLANK)) {
9330 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9331 }
9332 else {
9333 bindName = true;
9334
9335 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9336 }
9337
9338 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9339
9340 String sql = query.toString();
9341
9342 Session session = null;
9343
9344 try {
9345 session = openSession();
9346
9347 Query q = session.createQuery(sql);
9348
9349 QueryPos qPos = QueryPos.getInstance(q);
9350
9351 qPos.add(parentCategoryId);
9352
9353 if (bindName) {
9354 qPos.add(name);
9355 }
9356
9357 qPos.add(vocabularyId);
9358
9359 List<AssetCategory> list = q.list();
9360
9361 if (list.isEmpty()) {
9362 finderCache.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9363 finderArgs, list);
9364 }
9365 else {
9366 AssetCategory assetCategory = list.get(0);
9367
9368 result = assetCategory;
9369
9370 cacheResult(assetCategory);
9371
9372 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
9373 (assetCategory.getName() == null) ||
9374 !assetCategory.getName().equals(name) ||
9375 (assetCategory.getVocabularyId() != vocabularyId)) {
9376 finderCache.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9377 finderArgs, assetCategory);
9378 }
9379 }
9380 }
9381 catch (Exception e) {
9382 finderCache.removeResult(FINDER_PATH_FETCH_BY_P_N_V, finderArgs);
9383
9384 throw processException(e);
9385 }
9386 finally {
9387 closeSession(session);
9388 }
9389 }
9390
9391 if (result instanceof List<?>) {
9392 return null;
9393 }
9394 else {
9395 return (AssetCategory)result;
9396 }
9397 }
9398
9399
9407 @Override
9408 public AssetCategory removeByP_N_V(long parentCategoryId, String name,
9409 long vocabularyId) throws NoSuchCategoryException {
9410 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
9411 vocabularyId);
9412
9413 return remove(assetCategory);
9414 }
9415
9416
9424 @Override
9425 public int countByP_N_V(long parentCategoryId, String name,
9426 long vocabularyId) {
9427 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N_V;
9428
9429 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9430
9431 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9432
9433 if (count == null) {
9434 StringBundler query = new StringBundler(4);
9435
9436 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9437
9438 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9439
9440 boolean bindName = false;
9441
9442 if (name == null) {
9443 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9444 }
9445 else if (name.equals(StringPool.BLANK)) {
9446 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9447 }
9448 else {
9449 bindName = true;
9450
9451 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9452 }
9453
9454 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9455
9456 String sql = query.toString();
9457
9458 Session session = null;
9459
9460 try {
9461 session = openSession();
9462
9463 Query q = session.createQuery(sql);
9464
9465 QueryPos qPos = QueryPos.getInstance(q);
9466
9467 qPos.add(parentCategoryId);
9468
9469 if (bindName) {
9470 qPos.add(name);
9471 }
9472
9473 qPos.add(vocabularyId);
9474
9475 count = (Long)q.uniqueResult();
9476
9477 finderCache.putResult(finderPath, finderArgs, count);
9478 }
9479 catch (Exception e) {
9480 finderCache.removeResult(finderPath, finderArgs);
9481
9482 throw processException(e);
9483 }
9484 finally {
9485 closeSession(session);
9486 }
9487 }
9488
9489 return count.intValue();
9490 }
9491
9492 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
9493 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
9494 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
9495 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
9496 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9497 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9498 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9499 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9500 "findByG_P_N_V",
9501 new String[] {
9502 Long.class.getName(), Long.class.getName(),
9503 String.class.getName(), Long.class.getName(),
9504
9505 Integer.class.getName(), Integer.class.getName(),
9506 OrderByComparator.class.getName()
9507 });
9508 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V =
9509 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9510 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9511 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
9512 "findByG_P_N_V",
9513 new String[] {
9514 Long.class.getName(), Long.class.getName(),
9515 String.class.getName(), Long.class.getName()
9516 },
9517 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
9518 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9519 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9520 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9521 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9522 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9523 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N_V",
9524 new String[] {
9525 Long.class.getName(), Long.class.getName(),
9526 String.class.getName(), Long.class.getName()
9527 });
9528
9529
9538 @Override
9539 public List<AssetCategory> findByG_P_N_V(long groupId,
9540 long parentCategoryId, String name, long vocabularyId) {
9541 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9542 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9543 }
9544
9545
9560 @Override
9561 public List<AssetCategory> findByG_P_N_V(long groupId,
9562 long parentCategoryId, String name, long vocabularyId, int start,
9563 int end) {
9564 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9565 start, end, null);
9566 }
9567
9568
9584 @Override
9585 public List<AssetCategory> findByG_P_N_V(long groupId,
9586 long parentCategoryId, String name, long vocabularyId, int start,
9587 int end, OrderByComparator<AssetCategory> orderByComparator) {
9588 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9589 start, end, orderByComparator, true);
9590 }
9591
9592
9609 @Override
9610 public List<AssetCategory> findByG_P_N_V(long groupId,
9611 long parentCategoryId, String name, long vocabularyId, int start,
9612 int end, OrderByComparator<AssetCategory> orderByComparator,
9613 boolean retrieveFromCache) {
9614 boolean pagination = true;
9615 FinderPath finderPath = null;
9616 Object[] finderArgs = null;
9617
9618 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9619 (orderByComparator == null)) {
9620 pagination = false;
9621 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V;
9622 finderArgs = new Object[] {
9623 groupId, parentCategoryId, name, vocabularyId
9624 };
9625 }
9626 else {
9627 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V;
9628 finderArgs = new Object[] {
9629 groupId, parentCategoryId, name, vocabularyId,
9630
9631 start, end, orderByComparator
9632 };
9633 }
9634
9635 List<AssetCategory> list = null;
9636
9637 if (retrieveFromCache) {
9638 list = (List<AssetCategory>)finderCache.getResult(finderPath,
9639 finderArgs, this);
9640
9641 if ((list != null) && !list.isEmpty()) {
9642 for (AssetCategory assetCategory : list) {
9643 if ((groupId != assetCategory.getGroupId()) ||
9644 (parentCategoryId != assetCategory.getParentCategoryId()) ||
9645 !Objects.equals(name, assetCategory.getName()) ||
9646 (vocabularyId != assetCategory.getVocabularyId())) {
9647 list = null;
9648
9649 break;
9650 }
9651 }
9652 }
9653 }
9654
9655 if (list == null) {
9656 StringBundler query = null;
9657
9658 if (orderByComparator != null) {
9659 query = new StringBundler(6 +
9660 (orderByComparator.getOrderByFields().length * 2));
9661 }
9662 else {
9663 query = new StringBundler(6);
9664 }
9665
9666 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9667
9668 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9669
9670 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9671
9672 boolean bindName = false;
9673
9674 if (name == null) {
9675 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9676 }
9677 else if (name.equals(StringPool.BLANK)) {
9678 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9679 }
9680 else {
9681 bindName = true;
9682
9683 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9684 }
9685
9686 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9687
9688 if (orderByComparator != null) {
9689 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9690 orderByComparator);
9691 }
9692 else
9693 if (pagination) {
9694 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9695 }
9696
9697 String sql = query.toString();
9698
9699 Session session = null;
9700
9701 try {
9702 session = openSession();
9703
9704 Query q = session.createQuery(sql);
9705
9706 QueryPos qPos = QueryPos.getInstance(q);
9707
9708 qPos.add(groupId);
9709
9710 qPos.add(parentCategoryId);
9711
9712 if (bindName) {
9713 qPos.add(name);
9714 }
9715
9716 qPos.add(vocabularyId);
9717
9718 if (!pagination) {
9719 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9720 start, end, false);
9721
9722 Collections.sort(list);
9723
9724 list = Collections.unmodifiableList(list);
9725 }
9726 else {
9727 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9728 start, end);
9729 }
9730
9731 cacheResult(list);
9732
9733 finderCache.putResult(finderPath, finderArgs, list);
9734 }
9735 catch (Exception e) {
9736 finderCache.removeResult(finderPath, finderArgs);
9737
9738 throw processException(e);
9739 }
9740 finally {
9741 closeSession(session);
9742 }
9743 }
9744
9745 return list;
9746 }
9747
9748
9759 @Override
9760 public AssetCategory findByG_P_N_V_First(long groupId,
9761 long parentCategoryId, String name, long vocabularyId,
9762 OrderByComparator<AssetCategory> orderByComparator)
9763 throws NoSuchCategoryException {
9764 AssetCategory assetCategory = fetchByG_P_N_V_First(groupId,
9765 parentCategoryId, name, vocabularyId, orderByComparator);
9766
9767 if (assetCategory != null) {
9768 return assetCategory;
9769 }
9770
9771 StringBundler msg = new StringBundler(10);
9772
9773 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9774
9775 msg.append("groupId=");
9776 msg.append(groupId);
9777
9778 msg.append(", parentCategoryId=");
9779 msg.append(parentCategoryId);
9780
9781 msg.append(", name=");
9782 msg.append(name);
9783
9784 msg.append(", vocabularyId=");
9785 msg.append(vocabularyId);
9786
9787 msg.append(StringPool.CLOSE_CURLY_BRACE);
9788
9789 throw new NoSuchCategoryException(msg.toString());
9790 }
9791
9792
9802 @Override
9803 public AssetCategory fetchByG_P_N_V_First(long groupId,
9804 long parentCategoryId, String name, long vocabularyId,
9805 OrderByComparator<AssetCategory> orderByComparator) {
9806 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9807 name, vocabularyId, 0, 1, orderByComparator);
9808
9809 if (!list.isEmpty()) {
9810 return list.get(0);
9811 }
9812
9813 return null;
9814 }
9815
9816
9827 @Override
9828 public AssetCategory findByG_P_N_V_Last(long groupId,
9829 long parentCategoryId, String name, long vocabularyId,
9830 OrderByComparator<AssetCategory> orderByComparator)
9831 throws NoSuchCategoryException {
9832 AssetCategory assetCategory = fetchByG_P_N_V_Last(groupId,
9833 parentCategoryId, name, vocabularyId, orderByComparator);
9834
9835 if (assetCategory != null) {
9836 return assetCategory;
9837 }
9838
9839 StringBundler msg = new StringBundler(10);
9840
9841 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9842
9843 msg.append("groupId=");
9844 msg.append(groupId);
9845
9846 msg.append(", parentCategoryId=");
9847 msg.append(parentCategoryId);
9848
9849 msg.append(", name=");
9850 msg.append(name);
9851
9852 msg.append(", vocabularyId=");
9853 msg.append(vocabularyId);
9854
9855 msg.append(StringPool.CLOSE_CURLY_BRACE);
9856
9857 throw new NoSuchCategoryException(msg.toString());
9858 }
9859
9860
9870 @Override
9871 public AssetCategory fetchByG_P_N_V_Last(long groupId,
9872 long parentCategoryId, String name, long vocabularyId,
9873 OrderByComparator<AssetCategory> orderByComparator) {
9874 int count = countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
9875
9876 if (count == 0) {
9877 return null;
9878 }
9879
9880 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9881 name, vocabularyId, count - 1, count, orderByComparator);
9882
9883 if (!list.isEmpty()) {
9884 return list.get(0);
9885 }
9886
9887 return null;
9888 }
9889
9890
9902 @Override
9903 public AssetCategory[] findByG_P_N_V_PrevAndNext(long categoryId,
9904 long groupId, long parentCategoryId, String name, long vocabularyId,
9905 OrderByComparator<AssetCategory> orderByComparator)
9906 throws NoSuchCategoryException {
9907 AssetCategory assetCategory = findByPrimaryKey(categoryId);
9908
9909 Session session = null;
9910
9911 try {
9912 session = openSession();
9913
9914 AssetCategory[] array = new AssetCategoryImpl[3];
9915
9916 array[0] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9917 groupId, parentCategoryId, name, vocabularyId,
9918 orderByComparator, true);
9919
9920 array[1] = assetCategory;
9921
9922 array[2] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9923 groupId, parentCategoryId, name, vocabularyId,
9924 orderByComparator, false);
9925
9926 return array;
9927 }
9928 catch (Exception e) {
9929 throw processException(e);
9930 }
9931 finally {
9932 closeSession(session);
9933 }
9934 }
9935
9936 protected AssetCategory getByG_P_N_V_PrevAndNext(Session session,
9937 AssetCategory assetCategory, long groupId, long parentCategoryId,
9938 String name, long vocabularyId,
9939 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
9940 StringBundler query = null;
9941
9942 if (orderByComparator != null) {
9943 query = new StringBundler(7 +
9944 (orderByComparator.getOrderByConditionFields().length * 3) +
9945 (orderByComparator.getOrderByFields().length * 3));
9946 }
9947 else {
9948 query = new StringBundler(6);
9949 }
9950
9951 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9952
9953 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9954
9955 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9956
9957 boolean bindName = false;
9958
9959 if (name == null) {
9960 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9961 }
9962 else if (name.equals(StringPool.BLANK)) {
9963 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9964 }
9965 else {
9966 bindName = true;
9967
9968 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9969 }
9970
9971 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9972
9973 if (orderByComparator != null) {
9974 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9975
9976 if (orderByConditionFields.length > 0) {
9977 query.append(WHERE_AND);
9978 }
9979
9980 for (int i = 0; i < orderByConditionFields.length; i++) {
9981 query.append(_ORDER_BY_ENTITY_ALIAS);
9982 query.append(orderByConditionFields[i]);
9983
9984 if ((i + 1) < orderByConditionFields.length) {
9985 if (orderByComparator.isAscending() ^ previous) {
9986 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9987 }
9988 else {
9989 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9990 }
9991 }
9992 else {
9993 if (orderByComparator.isAscending() ^ previous) {
9994 query.append(WHERE_GREATER_THAN);
9995 }
9996 else {
9997 query.append(WHERE_LESSER_THAN);
9998 }
9999 }
10000 }
10001
10002 query.append(ORDER_BY_CLAUSE);
10003
10004 String[] orderByFields = orderByComparator.getOrderByFields();
10005
10006 for (int i = 0; i < orderByFields.length; i++) {
10007 query.append(_ORDER_BY_ENTITY_ALIAS);
10008 query.append(orderByFields[i]);
10009
10010 if ((i + 1) < orderByFields.length) {
10011 if (orderByComparator.isAscending() ^ previous) {
10012 query.append(ORDER_BY_ASC_HAS_NEXT);
10013 }
10014 else {
10015 query.append(ORDER_BY_DESC_HAS_NEXT);
10016 }
10017 }
10018 else {
10019 if (orderByComparator.isAscending() ^ previous) {
10020 query.append(ORDER_BY_ASC);
10021 }
10022 else {
10023 query.append(ORDER_BY_DESC);
10024 }
10025 }
10026 }
10027 }
10028 else {
10029 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
10030 }
10031
10032 String sql = query.toString();
10033
10034 Query q = session.createQuery(sql);
10035
10036 q.setFirstResult(0);
10037 q.setMaxResults(2);
10038
10039 QueryPos qPos = QueryPos.getInstance(q);
10040
10041 qPos.add(groupId);
10042
10043 qPos.add(parentCategoryId);
10044
10045 if (bindName) {
10046 qPos.add(name);
10047 }
10048
10049 qPos.add(vocabularyId);
10050
10051 if (orderByComparator != null) {
10052 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
10053
10054 for (Object value : values) {
10055 qPos.add(value);
10056 }
10057 }
10058
10059 List<AssetCategory> list = q.list();
10060
10061 if (list.size() == 2) {
10062 return list.get(1);
10063 }
10064 else {
10065 return null;
10066 }
10067 }
10068
10069
10078 @Override
10079 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
10080 long parentCategoryId, String name, long vocabularyId) {
10081 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
10082 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10083 }
10084
10085
10100 @Override
10101 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
10102 long parentCategoryId, String name, long vocabularyId, int start,
10103 int end) {
10104 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
10105 vocabularyId, start, end, null);
10106 }
10107
10108
10124 @Override
10125 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
10126 long parentCategoryId, String name, long vocabularyId, int start,
10127 int end, OrderByComparator<AssetCategory> orderByComparator) {
10128 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10129 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
10130 start, end, orderByComparator);
10131 }
10132
10133 StringBundler query = null;
10134
10135 if (orderByComparator != null) {
10136 query = new StringBundler(6 +
10137 (orderByComparator.getOrderByFields().length * 2));
10138 }
10139 else {
10140 query = new StringBundler(7);
10141 }
10142
10143 if (getDB().isSupportsInlineDistinct()) {
10144 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
10145 }
10146 else {
10147 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
10148 }
10149
10150 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10151
10152 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10153
10154 boolean bindName = false;
10155
10156 if (name == null) {
10157 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10158 }
10159 else if (name.equals(StringPool.BLANK)) {
10160 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10161 }
10162 else {
10163 bindName = true;
10164
10165 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10166 }
10167
10168 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10169
10170 if (!getDB().isSupportsInlineDistinct()) {
10171 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
10172 }
10173
10174 if (orderByComparator != null) {
10175 if (getDB().isSupportsInlineDistinct()) {
10176 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10177 orderByComparator, true);
10178 }
10179 else {
10180 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10181 orderByComparator, true);
10182 }
10183 }
10184 else {
10185 if (getDB().isSupportsInlineDistinct()) {
10186 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
10187 }
10188 else {
10189 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
10190 }
10191 }
10192
10193 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10194 AssetCategory.class.getName(),
10195 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10196
10197 Session session = null;
10198
10199 try {
10200 session = openSession();
10201
10202 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10203
10204 if (getDB().isSupportsInlineDistinct()) {
10205 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
10206 }
10207 else {
10208 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
10209 }
10210
10211 QueryPos qPos = QueryPos.getInstance(q);
10212
10213 qPos.add(groupId);
10214
10215 qPos.add(parentCategoryId);
10216
10217 if (bindName) {
10218 qPos.add(name);
10219 }
10220
10221 qPos.add(vocabularyId);
10222
10223 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
10224 end);
10225 }
10226 catch (Exception e) {
10227 throw processException(e);
10228 }
10229 finally {
10230 closeSession(session);
10231 }
10232 }
10233
10234
10246 @Override
10247 public AssetCategory[] filterFindByG_P_N_V_PrevAndNext(long categoryId,
10248 long groupId, long parentCategoryId, String name, long vocabularyId,
10249 OrderByComparator<AssetCategory> orderByComparator)
10250 throws NoSuchCategoryException {
10251 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10252 return findByG_P_N_V_PrevAndNext(categoryId, groupId,
10253 parentCategoryId, name, vocabularyId, orderByComparator);
10254 }
10255
10256 AssetCategory assetCategory = findByPrimaryKey(categoryId);
10257
10258 Session session = null;
10259
10260 try {
10261 session = openSession();
10262
10263 AssetCategory[] array = new AssetCategoryImpl[3];
10264
10265 array[0] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
10266 groupId, parentCategoryId, name, vocabularyId,
10267 orderByComparator, true);
10268
10269 array[1] = assetCategory;
10270
10271 array[2] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
10272 groupId, parentCategoryId, name, vocabularyId,
10273 orderByComparator, false);
10274
10275 return array;
10276 }
10277 catch (Exception e) {
10278 throw processException(e);
10279 }
10280 finally {
10281 closeSession(session);
10282 }
10283 }
10284
10285 protected AssetCategory filterGetByG_P_N_V_PrevAndNext(Session session,
10286 AssetCategory assetCategory, long groupId, long parentCategoryId,
10287 String name, long vocabularyId,
10288 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
10289 StringBundler query = null;
10290
10291 if (orderByComparator != null) {
10292 query = new StringBundler(8 +
10293 (orderByComparator.getOrderByConditionFields().length * 3) +
10294 (orderByComparator.getOrderByFields().length * 3));
10295 }
10296 else {
10297 query = new StringBundler(7);
10298 }
10299
10300 if (getDB().isSupportsInlineDistinct()) {
10301 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
10302 }
10303 else {
10304 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
10305 }
10306
10307 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10308
10309 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10310
10311 boolean bindName = false;
10312
10313 if (name == null) {
10314 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10315 }
10316 else if (name.equals(StringPool.BLANK)) {
10317 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10318 }
10319 else {
10320 bindName = true;
10321
10322 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10323 }
10324
10325 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10326
10327 if (!getDB().isSupportsInlineDistinct()) {
10328 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
10329 }
10330
10331 if (orderByComparator != null) {
10332 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10333
10334 if (orderByConditionFields.length > 0) {
10335 query.append(WHERE_AND);
10336 }
10337
10338 for (int i = 0; i < orderByConditionFields.length; i++) {
10339 if (getDB().isSupportsInlineDistinct()) {
10340 query.append(_ORDER_BY_ENTITY_ALIAS);
10341 }
10342 else {
10343 query.append(_ORDER_BY_ENTITY_TABLE);
10344 }
10345
10346 query.append(orderByConditionFields[i]);
10347
10348 if ((i + 1) < orderByConditionFields.length) {
10349 if (orderByComparator.isAscending() ^ previous) {
10350 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10351 }
10352 else {
10353 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10354 }
10355 }
10356 else {
10357 if (orderByComparator.isAscending() ^ previous) {
10358 query.append(WHERE_GREATER_THAN);
10359 }
10360 else {
10361 query.append(WHERE_LESSER_THAN);
10362 }
10363 }
10364 }
10365
10366 query.append(ORDER_BY_CLAUSE);
10367
10368 String[] orderByFields = orderByComparator.getOrderByFields();
10369
10370 for (int i = 0; i < orderByFields.length; i++) {
10371 if (getDB().isSupportsInlineDistinct()) {
10372 query.append(_ORDER_BY_ENTITY_ALIAS);
10373 }
10374 else {
10375 query.append(_ORDER_BY_ENTITY_TABLE);
10376 }
10377
10378 query.append(orderByFields[i]);
10379
10380 if ((i + 1) < orderByFields.length) {
10381 if (orderByComparator.isAscending() ^ previous) {
10382 query.append(ORDER_BY_ASC_HAS_NEXT);
10383 }
10384 else {
10385 query.append(ORDER_BY_DESC_HAS_NEXT);
10386 }
10387 }
10388 else {
10389 if (orderByComparator.isAscending() ^ previous) {
10390 query.append(ORDER_BY_ASC);
10391 }
10392 else {
10393 query.append(ORDER_BY_DESC);
10394 }
10395 }
10396 }
10397 }
10398 else {
10399 if (getDB().isSupportsInlineDistinct()) {
10400 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
10401 }
10402 else {
10403 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
10404 }
10405 }
10406
10407 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10408 AssetCategory.class.getName(),
10409 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10410
10411 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10412
10413 q.setFirstResult(0);
10414 q.setMaxResults(2);
10415
10416 if (getDB().isSupportsInlineDistinct()) {
10417 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
10418 }
10419 else {
10420 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
10421 }
10422
10423 QueryPos qPos = QueryPos.getInstance(q);
10424
10425 qPos.add(groupId);
10426
10427 qPos.add(parentCategoryId);
10428
10429 if (bindName) {
10430 qPos.add(name);
10431 }
10432
10433 qPos.add(vocabularyId);
10434
10435 if (orderByComparator != null) {
10436 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
10437
10438 for (Object value : values) {
10439 qPos.add(value);
10440 }
10441 }
10442
10443 List<AssetCategory> list = q.list();
10444
10445 if (list.size() == 2) {
10446 return list.get(1);
10447 }
10448 else {
10449 return null;
10450 }
10451 }
10452
10453
10461 @Override
10462 public void removeByG_P_N_V(long groupId, long parentCategoryId,
10463 String name, long vocabularyId) {
10464 for (AssetCategory assetCategory : findByG_P_N_V(groupId,
10465 parentCategoryId, name, vocabularyId, QueryUtil.ALL_POS,
10466 QueryUtil.ALL_POS, null)) {
10467 remove(assetCategory);
10468 }
10469 }
10470
10471
10480 @Override
10481 public int countByG_P_N_V(long groupId, long parentCategoryId, String name,
10482 long vocabularyId) {
10483 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N_V;
10484
10485 Object[] finderArgs = new Object[] {
10486 groupId, parentCategoryId, name, vocabularyId
10487 };
10488
10489 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10490
10491 if (count == null) {
10492 StringBundler query = new StringBundler(5);
10493
10494 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
10495
10496 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10497
10498 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10499
10500 boolean bindName = false;
10501
10502 if (name == null) {
10503 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10504 }
10505 else if (name.equals(StringPool.BLANK)) {
10506 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10507 }
10508 else {
10509 bindName = true;
10510
10511 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10512 }
10513
10514 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10515
10516 String sql = query.toString();
10517
10518 Session session = null;
10519
10520 try {
10521 session = openSession();
10522
10523 Query q = session.createQuery(sql);
10524
10525 QueryPos qPos = QueryPos.getInstance(q);
10526
10527 qPos.add(groupId);
10528
10529 qPos.add(parentCategoryId);
10530
10531 if (bindName) {
10532 qPos.add(name);
10533 }
10534
10535 qPos.add(vocabularyId);
10536
10537 count = (Long)q.uniqueResult();
10538
10539 finderCache.putResult(finderPath, finderArgs, count);
10540 }
10541 catch (Exception e) {
10542 finderCache.removeResult(finderPath, finderArgs);
10543
10544 throw processException(e);
10545 }
10546 finally {
10547 closeSession(session);
10548 }
10549 }
10550
10551 return count.intValue();
10552 }
10553
10554
10563 @Override
10564 public int filterCountByG_P_N_V(long groupId, long parentCategoryId,
10565 String name, long vocabularyId) {
10566 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10567 return countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
10568 }
10569
10570 StringBundler query = new StringBundler(5);
10571
10572 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
10573
10574 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10575
10576 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10577
10578 boolean bindName = false;
10579
10580 if (name == null) {
10581 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10582 }
10583 else if (name.equals(StringPool.BLANK)) {
10584 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10585 }
10586 else {
10587 bindName = true;
10588
10589 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10590 }
10591
10592 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10593
10594 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10595 AssetCategory.class.getName(),
10596 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10597
10598 Session session = null;
10599
10600 try {
10601 session = openSession();
10602
10603 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10604
10605 q.addScalar(COUNT_COLUMN_NAME,
10606 com.liferay.portal.kernel.dao.orm.Type.LONG);
10607
10608 QueryPos qPos = QueryPos.getInstance(q);
10609
10610 qPos.add(groupId);
10611
10612 qPos.add(parentCategoryId);
10613
10614 if (bindName) {
10615 qPos.add(name);
10616 }
10617
10618 qPos.add(vocabularyId);
10619
10620 Long count = (Long)q.uniqueResult();
10621
10622 return count.intValue();
10623 }
10624 catch (Exception e) {
10625 throw processException(e);
10626 }
10627 finally {
10628 closeSession(session);
10629 }
10630 }
10631
10632 private static final String _FINDER_COLUMN_G_P_N_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
10633 private static final String _FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
10634 private static final String _FINDER_COLUMN_G_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
10635 private static final String _FINDER_COLUMN_G_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
10636 private static final String _FINDER_COLUMN_G_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
10637 private static final String _FINDER_COLUMN_G_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
10638
10639 public AssetCategoryPersistenceImpl() {
10640 setModelClass(AssetCategory.class);
10641 }
10642
10643
10648 @Override
10649 public void cacheResult(AssetCategory assetCategory) {
10650 entityCache.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10651 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
10652 assetCategory);
10653
10654 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
10655 new Object[] { assetCategory.getUuid(), assetCategory.getGroupId() },
10656 assetCategory);
10657
10658 finderCache.putResult(FINDER_PATH_FETCH_BY_P_N_V,
10659 new Object[] {
10660 assetCategory.getParentCategoryId(), assetCategory.getName(),
10661 assetCategory.getVocabularyId()
10662 }, assetCategory);
10663
10664 assetCategory.resetOriginalValues();
10665 }
10666
10667
10672 @Override
10673 public void cacheResult(List<AssetCategory> assetCategories) {
10674 for (AssetCategory assetCategory : assetCategories) {
10675 if (entityCache.getResult(
10676 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10677 AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
10678 cacheResult(assetCategory);
10679 }
10680 else {
10681 assetCategory.resetOriginalValues();
10682 }
10683 }
10684 }
10685
10686
10693 @Override
10694 public void clearCache() {
10695 entityCache.clearCache(AssetCategoryImpl.class);
10696
10697 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
10698 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10699 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10700 }
10701
10702
10709 @Override
10710 public void clearCache(AssetCategory assetCategory) {
10711 entityCache.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10712 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10713
10714 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10715 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10716
10717 clearUniqueFindersCache((AssetCategoryModelImpl)assetCategory);
10718 }
10719
10720 @Override
10721 public void clearCache(List<AssetCategory> assetCategories) {
10722 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10723 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10724
10725 for (AssetCategory assetCategory : assetCategories) {
10726 entityCache.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10727 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10728
10729 clearUniqueFindersCache((AssetCategoryModelImpl)assetCategory);
10730 }
10731 }
10732
10733 protected void cacheUniqueFindersCache(
10734 AssetCategoryModelImpl assetCategoryModelImpl, boolean isNew) {
10735 if (isNew) {
10736 Object[] args = new Object[] {
10737 assetCategoryModelImpl.getUuid(),
10738 assetCategoryModelImpl.getGroupId()
10739 };
10740
10741 finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10742 Long.valueOf(1));
10743 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10744 assetCategoryModelImpl);
10745
10746 args = new Object[] {
10747 assetCategoryModelImpl.getParentCategoryId(),
10748 assetCategoryModelImpl.getName(),
10749 assetCategoryModelImpl.getVocabularyId()
10750 };
10751
10752 finderCache.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10753 Long.valueOf(1));
10754 finderCache.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10755 assetCategoryModelImpl);
10756 }
10757 else {
10758 if ((assetCategoryModelImpl.getColumnBitmask() &
10759 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10760 Object[] args = new Object[] {
10761 assetCategoryModelImpl.getUuid(),
10762 assetCategoryModelImpl.getGroupId()
10763 };
10764
10765 finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10766 Long.valueOf(1));
10767 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10768 assetCategoryModelImpl);
10769 }
10770
10771 if ((assetCategoryModelImpl.getColumnBitmask() &
10772 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10773 Object[] args = new Object[] {
10774 assetCategoryModelImpl.getParentCategoryId(),
10775 assetCategoryModelImpl.getName(),
10776 assetCategoryModelImpl.getVocabularyId()
10777 };
10778
10779 finderCache.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10780 Long.valueOf(1));
10781 finderCache.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10782 assetCategoryModelImpl);
10783 }
10784 }
10785 }
10786
10787 protected void clearUniqueFindersCache(
10788 AssetCategoryModelImpl assetCategoryModelImpl) {
10789 Object[] args = new Object[] {
10790 assetCategoryModelImpl.getUuid(),
10791 assetCategoryModelImpl.getGroupId()
10792 };
10793
10794 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10795 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10796
10797 if ((assetCategoryModelImpl.getColumnBitmask() &
10798 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10799 args = new Object[] {
10800 assetCategoryModelImpl.getOriginalUuid(),
10801 assetCategoryModelImpl.getOriginalGroupId()
10802 };
10803
10804 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10805 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10806 }
10807
10808 args = new Object[] {
10809 assetCategoryModelImpl.getParentCategoryId(),
10810 assetCategoryModelImpl.getName(),
10811 assetCategoryModelImpl.getVocabularyId()
10812 };
10813
10814 finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10815 finderCache.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10816
10817 if ((assetCategoryModelImpl.getColumnBitmask() &
10818 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10819 args = new Object[] {
10820 assetCategoryModelImpl.getOriginalParentCategoryId(),
10821 assetCategoryModelImpl.getOriginalName(),
10822 assetCategoryModelImpl.getOriginalVocabularyId()
10823 };
10824
10825 finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10826 finderCache.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10827 }
10828 }
10829
10830
10836 @Override
10837 public AssetCategory create(long categoryId) {
10838 AssetCategory assetCategory = new AssetCategoryImpl();
10839
10840 assetCategory.setNew(true);
10841 assetCategory.setPrimaryKey(categoryId);
10842
10843 String uuid = PortalUUIDUtil.generate();
10844
10845 assetCategory.setUuid(uuid);
10846
10847 assetCategory.setCompanyId(companyProvider.getCompanyId());
10848
10849 return assetCategory;
10850 }
10851
10852
10859 @Override
10860 public AssetCategory remove(long categoryId) throws NoSuchCategoryException {
10861 return remove((Serializable)categoryId);
10862 }
10863
10864
10871 @Override
10872 public AssetCategory remove(Serializable primaryKey)
10873 throws NoSuchCategoryException {
10874 Session session = null;
10875
10876 try {
10877 session = openSession();
10878
10879 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10880 primaryKey);
10881
10882 if (assetCategory == null) {
10883 if (_log.isDebugEnabled()) {
10884 _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
10885 }
10886
10887 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
10888 primaryKey);
10889 }
10890
10891 return remove(assetCategory);
10892 }
10893 catch (NoSuchCategoryException nsee) {
10894 throw nsee;
10895 }
10896 catch (Exception e) {
10897 throw processException(e);
10898 }
10899 finally {
10900 closeSession(session);
10901 }
10902 }
10903
10904 @Override
10905 protected AssetCategory removeImpl(AssetCategory assetCategory) {
10906 assetCategory = toUnwrappedModel(assetCategory);
10907
10908 assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(assetCategory.getPrimaryKey());
10909
10910 Session session = null;
10911
10912 try {
10913 session = openSession();
10914
10915 if (rebuildTreeEnabled) {
10916 if (session.isDirty()) {
10917 session.flush();
10918 }
10919
10920 nestedSetsTreeManager.delete(assetCategory);
10921
10922 clearCache();
10923
10924 session.clear();
10925 }
10926
10927 if (!session.contains(assetCategory)) {
10928 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10929 assetCategory.getPrimaryKeyObj());
10930 }
10931
10932 if (assetCategory != null) {
10933 session.delete(assetCategory);
10934 }
10935 }
10936 catch (Exception e) {
10937 throw processException(e);
10938 }
10939 finally {
10940 closeSession(session);
10941 }
10942
10943 if (assetCategory != null) {
10944 clearCache(assetCategory);
10945 }
10946
10947 return assetCategory;
10948 }
10949
10950 @Override
10951 public AssetCategory updateImpl(AssetCategory assetCategory) {
10952 assetCategory = toUnwrappedModel(assetCategory);
10953
10954 boolean isNew = assetCategory.isNew();
10955
10956 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10957
10958 if (Validator.isNull(assetCategory.getUuid())) {
10959 String uuid = PortalUUIDUtil.generate();
10960
10961 assetCategory.setUuid(uuid);
10962 }
10963
10964 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
10965
10966 Date now = new Date();
10967
10968 if (isNew && (assetCategory.getCreateDate() == null)) {
10969 if (serviceContext == null) {
10970 assetCategory.setCreateDate(now);
10971 }
10972 else {
10973 assetCategory.setCreateDate(serviceContext.getCreateDate(now));
10974 }
10975 }
10976
10977 if (!assetCategoryModelImpl.hasSetModifiedDate()) {
10978 if (serviceContext == null) {
10979 assetCategory.setModifiedDate(now);
10980 }
10981 else {
10982 assetCategory.setModifiedDate(serviceContext.getModifiedDate(
10983 now));
10984 }
10985 }
10986
10987 Session session = null;
10988
10989 try {
10990 session = openSession();
10991
10992 if (rebuildTreeEnabled) {
10993 if (session.isDirty()) {
10994 session.flush();
10995 }
10996
10997 if (isNew) {
10998 nestedSetsTreeManager.insert(assetCategory,
10999 fetchByPrimaryKey(assetCategory.getParentCategoryId()));
11000 }
11001 else if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
11002 nestedSetsTreeManager.move(assetCategory,
11003 fetchByPrimaryKey(
11004 assetCategoryModelImpl.getOriginalParentCategoryId()),
11005 fetchByPrimaryKey(assetCategory.getParentCategoryId()));
11006 }
11007
11008 clearCache();
11009
11010 session.clear();
11011 }
11012
11013 if (assetCategory.isNew()) {
11014 session.save(assetCategory);
11015
11016 assetCategory.setNew(false);
11017 }
11018 else {
11019 assetCategory = (AssetCategory)session.merge(assetCategory);
11020 }
11021 }
11022 catch (Exception e) {
11023 throw processException(e);
11024 }
11025 finally {
11026 closeSession(session);
11027 }
11028
11029 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11030
11031 if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
11032 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11033 }
11034
11035 else {
11036 if ((assetCategoryModelImpl.getColumnBitmask() &
11037 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
11038 Object[] args = new Object[] {
11039 assetCategoryModelImpl.getOriginalUuid()
11040 };
11041
11042 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
11043 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
11044 args);
11045
11046 args = new Object[] { assetCategoryModelImpl.getUuid() };
11047
11048 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
11049 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
11050 args);
11051 }
11052
11053 if ((assetCategoryModelImpl.getColumnBitmask() &
11054 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
11055 Object[] args = new Object[] {
11056 assetCategoryModelImpl.getOriginalUuid(),
11057 assetCategoryModelImpl.getOriginalCompanyId()
11058 };
11059
11060 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
11061 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
11062 args);
11063
11064 args = new Object[] {
11065 assetCategoryModelImpl.getUuid(),
11066 assetCategoryModelImpl.getCompanyId()
11067 };
11068
11069 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
11070 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
11071 args);
11072 }
11073
11074 if ((assetCategoryModelImpl.getColumnBitmask() &
11075 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
11076 Object[] args = new Object[] {
11077 assetCategoryModelImpl.getOriginalGroupId()
11078 };
11079
11080 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
11081 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
11082 args);
11083
11084 args = new Object[] { assetCategoryModelImpl.getGroupId() };
11085
11086 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
11087 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
11088 args);
11089 }
11090
11091 if ((assetCategoryModelImpl.getColumnBitmask() &
11092 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
11093 Object[] args = new Object[] {
11094 assetCategoryModelImpl.getOriginalParentCategoryId()
11095 };
11096
11097 finderCache.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
11098 args);
11099 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
11100 args);
11101
11102 args = new Object[] { assetCategoryModelImpl.getParentCategoryId() };
11103
11104 finderCache.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
11105 args);
11106 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
11107 args);
11108 }
11109
11110 if ((assetCategoryModelImpl.getColumnBitmask() &
11111 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
11112 Object[] args = new Object[] {
11113 assetCategoryModelImpl.getOriginalVocabularyId()
11114 };
11115
11116 finderCache.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID, args);
11117 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
11118 args);
11119
11120 args = new Object[] { assetCategoryModelImpl.getVocabularyId() };
11121
11122 finderCache.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID, args);
11123 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
11124 args);
11125 }
11126
11127 if ((assetCategoryModelImpl.getColumnBitmask() &
11128 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
11129 Object[] args = new Object[] {
11130 assetCategoryModelImpl.getOriginalGroupId(),
11131 assetCategoryModelImpl.getOriginalVocabularyId()
11132 };
11133
11134 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
11135 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
11136 args);
11137
11138 args = new Object[] {
11139 assetCategoryModelImpl.getGroupId(),
11140 assetCategoryModelImpl.getVocabularyId()
11141 };
11142
11143 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
11144 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
11145 args);
11146 }
11147
11148 if ((assetCategoryModelImpl.getColumnBitmask() &
11149 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
11150 Object[] args = new Object[] {
11151 assetCategoryModelImpl.getOriginalParentCategoryId(),
11152 assetCategoryModelImpl.getOriginalName()
11153 };
11154
11155 finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
11156 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
11157 args);
11158
11159 args = new Object[] {
11160 assetCategoryModelImpl.getParentCategoryId(),
11161 assetCategoryModelImpl.getName()
11162 };
11163
11164 finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
11165 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
11166 args);
11167 }
11168
11169 if ((assetCategoryModelImpl.getColumnBitmask() &
11170 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
11171 Object[] args = new Object[] {
11172 assetCategoryModelImpl.getOriginalParentCategoryId(),
11173 assetCategoryModelImpl.getOriginalVocabularyId()
11174 };
11175
11176 finderCache.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
11177 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
11178 args);
11179
11180 args = new Object[] {
11181 assetCategoryModelImpl.getParentCategoryId(),
11182 assetCategoryModelImpl.getVocabularyId()
11183 };
11184
11185 finderCache.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
11186 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
11187 args);
11188 }
11189
11190 if ((assetCategoryModelImpl.getColumnBitmask() &
11191 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
11192 Object[] args = new Object[] {
11193 assetCategoryModelImpl.getOriginalName(),
11194 assetCategoryModelImpl.getOriginalVocabularyId()
11195 };
11196
11197 finderCache.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
11198 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
11199 args);
11200
11201 args = new Object[] {
11202 assetCategoryModelImpl.getName(),
11203 assetCategoryModelImpl.getVocabularyId()
11204 };
11205
11206 finderCache.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
11207 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
11208 args);
11209 }
11210
11211 if ((assetCategoryModelImpl.getColumnBitmask() &
11212 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V.getColumnBitmask()) != 0) {
11213 Object[] args = new Object[] {
11214 assetCategoryModelImpl.getOriginalGroupId(),
11215 assetCategoryModelImpl.getOriginalParentCategoryId(),
11216 assetCategoryModelImpl.getOriginalVocabularyId()
11217 };
11218
11219 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
11220 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
11221 args);
11222
11223 args = new Object[] {
11224 assetCategoryModelImpl.getGroupId(),
11225 assetCategoryModelImpl.getParentCategoryId(),
11226 assetCategoryModelImpl.getVocabularyId()
11227 };
11228
11229 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
11230 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
11231 args);
11232 }
11233
11234 if ((assetCategoryModelImpl.getColumnBitmask() &
11235 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V.getColumnBitmask()) != 0) {
11236 Object[] args = new Object[] {
11237 assetCategoryModelImpl.getOriginalGroupId(),
11238 assetCategoryModelImpl.getOriginalParentCategoryId(),
11239 assetCategoryModelImpl.getOriginalName(),
11240 assetCategoryModelImpl.getOriginalVocabularyId()
11241 };
11242
11243 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
11244 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
11245 args);
11246
11247 args = new Object[] {
11248 assetCategoryModelImpl.getGroupId(),
11249 assetCategoryModelImpl.getParentCategoryId(),
11250 assetCategoryModelImpl.getName(),
11251 assetCategoryModelImpl.getVocabularyId()
11252 };
11253
11254 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
11255 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
11256 args);
11257 }
11258 }
11259
11260 entityCache.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11261 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
11262 assetCategory, false);
11263
11264 clearUniqueFindersCache(assetCategoryModelImpl);
11265 cacheUniqueFindersCache(assetCategoryModelImpl, isNew);
11266
11267 assetCategory.resetOriginalValues();
11268
11269 return assetCategory;
11270 }
11271
11272 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
11273 if (assetCategory instanceof AssetCategoryImpl) {
11274 return assetCategory;
11275 }
11276
11277 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
11278
11279 assetCategoryImpl.setNew(assetCategory.isNew());
11280 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
11281
11282 assetCategoryImpl.setUuid(assetCategory.getUuid());
11283 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
11284 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
11285 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
11286 assetCategoryImpl.setUserId(assetCategory.getUserId());
11287 assetCategoryImpl.setUserName(assetCategory.getUserName());
11288 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
11289 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
11290 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
11291 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
11292 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
11293 assetCategoryImpl.setName(assetCategory.getName());
11294 assetCategoryImpl.setTitle(assetCategory.getTitle());
11295 assetCategoryImpl.setDescription(assetCategory.getDescription());
11296 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
11297 assetCategoryImpl.setLastPublishDate(assetCategory.getLastPublishDate());
11298
11299 return assetCategoryImpl;
11300 }
11301
11302
11309 @Override
11310 public AssetCategory findByPrimaryKey(Serializable primaryKey)
11311 throws NoSuchCategoryException {
11312 AssetCategory assetCategory = fetchByPrimaryKey(primaryKey);
11313
11314 if (assetCategory == null) {
11315 if (_log.isDebugEnabled()) {
11316 _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
11317 }
11318
11319 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
11320 primaryKey);
11321 }
11322
11323 return assetCategory;
11324 }
11325
11326
11333 @Override
11334 public AssetCategory findByPrimaryKey(long categoryId)
11335 throws NoSuchCategoryException {
11336 return findByPrimaryKey((Serializable)categoryId);
11337 }
11338
11339
11345 @Override
11346 public AssetCategory fetchByPrimaryKey(Serializable primaryKey) {
11347 AssetCategory assetCategory = (AssetCategory)entityCache.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11348 AssetCategoryImpl.class, primaryKey);
11349
11350 if (assetCategory == _nullAssetCategory) {
11351 return null;
11352 }
11353
11354 if (assetCategory == null) {
11355 Session session = null;
11356
11357 try {
11358 session = openSession();
11359
11360 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
11361 primaryKey);
11362
11363 if (assetCategory != null) {
11364 cacheResult(assetCategory);
11365 }
11366 else {
11367 entityCache.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11368 AssetCategoryImpl.class, primaryKey, _nullAssetCategory);
11369 }
11370 }
11371 catch (Exception e) {
11372 entityCache.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11373 AssetCategoryImpl.class, primaryKey);
11374
11375 throw processException(e);
11376 }
11377 finally {
11378 closeSession(session);
11379 }
11380 }
11381
11382 return assetCategory;
11383 }
11384
11385
11391 @Override
11392 public AssetCategory fetchByPrimaryKey(long categoryId) {
11393 return fetchByPrimaryKey((Serializable)categoryId);
11394 }
11395
11396 @Override
11397 public Map<Serializable, AssetCategory> fetchByPrimaryKeys(
11398 Set<Serializable> primaryKeys) {
11399 if (primaryKeys.isEmpty()) {
11400 return Collections.emptyMap();
11401 }
11402
11403 Map<Serializable, AssetCategory> map = new HashMap<Serializable, AssetCategory>();
11404
11405 if (primaryKeys.size() == 1) {
11406 Iterator<Serializable> iterator = primaryKeys.iterator();
11407
11408 Serializable primaryKey = iterator.next();
11409
11410 AssetCategory assetCategory = fetchByPrimaryKey(primaryKey);
11411
11412 if (assetCategory != null) {
11413 map.put(primaryKey, assetCategory);
11414 }
11415
11416 return map;
11417 }
11418
11419 Set<Serializable> uncachedPrimaryKeys = null;
11420
11421 for (Serializable primaryKey : primaryKeys) {
11422 AssetCategory assetCategory = (AssetCategory)entityCache.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11423 AssetCategoryImpl.class, primaryKey);
11424
11425 if (assetCategory == null) {
11426 if (uncachedPrimaryKeys == null) {
11427 uncachedPrimaryKeys = new HashSet<Serializable>();
11428 }
11429
11430 uncachedPrimaryKeys.add(primaryKey);
11431 }
11432 else {
11433 map.put(primaryKey, assetCategory);
11434 }
11435 }
11436
11437 if (uncachedPrimaryKeys == null) {
11438 return map;
11439 }
11440
11441 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
11442 1);
11443
11444 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE_PKS_IN);
11445
11446 for (Serializable primaryKey : uncachedPrimaryKeys) {
11447 query.append(String.valueOf(primaryKey));
11448
11449 query.append(StringPool.COMMA);
11450 }
11451
11452 query.setIndex(query.index() - 1);
11453
11454 query.append(StringPool.CLOSE_PARENTHESIS);
11455
11456 String sql = query.toString();
11457
11458 Session session = null;
11459
11460 try {
11461 session = openSession();
11462
11463 Query q = session.createQuery(sql);
11464
11465 for (AssetCategory assetCategory : (List<AssetCategory>)q.list()) {
11466 map.put(assetCategory.getPrimaryKeyObj(), assetCategory);
11467
11468 cacheResult(assetCategory);
11469
11470 uncachedPrimaryKeys.remove(assetCategory.getPrimaryKeyObj());
11471 }
11472
11473 for (Serializable primaryKey : uncachedPrimaryKeys) {
11474 entityCache.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11475 AssetCategoryImpl.class, primaryKey, _nullAssetCategory);
11476 }
11477 }
11478 catch (Exception e) {
11479 throw processException(e);
11480 }
11481 finally {
11482 closeSession(session);
11483 }
11484
11485 return map;
11486 }
11487
11488
11493 @Override
11494 public List<AssetCategory> findAll() {
11495 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11496 }
11497
11498
11509 @Override
11510 public List<AssetCategory> findAll(int start, int end) {
11511 return findAll(start, end, null);
11512 }
11513
11514
11526 @Override
11527 public List<AssetCategory> findAll(int start, int end,
11528 OrderByComparator<AssetCategory> orderByComparator) {
11529 return findAll(start, end, orderByComparator, true);
11530 }
11531
11532
11545 @Override
11546 public List<AssetCategory> findAll(int start, int end,
11547 OrderByComparator<AssetCategory> orderByComparator,
11548 boolean retrieveFromCache) {
11549 boolean pagination = true;
11550 FinderPath finderPath = null;
11551 Object[] finderArgs = null;
11552
11553 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11554 (orderByComparator == null)) {
11555 pagination = false;
11556 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
11557 finderArgs = FINDER_ARGS_EMPTY;
11558 }
11559 else {
11560 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
11561 finderArgs = new Object[] { start, end, orderByComparator };
11562 }
11563
11564 List<AssetCategory> list = null;
11565
11566 if (retrieveFromCache) {
11567 list = (List<AssetCategory>)finderCache.getResult(finderPath,
11568 finderArgs, this);
11569 }
11570
11571 if (list == null) {
11572 StringBundler query = null;
11573 String sql = null;
11574
11575 if (orderByComparator != null) {
11576 query = new StringBundler(2 +
11577 (orderByComparator.getOrderByFields().length * 2));
11578
11579 query.append(_SQL_SELECT_ASSETCATEGORY);
11580
11581 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11582 orderByComparator);
11583
11584 sql = query.toString();
11585 }
11586 else {
11587 sql = _SQL_SELECT_ASSETCATEGORY;
11588
11589 if (pagination) {
11590 sql = sql.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
11591 }
11592 }
11593
11594 Session session = null;
11595
11596 try {
11597 session = openSession();
11598
11599 Query q = session.createQuery(sql);
11600
11601 if (!pagination) {
11602 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11603 start, end, false);
11604
11605 Collections.sort(list);
11606
11607 list = Collections.unmodifiableList(list);
11608 }
11609 else {
11610 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11611 start, end);
11612 }
11613
11614 cacheResult(list);
11615
11616 finderCache.putResult(finderPath, finderArgs, list);
11617 }
11618 catch (Exception e) {
11619 finderCache.removeResult(finderPath, finderArgs);
11620
11621 throw processException(e);
11622 }
11623 finally {
11624 closeSession(session);
11625 }
11626 }
11627
11628 return list;
11629 }
11630
11631
11635 @Override
11636 public void removeAll() {
11637 for (AssetCategory assetCategory : findAll()) {
11638 remove(assetCategory);
11639 }
11640 }
11641
11642
11647 @Override
11648 public int countAll() {
11649 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
11650 FINDER_ARGS_EMPTY, this);
11651
11652 if (count == null) {
11653 Session session = null;
11654
11655 try {
11656 session = openSession();
11657
11658 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
11659
11660 count = (Long)q.uniqueResult();
11661
11662 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
11663 count);
11664 }
11665 catch (Exception e) {
11666 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
11667 FINDER_ARGS_EMPTY);
11668
11669 throw processException(e);
11670 }
11671 finally {
11672 closeSession(session);
11673 }
11674 }
11675
11676 return count.intValue();
11677 }
11678
11679
11685 @Override
11686 public long[] getAssetEntryPrimaryKeys(long pk) {
11687 long[] pks = assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(pk);
11688
11689 return pks.clone();
11690 }
11691
11692
11698 @Override
11699 public List<com.liferay.asset.kernel.model.AssetEntry> getAssetEntries(
11700 long pk) {
11701 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
11702 }
11703
11704
11716 @Override
11717 public List<com.liferay.asset.kernel.model.AssetEntry> getAssetEntries(
11718 long pk, int start, int end) {
11719 return getAssetEntries(pk, start, end, null);
11720 }
11721
11722
11735 @Override
11736 public List<com.liferay.asset.kernel.model.AssetEntry> getAssetEntries(
11737 long pk, int start, int end,
11738 OrderByComparator<com.liferay.asset.kernel.model.AssetEntry> orderByComparator) {
11739 return assetCategoryToAssetEntryTableMapper.getRightBaseModels(pk,
11740 start, end, orderByComparator);
11741 }
11742
11743
11749 @Override
11750 public int getAssetEntriesSize(long pk) {
11751 long[] pks = assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(pk);
11752
11753 return pks.length;
11754 }
11755
11756
11763 @Override
11764 public boolean containsAssetEntry(long pk, long assetEntryPK) {
11765 return assetCategoryToAssetEntryTableMapper.containsTableMapping(pk,
11766 assetEntryPK);
11767 }
11768
11769
11775 @Override
11776 public boolean containsAssetEntries(long pk) {
11777 if (getAssetEntriesSize(pk) > 0) {
11778 return true;
11779 }
11780 else {
11781 return false;
11782 }
11783 }
11784
11785
11791 @Override
11792 public void addAssetEntry(long pk, long assetEntryPK) {
11793 AssetCategory assetCategory = fetchByPrimaryKey(pk);
11794
11795 if (assetCategory == null) {
11796 assetCategoryToAssetEntryTableMapper.addTableMapping(companyProvider.getCompanyId(),
11797 pk, assetEntryPK);
11798 }
11799 else {
11800 assetCategoryToAssetEntryTableMapper.addTableMapping(assetCategory.getCompanyId(),
11801 pk, assetEntryPK);
11802 }
11803 }
11804
11805
11811 @Override
11812 public void addAssetEntry(long pk,
11813 com.liferay.asset.kernel.model.AssetEntry assetEntry) {
11814 AssetCategory assetCategory = fetchByPrimaryKey(pk);
11815
11816 if (assetCategory == null) {
11817 assetCategoryToAssetEntryTableMapper.addTableMapping(companyProvider.getCompanyId(),
11818 pk, assetEntry.getPrimaryKey());
11819 }
11820 else {
11821 assetCategoryToAssetEntryTableMapper.addTableMapping(assetCategory.getCompanyId(),
11822 pk, assetEntry.getPrimaryKey());
11823 }
11824 }
11825
11826
11832 @Override
11833 public void addAssetEntries(long pk, long[] assetEntryPKs) {
11834 long companyId = 0;
11835
11836 AssetCategory assetCategory = fetchByPrimaryKey(pk);
11837
11838 if (assetCategory == null) {
11839 companyId = companyProvider.getCompanyId();
11840 }
11841 else {
11842 companyId = assetCategory.getCompanyId();
11843 }
11844
11845 for (long assetEntryPK : assetEntryPKs) {
11846 assetCategoryToAssetEntryTableMapper.addTableMapping(companyId, pk,
11847 assetEntryPK);
11848 }
11849 }
11850
11851
11857 @Override
11858 public void addAssetEntries(long pk,
11859 List<com.liferay.asset.kernel.model.AssetEntry> assetEntries) {
11860 long companyId = 0;
11861
11862 AssetCategory assetCategory = fetchByPrimaryKey(pk);
11863
11864 if (assetCategory == null) {
11865 companyId = companyProvider.getCompanyId();
11866 }
11867 else {
11868 companyId = assetCategory.getCompanyId();
11869 }
11870
11871 for (com.liferay.asset.kernel.model.AssetEntry assetEntry : assetEntries) {
11872 assetCategoryToAssetEntryTableMapper.addTableMapping(companyId, pk,
11873 assetEntry.getPrimaryKey());
11874 }
11875 }
11876
11877
11882 @Override
11883 public void clearAssetEntries(long pk) {
11884 assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
11885 }
11886
11887
11893 @Override
11894 public void removeAssetEntry(long pk, long assetEntryPK) {
11895 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk, assetEntryPK);
11896 }
11897
11898
11904 @Override
11905 public void removeAssetEntry(long pk,
11906 com.liferay.asset.kernel.model.AssetEntry assetEntry) {
11907 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11908 assetEntry.getPrimaryKey());
11909 }
11910
11911
11917 @Override
11918 public void removeAssetEntries(long pk, long[] assetEntryPKs) {
11919 for (long assetEntryPK : assetEntryPKs) {
11920 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11921 assetEntryPK);
11922 }
11923 }
11924
11925
11931 @Override
11932 public void removeAssetEntries(long pk,
11933 List<com.liferay.asset.kernel.model.AssetEntry> assetEntries) {
11934 for (com.liferay.asset.kernel.model.AssetEntry assetEntry : assetEntries) {
11935 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11936 assetEntry.getPrimaryKey());
11937 }
11938 }
11939
11940
11946 @Override
11947 public void setAssetEntries(long pk, long[] assetEntryPKs) {
11948 Set<Long> newAssetEntryPKsSet = SetUtil.fromArray(assetEntryPKs);
11949 Set<Long> oldAssetEntryPKsSet = SetUtil.fromArray(assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(
11950 pk));
11951
11952 Set<Long> removeAssetEntryPKsSet = new HashSet<Long>(oldAssetEntryPKsSet);
11953
11954 removeAssetEntryPKsSet.removeAll(newAssetEntryPKsSet);
11955
11956 for (long removeAssetEntryPK : removeAssetEntryPKsSet) {
11957 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11958 removeAssetEntryPK);
11959 }
11960
11961 newAssetEntryPKsSet.removeAll(oldAssetEntryPKsSet);
11962
11963 long companyId = 0;
11964
11965 AssetCategory assetCategory = fetchByPrimaryKey(pk);
11966
11967 if (assetCategory == null) {
11968 companyId = companyProvider.getCompanyId();
11969 }
11970 else {
11971 companyId = assetCategory.getCompanyId();
11972 }
11973
11974 for (long newAssetEntryPK : newAssetEntryPKsSet) {
11975 assetCategoryToAssetEntryTableMapper.addTableMapping(companyId, pk,
11976 newAssetEntryPK);
11977 }
11978 }
11979
11980
11986 @Override
11987 public void setAssetEntries(long pk,
11988 List<com.liferay.asset.kernel.model.AssetEntry> assetEntries) {
11989 try {
11990 long[] assetEntryPKs = new long[assetEntries.size()];
11991
11992 for (int i = 0; i < assetEntries.size(); i++) {
11993 com.liferay.asset.kernel.model.AssetEntry assetEntry = assetEntries.get(i);
11994
11995 assetEntryPKs[i] = assetEntry.getPrimaryKey();
11996 }
11997
11998 setAssetEntries(pk, assetEntryPKs);
11999 }
12000 catch (Exception e) {
12001 throw processException(e);
12002 }
12003 }
12004
12005 @Override
12006 public Set<String> getBadColumnNames() {
12007 return _badColumnNames;
12008 }
12009
12010 @Override
12011 protected Map<String, Integer> getTableColumnsMap() {
12012 return AssetCategoryModelImpl.TABLE_COLUMNS_MAP;
12013 }
12014
12015 @Override
12016 public long countAncestors(AssetCategory assetCategory) {
12017 Object[] finderArgs = new Object[] {
12018 assetCategory.getGroupId(), assetCategory.getLeftCategoryId(),
12019 assetCategory.getRightCategoryId()
12020 };
12021
12022 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS,
12023 finderArgs, this);
12024
12025 if (count == null) {
12026 try {
12027 count = nestedSetsTreeManager.countAncestors(assetCategory);
12028
12029 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS,
12030 finderArgs, count);
12031 }
12032 catch (SystemException se) {
12033 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS,
12034 finderArgs);
12035
12036 throw se;
12037 }
12038 }
12039
12040 return count.intValue();
12041 }
12042
12043 @Override
12044 public long countDescendants(AssetCategory assetCategory) {
12045 Object[] finderArgs = new Object[] {
12046 assetCategory.getGroupId(), assetCategory.getLeftCategoryId(),
12047 assetCategory.getRightCategoryId()
12048 };
12049
12050 Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS,
12051 finderArgs, this);
12052
12053 if (count == null) {
12054 try {
12055 count = nestedSetsTreeManager.countDescendants(assetCategory);
12056
12057 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS,
12058 finderArgs, count);
12059 }
12060 catch (SystemException se) {
12061 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS,
12062 finderArgs);
12063
12064 throw se;
12065 }
12066 }
12067
12068 return count.intValue();
12069 }
12070
12071 @Override
12072 public List<AssetCategory> getAncestors(AssetCategory assetCategory) {
12073 Object[] finderArgs = new Object[] {
12074 assetCategory.getGroupId(), assetCategory.getLeftCategoryId(),
12075 assetCategory.getRightCategoryId()
12076 };
12077
12078 List<AssetCategory> list = (List<AssetCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS,
12079 finderArgs, this);
12080
12081 if ((list != null) && !list.isEmpty()) {
12082 for (AssetCategory tempAssetCategory : list) {
12083 if ((assetCategory.getLeftCategoryId() < tempAssetCategory.getLeftCategoryId()) ||
12084 (assetCategory.getRightCategoryId() > tempAssetCategory.getRightCategoryId())) {
12085 list = null;
12086
12087 break;
12088 }
12089 }
12090 }
12091
12092 if (list == null) {
12093 try {
12094 list = nestedSetsTreeManager.getAncestors(assetCategory);
12095
12096 cacheResult(list);
12097
12098 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS,
12099 finderArgs, list);
12100 }
12101 catch (SystemException se) {
12102 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS,
12103 finderArgs);
12104
12105 throw se;
12106 }
12107 }
12108
12109 return list;
12110 }
12111
12112 @Override
12113 public List<AssetCategory> getDescendants(AssetCategory assetCategory) {
12114 Object[] finderArgs = new Object[] {
12115 assetCategory.getGroupId(), assetCategory.getLeftCategoryId(),
12116 assetCategory.getRightCategoryId()
12117 };
12118
12119 List<AssetCategory> list = (List<AssetCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS,
12120 finderArgs, this);
12121
12122 if ((list != null) && !list.isEmpty()) {
12123 for (AssetCategory tempAssetCategory : list) {
12124 if ((assetCategory.getLeftCategoryId() > tempAssetCategory.getLeftCategoryId()) ||
12125 (assetCategory.getRightCategoryId() < tempAssetCategory.getRightCategoryId())) {
12126 list = null;
12127
12128 break;
12129 }
12130 }
12131 }
12132
12133 if (list == null) {
12134 try {
12135 list = nestedSetsTreeManager.getDescendants(assetCategory);
12136
12137 cacheResult(list);
12138
12139 finderCache.putResult(FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS,
12140 finderArgs, list);
12141 }
12142 catch (SystemException se) {
12143 finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS,
12144 finderArgs);
12145
12146 throw se;
12147 }
12148 }
12149
12150 return list;
12151 }
12152
12153
12163 @Override
12164 public void rebuildTree(long groupId, boolean force) {
12165 if (!rebuildTreeEnabled) {
12166 return;
12167 }
12168
12169 if (force || (countOrphanTreeNodes(groupId) > 0)) {
12170 Session session = null;
12171
12172 try {
12173 session = openSession();
12174
12175 if (session.isDirty()) {
12176 session.flush();
12177 }
12178
12179 SQLQuery selectQuery = session.createSQLQuery(
12180 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
12181
12182 selectQuery.addScalar("categoryId",
12183 com.liferay.portal.kernel.dao.orm.Type.LONG);
12184
12185 SQLQuery updateQuery = session.createSQLQuery(
12186 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?");
12187
12188 rebuildTree(session, selectQuery, updateQuery, groupId, 0, 0);
12189 }
12190 catch (Exception e) {
12191 throw processException(e);
12192 }
12193 finally {
12194 closeSession(session);
12195 }
12196
12197 clearCache();
12198 }
12199 }
12200
12201 @Override
12202 public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
12203 this.rebuildTreeEnabled = rebuildTreeEnabled;
12204 }
12205
12206 protected long countOrphanTreeNodes(long groupId) {
12207 Session session = null;
12208
12209 try {
12210 session = openSession();
12211
12212 SQLQuery q = session.createSynchronizedSQLQuery(
12213 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
12214
12215 q.addScalar(COUNT_COLUMN_NAME,
12216 com.liferay.portal.kernel.dao.orm.Type.LONG);
12217
12218 QueryPos qPos = QueryPos.getInstance(q);
12219
12220 qPos.add(groupId);
12221
12222 return (Long)q.uniqueResult();
12223 }
12224 catch (Exception e) {
12225 throw processException(e);
12226 }
12227 finally {
12228 closeSession(session);
12229 }
12230 }
12231
12232 protected long rebuildTree(Session session, SQLQuery selectQuery,
12233 SQLQuery updateQuery, long groupId, long parentCategoryId,
12234 long leftCategoryId) {
12235 long rightCategoryId = leftCategoryId + 1;
12236
12237 QueryPos qPos = QueryPos.getInstance(selectQuery);
12238
12239 qPos.add(groupId);
12240 qPos.add(parentCategoryId);
12241
12242 List<Long> categoryIds = selectQuery.list();
12243
12244 for (long categoryId : categoryIds) {
12245 rightCategoryId = rebuildTree(session, selectQuery, updateQuery,
12246 groupId, categoryId, rightCategoryId);
12247 }
12248
12249 if (parentCategoryId > 0) {
12250 qPos = QueryPos.getInstance(updateQuery);
12251
12252 qPos.add(leftCategoryId);
12253 qPos.add(rightCategoryId);
12254 qPos.add(parentCategoryId);
12255
12256 updateQuery.executeUpdate();
12257 }
12258
12259 return rightCategoryId + 1;
12260 }
12261
12262
12265 public void afterPropertiesSet() {
12266 assetCategoryToAssetEntryTableMapper = TableMapperFactory.getTableMapper("AssetEntries_AssetCategories",
12267 "companyId", "categoryId", "entryId", this,
12268 assetEntryPersistence);
12269 }
12270
12271 public void destroy() {
12272 entityCache.removeCache(AssetCategoryImpl.class.getName());
12273 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
12274 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12275 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12276
12277 TableMapperFactory.removeTableMapper("AssetEntries_AssetCategories");
12278 }
12279
12280 @BeanReference(type = CompanyProviderWrapper.class)
12281 protected CompanyProvider companyProvider;
12282 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
12283 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
12284 @BeanReference(type = AssetEntryPersistence.class)
12285 protected AssetEntryPersistence assetEntryPersistence;
12286 protected TableMapper<AssetCategory, com.liferay.asset.kernel.model.AssetEntry> assetCategoryToAssetEntryTableMapper;
12287 protected NestedSetsTreeManager<AssetCategory> nestedSetsTreeManager = new PersistenceNestedSetsTreeManager<AssetCategory>(this,
12288 "AssetCategory", "AssetCategory", AssetCategoryImpl.class,
12289 "categoryId", "groupId", "leftCategoryId", "rightCategoryId");
12290 protected boolean rebuildTreeEnabled = true;
12291 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
12292 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE_PKS_IN = "SELECT assetCategory FROM AssetCategory assetCategory WHERE categoryId IN (";
12293 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
12294 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
12295 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
12296 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
12297 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
12298 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
12299 "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
12300 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
12301 ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
12302 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
12303 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
12304 private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
12305 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
12306 private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
12307 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
12308 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
12309 private static final Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
12310 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
12311 "uuid"
12312 });
12313 private static final AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
12314 @Override
12315 public Object clone() {
12316 return this;
12317 }
12318
12319 @Override
12320 public CacheModel<AssetCategory> toCacheModel() {
12321 return _nullAssetCategoryCacheModel;
12322 }
12323 };
12324
12325 private static final CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
12326 @Override
12327 public AssetCategory toEntityModel() {
12328 return _nullAssetCategory;
12329 }
12330 };
12331 }