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.SetUtil;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.StringUtil;
035 import com.liferay.portal.kernel.util.UnmodifiableList;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
040
041 import com.liferay.portlet.asset.NoSuchCategoryPropertyException;
042 import com.liferay.portlet.asset.model.AssetCategoryProperty;
043 import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyImpl;
044 import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyModelImpl;
045
046 import java.io.Serializable;
047
048 import java.util.ArrayList;
049 import java.util.Collections;
050 import java.util.List;
051 import java.util.Set;
052
053
065 public class AssetCategoryPropertyPersistenceImpl extends BasePersistenceImpl<AssetCategoryProperty>
066 implements AssetCategoryPropertyPersistence {
067
072 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryPropertyImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List1";
075 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List2";
077 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
078 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
079 AssetCategoryPropertyImpl.class,
080 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
082 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
083 AssetCategoryPropertyImpl.class,
084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
086 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
089 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
090 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
091 AssetCategoryPropertyImpl.class,
092 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
093 new String[] {
094 Long.class.getName(),
095
096 Integer.class.getName(), Integer.class.getName(),
097 OrderByComparator.class.getName()
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
100 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
101 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
102 AssetCategoryPropertyImpl.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
104 new String[] { Long.class.getName() },
105 AssetCategoryPropertyModelImpl.COMPANYID_COLUMN_BITMASK |
106 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
107 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
108 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
109 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
110 new String[] { Long.class.getName() });
111
112
119 @Override
120 public List<AssetCategoryProperty> findByCompanyId(long companyId)
121 throws SystemException {
122 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
123 null);
124 }
125
126
139 @Override
140 public List<AssetCategoryProperty> findByCompanyId(long companyId,
141 int start, int end) throws SystemException {
142 return findByCompanyId(companyId, start, end, null);
143 }
144
145
159 @Override
160 public List<AssetCategoryProperty> findByCompanyId(long companyId,
161 int start, int end, OrderByComparator orderByComparator)
162 throws SystemException {
163 boolean pagination = true;
164 FinderPath finderPath = null;
165 Object[] finderArgs = null;
166
167 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
168 (orderByComparator == null)) {
169 pagination = false;
170 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
171 finderArgs = new Object[] { companyId };
172 }
173 else {
174 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
175 finderArgs = new Object[] { companyId, start, end, orderByComparator };
176 }
177
178 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
179 finderArgs, this);
180
181 if ((list != null) && !list.isEmpty()) {
182 for (AssetCategoryProperty assetCategoryProperty : list) {
183 if ((companyId != assetCategoryProperty.getCompanyId())) {
184 list = null;
185
186 break;
187 }
188 }
189 }
190
191 if (list == null) {
192 StringBundler query = null;
193
194 if (orderByComparator != null) {
195 query = new StringBundler(3 +
196 (orderByComparator.getOrderByFields().length * 3));
197 }
198 else {
199 query = new StringBundler(3);
200 }
201
202 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
203
204 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
205
206 if (orderByComparator != null) {
207 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
208 orderByComparator);
209 }
210 else
211 if (pagination) {
212 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
213 }
214
215 String sql = query.toString();
216
217 Session session = null;
218
219 try {
220 session = openSession();
221
222 Query q = session.createQuery(sql);
223
224 QueryPos qPos = QueryPos.getInstance(q);
225
226 qPos.add(companyId);
227
228 if (!pagination) {
229 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
230 getDialect(), start, end, false);
231
232 Collections.sort(list);
233
234 list = new UnmodifiableList<AssetCategoryProperty>(list);
235 }
236 else {
237 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
238 getDialect(), start, end);
239 }
240
241 cacheResult(list);
242
243 FinderCacheUtil.putResult(finderPath, finderArgs, list);
244 }
245 catch (Exception e) {
246 FinderCacheUtil.removeResult(finderPath, finderArgs);
247
248 throw processException(e);
249 }
250 finally {
251 closeSession(session);
252 }
253 }
254
255 return list;
256 }
257
258
267 @Override
268 public AssetCategoryProperty findByCompanyId_First(long companyId,
269 OrderByComparator orderByComparator)
270 throws NoSuchCategoryPropertyException, SystemException {
271 AssetCategoryProperty assetCategoryProperty = fetchByCompanyId_First(companyId,
272 orderByComparator);
273
274 if (assetCategoryProperty != null) {
275 return assetCategoryProperty;
276 }
277
278 StringBundler msg = new StringBundler(4);
279
280 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
281
282 msg.append("companyId=");
283 msg.append(companyId);
284
285 msg.append(StringPool.CLOSE_CURLY_BRACE);
286
287 throw new NoSuchCategoryPropertyException(msg.toString());
288 }
289
290
298 @Override
299 public AssetCategoryProperty fetchByCompanyId_First(long companyId,
300 OrderByComparator orderByComparator) throws SystemException {
301 List<AssetCategoryProperty> list = findByCompanyId(companyId, 0, 1,
302 orderByComparator);
303
304 if (!list.isEmpty()) {
305 return list.get(0);
306 }
307
308 return null;
309 }
310
311
320 @Override
321 public AssetCategoryProperty findByCompanyId_Last(long companyId,
322 OrderByComparator orderByComparator)
323 throws NoSuchCategoryPropertyException, SystemException {
324 AssetCategoryProperty assetCategoryProperty = fetchByCompanyId_Last(companyId,
325 orderByComparator);
326
327 if (assetCategoryProperty != null) {
328 return assetCategoryProperty;
329 }
330
331 StringBundler msg = new StringBundler(4);
332
333 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
334
335 msg.append("companyId=");
336 msg.append(companyId);
337
338 msg.append(StringPool.CLOSE_CURLY_BRACE);
339
340 throw new NoSuchCategoryPropertyException(msg.toString());
341 }
342
343
351 @Override
352 public AssetCategoryProperty fetchByCompanyId_Last(long companyId,
353 OrderByComparator orderByComparator) throws SystemException {
354 int count = countByCompanyId(companyId);
355
356 if (count == 0) {
357 return null;
358 }
359
360 List<AssetCategoryProperty> list = findByCompanyId(companyId,
361 count - 1, count, orderByComparator);
362
363 if (!list.isEmpty()) {
364 return list.get(0);
365 }
366
367 return null;
368 }
369
370
380 @Override
381 public AssetCategoryProperty[] findByCompanyId_PrevAndNext(
382 long categoryPropertyId, long companyId,
383 OrderByComparator orderByComparator)
384 throws NoSuchCategoryPropertyException, SystemException {
385 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
386
387 Session session = null;
388
389 try {
390 session = openSession();
391
392 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
393
394 array[0] = getByCompanyId_PrevAndNext(session,
395 assetCategoryProperty, companyId, orderByComparator, true);
396
397 array[1] = assetCategoryProperty;
398
399 array[2] = getByCompanyId_PrevAndNext(session,
400 assetCategoryProperty, companyId, orderByComparator, false);
401
402 return array;
403 }
404 catch (Exception e) {
405 throw processException(e);
406 }
407 finally {
408 closeSession(session);
409 }
410 }
411
412 protected AssetCategoryProperty getByCompanyId_PrevAndNext(
413 Session session, AssetCategoryProperty assetCategoryProperty,
414 long companyId, OrderByComparator orderByComparator, boolean previous) {
415 StringBundler query = null;
416
417 if (orderByComparator != null) {
418 query = new StringBundler(6 +
419 (orderByComparator.getOrderByFields().length * 6));
420 }
421 else {
422 query = new StringBundler(3);
423 }
424
425 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
426
427 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
428
429 if (orderByComparator != null) {
430 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
431
432 if (orderByConditionFields.length > 0) {
433 query.append(WHERE_AND);
434 }
435
436 for (int i = 0; i < orderByConditionFields.length; i++) {
437 query.append(_ORDER_BY_ENTITY_ALIAS);
438 query.append(orderByConditionFields[i]);
439
440 if ((i + 1) < orderByConditionFields.length) {
441 if (orderByComparator.isAscending() ^ previous) {
442 query.append(WHERE_GREATER_THAN_HAS_NEXT);
443 }
444 else {
445 query.append(WHERE_LESSER_THAN_HAS_NEXT);
446 }
447 }
448 else {
449 if (orderByComparator.isAscending() ^ previous) {
450 query.append(WHERE_GREATER_THAN);
451 }
452 else {
453 query.append(WHERE_LESSER_THAN);
454 }
455 }
456 }
457
458 query.append(ORDER_BY_CLAUSE);
459
460 String[] orderByFields = orderByComparator.getOrderByFields();
461
462 for (int i = 0; i < orderByFields.length; i++) {
463 query.append(_ORDER_BY_ENTITY_ALIAS);
464 query.append(orderByFields[i]);
465
466 if ((i + 1) < orderByFields.length) {
467 if (orderByComparator.isAscending() ^ previous) {
468 query.append(ORDER_BY_ASC_HAS_NEXT);
469 }
470 else {
471 query.append(ORDER_BY_DESC_HAS_NEXT);
472 }
473 }
474 else {
475 if (orderByComparator.isAscending() ^ previous) {
476 query.append(ORDER_BY_ASC);
477 }
478 else {
479 query.append(ORDER_BY_DESC);
480 }
481 }
482 }
483 }
484 else {
485 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
486 }
487
488 String sql = query.toString();
489
490 Query q = session.createQuery(sql);
491
492 q.setFirstResult(0);
493 q.setMaxResults(2);
494
495 QueryPos qPos = QueryPos.getInstance(q);
496
497 qPos.add(companyId);
498
499 if (orderByComparator != null) {
500 Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
501
502 for (Object value : values) {
503 qPos.add(value);
504 }
505 }
506
507 List<AssetCategoryProperty> list = q.list();
508
509 if (list.size() == 2) {
510 return list.get(1);
511 }
512 else {
513 return null;
514 }
515 }
516
517
523 @Override
524 public void removeByCompanyId(long companyId) throws SystemException {
525 for (AssetCategoryProperty assetCategoryProperty : findByCompanyId(
526 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
527 remove(assetCategoryProperty);
528 }
529 }
530
531
538 @Override
539 public int countByCompanyId(long companyId) throws SystemException {
540 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
541
542 Object[] finderArgs = new Object[] { companyId };
543
544 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
545 this);
546
547 if (count == null) {
548 StringBundler query = new StringBundler(2);
549
550 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
551
552 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
553
554 String sql = query.toString();
555
556 Session session = null;
557
558 try {
559 session = openSession();
560
561 Query q = session.createQuery(sql);
562
563 QueryPos qPos = QueryPos.getInstance(q);
564
565 qPos.add(companyId);
566
567 count = (Long)q.uniqueResult();
568
569 FinderCacheUtil.putResult(finderPath, finderArgs, count);
570 }
571 catch (Exception e) {
572 FinderCacheUtil.removeResult(finderPath, finderArgs);
573
574 throw processException(e);
575 }
576 finally {
577 closeSession(session);
578 }
579 }
580
581 return count.intValue();
582 }
583
584 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetCategoryProperty.companyId = ?";
585 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CATEGORYID =
586 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
587 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
588 AssetCategoryPropertyImpl.class,
589 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCategoryId",
590 new String[] {
591 Long.class.getName(),
592
593 Integer.class.getName(), Integer.class.getName(),
594 OrderByComparator.class.getName()
595 });
596 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID =
597 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
598 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
599 AssetCategoryPropertyImpl.class,
600 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCategoryId",
601 new String[] { Long.class.getName() },
602 AssetCategoryPropertyModelImpl.CATEGORYID_COLUMN_BITMASK |
603 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
604 public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
605 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
606 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCategoryId",
607 new String[] { Long.class.getName() });
608
609
616 @Override
617 public List<AssetCategoryProperty> findByCategoryId(long categoryId)
618 throws SystemException {
619 return findByCategoryId(categoryId, QueryUtil.ALL_POS,
620 QueryUtil.ALL_POS, null);
621 }
622
623
636 @Override
637 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
638 int start, int end) throws SystemException {
639 return findByCategoryId(categoryId, start, end, null);
640 }
641
642
656 @Override
657 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
658 int start, int end, OrderByComparator orderByComparator)
659 throws SystemException {
660 boolean pagination = true;
661 FinderPath finderPath = null;
662 Object[] finderArgs = null;
663
664 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
665 (orderByComparator == null)) {
666 pagination = false;
667 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID;
668 finderArgs = new Object[] { categoryId };
669 }
670 else {
671 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CATEGORYID;
672 finderArgs = new Object[] { categoryId, start, end, orderByComparator };
673 }
674
675 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
676 finderArgs, this);
677
678 if ((list != null) && !list.isEmpty()) {
679 for (AssetCategoryProperty assetCategoryProperty : list) {
680 if ((categoryId != assetCategoryProperty.getCategoryId())) {
681 list = null;
682
683 break;
684 }
685 }
686 }
687
688 if (list == null) {
689 StringBundler query = null;
690
691 if (orderByComparator != null) {
692 query = new StringBundler(3 +
693 (orderByComparator.getOrderByFields().length * 3));
694 }
695 else {
696 query = new StringBundler(3);
697 }
698
699 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
700
701 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
702
703 if (orderByComparator != null) {
704 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
705 orderByComparator);
706 }
707 else
708 if (pagination) {
709 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
710 }
711
712 String sql = query.toString();
713
714 Session session = null;
715
716 try {
717 session = openSession();
718
719 Query q = session.createQuery(sql);
720
721 QueryPos qPos = QueryPos.getInstance(q);
722
723 qPos.add(categoryId);
724
725 if (!pagination) {
726 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
727 getDialect(), start, end, false);
728
729 Collections.sort(list);
730
731 list = new UnmodifiableList<AssetCategoryProperty>(list);
732 }
733 else {
734 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
735 getDialect(), start, end);
736 }
737
738 cacheResult(list);
739
740 FinderCacheUtil.putResult(finderPath, finderArgs, list);
741 }
742 catch (Exception e) {
743 FinderCacheUtil.removeResult(finderPath, finderArgs);
744
745 throw processException(e);
746 }
747 finally {
748 closeSession(session);
749 }
750 }
751
752 return list;
753 }
754
755
764 @Override
765 public AssetCategoryProperty findByCategoryId_First(long categoryId,
766 OrderByComparator orderByComparator)
767 throws NoSuchCategoryPropertyException, SystemException {
768 AssetCategoryProperty assetCategoryProperty = fetchByCategoryId_First(categoryId,
769 orderByComparator);
770
771 if (assetCategoryProperty != null) {
772 return assetCategoryProperty;
773 }
774
775 StringBundler msg = new StringBundler(4);
776
777 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
778
779 msg.append("categoryId=");
780 msg.append(categoryId);
781
782 msg.append(StringPool.CLOSE_CURLY_BRACE);
783
784 throw new NoSuchCategoryPropertyException(msg.toString());
785 }
786
787
795 @Override
796 public AssetCategoryProperty fetchByCategoryId_First(long categoryId,
797 OrderByComparator orderByComparator) throws SystemException {
798 List<AssetCategoryProperty> list = findByCategoryId(categoryId, 0, 1,
799 orderByComparator);
800
801 if (!list.isEmpty()) {
802 return list.get(0);
803 }
804
805 return null;
806 }
807
808
817 @Override
818 public AssetCategoryProperty findByCategoryId_Last(long categoryId,
819 OrderByComparator orderByComparator)
820 throws NoSuchCategoryPropertyException, SystemException {
821 AssetCategoryProperty assetCategoryProperty = fetchByCategoryId_Last(categoryId,
822 orderByComparator);
823
824 if (assetCategoryProperty != null) {
825 return assetCategoryProperty;
826 }
827
828 StringBundler msg = new StringBundler(4);
829
830 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
831
832 msg.append("categoryId=");
833 msg.append(categoryId);
834
835 msg.append(StringPool.CLOSE_CURLY_BRACE);
836
837 throw new NoSuchCategoryPropertyException(msg.toString());
838 }
839
840
848 @Override
849 public AssetCategoryProperty fetchByCategoryId_Last(long categoryId,
850 OrderByComparator orderByComparator) throws SystemException {
851 int count = countByCategoryId(categoryId);
852
853 if (count == 0) {
854 return null;
855 }
856
857 List<AssetCategoryProperty> list = findByCategoryId(categoryId,
858 count - 1, count, orderByComparator);
859
860 if (!list.isEmpty()) {
861 return list.get(0);
862 }
863
864 return null;
865 }
866
867
877 @Override
878 public AssetCategoryProperty[] findByCategoryId_PrevAndNext(
879 long categoryPropertyId, long categoryId,
880 OrderByComparator orderByComparator)
881 throws NoSuchCategoryPropertyException, SystemException {
882 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
883
884 Session session = null;
885
886 try {
887 session = openSession();
888
889 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
890
891 array[0] = getByCategoryId_PrevAndNext(session,
892 assetCategoryProperty, categoryId, orderByComparator, true);
893
894 array[1] = assetCategoryProperty;
895
896 array[2] = getByCategoryId_PrevAndNext(session,
897 assetCategoryProperty, categoryId, orderByComparator, false);
898
899 return array;
900 }
901 catch (Exception e) {
902 throw processException(e);
903 }
904 finally {
905 closeSession(session);
906 }
907 }
908
909 protected AssetCategoryProperty getByCategoryId_PrevAndNext(
910 Session session, AssetCategoryProperty assetCategoryProperty,
911 long categoryId, OrderByComparator orderByComparator, boolean previous) {
912 StringBundler query = null;
913
914 if (orderByComparator != null) {
915 query = new StringBundler(6 +
916 (orderByComparator.getOrderByFields().length * 6));
917 }
918 else {
919 query = new StringBundler(3);
920 }
921
922 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
923
924 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
925
926 if (orderByComparator != null) {
927 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
928
929 if (orderByConditionFields.length > 0) {
930 query.append(WHERE_AND);
931 }
932
933 for (int i = 0; i < orderByConditionFields.length; i++) {
934 query.append(_ORDER_BY_ENTITY_ALIAS);
935 query.append(orderByConditionFields[i]);
936
937 if ((i + 1) < orderByConditionFields.length) {
938 if (orderByComparator.isAscending() ^ previous) {
939 query.append(WHERE_GREATER_THAN_HAS_NEXT);
940 }
941 else {
942 query.append(WHERE_LESSER_THAN_HAS_NEXT);
943 }
944 }
945 else {
946 if (orderByComparator.isAscending() ^ previous) {
947 query.append(WHERE_GREATER_THAN);
948 }
949 else {
950 query.append(WHERE_LESSER_THAN);
951 }
952 }
953 }
954
955 query.append(ORDER_BY_CLAUSE);
956
957 String[] orderByFields = orderByComparator.getOrderByFields();
958
959 for (int i = 0; i < orderByFields.length; i++) {
960 query.append(_ORDER_BY_ENTITY_ALIAS);
961 query.append(orderByFields[i]);
962
963 if ((i + 1) < orderByFields.length) {
964 if (orderByComparator.isAscending() ^ previous) {
965 query.append(ORDER_BY_ASC_HAS_NEXT);
966 }
967 else {
968 query.append(ORDER_BY_DESC_HAS_NEXT);
969 }
970 }
971 else {
972 if (orderByComparator.isAscending() ^ previous) {
973 query.append(ORDER_BY_ASC);
974 }
975 else {
976 query.append(ORDER_BY_DESC);
977 }
978 }
979 }
980 }
981 else {
982 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
983 }
984
985 String sql = query.toString();
986
987 Query q = session.createQuery(sql);
988
989 q.setFirstResult(0);
990 q.setMaxResults(2);
991
992 QueryPos qPos = QueryPos.getInstance(q);
993
994 qPos.add(categoryId);
995
996 if (orderByComparator != null) {
997 Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
998
999 for (Object value : values) {
1000 qPos.add(value);
1001 }
1002 }
1003
1004 List<AssetCategoryProperty> list = q.list();
1005
1006 if (list.size() == 2) {
1007 return list.get(1);
1008 }
1009 else {
1010 return null;
1011 }
1012 }
1013
1014
1020 @Override
1021 public void removeByCategoryId(long categoryId) throws SystemException {
1022 for (AssetCategoryProperty assetCategoryProperty : findByCategoryId(
1023 categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1024 remove(assetCategoryProperty);
1025 }
1026 }
1027
1028
1035 @Override
1036 public int countByCategoryId(long categoryId) throws SystemException {
1037 FinderPath finderPath = FINDER_PATH_COUNT_BY_CATEGORYID;
1038
1039 Object[] finderArgs = new Object[] { categoryId };
1040
1041 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1042 this);
1043
1044 if (count == null) {
1045 StringBundler query = new StringBundler(2);
1046
1047 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1048
1049 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1050
1051 String sql = query.toString();
1052
1053 Session session = null;
1054
1055 try {
1056 session = openSession();
1057
1058 Query q = session.createQuery(sql);
1059
1060 QueryPos qPos = QueryPos.getInstance(q);
1061
1062 qPos.add(categoryId);
1063
1064 count = (Long)q.uniqueResult();
1065
1066 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1067 }
1068 catch (Exception e) {
1069 FinderCacheUtil.removeResult(finderPath, finderArgs);
1070
1071 throw processException(e);
1072 }
1073 finally {
1074 closeSession(session);
1075 }
1076 }
1077
1078 return count.intValue();
1079 }
1080
1081 private static final String _FINDER_COLUMN_CATEGORYID_CATEGORYID_2 = "assetCategoryProperty.categoryId = ?";
1082 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1083 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
1084 AssetCategoryPropertyImpl.class,
1085 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_K",
1086 new String[] {
1087 Long.class.getName(), String.class.getName(),
1088
1089 Integer.class.getName(), Integer.class.getName(),
1090 OrderByComparator.class.getName()
1091 });
1092 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1093 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
1094 AssetCategoryPropertyImpl.class,
1095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_K",
1096 new String[] { Long.class.getName(), String.class.getName() },
1097 AssetCategoryPropertyModelImpl.COMPANYID_COLUMN_BITMASK |
1098 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
1099 public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1100 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_K",
1102 new String[] { Long.class.getName(), String.class.getName() });
1103
1104
1112 @Override
1113 public List<AssetCategoryProperty> findByC_K(long companyId, String key)
1114 throws SystemException {
1115 return findByC_K(companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1116 null);
1117 }
1118
1119
1133 @Override
1134 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1135 int start, int end) throws SystemException {
1136 return findByC_K(companyId, key, start, end, null);
1137 }
1138
1139
1154 @Override
1155 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1156 int start, int end, OrderByComparator orderByComparator)
1157 throws SystemException {
1158 boolean pagination = true;
1159 FinderPath finderPath = null;
1160 Object[] finderArgs = null;
1161
1162 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1163 (orderByComparator == null)) {
1164 pagination = false;
1165 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K;
1166 finderArgs = new Object[] { companyId, key };
1167 }
1168 else {
1169 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_K;
1170 finderArgs = new Object[] {
1171 companyId, key,
1172
1173 start, end, orderByComparator
1174 };
1175 }
1176
1177 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
1178 finderArgs, this);
1179
1180 if ((list != null) && !list.isEmpty()) {
1181 for (AssetCategoryProperty assetCategoryProperty : list) {
1182 if ((companyId != assetCategoryProperty.getCompanyId()) ||
1183 !Validator.equals(key, assetCategoryProperty.getKey())) {
1184 list = null;
1185
1186 break;
1187 }
1188 }
1189 }
1190
1191 if (list == null) {
1192 StringBundler query = null;
1193
1194 if (orderByComparator != null) {
1195 query = new StringBundler(4 +
1196 (orderByComparator.getOrderByFields().length * 3));
1197 }
1198 else {
1199 query = new StringBundler(4);
1200 }
1201
1202 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1203
1204 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1205
1206 boolean bindKey = false;
1207
1208 if (key == null) {
1209 query.append(_FINDER_COLUMN_C_K_KEY_1);
1210 }
1211 else if (key.equals(StringPool.BLANK)) {
1212 query.append(_FINDER_COLUMN_C_K_KEY_3);
1213 }
1214 else {
1215 bindKey = true;
1216
1217 query.append(_FINDER_COLUMN_C_K_KEY_2);
1218 }
1219
1220 if (orderByComparator != null) {
1221 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1222 orderByComparator);
1223 }
1224 else
1225 if (pagination) {
1226 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1227 }
1228
1229 String sql = query.toString();
1230
1231 Session session = null;
1232
1233 try {
1234 session = openSession();
1235
1236 Query q = session.createQuery(sql);
1237
1238 QueryPos qPos = QueryPos.getInstance(q);
1239
1240 qPos.add(companyId);
1241
1242 if (bindKey) {
1243 qPos.add(key);
1244 }
1245
1246 if (!pagination) {
1247 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1248 getDialect(), start, end, false);
1249
1250 Collections.sort(list);
1251
1252 list = new UnmodifiableList<AssetCategoryProperty>(list);
1253 }
1254 else {
1255 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1256 getDialect(), start, end);
1257 }
1258
1259 cacheResult(list);
1260
1261 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1262 }
1263 catch (Exception e) {
1264 FinderCacheUtil.removeResult(finderPath, finderArgs);
1265
1266 throw processException(e);
1267 }
1268 finally {
1269 closeSession(session);
1270 }
1271 }
1272
1273 return list;
1274 }
1275
1276
1286 @Override
1287 public AssetCategoryProperty findByC_K_First(long companyId, String key,
1288 OrderByComparator orderByComparator)
1289 throws NoSuchCategoryPropertyException, SystemException {
1290 AssetCategoryProperty assetCategoryProperty = fetchByC_K_First(companyId,
1291 key, orderByComparator);
1292
1293 if (assetCategoryProperty != null) {
1294 return assetCategoryProperty;
1295 }
1296
1297 StringBundler msg = new StringBundler(6);
1298
1299 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1300
1301 msg.append("companyId=");
1302 msg.append(companyId);
1303
1304 msg.append(", key=");
1305 msg.append(key);
1306
1307 msg.append(StringPool.CLOSE_CURLY_BRACE);
1308
1309 throw new NoSuchCategoryPropertyException(msg.toString());
1310 }
1311
1312
1321 @Override
1322 public AssetCategoryProperty fetchByC_K_First(long companyId, String key,
1323 OrderByComparator orderByComparator) throws SystemException {
1324 List<AssetCategoryProperty> list = findByC_K(companyId, key, 0, 1,
1325 orderByComparator);
1326
1327 if (!list.isEmpty()) {
1328 return list.get(0);
1329 }
1330
1331 return null;
1332 }
1333
1334
1344 @Override
1345 public AssetCategoryProperty findByC_K_Last(long companyId, String key,
1346 OrderByComparator orderByComparator)
1347 throws NoSuchCategoryPropertyException, SystemException {
1348 AssetCategoryProperty assetCategoryProperty = fetchByC_K_Last(companyId,
1349 key, orderByComparator);
1350
1351 if (assetCategoryProperty != null) {
1352 return assetCategoryProperty;
1353 }
1354
1355 StringBundler msg = new StringBundler(6);
1356
1357 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1358
1359 msg.append("companyId=");
1360 msg.append(companyId);
1361
1362 msg.append(", key=");
1363 msg.append(key);
1364
1365 msg.append(StringPool.CLOSE_CURLY_BRACE);
1366
1367 throw new NoSuchCategoryPropertyException(msg.toString());
1368 }
1369
1370
1379 @Override
1380 public AssetCategoryProperty fetchByC_K_Last(long companyId, String key,
1381 OrderByComparator orderByComparator) throws SystemException {
1382 int count = countByC_K(companyId, key);
1383
1384 if (count == 0) {
1385 return null;
1386 }
1387
1388 List<AssetCategoryProperty> list = findByC_K(companyId, key, count - 1,
1389 count, orderByComparator);
1390
1391 if (!list.isEmpty()) {
1392 return list.get(0);
1393 }
1394
1395 return null;
1396 }
1397
1398
1409 @Override
1410 public AssetCategoryProperty[] findByC_K_PrevAndNext(
1411 long categoryPropertyId, long companyId, String key,
1412 OrderByComparator orderByComparator)
1413 throws NoSuchCategoryPropertyException, SystemException {
1414 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1415
1416 Session session = null;
1417
1418 try {
1419 session = openSession();
1420
1421 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1422
1423 array[0] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1424 companyId, key, orderByComparator, true);
1425
1426 array[1] = assetCategoryProperty;
1427
1428 array[2] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1429 companyId, key, orderByComparator, false);
1430
1431 return array;
1432 }
1433 catch (Exception e) {
1434 throw processException(e);
1435 }
1436 finally {
1437 closeSession(session);
1438 }
1439 }
1440
1441 protected AssetCategoryProperty getByC_K_PrevAndNext(Session session,
1442 AssetCategoryProperty assetCategoryProperty, long companyId,
1443 String key, OrderByComparator orderByComparator, boolean previous) {
1444 StringBundler query = null;
1445
1446 if (orderByComparator != null) {
1447 query = new StringBundler(6 +
1448 (orderByComparator.getOrderByFields().length * 6));
1449 }
1450 else {
1451 query = new StringBundler(3);
1452 }
1453
1454 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1455
1456 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1457
1458 boolean bindKey = false;
1459
1460 if (key == null) {
1461 query.append(_FINDER_COLUMN_C_K_KEY_1);
1462 }
1463 else if (key.equals(StringPool.BLANK)) {
1464 query.append(_FINDER_COLUMN_C_K_KEY_3);
1465 }
1466 else {
1467 bindKey = true;
1468
1469 query.append(_FINDER_COLUMN_C_K_KEY_2);
1470 }
1471
1472 if (orderByComparator != null) {
1473 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1474
1475 if (orderByConditionFields.length > 0) {
1476 query.append(WHERE_AND);
1477 }
1478
1479 for (int i = 0; i < orderByConditionFields.length; i++) {
1480 query.append(_ORDER_BY_ENTITY_ALIAS);
1481 query.append(orderByConditionFields[i]);
1482
1483 if ((i + 1) < orderByConditionFields.length) {
1484 if (orderByComparator.isAscending() ^ previous) {
1485 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1486 }
1487 else {
1488 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1489 }
1490 }
1491 else {
1492 if (orderByComparator.isAscending() ^ previous) {
1493 query.append(WHERE_GREATER_THAN);
1494 }
1495 else {
1496 query.append(WHERE_LESSER_THAN);
1497 }
1498 }
1499 }
1500
1501 query.append(ORDER_BY_CLAUSE);
1502
1503 String[] orderByFields = orderByComparator.getOrderByFields();
1504
1505 for (int i = 0; i < orderByFields.length; i++) {
1506 query.append(_ORDER_BY_ENTITY_ALIAS);
1507 query.append(orderByFields[i]);
1508
1509 if ((i + 1) < orderByFields.length) {
1510 if (orderByComparator.isAscending() ^ previous) {
1511 query.append(ORDER_BY_ASC_HAS_NEXT);
1512 }
1513 else {
1514 query.append(ORDER_BY_DESC_HAS_NEXT);
1515 }
1516 }
1517 else {
1518 if (orderByComparator.isAscending() ^ previous) {
1519 query.append(ORDER_BY_ASC);
1520 }
1521 else {
1522 query.append(ORDER_BY_DESC);
1523 }
1524 }
1525 }
1526 }
1527 else {
1528 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1529 }
1530
1531 String sql = query.toString();
1532
1533 Query q = session.createQuery(sql);
1534
1535 q.setFirstResult(0);
1536 q.setMaxResults(2);
1537
1538 QueryPos qPos = QueryPos.getInstance(q);
1539
1540 qPos.add(companyId);
1541
1542 if (bindKey) {
1543 qPos.add(key);
1544 }
1545
1546 if (orderByComparator != null) {
1547 Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
1548
1549 for (Object value : values) {
1550 qPos.add(value);
1551 }
1552 }
1553
1554 List<AssetCategoryProperty> list = q.list();
1555
1556 if (list.size() == 2) {
1557 return list.get(1);
1558 }
1559 else {
1560 return null;
1561 }
1562 }
1563
1564
1571 @Override
1572 public void removeByC_K(long companyId, String key)
1573 throws SystemException {
1574 for (AssetCategoryProperty assetCategoryProperty : findByC_K(
1575 companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1576 remove(assetCategoryProperty);
1577 }
1578 }
1579
1580
1588 @Override
1589 public int countByC_K(long companyId, String key) throws SystemException {
1590 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_K;
1591
1592 Object[] finderArgs = new Object[] { companyId, key };
1593
1594 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1595 this);
1596
1597 if (count == null) {
1598 StringBundler query = new StringBundler(3);
1599
1600 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1601
1602 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1603
1604 boolean bindKey = false;
1605
1606 if (key == null) {
1607 query.append(_FINDER_COLUMN_C_K_KEY_1);
1608 }
1609 else if (key.equals(StringPool.BLANK)) {
1610 query.append(_FINDER_COLUMN_C_K_KEY_3);
1611 }
1612 else {
1613 bindKey = true;
1614
1615 query.append(_FINDER_COLUMN_C_K_KEY_2);
1616 }
1617
1618 String sql = query.toString();
1619
1620 Session session = null;
1621
1622 try {
1623 session = openSession();
1624
1625 Query q = session.createQuery(sql);
1626
1627 QueryPos qPos = QueryPos.getInstance(q);
1628
1629 qPos.add(companyId);
1630
1631 if (bindKey) {
1632 qPos.add(key);
1633 }
1634
1635 count = (Long)q.uniqueResult();
1636
1637 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1638 }
1639 catch (Exception e) {
1640 FinderCacheUtil.removeResult(finderPath, finderArgs);
1641
1642 throw processException(e);
1643 }
1644 finally {
1645 closeSession(session);
1646 }
1647 }
1648
1649 return count.intValue();
1650 }
1651
1652 private static final String _FINDER_COLUMN_C_K_COMPANYID_2 = "assetCategoryProperty.companyId = ? AND ";
1653 private static final String _FINDER_COLUMN_C_K_KEY_1 = "assetCategoryProperty.key IS NULL";
1654 private static final String _FINDER_COLUMN_C_K_KEY_2 = "assetCategoryProperty.key = ?";
1655 private static final String _FINDER_COLUMN_C_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = '')";
1656 public static final FinderPath FINDER_PATH_FETCH_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1657 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
1658 AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_ENTITY,
1659 "fetchByCA_K",
1660 new String[] { Long.class.getName(), String.class.getName() },
1661 AssetCategoryPropertyModelImpl.CATEGORYID_COLUMN_BITMASK |
1662 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
1663 public static final FinderPath FINDER_PATH_COUNT_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1664 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1665 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCA_K",
1666 new String[] { Long.class.getName(), String.class.getName() });
1667
1668
1677 @Override
1678 public AssetCategoryProperty findByCA_K(long categoryId, String key)
1679 throws NoSuchCategoryPropertyException, SystemException {
1680 AssetCategoryProperty assetCategoryProperty = fetchByCA_K(categoryId,
1681 key);
1682
1683 if (assetCategoryProperty == null) {
1684 StringBundler msg = new StringBundler(6);
1685
1686 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1687
1688 msg.append("categoryId=");
1689 msg.append(categoryId);
1690
1691 msg.append(", key=");
1692 msg.append(key);
1693
1694 msg.append(StringPool.CLOSE_CURLY_BRACE);
1695
1696 if (_log.isWarnEnabled()) {
1697 _log.warn(msg.toString());
1698 }
1699
1700 throw new NoSuchCategoryPropertyException(msg.toString());
1701 }
1702
1703 return assetCategoryProperty;
1704 }
1705
1706
1714 @Override
1715 public AssetCategoryProperty fetchByCA_K(long categoryId, String key)
1716 throws SystemException {
1717 return fetchByCA_K(categoryId, key, true);
1718 }
1719
1720
1729 @Override
1730 public AssetCategoryProperty fetchByCA_K(long categoryId, String key,
1731 boolean retrieveFromCache) throws SystemException {
1732 Object[] finderArgs = new Object[] { categoryId, key };
1733
1734 Object result = null;
1735
1736 if (retrieveFromCache) {
1737 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CA_K,
1738 finderArgs, this);
1739 }
1740
1741 if (result instanceof AssetCategoryProperty) {
1742 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)result;
1743
1744 if ((categoryId != assetCategoryProperty.getCategoryId()) ||
1745 !Validator.equals(key, assetCategoryProperty.getKey())) {
1746 result = null;
1747 }
1748 }
1749
1750 if (result == null) {
1751 StringBundler query = new StringBundler(4);
1752
1753 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1754
1755 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1756
1757 boolean bindKey = false;
1758
1759 if (key == null) {
1760 query.append(_FINDER_COLUMN_CA_K_KEY_1);
1761 }
1762 else if (key.equals(StringPool.BLANK)) {
1763 query.append(_FINDER_COLUMN_CA_K_KEY_3);
1764 }
1765 else {
1766 bindKey = true;
1767
1768 query.append(_FINDER_COLUMN_CA_K_KEY_2);
1769 }
1770
1771 String sql = query.toString();
1772
1773 Session session = null;
1774
1775 try {
1776 session = openSession();
1777
1778 Query q = session.createQuery(sql);
1779
1780 QueryPos qPos = QueryPos.getInstance(q);
1781
1782 qPos.add(categoryId);
1783
1784 if (bindKey) {
1785 qPos.add(key);
1786 }
1787
1788 List<AssetCategoryProperty> list = q.list();
1789
1790 if (list.isEmpty()) {
1791 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1792 finderArgs, list);
1793 }
1794 else {
1795 AssetCategoryProperty assetCategoryProperty = list.get(0);
1796
1797 result = assetCategoryProperty;
1798
1799 cacheResult(assetCategoryProperty);
1800
1801 if ((assetCategoryProperty.getCategoryId() != categoryId) ||
1802 (assetCategoryProperty.getKey() == null) ||
1803 !assetCategoryProperty.getKey().equals(key)) {
1804 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1805 finderArgs, assetCategoryProperty);
1806 }
1807 }
1808 }
1809 catch (Exception e) {
1810 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
1811 finderArgs);
1812
1813 throw processException(e);
1814 }
1815 finally {
1816 closeSession(session);
1817 }
1818 }
1819
1820 if (result instanceof List<?>) {
1821 return null;
1822 }
1823 else {
1824 return (AssetCategoryProperty)result;
1825 }
1826 }
1827
1828
1836 @Override
1837 public AssetCategoryProperty removeByCA_K(long categoryId, String key)
1838 throws NoSuchCategoryPropertyException, SystemException {
1839 AssetCategoryProperty assetCategoryProperty = findByCA_K(categoryId, key);
1840
1841 return remove(assetCategoryProperty);
1842 }
1843
1844
1852 @Override
1853 public int countByCA_K(long categoryId, String key)
1854 throws SystemException {
1855 FinderPath finderPath = FINDER_PATH_COUNT_BY_CA_K;
1856
1857 Object[] finderArgs = new Object[] { categoryId, key };
1858
1859 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1860 this);
1861
1862 if (count == null) {
1863 StringBundler query = new StringBundler(3);
1864
1865 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1866
1867 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1868
1869 boolean bindKey = false;
1870
1871 if (key == null) {
1872 query.append(_FINDER_COLUMN_CA_K_KEY_1);
1873 }
1874 else if (key.equals(StringPool.BLANK)) {
1875 query.append(_FINDER_COLUMN_CA_K_KEY_3);
1876 }
1877 else {
1878 bindKey = true;
1879
1880 query.append(_FINDER_COLUMN_CA_K_KEY_2);
1881 }
1882
1883 String sql = query.toString();
1884
1885 Session session = null;
1886
1887 try {
1888 session = openSession();
1889
1890 Query q = session.createQuery(sql);
1891
1892 QueryPos qPos = QueryPos.getInstance(q);
1893
1894 qPos.add(categoryId);
1895
1896 if (bindKey) {
1897 qPos.add(key);
1898 }
1899
1900 count = (Long)q.uniqueResult();
1901
1902 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1903 }
1904 catch (Exception e) {
1905 FinderCacheUtil.removeResult(finderPath, finderArgs);
1906
1907 throw processException(e);
1908 }
1909 finally {
1910 closeSession(session);
1911 }
1912 }
1913
1914 return count.intValue();
1915 }
1916
1917 private static final String _FINDER_COLUMN_CA_K_CATEGORYID_2 = "assetCategoryProperty.categoryId = ? AND ";
1918 private static final String _FINDER_COLUMN_CA_K_KEY_1 = "assetCategoryProperty.key IS NULL";
1919 private static final String _FINDER_COLUMN_CA_K_KEY_2 = "assetCategoryProperty.key = ?";
1920 private static final String _FINDER_COLUMN_CA_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = '')";
1921
1922
1927 @Override
1928 public void cacheResult(AssetCategoryProperty assetCategoryProperty) {
1929 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1930 AssetCategoryPropertyImpl.class,
1931 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
1932
1933 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1934 new Object[] {
1935 assetCategoryProperty.getCategoryId(),
1936 assetCategoryProperty.getKey()
1937 }, assetCategoryProperty);
1938
1939 assetCategoryProperty.resetOriginalValues();
1940 }
1941
1942
1947 @Override
1948 public void cacheResult(List<AssetCategoryProperty> assetCategoryProperties) {
1949 for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
1950 if (EntityCacheUtil.getResult(
1951 AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1952 AssetCategoryPropertyImpl.class,
1953 assetCategoryProperty.getPrimaryKey()) == null) {
1954 cacheResult(assetCategoryProperty);
1955 }
1956 else {
1957 assetCategoryProperty.resetOriginalValues();
1958 }
1959 }
1960 }
1961
1962
1969 @Override
1970 public void clearCache() {
1971 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1972 CacheRegistryUtil.clear(AssetCategoryPropertyImpl.class.getName());
1973 }
1974
1975 EntityCacheUtil.clearCache(AssetCategoryPropertyImpl.class.getName());
1976
1977 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1978 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1979 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1980 }
1981
1982
1989 @Override
1990 public void clearCache(AssetCategoryProperty assetCategoryProperty) {
1991 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1992 AssetCategoryPropertyImpl.class,
1993 assetCategoryProperty.getPrimaryKey());
1994
1995 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1996 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1997
1998 clearUniqueFindersCache(assetCategoryProperty);
1999 }
2000
2001 @Override
2002 public void clearCache(List<AssetCategoryProperty> assetCategoryProperties) {
2003 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2004 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2005
2006 for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
2007 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2008 AssetCategoryPropertyImpl.class,
2009 assetCategoryProperty.getPrimaryKey());
2010
2011 clearUniqueFindersCache(assetCategoryProperty);
2012 }
2013 }
2014
2015 protected void cacheUniqueFindersCache(
2016 AssetCategoryProperty assetCategoryProperty) {
2017 if (assetCategoryProperty.isNew()) {
2018 Object[] args = new Object[] {
2019 assetCategoryProperty.getCategoryId(),
2020 assetCategoryProperty.getKey()
2021 };
2022
2023 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K, args,
2024 Long.valueOf(1));
2025 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K, args,
2026 assetCategoryProperty);
2027 }
2028 else {
2029 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
2030
2031 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2032 FINDER_PATH_FETCH_BY_CA_K.getColumnBitmask()) != 0) {
2033 Object[] args = new Object[] {
2034 assetCategoryProperty.getCategoryId(),
2035 assetCategoryProperty.getKey()
2036 };
2037
2038 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K, args,
2039 Long.valueOf(1));
2040 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K, args,
2041 assetCategoryProperty);
2042 }
2043 }
2044 }
2045
2046 protected void clearUniqueFindersCache(
2047 AssetCategoryProperty assetCategoryProperty) {
2048 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
2049
2050 Object[] args = new Object[] {
2051 assetCategoryProperty.getCategoryId(),
2052 assetCategoryProperty.getKey()
2053 };
2054
2055 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CA_K, args);
2056 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K, args);
2057
2058 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2059 FINDER_PATH_FETCH_BY_CA_K.getColumnBitmask()) != 0) {
2060 args = new Object[] {
2061 assetCategoryPropertyModelImpl.getOriginalCategoryId(),
2062 assetCategoryPropertyModelImpl.getOriginalKey()
2063 };
2064
2065 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CA_K, args);
2066 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K, args);
2067 }
2068 }
2069
2070
2076 @Override
2077 public AssetCategoryProperty create(long categoryPropertyId) {
2078 AssetCategoryProperty assetCategoryProperty = new AssetCategoryPropertyImpl();
2079
2080 assetCategoryProperty.setNew(true);
2081 assetCategoryProperty.setPrimaryKey(categoryPropertyId);
2082
2083 return assetCategoryProperty;
2084 }
2085
2086
2094 @Override
2095 public AssetCategoryProperty remove(long categoryPropertyId)
2096 throws NoSuchCategoryPropertyException, SystemException {
2097 return remove((Serializable)categoryPropertyId);
2098 }
2099
2100
2108 @Override
2109 public AssetCategoryProperty remove(Serializable primaryKey)
2110 throws NoSuchCategoryPropertyException, SystemException {
2111 Session session = null;
2112
2113 try {
2114 session = openSession();
2115
2116 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
2117 primaryKey);
2118
2119 if (assetCategoryProperty == null) {
2120 if (_log.isWarnEnabled()) {
2121 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2122 }
2123
2124 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2125 primaryKey);
2126 }
2127
2128 return remove(assetCategoryProperty);
2129 }
2130 catch (NoSuchCategoryPropertyException nsee) {
2131 throw nsee;
2132 }
2133 catch (Exception e) {
2134 throw processException(e);
2135 }
2136 finally {
2137 closeSession(session);
2138 }
2139 }
2140
2141 @Override
2142 protected AssetCategoryProperty removeImpl(
2143 AssetCategoryProperty assetCategoryProperty) throws SystemException {
2144 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
2145
2146 Session session = null;
2147
2148 try {
2149 session = openSession();
2150
2151 if (!session.contains(assetCategoryProperty)) {
2152 assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
2153 assetCategoryProperty.getPrimaryKeyObj());
2154 }
2155
2156 if (assetCategoryProperty != null) {
2157 session.delete(assetCategoryProperty);
2158 }
2159 }
2160 catch (Exception e) {
2161 throw processException(e);
2162 }
2163 finally {
2164 closeSession(session);
2165 }
2166
2167 if (assetCategoryProperty != null) {
2168 clearCache(assetCategoryProperty);
2169 }
2170
2171 return assetCategoryProperty;
2172 }
2173
2174 @Override
2175 public AssetCategoryProperty updateImpl(
2176 com.liferay.portlet.asset.model.AssetCategoryProperty assetCategoryProperty)
2177 throws SystemException {
2178 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
2179
2180 boolean isNew = assetCategoryProperty.isNew();
2181
2182 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
2183
2184 Session session = null;
2185
2186 try {
2187 session = openSession();
2188
2189 if (assetCategoryProperty.isNew()) {
2190 session.save(assetCategoryProperty);
2191
2192 assetCategoryProperty.setNew(false);
2193 }
2194 else {
2195 session.merge(assetCategoryProperty);
2196 }
2197 }
2198 catch (Exception e) {
2199 throw processException(e);
2200 }
2201 finally {
2202 closeSession(session);
2203 }
2204
2205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2206
2207 if (isNew || !AssetCategoryPropertyModelImpl.COLUMN_BITMASK_ENABLED) {
2208 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2209 }
2210
2211 else {
2212 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2213 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
2214 Object[] args = new Object[] {
2215 assetCategoryPropertyModelImpl.getOriginalCompanyId()
2216 };
2217
2218 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2219 args);
2220 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2221 args);
2222
2223 args = new Object[] {
2224 assetCategoryPropertyModelImpl.getCompanyId()
2225 };
2226
2227 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2228 args);
2229 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2230 args);
2231 }
2232
2233 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2234 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID.getColumnBitmask()) != 0) {
2235 Object[] args = new Object[] {
2236 assetCategoryPropertyModelImpl.getOriginalCategoryId()
2237 };
2238
2239 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID,
2240 args);
2241 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID,
2242 args);
2243
2244 args = new Object[] {
2245 assetCategoryPropertyModelImpl.getCategoryId()
2246 };
2247
2248 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID,
2249 args);
2250 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID,
2251 args);
2252 }
2253
2254 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2255 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K.getColumnBitmask()) != 0) {
2256 Object[] args = new Object[] {
2257 assetCategoryPropertyModelImpl.getOriginalCompanyId(),
2258 assetCategoryPropertyModelImpl.getOriginalKey()
2259 };
2260
2261 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
2262 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K,
2263 args);
2264
2265 args = new Object[] {
2266 assetCategoryPropertyModelImpl.getCompanyId(),
2267 assetCategoryPropertyModelImpl.getKey()
2268 };
2269
2270 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
2271 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K,
2272 args);
2273 }
2274 }
2275
2276 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2277 AssetCategoryPropertyImpl.class,
2278 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
2279
2280 clearUniqueFindersCache(assetCategoryProperty);
2281 cacheUniqueFindersCache(assetCategoryProperty);
2282
2283 return assetCategoryProperty;
2284 }
2285
2286 protected AssetCategoryProperty toUnwrappedModel(
2287 AssetCategoryProperty assetCategoryProperty) {
2288 if (assetCategoryProperty instanceof AssetCategoryPropertyImpl) {
2289 return assetCategoryProperty;
2290 }
2291
2292 AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
2293
2294 assetCategoryPropertyImpl.setNew(assetCategoryProperty.isNew());
2295 assetCategoryPropertyImpl.setPrimaryKey(assetCategoryProperty.getPrimaryKey());
2296
2297 assetCategoryPropertyImpl.setCategoryPropertyId(assetCategoryProperty.getCategoryPropertyId());
2298 assetCategoryPropertyImpl.setCompanyId(assetCategoryProperty.getCompanyId());
2299 assetCategoryPropertyImpl.setUserId(assetCategoryProperty.getUserId());
2300 assetCategoryPropertyImpl.setUserName(assetCategoryProperty.getUserName());
2301 assetCategoryPropertyImpl.setCreateDate(assetCategoryProperty.getCreateDate());
2302 assetCategoryPropertyImpl.setModifiedDate(assetCategoryProperty.getModifiedDate());
2303 assetCategoryPropertyImpl.setCategoryId(assetCategoryProperty.getCategoryId());
2304 assetCategoryPropertyImpl.setKey(assetCategoryProperty.getKey());
2305 assetCategoryPropertyImpl.setValue(assetCategoryProperty.getValue());
2306
2307 return assetCategoryPropertyImpl;
2308 }
2309
2310
2318 @Override
2319 public AssetCategoryProperty findByPrimaryKey(Serializable primaryKey)
2320 throws NoSuchCategoryPropertyException, SystemException {
2321 AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(primaryKey);
2322
2323 if (assetCategoryProperty == null) {
2324 if (_log.isWarnEnabled()) {
2325 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2326 }
2327
2328 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2329 primaryKey);
2330 }
2331
2332 return assetCategoryProperty;
2333 }
2334
2335
2343 @Override
2344 public AssetCategoryProperty findByPrimaryKey(long categoryPropertyId)
2345 throws NoSuchCategoryPropertyException, SystemException {
2346 return findByPrimaryKey((Serializable)categoryPropertyId);
2347 }
2348
2349
2356 @Override
2357 public AssetCategoryProperty fetchByPrimaryKey(Serializable primaryKey)
2358 throws SystemException {
2359 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)EntityCacheUtil.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2360 AssetCategoryPropertyImpl.class, primaryKey);
2361
2362 if (assetCategoryProperty == _nullAssetCategoryProperty) {
2363 return null;
2364 }
2365
2366 if (assetCategoryProperty == null) {
2367 Session session = null;
2368
2369 try {
2370 session = openSession();
2371
2372 assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
2373 primaryKey);
2374
2375 if (assetCategoryProperty != null) {
2376 cacheResult(assetCategoryProperty);
2377 }
2378 else {
2379 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2380 AssetCategoryPropertyImpl.class, primaryKey,
2381 _nullAssetCategoryProperty);
2382 }
2383 }
2384 catch (Exception e) {
2385 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2386 AssetCategoryPropertyImpl.class, primaryKey);
2387
2388 throw processException(e);
2389 }
2390 finally {
2391 closeSession(session);
2392 }
2393 }
2394
2395 return assetCategoryProperty;
2396 }
2397
2398
2405 @Override
2406 public AssetCategoryProperty fetchByPrimaryKey(long categoryPropertyId)
2407 throws SystemException {
2408 return fetchByPrimaryKey((Serializable)categoryPropertyId);
2409 }
2410
2411
2417 @Override
2418 public List<AssetCategoryProperty> findAll() throws SystemException {
2419 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2420 }
2421
2422
2434 @Override
2435 public List<AssetCategoryProperty> findAll(int start, int end)
2436 throws SystemException {
2437 return findAll(start, end, null);
2438 }
2439
2440
2453 @Override
2454 public List<AssetCategoryProperty> findAll(int start, int end,
2455 OrderByComparator orderByComparator) throws SystemException {
2456 boolean pagination = true;
2457 FinderPath finderPath = null;
2458 Object[] finderArgs = null;
2459
2460 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2461 (orderByComparator == null)) {
2462 pagination = false;
2463 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2464 finderArgs = FINDER_ARGS_EMPTY;
2465 }
2466 else {
2467 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2468 finderArgs = new Object[] { start, end, orderByComparator };
2469 }
2470
2471 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
2472 finderArgs, this);
2473
2474 if (list == null) {
2475 StringBundler query = null;
2476 String sql = null;
2477
2478 if (orderByComparator != null) {
2479 query = new StringBundler(2 +
2480 (orderByComparator.getOrderByFields().length * 3));
2481
2482 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY);
2483
2484 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2485 orderByComparator);
2486
2487 sql = query.toString();
2488 }
2489 else {
2490 sql = _SQL_SELECT_ASSETCATEGORYPROPERTY;
2491
2492 if (pagination) {
2493 sql = sql.concat(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
2494 }
2495 }
2496
2497 Session session = null;
2498
2499 try {
2500 session = openSession();
2501
2502 Query q = session.createQuery(sql);
2503
2504 if (!pagination) {
2505 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
2506 getDialect(), start, end, false);
2507
2508 Collections.sort(list);
2509
2510 list = new UnmodifiableList<AssetCategoryProperty>(list);
2511 }
2512 else {
2513 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
2514 getDialect(), start, end);
2515 }
2516
2517 cacheResult(list);
2518
2519 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2520 }
2521 catch (Exception e) {
2522 FinderCacheUtil.removeResult(finderPath, finderArgs);
2523
2524 throw processException(e);
2525 }
2526 finally {
2527 closeSession(session);
2528 }
2529 }
2530
2531 return list;
2532 }
2533
2534
2539 @Override
2540 public void removeAll() throws SystemException {
2541 for (AssetCategoryProperty assetCategoryProperty : findAll()) {
2542 remove(assetCategoryProperty);
2543 }
2544 }
2545
2546
2552 @Override
2553 public int countAll() throws SystemException {
2554 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2555 FINDER_ARGS_EMPTY, this);
2556
2557 if (count == null) {
2558 Session session = null;
2559
2560 try {
2561 session = openSession();
2562
2563 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORYPROPERTY);
2564
2565 count = (Long)q.uniqueResult();
2566
2567 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2568 FINDER_ARGS_EMPTY, count);
2569 }
2570 catch (Exception e) {
2571 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2572 FINDER_ARGS_EMPTY);
2573
2574 throw processException(e);
2575 }
2576 finally {
2577 closeSession(session);
2578 }
2579 }
2580
2581 return count.intValue();
2582 }
2583
2584 @Override
2585 protected Set<String> getBadColumnNames() {
2586 return _badColumnNames;
2587 }
2588
2589
2592 public void afterPropertiesSet() {
2593 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2594 com.liferay.portal.util.PropsUtil.get(
2595 "value.object.listener.com.liferay.portlet.asset.model.AssetCategoryProperty")));
2596
2597 if (listenerClassNames.length > 0) {
2598 try {
2599 List<ModelListener<AssetCategoryProperty>> listenersList = new ArrayList<ModelListener<AssetCategoryProperty>>();
2600
2601 for (String listenerClassName : listenerClassNames) {
2602 listenersList.add((ModelListener<AssetCategoryProperty>)InstanceFactory.newInstance(
2603 getClassLoader(), listenerClassName));
2604 }
2605
2606 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2607 }
2608 catch (Exception e) {
2609 _log.error(e);
2610 }
2611 }
2612 }
2613
2614 public void destroy() {
2615 EntityCacheUtil.removeCache(AssetCategoryPropertyImpl.class.getName());
2616 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2617 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2618 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2619 }
2620
2621 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty";
2622 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2623 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty";
2624 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2625 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategoryProperty.";
2626 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategoryProperty exists with the primary key ";
2627 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategoryProperty exists with the key {";
2628 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2629 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPropertyPersistenceImpl.class);
2630 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2631 "key"
2632 });
2633 private static AssetCategoryProperty _nullAssetCategoryProperty = new AssetCategoryPropertyImpl() {
2634 @Override
2635 public Object clone() {
2636 return this;
2637 }
2638
2639 @Override
2640 public CacheModel<AssetCategoryProperty> toCacheModel() {
2641 return _nullAssetCategoryPropertyCacheModel;
2642 }
2643 };
2644
2645 private static CacheModel<AssetCategoryProperty> _nullAssetCategoryPropertyCacheModel =
2646 new CacheModel<AssetCategoryProperty>() {
2647 @Override
2648 public AssetCategoryProperty toEntityModel() {
2649 return _nullAssetCategoryProperty;
2650 }
2651 };
2652 }