001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderPath;
021 import com.liferay.portal.kernel.dao.orm.Query;
022 import com.liferay.portal.kernel.dao.orm.QueryPos;
023 import com.liferay.portal.kernel.dao.orm.QueryUtil;
024 import com.liferay.portal.kernel.dao.orm.Session;
025 import com.liferay.portal.kernel.exception.SystemException;
026 import com.liferay.portal.kernel.log.Log;
027 import com.liferay.portal.kernel.log.LogFactoryUtil;
028 import com.liferay.portal.kernel.util.GetterUtil;
029 import com.liferay.portal.kernel.util.InstanceFactory;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.StringBundler;
032 import com.liferay.portal.kernel.util.StringPool;
033 import com.liferay.portal.kernel.util.StringUtil;
034 import com.liferay.portal.kernel.util.UnmodifiableList;
035 import com.liferay.portal.kernel.util.Validator;
036 import com.liferay.portal.model.CacheModel;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
039
040 import com.liferay.portlet.asset.NoSuchCategoryPropertyException;
041 import com.liferay.portlet.asset.model.AssetCategoryProperty;
042 import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyImpl;
043 import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyModelImpl;
044
045 import java.io.Serializable;
046
047 import java.util.ArrayList;
048 import java.util.Collections;
049 import java.util.List;
050
051
063 public class AssetCategoryPropertyPersistenceImpl extends BasePersistenceImpl<AssetCategoryProperty>
064 implements AssetCategoryPropertyPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryPropertyImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
076 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
077 AssetCategoryPropertyImpl.class,
078 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
079 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
080 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
081 AssetCategoryPropertyImpl.class,
082 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
083 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
084 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
085 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
086 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
087 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
088 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
089 AssetCategoryPropertyImpl.class,
090 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
091 new String[] {
092 Long.class.getName(),
093
094 Integer.class.getName(), Integer.class.getName(),
095 OrderByComparator.class.getName()
096 });
097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
098 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
099 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
100 AssetCategoryPropertyImpl.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
102 new String[] { Long.class.getName() },
103 AssetCategoryPropertyModelImpl.COMPANYID_COLUMN_BITMASK |
104 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
106 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
108 new String[] { Long.class.getName() });
109
110
117 public List<AssetCategoryProperty> findByCompanyId(long companyId)
118 throws SystemException {
119 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
120 null);
121 }
122
123
136 public List<AssetCategoryProperty> findByCompanyId(long companyId,
137 int start, int end) throws SystemException {
138 return findByCompanyId(companyId, start, end, null);
139 }
140
141
155 public List<AssetCategoryProperty> findByCompanyId(long companyId,
156 int start, int end, OrderByComparator orderByComparator)
157 throws SystemException {
158 boolean pagination = true;
159 FinderPath finderPath = null;
160 Object[] finderArgs = null;
161
162 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
163 (orderByComparator == null)) {
164 pagination = false;
165 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
166 finderArgs = new Object[] { companyId };
167 }
168 else {
169 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
170 finderArgs = new Object[] { companyId, start, end, orderByComparator };
171 }
172
173 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
174 finderArgs, this);
175
176 if ((list != null) && !list.isEmpty()) {
177 for (AssetCategoryProperty assetCategoryProperty : list) {
178 if ((companyId != assetCategoryProperty.getCompanyId())) {
179 list = null;
180
181 break;
182 }
183 }
184 }
185
186 if (list == null) {
187 StringBundler query = null;
188
189 if (orderByComparator != null) {
190 query = new StringBundler(3 +
191 (orderByComparator.getOrderByFields().length * 3));
192 }
193 else {
194 query = new StringBundler(3);
195 }
196
197 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
198
199 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
200
201 if (orderByComparator != null) {
202 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
203 orderByComparator);
204 }
205 else
206 if (pagination) {
207 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
208 }
209
210 String sql = query.toString();
211
212 Session session = null;
213
214 try {
215 session = openSession();
216
217 Query q = session.createQuery(sql);
218
219 QueryPos qPos = QueryPos.getInstance(q);
220
221 qPos.add(companyId);
222
223 if (!pagination) {
224 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
225 getDialect(), start, end, false);
226
227 Collections.sort(list);
228
229 list = new UnmodifiableList<AssetCategoryProperty>(list);
230 }
231 else {
232 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
233 getDialect(), start, end);
234 }
235
236 cacheResult(list);
237
238 FinderCacheUtil.putResult(finderPath, finderArgs, list);
239 }
240 catch (Exception e) {
241 FinderCacheUtil.removeResult(finderPath, finderArgs);
242
243 throw processException(e);
244 }
245 finally {
246 closeSession(session);
247 }
248 }
249
250 return list;
251 }
252
253
262 public AssetCategoryProperty findByCompanyId_First(long companyId,
263 OrderByComparator orderByComparator)
264 throws NoSuchCategoryPropertyException, SystemException {
265 AssetCategoryProperty assetCategoryProperty = fetchByCompanyId_First(companyId,
266 orderByComparator);
267
268 if (assetCategoryProperty != null) {
269 return assetCategoryProperty;
270 }
271
272 StringBundler msg = new StringBundler(4);
273
274 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
275
276 msg.append("companyId=");
277 msg.append(companyId);
278
279 msg.append(StringPool.CLOSE_CURLY_BRACE);
280
281 throw new NoSuchCategoryPropertyException(msg.toString());
282 }
283
284
292 public AssetCategoryProperty fetchByCompanyId_First(long companyId,
293 OrderByComparator orderByComparator) throws SystemException {
294 List<AssetCategoryProperty> list = findByCompanyId(companyId, 0, 1,
295 orderByComparator);
296
297 if (!list.isEmpty()) {
298 return list.get(0);
299 }
300
301 return null;
302 }
303
304
313 public AssetCategoryProperty findByCompanyId_Last(long companyId,
314 OrderByComparator orderByComparator)
315 throws NoSuchCategoryPropertyException, SystemException {
316 AssetCategoryProperty assetCategoryProperty = fetchByCompanyId_Last(companyId,
317 orderByComparator);
318
319 if (assetCategoryProperty != null) {
320 return assetCategoryProperty;
321 }
322
323 StringBundler msg = new StringBundler(4);
324
325 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
326
327 msg.append("companyId=");
328 msg.append(companyId);
329
330 msg.append(StringPool.CLOSE_CURLY_BRACE);
331
332 throw new NoSuchCategoryPropertyException(msg.toString());
333 }
334
335
343 public AssetCategoryProperty fetchByCompanyId_Last(long companyId,
344 OrderByComparator orderByComparator) throws SystemException {
345 int count = countByCompanyId(companyId);
346
347 List<AssetCategoryProperty> list = findByCompanyId(companyId,
348 count - 1, count, orderByComparator);
349
350 if (!list.isEmpty()) {
351 return list.get(0);
352 }
353
354 return null;
355 }
356
357
367 public AssetCategoryProperty[] findByCompanyId_PrevAndNext(
368 long categoryPropertyId, long companyId,
369 OrderByComparator orderByComparator)
370 throws NoSuchCategoryPropertyException, SystemException {
371 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
372
373 Session session = null;
374
375 try {
376 session = openSession();
377
378 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
379
380 array[0] = getByCompanyId_PrevAndNext(session,
381 assetCategoryProperty, companyId, orderByComparator, true);
382
383 array[1] = assetCategoryProperty;
384
385 array[2] = getByCompanyId_PrevAndNext(session,
386 assetCategoryProperty, companyId, orderByComparator, false);
387
388 return array;
389 }
390 catch (Exception e) {
391 throw processException(e);
392 }
393 finally {
394 closeSession(session);
395 }
396 }
397
398 protected AssetCategoryProperty getByCompanyId_PrevAndNext(
399 Session session, AssetCategoryProperty assetCategoryProperty,
400 long companyId, OrderByComparator orderByComparator, boolean previous) {
401 StringBundler query = null;
402
403 if (orderByComparator != null) {
404 query = new StringBundler(6 +
405 (orderByComparator.getOrderByFields().length * 6));
406 }
407 else {
408 query = new StringBundler(3);
409 }
410
411 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
412
413 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
414
415 if (orderByComparator != null) {
416 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
417
418 if (orderByConditionFields.length > 0) {
419 query.append(WHERE_AND);
420 }
421
422 for (int i = 0; i < orderByConditionFields.length; i++) {
423 query.append(_ORDER_BY_ENTITY_ALIAS);
424 query.append(orderByConditionFields[i]);
425
426 if ((i + 1) < orderByConditionFields.length) {
427 if (orderByComparator.isAscending() ^ previous) {
428 query.append(WHERE_GREATER_THAN_HAS_NEXT);
429 }
430 else {
431 query.append(WHERE_LESSER_THAN_HAS_NEXT);
432 }
433 }
434 else {
435 if (orderByComparator.isAscending() ^ previous) {
436 query.append(WHERE_GREATER_THAN);
437 }
438 else {
439 query.append(WHERE_LESSER_THAN);
440 }
441 }
442 }
443
444 query.append(ORDER_BY_CLAUSE);
445
446 String[] orderByFields = orderByComparator.getOrderByFields();
447
448 for (int i = 0; i < orderByFields.length; i++) {
449 query.append(_ORDER_BY_ENTITY_ALIAS);
450 query.append(orderByFields[i]);
451
452 if ((i + 1) < orderByFields.length) {
453 if (orderByComparator.isAscending() ^ previous) {
454 query.append(ORDER_BY_ASC_HAS_NEXT);
455 }
456 else {
457 query.append(ORDER_BY_DESC_HAS_NEXT);
458 }
459 }
460 else {
461 if (orderByComparator.isAscending() ^ previous) {
462 query.append(ORDER_BY_ASC);
463 }
464 else {
465 query.append(ORDER_BY_DESC);
466 }
467 }
468 }
469 }
470 else {
471 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
472 }
473
474 String sql = query.toString();
475
476 Query q = session.createQuery(sql);
477
478 q.setFirstResult(0);
479 q.setMaxResults(2);
480
481 QueryPos qPos = QueryPos.getInstance(q);
482
483 qPos.add(companyId);
484
485 if (orderByComparator != null) {
486 Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
487
488 for (Object value : values) {
489 qPos.add(value);
490 }
491 }
492
493 List<AssetCategoryProperty> list = q.list();
494
495 if (list.size() == 2) {
496 return list.get(1);
497 }
498 else {
499 return null;
500 }
501 }
502
503
509 public void removeByCompanyId(long companyId) throws SystemException {
510 for (AssetCategoryProperty assetCategoryProperty : findByCompanyId(
511 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
512 remove(assetCategoryProperty);
513 }
514 }
515
516
523 public int countByCompanyId(long companyId) throws SystemException {
524 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
525
526 Object[] finderArgs = new Object[] { companyId };
527
528 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
529 this);
530
531 if (count == null) {
532 StringBundler query = new StringBundler(2);
533
534 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
535
536 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
537
538 String sql = query.toString();
539
540 Session session = null;
541
542 try {
543 session = openSession();
544
545 Query q = session.createQuery(sql);
546
547 QueryPos qPos = QueryPos.getInstance(q);
548
549 qPos.add(companyId);
550
551 count = (Long)q.uniqueResult();
552
553 FinderCacheUtil.putResult(finderPath, finderArgs, count);
554 }
555 catch (Exception e) {
556 FinderCacheUtil.removeResult(finderPath, finderArgs);
557
558 throw processException(e);
559 }
560 finally {
561 closeSession(session);
562 }
563 }
564
565 return count.intValue();
566 }
567
568 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetCategoryProperty.companyId = ?";
569 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CATEGORYID =
570 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
571 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
572 AssetCategoryPropertyImpl.class,
573 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCategoryId",
574 new String[] {
575 Long.class.getName(),
576
577 Integer.class.getName(), Integer.class.getName(),
578 OrderByComparator.class.getName()
579 });
580 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID =
581 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
582 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
583 AssetCategoryPropertyImpl.class,
584 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCategoryId",
585 new String[] { Long.class.getName() },
586 AssetCategoryPropertyModelImpl.CATEGORYID_COLUMN_BITMASK |
587 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
588 public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
589 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
590 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCategoryId",
591 new String[] { Long.class.getName() });
592
593
600 public List<AssetCategoryProperty> findByCategoryId(long categoryId)
601 throws SystemException {
602 return findByCategoryId(categoryId, QueryUtil.ALL_POS,
603 QueryUtil.ALL_POS, null);
604 }
605
606
619 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
620 int start, int end) throws SystemException {
621 return findByCategoryId(categoryId, start, end, null);
622 }
623
624
638 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
639 int start, int end, OrderByComparator orderByComparator)
640 throws SystemException {
641 boolean pagination = true;
642 FinderPath finderPath = null;
643 Object[] finderArgs = null;
644
645 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
646 (orderByComparator == null)) {
647 pagination = false;
648 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID;
649 finderArgs = new Object[] { categoryId };
650 }
651 else {
652 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CATEGORYID;
653 finderArgs = new Object[] { categoryId, start, end, orderByComparator };
654 }
655
656 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
657 finderArgs, this);
658
659 if ((list != null) && !list.isEmpty()) {
660 for (AssetCategoryProperty assetCategoryProperty : list) {
661 if ((categoryId != assetCategoryProperty.getCategoryId())) {
662 list = null;
663
664 break;
665 }
666 }
667 }
668
669 if (list == null) {
670 StringBundler query = null;
671
672 if (orderByComparator != null) {
673 query = new StringBundler(3 +
674 (orderByComparator.getOrderByFields().length * 3));
675 }
676 else {
677 query = new StringBundler(3);
678 }
679
680 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
681
682 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
683
684 if (orderByComparator != null) {
685 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
686 orderByComparator);
687 }
688 else
689 if (pagination) {
690 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
691 }
692
693 String sql = query.toString();
694
695 Session session = null;
696
697 try {
698 session = openSession();
699
700 Query q = session.createQuery(sql);
701
702 QueryPos qPos = QueryPos.getInstance(q);
703
704 qPos.add(categoryId);
705
706 if (!pagination) {
707 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
708 getDialect(), start, end, false);
709
710 Collections.sort(list);
711
712 list = new UnmodifiableList<AssetCategoryProperty>(list);
713 }
714 else {
715 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
716 getDialect(), start, end);
717 }
718
719 cacheResult(list);
720
721 FinderCacheUtil.putResult(finderPath, finderArgs, list);
722 }
723 catch (Exception e) {
724 FinderCacheUtil.removeResult(finderPath, finderArgs);
725
726 throw processException(e);
727 }
728 finally {
729 closeSession(session);
730 }
731 }
732
733 return list;
734 }
735
736
745 public AssetCategoryProperty findByCategoryId_First(long categoryId,
746 OrderByComparator orderByComparator)
747 throws NoSuchCategoryPropertyException, SystemException {
748 AssetCategoryProperty assetCategoryProperty = fetchByCategoryId_First(categoryId,
749 orderByComparator);
750
751 if (assetCategoryProperty != null) {
752 return assetCategoryProperty;
753 }
754
755 StringBundler msg = new StringBundler(4);
756
757 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
758
759 msg.append("categoryId=");
760 msg.append(categoryId);
761
762 msg.append(StringPool.CLOSE_CURLY_BRACE);
763
764 throw new NoSuchCategoryPropertyException(msg.toString());
765 }
766
767
775 public AssetCategoryProperty fetchByCategoryId_First(long categoryId,
776 OrderByComparator orderByComparator) throws SystemException {
777 List<AssetCategoryProperty> list = findByCategoryId(categoryId, 0, 1,
778 orderByComparator);
779
780 if (!list.isEmpty()) {
781 return list.get(0);
782 }
783
784 return null;
785 }
786
787
796 public AssetCategoryProperty findByCategoryId_Last(long categoryId,
797 OrderByComparator orderByComparator)
798 throws NoSuchCategoryPropertyException, SystemException {
799 AssetCategoryProperty assetCategoryProperty = fetchByCategoryId_Last(categoryId,
800 orderByComparator);
801
802 if (assetCategoryProperty != null) {
803 return assetCategoryProperty;
804 }
805
806 StringBundler msg = new StringBundler(4);
807
808 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
809
810 msg.append("categoryId=");
811 msg.append(categoryId);
812
813 msg.append(StringPool.CLOSE_CURLY_BRACE);
814
815 throw new NoSuchCategoryPropertyException(msg.toString());
816 }
817
818
826 public AssetCategoryProperty fetchByCategoryId_Last(long categoryId,
827 OrderByComparator orderByComparator) throws SystemException {
828 int count = countByCategoryId(categoryId);
829
830 List<AssetCategoryProperty> list = findByCategoryId(categoryId,
831 count - 1, count, orderByComparator);
832
833 if (!list.isEmpty()) {
834 return list.get(0);
835 }
836
837 return null;
838 }
839
840
850 public AssetCategoryProperty[] findByCategoryId_PrevAndNext(
851 long categoryPropertyId, long categoryId,
852 OrderByComparator orderByComparator)
853 throws NoSuchCategoryPropertyException, SystemException {
854 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
855
856 Session session = null;
857
858 try {
859 session = openSession();
860
861 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
862
863 array[0] = getByCategoryId_PrevAndNext(session,
864 assetCategoryProperty, categoryId, orderByComparator, true);
865
866 array[1] = assetCategoryProperty;
867
868 array[2] = getByCategoryId_PrevAndNext(session,
869 assetCategoryProperty, categoryId, orderByComparator, false);
870
871 return array;
872 }
873 catch (Exception e) {
874 throw processException(e);
875 }
876 finally {
877 closeSession(session);
878 }
879 }
880
881 protected AssetCategoryProperty getByCategoryId_PrevAndNext(
882 Session session, AssetCategoryProperty assetCategoryProperty,
883 long categoryId, OrderByComparator orderByComparator, boolean previous) {
884 StringBundler query = null;
885
886 if (orderByComparator != null) {
887 query = new StringBundler(6 +
888 (orderByComparator.getOrderByFields().length * 6));
889 }
890 else {
891 query = new StringBundler(3);
892 }
893
894 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
895
896 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
897
898 if (orderByComparator != null) {
899 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
900
901 if (orderByConditionFields.length > 0) {
902 query.append(WHERE_AND);
903 }
904
905 for (int i = 0; i < orderByConditionFields.length; i++) {
906 query.append(_ORDER_BY_ENTITY_ALIAS);
907 query.append(orderByConditionFields[i]);
908
909 if ((i + 1) < orderByConditionFields.length) {
910 if (orderByComparator.isAscending() ^ previous) {
911 query.append(WHERE_GREATER_THAN_HAS_NEXT);
912 }
913 else {
914 query.append(WHERE_LESSER_THAN_HAS_NEXT);
915 }
916 }
917 else {
918 if (orderByComparator.isAscending() ^ previous) {
919 query.append(WHERE_GREATER_THAN);
920 }
921 else {
922 query.append(WHERE_LESSER_THAN);
923 }
924 }
925 }
926
927 query.append(ORDER_BY_CLAUSE);
928
929 String[] orderByFields = orderByComparator.getOrderByFields();
930
931 for (int i = 0; i < orderByFields.length; i++) {
932 query.append(_ORDER_BY_ENTITY_ALIAS);
933 query.append(orderByFields[i]);
934
935 if ((i + 1) < orderByFields.length) {
936 if (orderByComparator.isAscending() ^ previous) {
937 query.append(ORDER_BY_ASC_HAS_NEXT);
938 }
939 else {
940 query.append(ORDER_BY_DESC_HAS_NEXT);
941 }
942 }
943 else {
944 if (orderByComparator.isAscending() ^ previous) {
945 query.append(ORDER_BY_ASC);
946 }
947 else {
948 query.append(ORDER_BY_DESC);
949 }
950 }
951 }
952 }
953 else {
954 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
955 }
956
957 String sql = query.toString();
958
959 Query q = session.createQuery(sql);
960
961 q.setFirstResult(0);
962 q.setMaxResults(2);
963
964 QueryPos qPos = QueryPos.getInstance(q);
965
966 qPos.add(categoryId);
967
968 if (orderByComparator != null) {
969 Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
970
971 for (Object value : values) {
972 qPos.add(value);
973 }
974 }
975
976 List<AssetCategoryProperty> list = q.list();
977
978 if (list.size() == 2) {
979 return list.get(1);
980 }
981 else {
982 return null;
983 }
984 }
985
986
992 public void removeByCategoryId(long categoryId) throws SystemException {
993 for (AssetCategoryProperty assetCategoryProperty : findByCategoryId(
994 categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
995 remove(assetCategoryProperty);
996 }
997 }
998
999
1006 public int countByCategoryId(long categoryId) throws SystemException {
1007 FinderPath finderPath = FINDER_PATH_COUNT_BY_CATEGORYID;
1008
1009 Object[] finderArgs = new Object[] { categoryId };
1010
1011 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1012 this);
1013
1014 if (count == null) {
1015 StringBundler query = new StringBundler(2);
1016
1017 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1018
1019 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1020
1021 String sql = query.toString();
1022
1023 Session session = null;
1024
1025 try {
1026 session = openSession();
1027
1028 Query q = session.createQuery(sql);
1029
1030 QueryPos qPos = QueryPos.getInstance(q);
1031
1032 qPos.add(categoryId);
1033
1034 count = (Long)q.uniqueResult();
1035
1036 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1037 }
1038 catch (Exception e) {
1039 FinderCacheUtil.removeResult(finderPath, finderArgs);
1040
1041 throw processException(e);
1042 }
1043 finally {
1044 closeSession(session);
1045 }
1046 }
1047
1048 return count.intValue();
1049 }
1050
1051 private static final String _FINDER_COLUMN_CATEGORYID_CATEGORYID_2 = "assetCategoryProperty.categoryId = ?";
1052 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1053 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
1054 AssetCategoryPropertyImpl.class,
1055 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_K",
1056 new String[] {
1057 Long.class.getName(), String.class.getName(),
1058
1059 Integer.class.getName(), Integer.class.getName(),
1060 OrderByComparator.class.getName()
1061 });
1062 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1063 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
1064 AssetCategoryPropertyImpl.class,
1065 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_K",
1066 new String[] { Long.class.getName(), String.class.getName() },
1067 AssetCategoryPropertyModelImpl.COMPANYID_COLUMN_BITMASK |
1068 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
1069 public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1070 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1071 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_K",
1072 new String[] { Long.class.getName(), String.class.getName() });
1073
1074
1082 public List<AssetCategoryProperty> findByC_K(long companyId, String key)
1083 throws SystemException {
1084 return findByC_K(companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1085 null);
1086 }
1087
1088
1102 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1103 int start, int end) throws SystemException {
1104 return findByC_K(companyId, key, start, end, null);
1105 }
1106
1107
1122 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1123 int start, int end, OrderByComparator orderByComparator)
1124 throws SystemException {
1125 boolean pagination = true;
1126 FinderPath finderPath = null;
1127 Object[] finderArgs = null;
1128
1129 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1130 (orderByComparator == null)) {
1131 pagination = false;
1132 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K;
1133 finderArgs = new Object[] { companyId, key };
1134 }
1135 else {
1136 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_K;
1137 finderArgs = new Object[] {
1138 companyId, key,
1139
1140 start, end, orderByComparator
1141 };
1142 }
1143
1144 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
1145 finderArgs, this);
1146
1147 if ((list != null) && !list.isEmpty()) {
1148 for (AssetCategoryProperty assetCategoryProperty : list) {
1149 if ((companyId != assetCategoryProperty.getCompanyId()) ||
1150 !Validator.equals(key, assetCategoryProperty.getKey())) {
1151 list = null;
1152
1153 break;
1154 }
1155 }
1156 }
1157
1158 if (list == null) {
1159 StringBundler query = null;
1160
1161 if (orderByComparator != null) {
1162 query = new StringBundler(4 +
1163 (orderByComparator.getOrderByFields().length * 3));
1164 }
1165 else {
1166 query = new StringBundler(4);
1167 }
1168
1169 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1170
1171 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1172
1173 boolean bindKey = false;
1174
1175 if (key == null) {
1176 query.append(_FINDER_COLUMN_C_K_KEY_1);
1177 }
1178 else if (key.equals(StringPool.BLANK)) {
1179 query.append(_FINDER_COLUMN_C_K_KEY_3);
1180 }
1181 else {
1182 bindKey = true;
1183
1184 query.append(_FINDER_COLUMN_C_K_KEY_2);
1185 }
1186
1187 if (orderByComparator != null) {
1188 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1189 orderByComparator);
1190 }
1191 else
1192 if (pagination) {
1193 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1194 }
1195
1196 String sql = query.toString();
1197
1198 Session session = null;
1199
1200 try {
1201 session = openSession();
1202
1203 Query q = session.createQuery(sql);
1204
1205 QueryPos qPos = QueryPos.getInstance(q);
1206
1207 qPos.add(companyId);
1208
1209 if (bindKey) {
1210 qPos.add(key);
1211 }
1212
1213 if (!pagination) {
1214 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1215 getDialect(), start, end, false);
1216
1217 Collections.sort(list);
1218
1219 list = new UnmodifiableList<AssetCategoryProperty>(list);
1220 }
1221 else {
1222 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1223 getDialect(), start, end);
1224 }
1225
1226 cacheResult(list);
1227
1228 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1229 }
1230 catch (Exception e) {
1231 FinderCacheUtil.removeResult(finderPath, finderArgs);
1232
1233 throw processException(e);
1234 }
1235 finally {
1236 closeSession(session);
1237 }
1238 }
1239
1240 return list;
1241 }
1242
1243
1253 public AssetCategoryProperty findByC_K_First(long companyId, String key,
1254 OrderByComparator orderByComparator)
1255 throws NoSuchCategoryPropertyException, SystemException {
1256 AssetCategoryProperty assetCategoryProperty = fetchByC_K_First(companyId,
1257 key, orderByComparator);
1258
1259 if (assetCategoryProperty != null) {
1260 return assetCategoryProperty;
1261 }
1262
1263 StringBundler msg = new StringBundler(6);
1264
1265 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1266
1267 msg.append("companyId=");
1268 msg.append(companyId);
1269
1270 msg.append(", key=");
1271 msg.append(key);
1272
1273 msg.append(StringPool.CLOSE_CURLY_BRACE);
1274
1275 throw new NoSuchCategoryPropertyException(msg.toString());
1276 }
1277
1278
1287 public AssetCategoryProperty fetchByC_K_First(long companyId, String key,
1288 OrderByComparator orderByComparator) throws SystemException {
1289 List<AssetCategoryProperty> list = findByC_K(companyId, key, 0, 1,
1290 orderByComparator);
1291
1292 if (!list.isEmpty()) {
1293 return list.get(0);
1294 }
1295
1296 return null;
1297 }
1298
1299
1309 public AssetCategoryProperty findByC_K_Last(long companyId, String key,
1310 OrderByComparator orderByComparator)
1311 throws NoSuchCategoryPropertyException, SystemException {
1312 AssetCategoryProperty assetCategoryProperty = fetchByC_K_Last(companyId,
1313 key, orderByComparator);
1314
1315 if (assetCategoryProperty != null) {
1316 return assetCategoryProperty;
1317 }
1318
1319 StringBundler msg = new StringBundler(6);
1320
1321 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1322
1323 msg.append("companyId=");
1324 msg.append(companyId);
1325
1326 msg.append(", key=");
1327 msg.append(key);
1328
1329 msg.append(StringPool.CLOSE_CURLY_BRACE);
1330
1331 throw new NoSuchCategoryPropertyException(msg.toString());
1332 }
1333
1334
1343 public AssetCategoryProperty fetchByC_K_Last(long companyId, String key,
1344 OrderByComparator orderByComparator) throws SystemException {
1345 int count = countByC_K(companyId, key);
1346
1347 List<AssetCategoryProperty> list = findByC_K(companyId, key, count - 1,
1348 count, orderByComparator);
1349
1350 if (!list.isEmpty()) {
1351 return list.get(0);
1352 }
1353
1354 return null;
1355 }
1356
1357
1368 public AssetCategoryProperty[] findByC_K_PrevAndNext(
1369 long categoryPropertyId, long companyId, String key,
1370 OrderByComparator orderByComparator)
1371 throws NoSuchCategoryPropertyException, SystemException {
1372 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1373
1374 Session session = null;
1375
1376 try {
1377 session = openSession();
1378
1379 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1380
1381 array[0] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1382 companyId, key, orderByComparator, true);
1383
1384 array[1] = assetCategoryProperty;
1385
1386 array[2] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1387 companyId, key, orderByComparator, false);
1388
1389 return array;
1390 }
1391 catch (Exception e) {
1392 throw processException(e);
1393 }
1394 finally {
1395 closeSession(session);
1396 }
1397 }
1398
1399 protected AssetCategoryProperty getByC_K_PrevAndNext(Session session,
1400 AssetCategoryProperty assetCategoryProperty, long companyId,
1401 String key, OrderByComparator orderByComparator, boolean previous) {
1402 StringBundler query = null;
1403
1404 if (orderByComparator != null) {
1405 query = new StringBundler(6 +
1406 (orderByComparator.getOrderByFields().length * 6));
1407 }
1408 else {
1409 query = new StringBundler(3);
1410 }
1411
1412 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1413
1414 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1415
1416 boolean bindKey = false;
1417
1418 if (key == null) {
1419 query.append(_FINDER_COLUMN_C_K_KEY_1);
1420 }
1421 else if (key.equals(StringPool.BLANK)) {
1422 query.append(_FINDER_COLUMN_C_K_KEY_3);
1423 }
1424 else {
1425 bindKey = true;
1426
1427 query.append(_FINDER_COLUMN_C_K_KEY_2);
1428 }
1429
1430 if (orderByComparator != null) {
1431 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1432
1433 if (orderByConditionFields.length > 0) {
1434 query.append(WHERE_AND);
1435 }
1436
1437 for (int i = 0; i < orderByConditionFields.length; i++) {
1438 query.append(_ORDER_BY_ENTITY_ALIAS);
1439 query.append(orderByConditionFields[i]);
1440
1441 if ((i + 1) < orderByConditionFields.length) {
1442 if (orderByComparator.isAscending() ^ previous) {
1443 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1444 }
1445 else {
1446 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1447 }
1448 }
1449 else {
1450 if (orderByComparator.isAscending() ^ previous) {
1451 query.append(WHERE_GREATER_THAN);
1452 }
1453 else {
1454 query.append(WHERE_LESSER_THAN);
1455 }
1456 }
1457 }
1458
1459 query.append(ORDER_BY_CLAUSE);
1460
1461 String[] orderByFields = orderByComparator.getOrderByFields();
1462
1463 for (int i = 0; i < orderByFields.length; i++) {
1464 query.append(_ORDER_BY_ENTITY_ALIAS);
1465 query.append(orderByFields[i]);
1466
1467 if ((i + 1) < orderByFields.length) {
1468 if (orderByComparator.isAscending() ^ previous) {
1469 query.append(ORDER_BY_ASC_HAS_NEXT);
1470 }
1471 else {
1472 query.append(ORDER_BY_DESC_HAS_NEXT);
1473 }
1474 }
1475 else {
1476 if (orderByComparator.isAscending() ^ previous) {
1477 query.append(ORDER_BY_ASC);
1478 }
1479 else {
1480 query.append(ORDER_BY_DESC);
1481 }
1482 }
1483 }
1484 }
1485 else {
1486 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1487 }
1488
1489 String sql = query.toString();
1490
1491 Query q = session.createQuery(sql);
1492
1493 q.setFirstResult(0);
1494 q.setMaxResults(2);
1495
1496 QueryPos qPos = QueryPos.getInstance(q);
1497
1498 qPos.add(companyId);
1499
1500 if (bindKey) {
1501 qPos.add(key);
1502 }
1503
1504 if (orderByComparator != null) {
1505 Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
1506
1507 for (Object value : values) {
1508 qPos.add(value);
1509 }
1510 }
1511
1512 List<AssetCategoryProperty> list = q.list();
1513
1514 if (list.size() == 2) {
1515 return list.get(1);
1516 }
1517 else {
1518 return null;
1519 }
1520 }
1521
1522
1529 public void removeByC_K(long companyId, String key)
1530 throws SystemException {
1531 for (AssetCategoryProperty assetCategoryProperty : findByC_K(
1532 companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1533 remove(assetCategoryProperty);
1534 }
1535 }
1536
1537
1545 public int countByC_K(long companyId, String key) throws SystemException {
1546 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_K;
1547
1548 Object[] finderArgs = new Object[] { companyId, key };
1549
1550 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1551 this);
1552
1553 if (count == null) {
1554 StringBundler query = new StringBundler(3);
1555
1556 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1557
1558 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1559
1560 boolean bindKey = false;
1561
1562 if (key == null) {
1563 query.append(_FINDER_COLUMN_C_K_KEY_1);
1564 }
1565 else if (key.equals(StringPool.BLANK)) {
1566 query.append(_FINDER_COLUMN_C_K_KEY_3);
1567 }
1568 else {
1569 bindKey = true;
1570
1571 query.append(_FINDER_COLUMN_C_K_KEY_2);
1572 }
1573
1574 String sql = query.toString();
1575
1576 Session session = null;
1577
1578 try {
1579 session = openSession();
1580
1581 Query q = session.createQuery(sql);
1582
1583 QueryPos qPos = QueryPos.getInstance(q);
1584
1585 qPos.add(companyId);
1586
1587 if (bindKey) {
1588 qPos.add(key);
1589 }
1590
1591 count = (Long)q.uniqueResult();
1592
1593 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1594 }
1595 catch (Exception e) {
1596 FinderCacheUtil.removeResult(finderPath, finderArgs);
1597
1598 throw processException(e);
1599 }
1600 finally {
1601 closeSession(session);
1602 }
1603 }
1604
1605 return count.intValue();
1606 }
1607
1608 private static final String _FINDER_COLUMN_C_K_COMPANYID_2 = "assetCategoryProperty.companyId = ? AND ";
1609 private static final String _FINDER_COLUMN_C_K_KEY_1 = "assetCategoryProperty.key IS NULL";
1610 private static final String _FINDER_COLUMN_C_K_KEY_2 = "assetCategoryProperty.key = ?";
1611 private static final String _FINDER_COLUMN_C_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = '')";
1612 public static final FinderPath FINDER_PATH_FETCH_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1613 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
1614 AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_ENTITY,
1615 "fetchByCA_K",
1616 new String[] { Long.class.getName(), String.class.getName() },
1617 AssetCategoryPropertyModelImpl.CATEGORYID_COLUMN_BITMASK |
1618 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
1619 public static final FinderPath FINDER_PATH_COUNT_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1620 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1621 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCA_K",
1622 new String[] { Long.class.getName(), String.class.getName() });
1623
1624
1633 public AssetCategoryProperty findByCA_K(long categoryId, String key)
1634 throws NoSuchCategoryPropertyException, SystemException {
1635 AssetCategoryProperty assetCategoryProperty = fetchByCA_K(categoryId,
1636 key);
1637
1638 if (assetCategoryProperty == null) {
1639 StringBundler msg = new StringBundler(6);
1640
1641 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1642
1643 msg.append("categoryId=");
1644 msg.append(categoryId);
1645
1646 msg.append(", key=");
1647 msg.append(key);
1648
1649 msg.append(StringPool.CLOSE_CURLY_BRACE);
1650
1651 if (_log.isWarnEnabled()) {
1652 _log.warn(msg.toString());
1653 }
1654
1655 throw new NoSuchCategoryPropertyException(msg.toString());
1656 }
1657
1658 return assetCategoryProperty;
1659 }
1660
1661
1669 public AssetCategoryProperty fetchByCA_K(long categoryId, String key)
1670 throws SystemException {
1671 return fetchByCA_K(categoryId, key, true);
1672 }
1673
1674
1683 public AssetCategoryProperty fetchByCA_K(long categoryId, String key,
1684 boolean retrieveFromCache) throws SystemException {
1685 Object[] finderArgs = new Object[] { categoryId, key };
1686
1687 Object result = null;
1688
1689 if (retrieveFromCache) {
1690 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CA_K,
1691 finderArgs, this);
1692 }
1693
1694 if (result instanceof AssetCategoryProperty) {
1695 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)result;
1696
1697 if ((categoryId != assetCategoryProperty.getCategoryId()) ||
1698 !Validator.equals(key, assetCategoryProperty.getKey())) {
1699 result = null;
1700 }
1701 }
1702
1703 if (result == null) {
1704 StringBundler query = new StringBundler(4);
1705
1706 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1707
1708 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1709
1710 boolean bindKey = false;
1711
1712 if (key == null) {
1713 query.append(_FINDER_COLUMN_CA_K_KEY_1);
1714 }
1715 else if (key.equals(StringPool.BLANK)) {
1716 query.append(_FINDER_COLUMN_CA_K_KEY_3);
1717 }
1718 else {
1719 bindKey = true;
1720
1721 query.append(_FINDER_COLUMN_CA_K_KEY_2);
1722 }
1723
1724 String sql = query.toString();
1725
1726 Session session = null;
1727
1728 try {
1729 session = openSession();
1730
1731 Query q = session.createQuery(sql);
1732
1733 QueryPos qPos = QueryPos.getInstance(q);
1734
1735 qPos.add(categoryId);
1736
1737 if (bindKey) {
1738 qPos.add(key);
1739 }
1740
1741 List<AssetCategoryProperty> list = q.list();
1742
1743 if (list.isEmpty()) {
1744 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1745 finderArgs, list);
1746 }
1747 else {
1748 AssetCategoryProperty assetCategoryProperty = list.get(0);
1749
1750 result = assetCategoryProperty;
1751
1752 cacheResult(assetCategoryProperty);
1753
1754 if ((assetCategoryProperty.getCategoryId() != categoryId) ||
1755 (assetCategoryProperty.getKey() == null) ||
1756 !assetCategoryProperty.getKey().equals(key)) {
1757 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1758 finderArgs, assetCategoryProperty);
1759 }
1760 }
1761 }
1762 catch (Exception e) {
1763 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
1764 finderArgs);
1765
1766 throw processException(e);
1767 }
1768 finally {
1769 closeSession(session);
1770 }
1771 }
1772
1773 if (result instanceof List<?>) {
1774 return null;
1775 }
1776 else {
1777 return (AssetCategoryProperty)result;
1778 }
1779 }
1780
1781
1789 public AssetCategoryProperty removeByCA_K(long categoryId, String key)
1790 throws NoSuchCategoryPropertyException, SystemException {
1791 AssetCategoryProperty assetCategoryProperty = findByCA_K(categoryId, key);
1792
1793 return remove(assetCategoryProperty);
1794 }
1795
1796
1804 public int countByCA_K(long categoryId, String key)
1805 throws SystemException {
1806 FinderPath finderPath = FINDER_PATH_COUNT_BY_CA_K;
1807
1808 Object[] finderArgs = new Object[] { categoryId, key };
1809
1810 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1811 this);
1812
1813 if (count == null) {
1814 StringBundler query = new StringBundler(3);
1815
1816 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1817
1818 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1819
1820 boolean bindKey = false;
1821
1822 if (key == null) {
1823 query.append(_FINDER_COLUMN_CA_K_KEY_1);
1824 }
1825 else if (key.equals(StringPool.BLANK)) {
1826 query.append(_FINDER_COLUMN_CA_K_KEY_3);
1827 }
1828 else {
1829 bindKey = true;
1830
1831 query.append(_FINDER_COLUMN_CA_K_KEY_2);
1832 }
1833
1834 String sql = query.toString();
1835
1836 Session session = null;
1837
1838 try {
1839 session = openSession();
1840
1841 Query q = session.createQuery(sql);
1842
1843 QueryPos qPos = QueryPos.getInstance(q);
1844
1845 qPos.add(categoryId);
1846
1847 if (bindKey) {
1848 qPos.add(key);
1849 }
1850
1851 count = (Long)q.uniqueResult();
1852
1853 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1854 }
1855 catch (Exception e) {
1856 FinderCacheUtil.removeResult(finderPath, finderArgs);
1857
1858 throw processException(e);
1859 }
1860 finally {
1861 closeSession(session);
1862 }
1863 }
1864
1865 return count.intValue();
1866 }
1867
1868 private static final String _FINDER_COLUMN_CA_K_CATEGORYID_2 = "assetCategoryProperty.categoryId = ? AND ";
1869 private static final String _FINDER_COLUMN_CA_K_KEY_1 = "assetCategoryProperty.key IS NULL";
1870 private static final String _FINDER_COLUMN_CA_K_KEY_2 = "assetCategoryProperty.key = ?";
1871 private static final String _FINDER_COLUMN_CA_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = '')";
1872
1873
1878 public void cacheResult(AssetCategoryProperty assetCategoryProperty) {
1879 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1880 AssetCategoryPropertyImpl.class,
1881 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
1882
1883 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1884 new Object[] {
1885 assetCategoryProperty.getCategoryId(),
1886 assetCategoryProperty.getKey()
1887 }, assetCategoryProperty);
1888
1889 assetCategoryProperty.resetOriginalValues();
1890 }
1891
1892
1897 public void cacheResult(List<AssetCategoryProperty> assetCategoryProperties) {
1898 for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
1899 if (EntityCacheUtil.getResult(
1900 AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1901 AssetCategoryPropertyImpl.class,
1902 assetCategoryProperty.getPrimaryKey()) == null) {
1903 cacheResult(assetCategoryProperty);
1904 }
1905 else {
1906 assetCategoryProperty.resetOriginalValues();
1907 }
1908 }
1909 }
1910
1911
1918 @Override
1919 public void clearCache() {
1920 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1921 CacheRegistryUtil.clear(AssetCategoryPropertyImpl.class.getName());
1922 }
1923
1924 EntityCacheUtil.clearCache(AssetCategoryPropertyImpl.class.getName());
1925
1926 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1927 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1928 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1929 }
1930
1931
1938 @Override
1939 public void clearCache(AssetCategoryProperty assetCategoryProperty) {
1940 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1941 AssetCategoryPropertyImpl.class,
1942 assetCategoryProperty.getPrimaryKey());
1943
1944 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1945 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1946
1947 clearUniqueFindersCache(assetCategoryProperty);
1948 }
1949
1950 @Override
1951 public void clearCache(List<AssetCategoryProperty> assetCategoryProperties) {
1952 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1953 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1954
1955 for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
1956 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1957 AssetCategoryPropertyImpl.class,
1958 assetCategoryProperty.getPrimaryKey());
1959
1960 clearUniqueFindersCache(assetCategoryProperty);
1961 }
1962 }
1963
1964 protected void cacheUniqueFindersCache(
1965 AssetCategoryProperty assetCategoryProperty) {
1966 if (assetCategoryProperty.isNew()) {
1967 Object[] args = new Object[] {
1968 assetCategoryProperty.getCategoryId(),
1969 assetCategoryProperty.getKey()
1970 };
1971
1972 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K, args,
1973 Long.valueOf(1));
1974 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K, args,
1975 assetCategoryProperty);
1976 }
1977 else {
1978 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
1979
1980 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
1981 FINDER_PATH_FETCH_BY_CA_K.getColumnBitmask()) != 0) {
1982 Object[] args = new Object[] {
1983 assetCategoryProperty.getCategoryId(),
1984 assetCategoryProperty.getKey()
1985 };
1986
1987 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K, args,
1988 Long.valueOf(1));
1989 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K, args,
1990 assetCategoryProperty);
1991 }
1992 }
1993 }
1994
1995 protected void clearUniqueFindersCache(
1996 AssetCategoryProperty assetCategoryProperty) {
1997 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
1998
1999 Object[] args = new Object[] {
2000 assetCategoryProperty.getCategoryId(),
2001 assetCategoryProperty.getKey()
2002 };
2003
2004 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CA_K, args);
2005 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K, args);
2006
2007 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2008 FINDER_PATH_FETCH_BY_CA_K.getColumnBitmask()) != 0) {
2009 args = new Object[] {
2010 assetCategoryPropertyModelImpl.getOriginalCategoryId(),
2011 assetCategoryPropertyModelImpl.getOriginalKey()
2012 };
2013
2014 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CA_K, args);
2015 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K, args);
2016 }
2017 }
2018
2019
2025 public AssetCategoryProperty create(long categoryPropertyId) {
2026 AssetCategoryProperty assetCategoryProperty = new AssetCategoryPropertyImpl();
2027
2028 assetCategoryProperty.setNew(true);
2029 assetCategoryProperty.setPrimaryKey(categoryPropertyId);
2030
2031 return assetCategoryProperty;
2032 }
2033
2034
2042 public AssetCategoryProperty remove(long categoryPropertyId)
2043 throws NoSuchCategoryPropertyException, SystemException {
2044 return remove((Serializable)categoryPropertyId);
2045 }
2046
2047
2055 @Override
2056 public AssetCategoryProperty remove(Serializable primaryKey)
2057 throws NoSuchCategoryPropertyException, SystemException {
2058 Session session = null;
2059
2060 try {
2061 session = openSession();
2062
2063 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
2064 primaryKey);
2065
2066 if (assetCategoryProperty == null) {
2067 if (_log.isWarnEnabled()) {
2068 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2069 }
2070
2071 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2072 primaryKey);
2073 }
2074
2075 return remove(assetCategoryProperty);
2076 }
2077 catch (NoSuchCategoryPropertyException nsee) {
2078 throw nsee;
2079 }
2080 catch (Exception e) {
2081 throw processException(e);
2082 }
2083 finally {
2084 closeSession(session);
2085 }
2086 }
2087
2088 @Override
2089 protected AssetCategoryProperty removeImpl(
2090 AssetCategoryProperty assetCategoryProperty) throws SystemException {
2091 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
2092
2093 Session session = null;
2094
2095 try {
2096 session = openSession();
2097
2098 if (!session.contains(assetCategoryProperty)) {
2099 assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
2100 assetCategoryProperty.getPrimaryKeyObj());
2101 }
2102
2103 if (assetCategoryProperty != null) {
2104 session.delete(assetCategoryProperty);
2105 }
2106 }
2107 catch (Exception e) {
2108 throw processException(e);
2109 }
2110 finally {
2111 closeSession(session);
2112 }
2113
2114 if (assetCategoryProperty != null) {
2115 clearCache(assetCategoryProperty);
2116 }
2117
2118 return assetCategoryProperty;
2119 }
2120
2121 @Override
2122 public AssetCategoryProperty updateImpl(
2123 com.liferay.portlet.asset.model.AssetCategoryProperty assetCategoryProperty)
2124 throws SystemException {
2125 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
2126
2127 boolean isNew = assetCategoryProperty.isNew();
2128
2129 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
2130
2131 Session session = null;
2132
2133 try {
2134 session = openSession();
2135
2136 if (assetCategoryProperty.isNew()) {
2137 session.save(assetCategoryProperty);
2138
2139 assetCategoryProperty.setNew(false);
2140 }
2141 else {
2142 session.merge(assetCategoryProperty);
2143 }
2144 }
2145 catch (Exception e) {
2146 throw processException(e);
2147 }
2148 finally {
2149 closeSession(session);
2150 }
2151
2152 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2153
2154 if (isNew || !AssetCategoryPropertyModelImpl.COLUMN_BITMASK_ENABLED) {
2155 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2156 }
2157
2158 else {
2159 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2160 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
2161 Object[] args = new Object[] {
2162 assetCategoryPropertyModelImpl.getOriginalCompanyId()
2163 };
2164
2165 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2166 args);
2167 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2168 args);
2169
2170 args = new Object[] {
2171 assetCategoryPropertyModelImpl.getCompanyId()
2172 };
2173
2174 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2175 args);
2176 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2177 args);
2178 }
2179
2180 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2181 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID.getColumnBitmask()) != 0) {
2182 Object[] args = new Object[] {
2183 assetCategoryPropertyModelImpl.getOriginalCategoryId()
2184 };
2185
2186 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID,
2187 args);
2188 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID,
2189 args);
2190
2191 args = new Object[] {
2192 assetCategoryPropertyModelImpl.getCategoryId()
2193 };
2194
2195 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID,
2196 args);
2197 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID,
2198 args);
2199 }
2200
2201 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2202 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K.getColumnBitmask()) != 0) {
2203 Object[] args = new Object[] {
2204 assetCategoryPropertyModelImpl.getOriginalCompanyId(),
2205 assetCategoryPropertyModelImpl.getOriginalKey()
2206 };
2207
2208 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
2209 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K,
2210 args);
2211
2212 args = new Object[] {
2213 assetCategoryPropertyModelImpl.getCompanyId(),
2214 assetCategoryPropertyModelImpl.getKey()
2215 };
2216
2217 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
2218 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K,
2219 args);
2220 }
2221 }
2222
2223 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2224 AssetCategoryPropertyImpl.class,
2225 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
2226
2227 clearUniqueFindersCache(assetCategoryProperty);
2228 cacheUniqueFindersCache(assetCategoryProperty);
2229
2230 return assetCategoryProperty;
2231 }
2232
2233 protected AssetCategoryProperty toUnwrappedModel(
2234 AssetCategoryProperty assetCategoryProperty) {
2235 if (assetCategoryProperty instanceof AssetCategoryPropertyImpl) {
2236 return assetCategoryProperty;
2237 }
2238
2239 AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
2240
2241 assetCategoryPropertyImpl.setNew(assetCategoryProperty.isNew());
2242 assetCategoryPropertyImpl.setPrimaryKey(assetCategoryProperty.getPrimaryKey());
2243
2244 assetCategoryPropertyImpl.setCategoryPropertyId(assetCategoryProperty.getCategoryPropertyId());
2245 assetCategoryPropertyImpl.setCompanyId(assetCategoryProperty.getCompanyId());
2246 assetCategoryPropertyImpl.setUserId(assetCategoryProperty.getUserId());
2247 assetCategoryPropertyImpl.setUserName(assetCategoryProperty.getUserName());
2248 assetCategoryPropertyImpl.setCreateDate(assetCategoryProperty.getCreateDate());
2249 assetCategoryPropertyImpl.setModifiedDate(assetCategoryProperty.getModifiedDate());
2250 assetCategoryPropertyImpl.setCategoryId(assetCategoryProperty.getCategoryId());
2251 assetCategoryPropertyImpl.setKey(assetCategoryProperty.getKey());
2252 assetCategoryPropertyImpl.setValue(assetCategoryProperty.getValue());
2253
2254 return assetCategoryPropertyImpl;
2255 }
2256
2257
2265 @Override
2266 public AssetCategoryProperty findByPrimaryKey(Serializable primaryKey)
2267 throws NoSuchCategoryPropertyException, SystemException {
2268 AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(primaryKey);
2269
2270 if (assetCategoryProperty == null) {
2271 if (_log.isWarnEnabled()) {
2272 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2273 }
2274
2275 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2276 primaryKey);
2277 }
2278
2279 return assetCategoryProperty;
2280 }
2281
2282
2290 public AssetCategoryProperty findByPrimaryKey(long categoryPropertyId)
2291 throws NoSuchCategoryPropertyException, SystemException {
2292 return findByPrimaryKey((Serializable)categoryPropertyId);
2293 }
2294
2295
2302 @Override
2303 public AssetCategoryProperty fetchByPrimaryKey(Serializable primaryKey)
2304 throws SystemException {
2305 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)EntityCacheUtil.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2306 AssetCategoryPropertyImpl.class, primaryKey);
2307
2308 if (assetCategoryProperty == _nullAssetCategoryProperty) {
2309 return null;
2310 }
2311
2312 if (assetCategoryProperty == null) {
2313 Session session = null;
2314
2315 try {
2316 session = openSession();
2317
2318 assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
2319 primaryKey);
2320
2321 if (assetCategoryProperty != null) {
2322 cacheResult(assetCategoryProperty);
2323 }
2324 else {
2325 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2326 AssetCategoryPropertyImpl.class, primaryKey,
2327 _nullAssetCategoryProperty);
2328 }
2329 }
2330 catch (Exception e) {
2331 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2332 AssetCategoryPropertyImpl.class, primaryKey);
2333
2334 throw processException(e);
2335 }
2336 finally {
2337 closeSession(session);
2338 }
2339 }
2340
2341 return assetCategoryProperty;
2342 }
2343
2344
2351 public AssetCategoryProperty fetchByPrimaryKey(long categoryPropertyId)
2352 throws SystemException {
2353 return fetchByPrimaryKey((Serializable)categoryPropertyId);
2354 }
2355
2356
2362 public List<AssetCategoryProperty> findAll() throws SystemException {
2363 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2364 }
2365
2366
2378 public List<AssetCategoryProperty> findAll(int start, int end)
2379 throws SystemException {
2380 return findAll(start, end, null);
2381 }
2382
2383
2396 public List<AssetCategoryProperty> findAll(int start, int end,
2397 OrderByComparator orderByComparator) throws SystemException {
2398 boolean pagination = true;
2399 FinderPath finderPath = null;
2400 Object[] finderArgs = null;
2401
2402 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2403 (orderByComparator == null)) {
2404 pagination = false;
2405 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2406 finderArgs = FINDER_ARGS_EMPTY;
2407 }
2408 else {
2409 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2410 finderArgs = new Object[] { start, end, orderByComparator };
2411 }
2412
2413 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
2414 finderArgs, this);
2415
2416 if (list == null) {
2417 StringBundler query = null;
2418 String sql = null;
2419
2420 if (orderByComparator != null) {
2421 query = new StringBundler(2 +
2422 (orderByComparator.getOrderByFields().length * 3));
2423
2424 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY);
2425
2426 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2427 orderByComparator);
2428
2429 sql = query.toString();
2430 }
2431 else {
2432 sql = _SQL_SELECT_ASSETCATEGORYPROPERTY;
2433
2434 if (pagination) {
2435 sql = sql.concat(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
2436 }
2437 }
2438
2439 Session session = null;
2440
2441 try {
2442 session = openSession();
2443
2444 Query q = session.createQuery(sql);
2445
2446 if (!pagination) {
2447 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
2448 getDialect(), start, end, false);
2449
2450 Collections.sort(list);
2451
2452 list = new UnmodifiableList<AssetCategoryProperty>(list);
2453 }
2454 else {
2455 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
2456 getDialect(), start, end);
2457 }
2458
2459 cacheResult(list);
2460
2461 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2462 }
2463 catch (Exception e) {
2464 FinderCacheUtil.removeResult(finderPath, finderArgs);
2465
2466 throw processException(e);
2467 }
2468 finally {
2469 closeSession(session);
2470 }
2471 }
2472
2473 return list;
2474 }
2475
2476
2481 public void removeAll() throws SystemException {
2482 for (AssetCategoryProperty assetCategoryProperty : findAll()) {
2483 remove(assetCategoryProperty);
2484 }
2485 }
2486
2487
2493 public int countAll() throws SystemException {
2494 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2495 FINDER_ARGS_EMPTY, this);
2496
2497 if (count == null) {
2498 Session session = null;
2499
2500 try {
2501 session = openSession();
2502
2503 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORYPROPERTY);
2504
2505 count = (Long)q.uniqueResult();
2506
2507 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2508 FINDER_ARGS_EMPTY, count);
2509 }
2510 catch (Exception e) {
2511 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2512 FINDER_ARGS_EMPTY);
2513
2514 throw processException(e);
2515 }
2516 finally {
2517 closeSession(session);
2518 }
2519 }
2520
2521 return count.intValue();
2522 }
2523
2524
2527 public void afterPropertiesSet() {
2528 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2529 com.liferay.portal.util.PropsUtil.get(
2530 "value.object.listener.com.liferay.portlet.asset.model.AssetCategoryProperty")));
2531
2532 if (listenerClassNames.length > 0) {
2533 try {
2534 List<ModelListener<AssetCategoryProperty>> listenersList = new ArrayList<ModelListener<AssetCategoryProperty>>();
2535
2536 for (String listenerClassName : listenerClassNames) {
2537 listenersList.add((ModelListener<AssetCategoryProperty>)InstanceFactory.newInstance(
2538 listenerClassName));
2539 }
2540
2541 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2542 }
2543 catch (Exception e) {
2544 _log.error(e);
2545 }
2546 }
2547 }
2548
2549 public void destroy() {
2550 EntityCacheUtil.removeCache(AssetCategoryPropertyImpl.class.getName());
2551 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2552 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2553 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2554 }
2555
2556 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty";
2557 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2558 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty";
2559 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2560 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategoryProperty.";
2561 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategoryProperty exists with the primary key ";
2562 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategoryProperty exists with the key {";
2563 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2564 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPropertyPersistenceImpl.class);
2565 private static AssetCategoryProperty _nullAssetCategoryProperty = new AssetCategoryPropertyImpl() {
2566 @Override
2567 public Object clone() {
2568 return this;
2569 }
2570
2571 @Override
2572 public CacheModel<AssetCategoryProperty> toCacheModel() {
2573 return _nullAssetCategoryPropertyCacheModel;
2574 }
2575 };
2576
2577 private static CacheModel<AssetCategoryProperty> _nullAssetCategoryPropertyCacheModel =
2578 new CacheModel<AssetCategoryProperty>() {
2579 public AssetCategoryProperty toEntityModel() {
2580 return _nullAssetCategoryProperty;
2581 }
2582 };
2583 }