001
014
015 package com.liferay.portlet.asset.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.asset.kernel.exception.NoSuchCategoryPropertyException;
020 import com.liferay.asset.kernel.model.AssetCategoryProperty;
021 import com.liferay.asset.kernel.service.persistence.AssetCategoryPropertyPersistence;
022
023 import com.liferay.portal.kernel.bean.BeanReference;
024 import com.liferay.portal.kernel.dao.orm.EntityCache;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCache;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.log.Log;
034 import com.liferay.portal.kernel.log.LogFactoryUtil;
035 import com.liferay.portal.kernel.model.CacheModel;
036 import com.liferay.portal.kernel.service.ServiceContext;
037 import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
038 import com.liferay.portal.kernel.service.persistence.CompanyProvider;
039 import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
040 import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
041 import com.liferay.portal.kernel.util.OrderByComparator;
042 import com.liferay.portal.kernel.util.SetUtil;
043 import com.liferay.portal.kernel.util.StringBundler;
044 import com.liferay.portal.kernel.util.StringPool;
045
046 import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyImpl;
047 import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyModelImpl;
048
049 import java.io.Serializable;
050
051 import java.util.Collections;
052 import java.util.Date;
053 import java.util.HashMap;
054 import java.util.HashSet;
055 import java.util.Iterator;
056 import java.util.List;
057 import java.util.Map;
058 import java.util.Objects;
059 import java.util.Set;
060
061
073 @ProviderType
074 public class AssetCategoryPropertyPersistenceImpl extends BasePersistenceImpl<AssetCategoryProperty>
075 implements AssetCategoryPropertyPersistence {
076
081 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryPropertyImpl.class.getName();
082 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083 ".List1";
084 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085 ".List2";
086 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
087 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
088 AssetCategoryPropertyImpl.class,
089 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
091 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
092 AssetCategoryPropertyImpl.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
094 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
095 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
097 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
098 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
099 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
100 AssetCategoryPropertyImpl.class,
101 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
102 new String[] {
103 Long.class.getName(),
104
105 Integer.class.getName(), Integer.class.getName(),
106 OrderByComparator.class.getName()
107 });
108 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
109 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
110 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
111 AssetCategoryPropertyImpl.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
113 new String[] { Long.class.getName() },
114 AssetCategoryPropertyModelImpl.COMPANYID_COLUMN_BITMASK |
115 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
116 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
117 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
118 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
119 new String[] { Long.class.getName() });
120
121
127 @Override
128 public List<AssetCategoryProperty> findByCompanyId(long companyId) {
129 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
130 null);
131 }
132
133
145 @Override
146 public List<AssetCategoryProperty> findByCompanyId(long companyId,
147 int start, int end) {
148 return findByCompanyId(companyId, start, end, null);
149 }
150
151
164 @Override
165 public List<AssetCategoryProperty> findByCompanyId(long companyId,
166 int start, int end,
167 OrderByComparator<AssetCategoryProperty> orderByComparator) {
168 return findByCompanyId(companyId, start, end, orderByComparator, true);
169 }
170
171
185 @Override
186 public List<AssetCategoryProperty> findByCompanyId(long companyId,
187 int start, int end,
188 OrderByComparator<AssetCategoryProperty> orderByComparator,
189 boolean retrieveFromCache) {
190 boolean pagination = true;
191 FinderPath finderPath = null;
192 Object[] finderArgs = null;
193
194 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
195 (orderByComparator == null)) {
196 pagination = false;
197 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
198 finderArgs = new Object[] { companyId };
199 }
200 else {
201 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
202 finderArgs = new Object[] { companyId, start, end, orderByComparator };
203 }
204
205 List<AssetCategoryProperty> list = null;
206
207 if (retrieveFromCache) {
208 list = (List<AssetCategoryProperty>)finderCache.getResult(finderPath,
209 finderArgs, this);
210
211 if ((list != null) && !list.isEmpty()) {
212 for (AssetCategoryProperty assetCategoryProperty : list) {
213 if ((companyId != assetCategoryProperty.getCompanyId())) {
214 list = null;
215
216 break;
217 }
218 }
219 }
220 }
221
222 if (list == null) {
223 StringBundler query = null;
224
225 if (orderByComparator != null) {
226 query = new StringBundler(3 +
227 (orderByComparator.getOrderByFields().length * 2));
228 }
229 else {
230 query = new StringBundler(3);
231 }
232
233 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
234
235 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
236
237 if (orderByComparator != null) {
238 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
239 orderByComparator);
240 }
241 else
242 if (pagination) {
243 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
244 }
245
246 String sql = query.toString();
247
248 Session session = null;
249
250 try {
251 session = openSession();
252
253 Query q = session.createQuery(sql);
254
255 QueryPos qPos = QueryPos.getInstance(q);
256
257 qPos.add(companyId);
258
259 if (!pagination) {
260 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
261 getDialect(), start, end, false);
262
263 Collections.sort(list);
264
265 list = Collections.unmodifiableList(list);
266 }
267 else {
268 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
269 getDialect(), start, end);
270 }
271
272 cacheResult(list);
273
274 finderCache.putResult(finderPath, finderArgs, list);
275 }
276 catch (Exception e) {
277 finderCache.removeResult(finderPath, finderArgs);
278
279 throw processException(e);
280 }
281 finally {
282 closeSession(session);
283 }
284 }
285
286 return list;
287 }
288
289
297 @Override
298 public AssetCategoryProperty findByCompanyId_First(long companyId,
299 OrderByComparator<AssetCategoryProperty> orderByComparator)
300 throws NoSuchCategoryPropertyException {
301 AssetCategoryProperty assetCategoryProperty = fetchByCompanyId_First(companyId,
302 orderByComparator);
303
304 if (assetCategoryProperty != null) {
305 return assetCategoryProperty;
306 }
307
308 StringBundler msg = new StringBundler(4);
309
310 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
311
312 msg.append("companyId=");
313 msg.append(companyId);
314
315 msg.append(StringPool.CLOSE_CURLY_BRACE);
316
317 throw new NoSuchCategoryPropertyException(msg.toString());
318 }
319
320
327 @Override
328 public AssetCategoryProperty fetchByCompanyId_First(long companyId,
329 OrderByComparator<AssetCategoryProperty> orderByComparator) {
330 List<AssetCategoryProperty> list = findByCompanyId(companyId, 0, 1,
331 orderByComparator);
332
333 if (!list.isEmpty()) {
334 return list.get(0);
335 }
336
337 return null;
338 }
339
340
348 @Override
349 public AssetCategoryProperty findByCompanyId_Last(long companyId,
350 OrderByComparator<AssetCategoryProperty> orderByComparator)
351 throws NoSuchCategoryPropertyException {
352 AssetCategoryProperty assetCategoryProperty = fetchByCompanyId_Last(companyId,
353 orderByComparator);
354
355 if (assetCategoryProperty != null) {
356 return assetCategoryProperty;
357 }
358
359 StringBundler msg = new StringBundler(4);
360
361 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
362
363 msg.append("companyId=");
364 msg.append(companyId);
365
366 msg.append(StringPool.CLOSE_CURLY_BRACE);
367
368 throw new NoSuchCategoryPropertyException(msg.toString());
369 }
370
371
378 @Override
379 public AssetCategoryProperty fetchByCompanyId_Last(long companyId,
380 OrderByComparator<AssetCategoryProperty> orderByComparator) {
381 int count = countByCompanyId(companyId);
382
383 if (count == 0) {
384 return null;
385 }
386
387 List<AssetCategoryProperty> list = findByCompanyId(companyId,
388 count - 1, count, orderByComparator);
389
390 if (!list.isEmpty()) {
391 return list.get(0);
392 }
393
394 return null;
395 }
396
397
406 @Override
407 public AssetCategoryProperty[] findByCompanyId_PrevAndNext(
408 long categoryPropertyId, long companyId,
409 OrderByComparator<AssetCategoryProperty> orderByComparator)
410 throws NoSuchCategoryPropertyException {
411 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
412
413 Session session = null;
414
415 try {
416 session = openSession();
417
418 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
419
420 array[0] = getByCompanyId_PrevAndNext(session,
421 assetCategoryProperty, companyId, orderByComparator, true);
422
423 array[1] = assetCategoryProperty;
424
425 array[2] = getByCompanyId_PrevAndNext(session,
426 assetCategoryProperty, companyId, orderByComparator, false);
427
428 return array;
429 }
430 catch (Exception e) {
431 throw processException(e);
432 }
433 finally {
434 closeSession(session);
435 }
436 }
437
438 protected AssetCategoryProperty getByCompanyId_PrevAndNext(
439 Session session, AssetCategoryProperty assetCategoryProperty,
440 long companyId,
441 OrderByComparator<AssetCategoryProperty> orderByComparator,
442 boolean previous) {
443 StringBundler query = null;
444
445 if (orderByComparator != null) {
446 query = new StringBundler(4 +
447 (orderByComparator.getOrderByConditionFields().length * 3) +
448 (orderByComparator.getOrderByFields().length * 3));
449 }
450 else {
451 query = new StringBundler(3);
452 }
453
454 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
455
456 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
457
458 if (orderByComparator != null) {
459 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
460
461 if (orderByConditionFields.length > 0) {
462 query.append(WHERE_AND);
463 }
464
465 for (int i = 0; i < orderByConditionFields.length; i++) {
466 query.append(_ORDER_BY_ENTITY_ALIAS);
467 query.append(orderByConditionFields[i]);
468
469 if ((i + 1) < orderByConditionFields.length) {
470 if (orderByComparator.isAscending() ^ previous) {
471 query.append(WHERE_GREATER_THAN_HAS_NEXT);
472 }
473 else {
474 query.append(WHERE_LESSER_THAN_HAS_NEXT);
475 }
476 }
477 else {
478 if (orderByComparator.isAscending() ^ previous) {
479 query.append(WHERE_GREATER_THAN);
480 }
481 else {
482 query.append(WHERE_LESSER_THAN);
483 }
484 }
485 }
486
487 query.append(ORDER_BY_CLAUSE);
488
489 String[] orderByFields = orderByComparator.getOrderByFields();
490
491 for (int i = 0; i < orderByFields.length; i++) {
492 query.append(_ORDER_BY_ENTITY_ALIAS);
493 query.append(orderByFields[i]);
494
495 if ((i + 1) < orderByFields.length) {
496 if (orderByComparator.isAscending() ^ previous) {
497 query.append(ORDER_BY_ASC_HAS_NEXT);
498 }
499 else {
500 query.append(ORDER_BY_DESC_HAS_NEXT);
501 }
502 }
503 else {
504 if (orderByComparator.isAscending() ^ previous) {
505 query.append(ORDER_BY_ASC);
506 }
507 else {
508 query.append(ORDER_BY_DESC);
509 }
510 }
511 }
512 }
513 else {
514 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
515 }
516
517 String sql = query.toString();
518
519 Query q = session.createQuery(sql);
520
521 q.setFirstResult(0);
522 q.setMaxResults(2);
523
524 QueryPos qPos = QueryPos.getInstance(q);
525
526 qPos.add(companyId);
527
528 if (orderByComparator != null) {
529 Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
530
531 for (Object value : values) {
532 qPos.add(value);
533 }
534 }
535
536 List<AssetCategoryProperty> list = q.list();
537
538 if (list.size() == 2) {
539 return list.get(1);
540 }
541 else {
542 return null;
543 }
544 }
545
546
551 @Override
552 public void removeByCompanyId(long companyId) {
553 for (AssetCategoryProperty assetCategoryProperty : findByCompanyId(
554 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
555 remove(assetCategoryProperty);
556 }
557 }
558
559
565 @Override
566 public int countByCompanyId(long companyId) {
567 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
568
569 Object[] finderArgs = new Object[] { companyId };
570
571 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
572
573 if (count == null) {
574 StringBundler query = new StringBundler(2);
575
576 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
577
578 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
579
580 String sql = query.toString();
581
582 Session session = null;
583
584 try {
585 session = openSession();
586
587 Query q = session.createQuery(sql);
588
589 QueryPos qPos = QueryPos.getInstance(q);
590
591 qPos.add(companyId);
592
593 count = (Long)q.uniqueResult();
594
595 finderCache.putResult(finderPath, finderArgs, count);
596 }
597 catch (Exception e) {
598 finderCache.removeResult(finderPath, finderArgs);
599
600 throw processException(e);
601 }
602 finally {
603 closeSession(session);
604 }
605 }
606
607 return count.intValue();
608 }
609
610 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetCategoryProperty.companyId = ?";
611 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CATEGORYID =
612 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
613 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
614 AssetCategoryPropertyImpl.class,
615 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCategoryId",
616 new String[] {
617 Long.class.getName(),
618
619 Integer.class.getName(), Integer.class.getName(),
620 OrderByComparator.class.getName()
621 });
622 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID =
623 new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
624 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
625 AssetCategoryPropertyImpl.class,
626 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCategoryId",
627 new String[] { Long.class.getName() },
628 AssetCategoryPropertyModelImpl.CATEGORYID_COLUMN_BITMASK |
629 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
630 public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
631 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
632 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCategoryId",
633 new String[] { Long.class.getName() });
634
635
641 @Override
642 public List<AssetCategoryProperty> findByCategoryId(long categoryId) {
643 return findByCategoryId(categoryId, QueryUtil.ALL_POS,
644 QueryUtil.ALL_POS, null);
645 }
646
647
659 @Override
660 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
661 int start, int end) {
662 return findByCategoryId(categoryId, start, end, null);
663 }
664
665
678 @Override
679 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
680 int start, int end,
681 OrderByComparator<AssetCategoryProperty> orderByComparator) {
682 return findByCategoryId(categoryId, start, end, orderByComparator, true);
683 }
684
685
699 @Override
700 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
701 int start, int end,
702 OrderByComparator<AssetCategoryProperty> orderByComparator,
703 boolean retrieveFromCache) {
704 boolean pagination = true;
705 FinderPath finderPath = null;
706 Object[] finderArgs = null;
707
708 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
709 (orderByComparator == null)) {
710 pagination = false;
711 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID;
712 finderArgs = new Object[] { categoryId };
713 }
714 else {
715 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CATEGORYID;
716 finderArgs = new Object[] { categoryId, start, end, orderByComparator };
717 }
718
719 List<AssetCategoryProperty> list = null;
720
721 if (retrieveFromCache) {
722 list = (List<AssetCategoryProperty>)finderCache.getResult(finderPath,
723 finderArgs, this);
724
725 if ((list != null) && !list.isEmpty()) {
726 for (AssetCategoryProperty assetCategoryProperty : list) {
727 if ((categoryId != assetCategoryProperty.getCategoryId())) {
728 list = null;
729
730 break;
731 }
732 }
733 }
734 }
735
736 if (list == null) {
737 StringBundler query = null;
738
739 if (orderByComparator != null) {
740 query = new StringBundler(3 +
741 (orderByComparator.getOrderByFields().length * 2));
742 }
743 else {
744 query = new StringBundler(3);
745 }
746
747 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
748
749 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
750
751 if (orderByComparator != null) {
752 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
753 orderByComparator);
754 }
755 else
756 if (pagination) {
757 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
758 }
759
760 String sql = query.toString();
761
762 Session session = null;
763
764 try {
765 session = openSession();
766
767 Query q = session.createQuery(sql);
768
769 QueryPos qPos = QueryPos.getInstance(q);
770
771 qPos.add(categoryId);
772
773 if (!pagination) {
774 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
775 getDialect(), start, end, false);
776
777 Collections.sort(list);
778
779 list = Collections.unmodifiableList(list);
780 }
781 else {
782 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
783 getDialect(), start, end);
784 }
785
786 cacheResult(list);
787
788 finderCache.putResult(finderPath, finderArgs, list);
789 }
790 catch (Exception e) {
791 finderCache.removeResult(finderPath, finderArgs);
792
793 throw processException(e);
794 }
795 finally {
796 closeSession(session);
797 }
798 }
799
800 return list;
801 }
802
803
811 @Override
812 public AssetCategoryProperty findByCategoryId_First(long categoryId,
813 OrderByComparator<AssetCategoryProperty> orderByComparator)
814 throws NoSuchCategoryPropertyException {
815 AssetCategoryProperty assetCategoryProperty = fetchByCategoryId_First(categoryId,
816 orderByComparator);
817
818 if (assetCategoryProperty != null) {
819 return assetCategoryProperty;
820 }
821
822 StringBundler msg = new StringBundler(4);
823
824 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
825
826 msg.append("categoryId=");
827 msg.append(categoryId);
828
829 msg.append(StringPool.CLOSE_CURLY_BRACE);
830
831 throw new NoSuchCategoryPropertyException(msg.toString());
832 }
833
834
841 @Override
842 public AssetCategoryProperty fetchByCategoryId_First(long categoryId,
843 OrderByComparator<AssetCategoryProperty> orderByComparator) {
844 List<AssetCategoryProperty> list = findByCategoryId(categoryId, 0, 1,
845 orderByComparator);
846
847 if (!list.isEmpty()) {
848 return list.get(0);
849 }
850
851 return null;
852 }
853
854
862 @Override
863 public AssetCategoryProperty findByCategoryId_Last(long categoryId,
864 OrderByComparator<AssetCategoryProperty> orderByComparator)
865 throws NoSuchCategoryPropertyException {
866 AssetCategoryProperty assetCategoryProperty = fetchByCategoryId_Last(categoryId,
867 orderByComparator);
868
869 if (assetCategoryProperty != null) {
870 return assetCategoryProperty;
871 }
872
873 StringBundler msg = new StringBundler(4);
874
875 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
876
877 msg.append("categoryId=");
878 msg.append(categoryId);
879
880 msg.append(StringPool.CLOSE_CURLY_BRACE);
881
882 throw new NoSuchCategoryPropertyException(msg.toString());
883 }
884
885
892 @Override
893 public AssetCategoryProperty fetchByCategoryId_Last(long categoryId,
894 OrderByComparator<AssetCategoryProperty> orderByComparator) {
895 int count = countByCategoryId(categoryId);
896
897 if (count == 0) {
898 return null;
899 }
900
901 List<AssetCategoryProperty> list = findByCategoryId(categoryId,
902 count - 1, count, orderByComparator);
903
904 if (!list.isEmpty()) {
905 return list.get(0);
906 }
907
908 return null;
909 }
910
911
920 @Override
921 public AssetCategoryProperty[] findByCategoryId_PrevAndNext(
922 long categoryPropertyId, long categoryId,
923 OrderByComparator<AssetCategoryProperty> orderByComparator)
924 throws NoSuchCategoryPropertyException {
925 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
926
927 Session session = null;
928
929 try {
930 session = openSession();
931
932 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
933
934 array[0] = getByCategoryId_PrevAndNext(session,
935 assetCategoryProperty, categoryId, orderByComparator, true);
936
937 array[1] = assetCategoryProperty;
938
939 array[2] = getByCategoryId_PrevAndNext(session,
940 assetCategoryProperty, categoryId, orderByComparator, false);
941
942 return array;
943 }
944 catch (Exception e) {
945 throw processException(e);
946 }
947 finally {
948 closeSession(session);
949 }
950 }
951
952 protected AssetCategoryProperty getByCategoryId_PrevAndNext(
953 Session session, AssetCategoryProperty assetCategoryProperty,
954 long categoryId,
955 OrderByComparator<AssetCategoryProperty> orderByComparator,
956 boolean previous) {
957 StringBundler query = null;
958
959 if (orderByComparator != null) {
960 query = new StringBundler(4 +
961 (orderByComparator.getOrderByConditionFields().length * 3) +
962 (orderByComparator.getOrderByFields().length * 3));
963 }
964 else {
965 query = new StringBundler(3);
966 }
967
968 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
969
970 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
971
972 if (orderByComparator != null) {
973 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
974
975 if (orderByConditionFields.length > 0) {
976 query.append(WHERE_AND);
977 }
978
979 for (int i = 0; i < orderByConditionFields.length; i++) {
980 query.append(_ORDER_BY_ENTITY_ALIAS);
981 query.append(orderByConditionFields[i]);
982
983 if ((i + 1) < orderByConditionFields.length) {
984 if (orderByComparator.isAscending() ^ previous) {
985 query.append(WHERE_GREATER_THAN_HAS_NEXT);
986 }
987 else {
988 query.append(WHERE_LESSER_THAN_HAS_NEXT);
989 }
990 }
991 else {
992 if (orderByComparator.isAscending() ^ previous) {
993 query.append(WHERE_GREATER_THAN);
994 }
995 else {
996 query.append(WHERE_LESSER_THAN);
997 }
998 }
999 }
1000
1001 query.append(ORDER_BY_CLAUSE);
1002
1003 String[] orderByFields = orderByComparator.getOrderByFields();
1004
1005 for (int i = 0; i < orderByFields.length; i++) {
1006 query.append(_ORDER_BY_ENTITY_ALIAS);
1007 query.append(orderByFields[i]);
1008
1009 if ((i + 1) < orderByFields.length) {
1010 if (orderByComparator.isAscending() ^ previous) {
1011 query.append(ORDER_BY_ASC_HAS_NEXT);
1012 }
1013 else {
1014 query.append(ORDER_BY_DESC_HAS_NEXT);
1015 }
1016 }
1017 else {
1018 if (orderByComparator.isAscending() ^ previous) {
1019 query.append(ORDER_BY_ASC);
1020 }
1021 else {
1022 query.append(ORDER_BY_DESC);
1023 }
1024 }
1025 }
1026 }
1027 else {
1028 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1029 }
1030
1031 String sql = query.toString();
1032
1033 Query q = session.createQuery(sql);
1034
1035 q.setFirstResult(0);
1036 q.setMaxResults(2);
1037
1038 QueryPos qPos = QueryPos.getInstance(q);
1039
1040 qPos.add(categoryId);
1041
1042 if (orderByComparator != null) {
1043 Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
1044
1045 for (Object value : values) {
1046 qPos.add(value);
1047 }
1048 }
1049
1050 List<AssetCategoryProperty> list = q.list();
1051
1052 if (list.size() == 2) {
1053 return list.get(1);
1054 }
1055 else {
1056 return null;
1057 }
1058 }
1059
1060
1065 @Override
1066 public void removeByCategoryId(long categoryId) {
1067 for (AssetCategoryProperty assetCategoryProperty : findByCategoryId(
1068 categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1069 remove(assetCategoryProperty);
1070 }
1071 }
1072
1073
1079 @Override
1080 public int countByCategoryId(long categoryId) {
1081 FinderPath finderPath = FINDER_PATH_COUNT_BY_CATEGORYID;
1082
1083 Object[] finderArgs = new Object[] { categoryId };
1084
1085 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1086
1087 if (count == null) {
1088 StringBundler query = new StringBundler(2);
1089
1090 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1091
1092 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1093
1094 String sql = query.toString();
1095
1096 Session session = null;
1097
1098 try {
1099 session = openSession();
1100
1101 Query q = session.createQuery(sql);
1102
1103 QueryPos qPos = QueryPos.getInstance(q);
1104
1105 qPos.add(categoryId);
1106
1107 count = (Long)q.uniqueResult();
1108
1109 finderCache.putResult(finderPath, finderArgs, count);
1110 }
1111 catch (Exception e) {
1112 finderCache.removeResult(finderPath, finderArgs);
1113
1114 throw processException(e);
1115 }
1116 finally {
1117 closeSession(session);
1118 }
1119 }
1120
1121 return count.intValue();
1122 }
1123
1124 private static final String _FINDER_COLUMN_CATEGORYID_CATEGORYID_2 = "assetCategoryProperty.categoryId = ?";
1125 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1126 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
1127 AssetCategoryPropertyImpl.class,
1128 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_K",
1129 new String[] {
1130 Long.class.getName(), String.class.getName(),
1131
1132 Integer.class.getName(), Integer.class.getName(),
1133 OrderByComparator.class.getName()
1134 });
1135 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1136 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
1137 AssetCategoryPropertyImpl.class,
1138 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_K",
1139 new String[] { Long.class.getName(), String.class.getName() },
1140 AssetCategoryPropertyModelImpl.COMPANYID_COLUMN_BITMASK |
1141 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
1142 public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1143 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1144 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_K",
1145 new String[] { Long.class.getName(), String.class.getName() });
1146
1147
1154 @Override
1155 public List<AssetCategoryProperty> findByC_K(long companyId, String key) {
1156 return findByC_K(companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1157 null);
1158 }
1159
1160
1173 @Override
1174 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1175 int start, int end) {
1176 return findByC_K(companyId, key, start, end, null);
1177 }
1178
1179
1193 @Override
1194 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1195 int start, int end,
1196 OrderByComparator<AssetCategoryProperty> orderByComparator) {
1197 return findByC_K(companyId, key, start, end, orderByComparator, true);
1198 }
1199
1200
1215 @Override
1216 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1217 int start, int end,
1218 OrderByComparator<AssetCategoryProperty> orderByComparator,
1219 boolean retrieveFromCache) {
1220 boolean pagination = true;
1221 FinderPath finderPath = null;
1222 Object[] finderArgs = null;
1223
1224 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1225 (orderByComparator == null)) {
1226 pagination = false;
1227 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K;
1228 finderArgs = new Object[] { companyId, key };
1229 }
1230 else {
1231 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_K;
1232 finderArgs = new Object[] {
1233 companyId, key,
1234
1235 start, end, orderByComparator
1236 };
1237 }
1238
1239 List<AssetCategoryProperty> list = null;
1240
1241 if (retrieveFromCache) {
1242 list = (List<AssetCategoryProperty>)finderCache.getResult(finderPath,
1243 finderArgs, this);
1244
1245 if ((list != null) && !list.isEmpty()) {
1246 for (AssetCategoryProperty assetCategoryProperty : list) {
1247 if ((companyId != assetCategoryProperty.getCompanyId()) ||
1248 !Objects.equals(key, assetCategoryProperty.getKey())) {
1249 list = null;
1250
1251 break;
1252 }
1253 }
1254 }
1255 }
1256
1257 if (list == null) {
1258 StringBundler query = null;
1259
1260 if (orderByComparator != null) {
1261 query = new StringBundler(4 +
1262 (orderByComparator.getOrderByFields().length * 2));
1263 }
1264 else {
1265 query = new StringBundler(4);
1266 }
1267
1268 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1269
1270 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1271
1272 boolean bindKey = false;
1273
1274 if (key == null) {
1275 query.append(_FINDER_COLUMN_C_K_KEY_1);
1276 }
1277 else if (key.equals(StringPool.BLANK)) {
1278 query.append(_FINDER_COLUMN_C_K_KEY_3);
1279 }
1280 else {
1281 bindKey = true;
1282
1283 query.append(_FINDER_COLUMN_C_K_KEY_2);
1284 }
1285
1286 if (orderByComparator != null) {
1287 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1288 orderByComparator);
1289 }
1290 else
1291 if (pagination) {
1292 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1293 }
1294
1295 String sql = query.toString();
1296
1297 Session session = null;
1298
1299 try {
1300 session = openSession();
1301
1302 Query q = session.createQuery(sql);
1303
1304 QueryPos qPos = QueryPos.getInstance(q);
1305
1306 qPos.add(companyId);
1307
1308 if (bindKey) {
1309 qPos.add(key);
1310 }
1311
1312 if (!pagination) {
1313 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1314 getDialect(), start, end, false);
1315
1316 Collections.sort(list);
1317
1318 list = Collections.unmodifiableList(list);
1319 }
1320 else {
1321 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1322 getDialect(), start, end);
1323 }
1324
1325 cacheResult(list);
1326
1327 finderCache.putResult(finderPath, finderArgs, list);
1328 }
1329 catch (Exception e) {
1330 finderCache.removeResult(finderPath, finderArgs);
1331
1332 throw processException(e);
1333 }
1334 finally {
1335 closeSession(session);
1336 }
1337 }
1338
1339 return list;
1340 }
1341
1342
1351 @Override
1352 public AssetCategoryProperty findByC_K_First(long companyId, String key,
1353 OrderByComparator<AssetCategoryProperty> orderByComparator)
1354 throws NoSuchCategoryPropertyException {
1355 AssetCategoryProperty assetCategoryProperty = fetchByC_K_First(companyId,
1356 key, orderByComparator);
1357
1358 if (assetCategoryProperty != null) {
1359 return assetCategoryProperty;
1360 }
1361
1362 StringBundler msg = new StringBundler(6);
1363
1364 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1365
1366 msg.append("companyId=");
1367 msg.append(companyId);
1368
1369 msg.append(", key=");
1370 msg.append(key);
1371
1372 msg.append(StringPool.CLOSE_CURLY_BRACE);
1373
1374 throw new NoSuchCategoryPropertyException(msg.toString());
1375 }
1376
1377
1385 @Override
1386 public AssetCategoryProperty fetchByC_K_First(long companyId, String key,
1387 OrderByComparator<AssetCategoryProperty> orderByComparator) {
1388 List<AssetCategoryProperty> list = findByC_K(companyId, key, 0, 1,
1389 orderByComparator);
1390
1391 if (!list.isEmpty()) {
1392 return list.get(0);
1393 }
1394
1395 return null;
1396 }
1397
1398
1407 @Override
1408 public AssetCategoryProperty findByC_K_Last(long companyId, String key,
1409 OrderByComparator<AssetCategoryProperty> orderByComparator)
1410 throws NoSuchCategoryPropertyException {
1411 AssetCategoryProperty assetCategoryProperty = fetchByC_K_Last(companyId,
1412 key, orderByComparator);
1413
1414 if (assetCategoryProperty != null) {
1415 return assetCategoryProperty;
1416 }
1417
1418 StringBundler msg = new StringBundler(6);
1419
1420 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1421
1422 msg.append("companyId=");
1423 msg.append(companyId);
1424
1425 msg.append(", key=");
1426 msg.append(key);
1427
1428 msg.append(StringPool.CLOSE_CURLY_BRACE);
1429
1430 throw new NoSuchCategoryPropertyException(msg.toString());
1431 }
1432
1433
1441 @Override
1442 public AssetCategoryProperty fetchByC_K_Last(long companyId, String key,
1443 OrderByComparator<AssetCategoryProperty> orderByComparator) {
1444 int count = countByC_K(companyId, key);
1445
1446 if (count == 0) {
1447 return null;
1448 }
1449
1450 List<AssetCategoryProperty> list = findByC_K(companyId, key, count - 1,
1451 count, orderByComparator);
1452
1453 if (!list.isEmpty()) {
1454 return list.get(0);
1455 }
1456
1457 return null;
1458 }
1459
1460
1470 @Override
1471 public AssetCategoryProperty[] findByC_K_PrevAndNext(
1472 long categoryPropertyId, long companyId, String key,
1473 OrderByComparator<AssetCategoryProperty> orderByComparator)
1474 throws NoSuchCategoryPropertyException {
1475 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1476
1477 Session session = null;
1478
1479 try {
1480 session = openSession();
1481
1482 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1483
1484 array[0] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1485 companyId, key, orderByComparator, true);
1486
1487 array[1] = assetCategoryProperty;
1488
1489 array[2] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1490 companyId, key, orderByComparator, false);
1491
1492 return array;
1493 }
1494 catch (Exception e) {
1495 throw processException(e);
1496 }
1497 finally {
1498 closeSession(session);
1499 }
1500 }
1501
1502 protected AssetCategoryProperty getByC_K_PrevAndNext(Session session,
1503 AssetCategoryProperty assetCategoryProperty, long companyId,
1504 String key, OrderByComparator<AssetCategoryProperty> orderByComparator,
1505 boolean previous) {
1506 StringBundler query = null;
1507
1508 if (orderByComparator != null) {
1509 query = new StringBundler(5 +
1510 (orderByComparator.getOrderByConditionFields().length * 3) +
1511 (orderByComparator.getOrderByFields().length * 3));
1512 }
1513 else {
1514 query = new StringBundler(4);
1515 }
1516
1517 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1518
1519 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1520
1521 boolean bindKey = false;
1522
1523 if (key == null) {
1524 query.append(_FINDER_COLUMN_C_K_KEY_1);
1525 }
1526 else if (key.equals(StringPool.BLANK)) {
1527 query.append(_FINDER_COLUMN_C_K_KEY_3);
1528 }
1529 else {
1530 bindKey = true;
1531
1532 query.append(_FINDER_COLUMN_C_K_KEY_2);
1533 }
1534
1535 if (orderByComparator != null) {
1536 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1537
1538 if (orderByConditionFields.length > 0) {
1539 query.append(WHERE_AND);
1540 }
1541
1542 for (int i = 0; i < orderByConditionFields.length; i++) {
1543 query.append(_ORDER_BY_ENTITY_ALIAS);
1544 query.append(orderByConditionFields[i]);
1545
1546 if ((i + 1) < orderByConditionFields.length) {
1547 if (orderByComparator.isAscending() ^ previous) {
1548 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1549 }
1550 else {
1551 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1552 }
1553 }
1554 else {
1555 if (orderByComparator.isAscending() ^ previous) {
1556 query.append(WHERE_GREATER_THAN);
1557 }
1558 else {
1559 query.append(WHERE_LESSER_THAN);
1560 }
1561 }
1562 }
1563
1564 query.append(ORDER_BY_CLAUSE);
1565
1566 String[] orderByFields = orderByComparator.getOrderByFields();
1567
1568 for (int i = 0; i < orderByFields.length; i++) {
1569 query.append(_ORDER_BY_ENTITY_ALIAS);
1570 query.append(orderByFields[i]);
1571
1572 if ((i + 1) < orderByFields.length) {
1573 if (orderByComparator.isAscending() ^ previous) {
1574 query.append(ORDER_BY_ASC_HAS_NEXT);
1575 }
1576 else {
1577 query.append(ORDER_BY_DESC_HAS_NEXT);
1578 }
1579 }
1580 else {
1581 if (orderByComparator.isAscending() ^ previous) {
1582 query.append(ORDER_BY_ASC);
1583 }
1584 else {
1585 query.append(ORDER_BY_DESC);
1586 }
1587 }
1588 }
1589 }
1590 else {
1591 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1592 }
1593
1594 String sql = query.toString();
1595
1596 Query q = session.createQuery(sql);
1597
1598 q.setFirstResult(0);
1599 q.setMaxResults(2);
1600
1601 QueryPos qPos = QueryPos.getInstance(q);
1602
1603 qPos.add(companyId);
1604
1605 if (bindKey) {
1606 qPos.add(key);
1607 }
1608
1609 if (orderByComparator != null) {
1610 Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
1611
1612 for (Object value : values) {
1613 qPos.add(value);
1614 }
1615 }
1616
1617 List<AssetCategoryProperty> list = q.list();
1618
1619 if (list.size() == 2) {
1620 return list.get(1);
1621 }
1622 else {
1623 return null;
1624 }
1625 }
1626
1627
1633 @Override
1634 public void removeByC_K(long companyId, String key) {
1635 for (AssetCategoryProperty assetCategoryProperty : findByC_K(
1636 companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1637 remove(assetCategoryProperty);
1638 }
1639 }
1640
1641
1648 @Override
1649 public int countByC_K(long companyId, String key) {
1650 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_K;
1651
1652 Object[] finderArgs = new Object[] { companyId, key };
1653
1654 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1655
1656 if (count == null) {
1657 StringBundler query = new StringBundler(3);
1658
1659 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1660
1661 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1662
1663 boolean bindKey = false;
1664
1665 if (key == null) {
1666 query.append(_FINDER_COLUMN_C_K_KEY_1);
1667 }
1668 else if (key.equals(StringPool.BLANK)) {
1669 query.append(_FINDER_COLUMN_C_K_KEY_3);
1670 }
1671 else {
1672 bindKey = true;
1673
1674 query.append(_FINDER_COLUMN_C_K_KEY_2);
1675 }
1676
1677 String sql = query.toString();
1678
1679 Session session = null;
1680
1681 try {
1682 session = openSession();
1683
1684 Query q = session.createQuery(sql);
1685
1686 QueryPos qPos = QueryPos.getInstance(q);
1687
1688 qPos.add(companyId);
1689
1690 if (bindKey) {
1691 qPos.add(key);
1692 }
1693
1694 count = (Long)q.uniqueResult();
1695
1696 finderCache.putResult(finderPath, finderArgs, count);
1697 }
1698 catch (Exception e) {
1699 finderCache.removeResult(finderPath, finderArgs);
1700
1701 throw processException(e);
1702 }
1703 finally {
1704 closeSession(session);
1705 }
1706 }
1707
1708 return count.intValue();
1709 }
1710
1711 private static final String _FINDER_COLUMN_C_K_COMPANYID_2 = "assetCategoryProperty.companyId = ? AND ";
1712 private static final String _FINDER_COLUMN_C_K_KEY_1 = "assetCategoryProperty.key IS NULL";
1713 private static final String _FINDER_COLUMN_C_K_KEY_2 = "assetCategoryProperty.key = ?";
1714 private static final String _FINDER_COLUMN_C_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = '')";
1715 public static final FinderPath FINDER_PATH_FETCH_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1716 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
1717 AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_ENTITY,
1718 "fetchByCA_K",
1719 new String[] { Long.class.getName(), String.class.getName() },
1720 AssetCategoryPropertyModelImpl.CATEGORYID_COLUMN_BITMASK |
1721 AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
1722 public static final FinderPath FINDER_PATH_COUNT_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1723 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1724 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCA_K",
1725 new String[] { Long.class.getName(), String.class.getName() });
1726
1727
1735 @Override
1736 public AssetCategoryProperty findByCA_K(long categoryId, String key)
1737 throws NoSuchCategoryPropertyException {
1738 AssetCategoryProperty assetCategoryProperty = fetchByCA_K(categoryId,
1739 key);
1740
1741 if (assetCategoryProperty == null) {
1742 StringBundler msg = new StringBundler(6);
1743
1744 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1745
1746 msg.append("categoryId=");
1747 msg.append(categoryId);
1748
1749 msg.append(", key=");
1750 msg.append(key);
1751
1752 msg.append(StringPool.CLOSE_CURLY_BRACE);
1753
1754 if (_log.isDebugEnabled()) {
1755 _log.debug(msg.toString());
1756 }
1757
1758 throw new NoSuchCategoryPropertyException(msg.toString());
1759 }
1760
1761 return assetCategoryProperty;
1762 }
1763
1764
1771 @Override
1772 public AssetCategoryProperty fetchByCA_K(long categoryId, String key) {
1773 return fetchByCA_K(categoryId, key, true);
1774 }
1775
1776
1784 @Override
1785 public AssetCategoryProperty fetchByCA_K(long categoryId, String key,
1786 boolean retrieveFromCache) {
1787 Object[] finderArgs = new Object[] { categoryId, key };
1788
1789 Object result = null;
1790
1791 if (retrieveFromCache) {
1792 result = finderCache.getResult(FINDER_PATH_FETCH_BY_CA_K,
1793 finderArgs, this);
1794 }
1795
1796 if (result instanceof AssetCategoryProperty) {
1797 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)result;
1798
1799 if ((categoryId != assetCategoryProperty.getCategoryId()) ||
1800 !Objects.equals(key, assetCategoryProperty.getKey())) {
1801 result = null;
1802 }
1803 }
1804
1805 if (result == null) {
1806 StringBundler query = new StringBundler(4);
1807
1808 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1809
1810 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1811
1812 boolean bindKey = false;
1813
1814 if (key == null) {
1815 query.append(_FINDER_COLUMN_CA_K_KEY_1);
1816 }
1817 else if (key.equals(StringPool.BLANK)) {
1818 query.append(_FINDER_COLUMN_CA_K_KEY_3);
1819 }
1820 else {
1821 bindKey = true;
1822
1823 query.append(_FINDER_COLUMN_CA_K_KEY_2);
1824 }
1825
1826 String sql = query.toString();
1827
1828 Session session = null;
1829
1830 try {
1831 session = openSession();
1832
1833 Query q = session.createQuery(sql);
1834
1835 QueryPos qPos = QueryPos.getInstance(q);
1836
1837 qPos.add(categoryId);
1838
1839 if (bindKey) {
1840 qPos.add(key);
1841 }
1842
1843 List<AssetCategoryProperty> list = q.list();
1844
1845 if (list.isEmpty()) {
1846 finderCache.putResult(FINDER_PATH_FETCH_BY_CA_K,
1847 finderArgs, list);
1848 }
1849 else {
1850 AssetCategoryProperty assetCategoryProperty = list.get(0);
1851
1852 result = assetCategoryProperty;
1853
1854 cacheResult(assetCategoryProperty);
1855
1856 if ((assetCategoryProperty.getCategoryId() != categoryId) ||
1857 (assetCategoryProperty.getKey() == null) ||
1858 !assetCategoryProperty.getKey().equals(key)) {
1859 finderCache.putResult(FINDER_PATH_FETCH_BY_CA_K,
1860 finderArgs, assetCategoryProperty);
1861 }
1862 }
1863 }
1864 catch (Exception e) {
1865 finderCache.removeResult(FINDER_PATH_FETCH_BY_CA_K, finderArgs);
1866
1867 throw processException(e);
1868 }
1869 finally {
1870 closeSession(session);
1871 }
1872 }
1873
1874 if (result instanceof List<?>) {
1875 return null;
1876 }
1877 else {
1878 return (AssetCategoryProperty)result;
1879 }
1880 }
1881
1882
1889 @Override
1890 public AssetCategoryProperty removeByCA_K(long categoryId, String key)
1891 throws NoSuchCategoryPropertyException {
1892 AssetCategoryProperty assetCategoryProperty = findByCA_K(categoryId, key);
1893
1894 return remove(assetCategoryProperty);
1895 }
1896
1897
1904 @Override
1905 public int countByCA_K(long categoryId, String key) {
1906 FinderPath finderPath = FINDER_PATH_COUNT_BY_CA_K;
1907
1908 Object[] finderArgs = new Object[] { categoryId, key };
1909
1910 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1911
1912 if (count == null) {
1913 StringBundler query = new StringBundler(3);
1914
1915 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1916
1917 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1918
1919 boolean bindKey = false;
1920
1921 if (key == null) {
1922 query.append(_FINDER_COLUMN_CA_K_KEY_1);
1923 }
1924 else if (key.equals(StringPool.BLANK)) {
1925 query.append(_FINDER_COLUMN_CA_K_KEY_3);
1926 }
1927 else {
1928 bindKey = true;
1929
1930 query.append(_FINDER_COLUMN_CA_K_KEY_2);
1931 }
1932
1933 String sql = query.toString();
1934
1935 Session session = null;
1936
1937 try {
1938 session = openSession();
1939
1940 Query q = session.createQuery(sql);
1941
1942 QueryPos qPos = QueryPos.getInstance(q);
1943
1944 qPos.add(categoryId);
1945
1946 if (bindKey) {
1947 qPos.add(key);
1948 }
1949
1950 count = (Long)q.uniqueResult();
1951
1952 finderCache.putResult(finderPath, finderArgs, count);
1953 }
1954 catch (Exception e) {
1955 finderCache.removeResult(finderPath, finderArgs);
1956
1957 throw processException(e);
1958 }
1959 finally {
1960 closeSession(session);
1961 }
1962 }
1963
1964 return count.intValue();
1965 }
1966
1967 private static final String _FINDER_COLUMN_CA_K_CATEGORYID_2 = "assetCategoryProperty.categoryId = ? AND ";
1968 private static final String _FINDER_COLUMN_CA_K_KEY_1 = "assetCategoryProperty.key IS NULL";
1969 private static final String _FINDER_COLUMN_CA_K_KEY_2 = "assetCategoryProperty.key = ?";
1970 private static final String _FINDER_COLUMN_CA_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = '')";
1971
1972 public AssetCategoryPropertyPersistenceImpl() {
1973 setModelClass(AssetCategoryProperty.class);
1974 }
1975
1976
1981 @Override
1982 public void cacheResult(AssetCategoryProperty assetCategoryProperty) {
1983 entityCache.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
1984 AssetCategoryPropertyImpl.class,
1985 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
1986
1987 finderCache.putResult(FINDER_PATH_FETCH_BY_CA_K,
1988 new Object[] {
1989 assetCategoryProperty.getCategoryId(),
1990 assetCategoryProperty.getKey()
1991 }, assetCategoryProperty);
1992
1993 assetCategoryProperty.resetOriginalValues();
1994 }
1995
1996
2001 @Override
2002 public void cacheResult(List<AssetCategoryProperty> assetCategoryProperties) {
2003 for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
2004 if (entityCache.getResult(
2005 AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2006 AssetCategoryPropertyImpl.class,
2007 assetCategoryProperty.getPrimaryKey()) == null) {
2008 cacheResult(assetCategoryProperty);
2009 }
2010 else {
2011 assetCategoryProperty.resetOriginalValues();
2012 }
2013 }
2014 }
2015
2016
2023 @Override
2024 public void clearCache() {
2025 entityCache.clearCache(AssetCategoryPropertyImpl.class);
2026
2027 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
2028 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2029 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2030 }
2031
2032
2039 @Override
2040 public void clearCache(AssetCategoryProperty assetCategoryProperty) {
2041 entityCache.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2042 AssetCategoryPropertyImpl.class,
2043 assetCategoryProperty.getPrimaryKey());
2044
2045 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2046 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2047
2048 clearUniqueFindersCache((AssetCategoryPropertyModelImpl)assetCategoryProperty);
2049 }
2050
2051 @Override
2052 public void clearCache(List<AssetCategoryProperty> assetCategoryProperties) {
2053 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2054 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2055
2056 for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
2057 entityCache.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2058 AssetCategoryPropertyImpl.class,
2059 assetCategoryProperty.getPrimaryKey());
2060
2061 clearUniqueFindersCache((AssetCategoryPropertyModelImpl)assetCategoryProperty);
2062 }
2063 }
2064
2065 protected void cacheUniqueFindersCache(
2066 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl,
2067 boolean isNew) {
2068 if (isNew) {
2069 Object[] args = new Object[] {
2070 assetCategoryPropertyModelImpl.getCategoryId(),
2071 assetCategoryPropertyModelImpl.getKey()
2072 };
2073
2074 finderCache.putResult(FINDER_PATH_COUNT_BY_CA_K, args,
2075 Long.valueOf(1));
2076 finderCache.putResult(FINDER_PATH_FETCH_BY_CA_K, args,
2077 assetCategoryPropertyModelImpl);
2078 }
2079 else {
2080 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2081 FINDER_PATH_FETCH_BY_CA_K.getColumnBitmask()) != 0) {
2082 Object[] args = new Object[] {
2083 assetCategoryPropertyModelImpl.getCategoryId(),
2084 assetCategoryPropertyModelImpl.getKey()
2085 };
2086
2087 finderCache.putResult(FINDER_PATH_COUNT_BY_CA_K, args,
2088 Long.valueOf(1));
2089 finderCache.putResult(FINDER_PATH_FETCH_BY_CA_K, args,
2090 assetCategoryPropertyModelImpl);
2091 }
2092 }
2093 }
2094
2095 protected void clearUniqueFindersCache(
2096 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl) {
2097 Object[] args = new Object[] {
2098 assetCategoryPropertyModelImpl.getCategoryId(),
2099 assetCategoryPropertyModelImpl.getKey()
2100 };
2101
2102 finderCache.removeResult(FINDER_PATH_COUNT_BY_CA_K, args);
2103 finderCache.removeResult(FINDER_PATH_FETCH_BY_CA_K, args);
2104
2105 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2106 FINDER_PATH_FETCH_BY_CA_K.getColumnBitmask()) != 0) {
2107 args = new Object[] {
2108 assetCategoryPropertyModelImpl.getOriginalCategoryId(),
2109 assetCategoryPropertyModelImpl.getOriginalKey()
2110 };
2111
2112 finderCache.removeResult(FINDER_PATH_COUNT_BY_CA_K, args);
2113 finderCache.removeResult(FINDER_PATH_FETCH_BY_CA_K, args);
2114 }
2115 }
2116
2117
2123 @Override
2124 public AssetCategoryProperty create(long categoryPropertyId) {
2125 AssetCategoryProperty assetCategoryProperty = new AssetCategoryPropertyImpl();
2126
2127 assetCategoryProperty.setNew(true);
2128 assetCategoryProperty.setPrimaryKey(categoryPropertyId);
2129
2130 assetCategoryProperty.setCompanyId(companyProvider.getCompanyId());
2131
2132 return assetCategoryProperty;
2133 }
2134
2135
2142 @Override
2143 public AssetCategoryProperty remove(long categoryPropertyId)
2144 throws NoSuchCategoryPropertyException {
2145 return remove((Serializable)categoryPropertyId);
2146 }
2147
2148
2155 @Override
2156 public AssetCategoryProperty remove(Serializable primaryKey)
2157 throws NoSuchCategoryPropertyException {
2158 Session session = null;
2159
2160 try {
2161 session = openSession();
2162
2163 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
2164 primaryKey);
2165
2166 if (assetCategoryProperty == null) {
2167 if (_log.isDebugEnabled()) {
2168 _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2169 }
2170
2171 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2172 primaryKey);
2173 }
2174
2175 return remove(assetCategoryProperty);
2176 }
2177 catch (NoSuchCategoryPropertyException nsee) {
2178 throw nsee;
2179 }
2180 catch (Exception e) {
2181 throw processException(e);
2182 }
2183 finally {
2184 closeSession(session);
2185 }
2186 }
2187
2188 @Override
2189 protected AssetCategoryProperty removeImpl(
2190 AssetCategoryProperty assetCategoryProperty) {
2191 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
2192
2193 Session session = null;
2194
2195 try {
2196 session = openSession();
2197
2198 if (!session.contains(assetCategoryProperty)) {
2199 assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
2200 assetCategoryProperty.getPrimaryKeyObj());
2201 }
2202
2203 if (assetCategoryProperty != null) {
2204 session.delete(assetCategoryProperty);
2205 }
2206 }
2207 catch (Exception e) {
2208 throw processException(e);
2209 }
2210 finally {
2211 closeSession(session);
2212 }
2213
2214 if (assetCategoryProperty != null) {
2215 clearCache(assetCategoryProperty);
2216 }
2217
2218 return assetCategoryProperty;
2219 }
2220
2221 @Override
2222 public AssetCategoryProperty updateImpl(
2223 AssetCategoryProperty assetCategoryProperty) {
2224 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
2225
2226 boolean isNew = assetCategoryProperty.isNew();
2227
2228 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
2229
2230 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
2231
2232 Date now = new Date();
2233
2234 if (isNew && (assetCategoryProperty.getCreateDate() == null)) {
2235 if (serviceContext == null) {
2236 assetCategoryProperty.setCreateDate(now);
2237 }
2238 else {
2239 assetCategoryProperty.setCreateDate(serviceContext.getCreateDate(
2240 now));
2241 }
2242 }
2243
2244 if (!assetCategoryPropertyModelImpl.hasSetModifiedDate()) {
2245 if (serviceContext == null) {
2246 assetCategoryProperty.setModifiedDate(now);
2247 }
2248 else {
2249 assetCategoryProperty.setModifiedDate(serviceContext.getModifiedDate(
2250 now));
2251 }
2252 }
2253
2254 Session session = null;
2255
2256 try {
2257 session = openSession();
2258
2259 if (assetCategoryProperty.isNew()) {
2260 session.save(assetCategoryProperty);
2261
2262 assetCategoryProperty.setNew(false);
2263 }
2264 else {
2265 assetCategoryProperty = (AssetCategoryProperty)session.merge(assetCategoryProperty);
2266 }
2267 }
2268 catch (Exception e) {
2269 throw processException(e);
2270 }
2271 finally {
2272 closeSession(session);
2273 }
2274
2275 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2276
2277 if (isNew || !AssetCategoryPropertyModelImpl.COLUMN_BITMASK_ENABLED) {
2278 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2279 }
2280
2281 else {
2282 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2283 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
2284 Object[] args = new Object[] {
2285 assetCategoryPropertyModelImpl.getOriginalCompanyId()
2286 };
2287
2288 finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
2289 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2290 args);
2291
2292 args = new Object[] {
2293 assetCategoryPropertyModelImpl.getCompanyId()
2294 };
2295
2296 finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
2297 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2298 args);
2299 }
2300
2301 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2302 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID.getColumnBitmask()) != 0) {
2303 Object[] args = new Object[] {
2304 assetCategoryPropertyModelImpl.getOriginalCategoryId()
2305 };
2306
2307 finderCache.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID, args);
2308 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID,
2309 args);
2310
2311 args = new Object[] {
2312 assetCategoryPropertyModelImpl.getCategoryId()
2313 };
2314
2315 finderCache.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID, args);
2316 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID,
2317 args);
2318 }
2319
2320 if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
2321 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K.getColumnBitmask()) != 0) {
2322 Object[] args = new Object[] {
2323 assetCategoryPropertyModelImpl.getOriginalCompanyId(),
2324 assetCategoryPropertyModelImpl.getOriginalKey()
2325 };
2326
2327 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
2328 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K,
2329 args);
2330
2331 args = new Object[] {
2332 assetCategoryPropertyModelImpl.getCompanyId(),
2333 assetCategoryPropertyModelImpl.getKey()
2334 };
2335
2336 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
2337 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K,
2338 args);
2339 }
2340 }
2341
2342 entityCache.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2343 AssetCategoryPropertyImpl.class,
2344 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty, false);
2345
2346 clearUniqueFindersCache(assetCategoryPropertyModelImpl);
2347 cacheUniqueFindersCache(assetCategoryPropertyModelImpl, isNew);
2348
2349 assetCategoryProperty.resetOriginalValues();
2350
2351 return assetCategoryProperty;
2352 }
2353
2354 protected AssetCategoryProperty toUnwrappedModel(
2355 AssetCategoryProperty assetCategoryProperty) {
2356 if (assetCategoryProperty instanceof AssetCategoryPropertyImpl) {
2357 return assetCategoryProperty;
2358 }
2359
2360 AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
2361
2362 assetCategoryPropertyImpl.setNew(assetCategoryProperty.isNew());
2363 assetCategoryPropertyImpl.setPrimaryKey(assetCategoryProperty.getPrimaryKey());
2364
2365 assetCategoryPropertyImpl.setCategoryPropertyId(assetCategoryProperty.getCategoryPropertyId());
2366 assetCategoryPropertyImpl.setCompanyId(assetCategoryProperty.getCompanyId());
2367 assetCategoryPropertyImpl.setUserId(assetCategoryProperty.getUserId());
2368 assetCategoryPropertyImpl.setUserName(assetCategoryProperty.getUserName());
2369 assetCategoryPropertyImpl.setCreateDate(assetCategoryProperty.getCreateDate());
2370 assetCategoryPropertyImpl.setModifiedDate(assetCategoryProperty.getModifiedDate());
2371 assetCategoryPropertyImpl.setCategoryId(assetCategoryProperty.getCategoryId());
2372 assetCategoryPropertyImpl.setKey(assetCategoryProperty.getKey());
2373 assetCategoryPropertyImpl.setValue(assetCategoryProperty.getValue());
2374
2375 return assetCategoryPropertyImpl;
2376 }
2377
2378
2385 @Override
2386 public AssetCategoryProperty findByPrimaryKey(Serializable primaryKey)
2387 throws NoSuchCategoryPropertyException {
2388 AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(primaryKey);
2389
2390 if (assetCategoryProperty == null) {
2391 if (_log.isDebugEnabled()) {
2392 _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2393 }
2394
2395 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2396 primaryKey);
2397 }
2398
2399 return assetCategoryProperty;
2400 }
2401
2402
2409 @Override
2410 public AssetCategoryProperty findByPrimaryKey(long categoryPropertyId)
2411 throws NoSuchCategoryPropertyException {
2412 return findByPrimaryKey((Serializable)categoryPropertyId);
2413 }
2414
2415
2421 @Override
2422 public AssetCategoryProperty fetchByPrimaryKey(Serializable primaryKey) {
2423 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)entityCache.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2424 AssetCategoryPropertyImpl.class, primaryKey);
2425
2426 if (assetCategoryProperty == _nullAssetCategoryProperty) {
2427 return null;
2428 }
2429
2430 if (assetCategoryProperty == null) {
2431 Session session = null;
2432
2433 try {
2434 session = openSession();
2435
2436 assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
2437 primaryKey);
2438
2439 if (assetCategoryProperty != null) {
2440 cacheResult(assetCategoryProperty);
2441 }
2442 else {
2443 entityCache.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2444 AssetCategoryPropertyImpl.class, primaryKey,
2445 _nullAssetCategoryProperty);
2446 }
2447 }
2448 catch (Exception e) {
2449 entityCache.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2450 AssetCategoryPropertyImpl.class, primaryKey);
2451
2452 throw processException(e);
2453 }
2454 finally {
2455 closeSession(session);
2456 }
2457 }
2458
2459 return assetCategoryProperty;
2460 }
2461
2462
2468 @Override
2469 public AssetCategoryProperty fetchByPrimaryKey(long categoryPropertyId) {
2470 return fetchByPrimaryKey((Serializable)categoryPropertyId);
2471 }
2472
2473 @Override
2474 public Map<Serializable, AssetCategoryProperty> fetchByPrimaryKeys(
2475 Set<Serializable> primaryKeys) {
2476 if (primaryKeys.isEmpty()) {
2477 return Collections.emptyMap();
2478 }
2479
2480 Map<Serializable, AssetCategoryProperty> map = new HashMap<Serializable, AssetCategoryProperty>();
2481
2482 if (primaryKeys.size() == 1) {
2483 Iterator<Serializable> iterator = primaryKeys.iterator();
2484
2485 Serializable primaryKey = iterator.next();
2486
2487 AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(primaryKey);
2488
2489 if (assetCategoryProperty != null) {
2490 map.put(primaryKey, assetCategoryProperty);
2491 }
2492
2493 return map;
2494 }
2495
2496 Set<Serializable> uncachedPrimaryKeys = null;
2497
2498 for (Serializable primaryKey : primaryKeys) {
2499 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)entityCache.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2500 AssetCategoryPropertyImpl.class, primaryKey);
2501
2502 if (assetCategoryProperty == null) {
2503 if (uncachedPrimaryKeys == null) {
2504 uncachedPrimaryKeys = new HashSet<Serializable>();
2505 }
2506
2507 uncachedPrimaryKeys.add(primaryKey);
2508 }
2509 else {
2510 map.put(primaryKey, assetCategoryProperty);
2511 }
2512 }
2513
2514 if (uncachedPrimaryKeys == null) {
2515 return map;
2516 }
2517
2518 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2519 1);
2520
2521 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE_PKS_IN);
2522
2523 for (Serializable primaryKey : uncachedPrimaryKeys) {
2524 query.append(String.valueOf(primaryKey));
2525
2526 query.append(StringPool.COMMA);
2527 }
2528
2529 query.setIndex(query.index() - 1);
2530
2531 query.append(StringPool.CLOSE_PARENTHESIS);
2532
2533 String sql = query.toString();
2534
2535 Session session = null;
2536
2537 try {
2538 session = openSession();
2539
2540 Query q = session.createQuery(sql);
2541
2542 for (AssetCategoryProperty assetCategoryProperty : (List<AssetCategoryProperty>)q.list()) {
2543 map.put(assetCategoryProperty.getPrimaryKeyObj(),
2544 assetCategoryProperty);
2545
2546 cacheResult(assetCategoryProperty);
2547
2548 uncachedPrimaryKeys.remove(assetCategoryProperty.getPrimaryKeyObj());
2549 }
2550
2551 for (Serializable primaryKey : uncachedPrimaryKeys) {
2552 entityCache.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
2553 AssetCategoryPropertyImpl.class, primaryKey,
2554 _nullAssetCategoryProperty);
2555 }
2556 }
2557 catch (Exception e) {
2558 throw processException(e);
2559 }
2560 finally {
2561 closeSession(session);
2562 }
2563
2564 return map;
2565 }
2566
2567
2572 @Override
2573 public List<AssetCategoryProperty> findAll() {
2574 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2575 }
2576
2577
2588 @Override
2589 public List<AssetCategoryProperty> findAll(int start, int end) {
2590 return findAll(start, end, null);
2591 }
2592
2593
2605 @Override
2606 public List<AssetCategoryProperty> findAll(int start, int end,
2607 OrderByComparator<AssetCategoryProperty> orderByComparator) {
2608 return findAll(start, end, orderByComparator, true);
2609 }
2610
2611
2624 @Override
2625 public List<AssetCategoryProperty> findAll(int start, int end,
2626 OrderByComparator<AssetCategoryProperty> orderByComparator,
2627 boolean retrieveFromCache) {
2628 boolean pagination = true;
2629 FinderPath finderPath = null;
2630 Object[] finderArgs = null;
2631
2632 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2633 (orderByComparator == null)) {
2634 pagination = false;
2635 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2636 finderArgs = FINDER_ARGS_EMPTY;
2637 }
2638 else {
2639 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2640 finderArgs = new Object[] { start, end, orderByComparator };
2641 }
2642
2643 List<AssetCategoryProperty> list = null;
2644
2645 if (retrieveFromCache) {
2646 list = (List<AssetCategoryProperty>)finderCache.getResult(finderPath,
2647 finderArgs, this);
2648 }
2649
2650 if (list == null) {
2651 StringBundler query = null;
2652 String sql = null;
2653
2654 if (orderByComparator != null) {
2655 query = new StringBundler(2 +
2656 (orderByComparator.getOrderByFields().length * 2));
2657
2658 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY);
2659
2660 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2661 orderByComparator);
2662
2663 sql = query.toString();
2664 }
2665 else {
2666 sql = _SQL_SELECT_ASSETCATEGORYPROPERTY;
2667
2668 if (pagination) {
2669 sql = sql.concat(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
2670 }
2671 }
2672
2673 Session session = null;
2674
2675 try {
2676 session = openSession();
2677
2678 Query q = session.createQuery(sql);
2679
2680 if (!pagination) {
2681 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
2682 getDialect(), start, end, false);
2683
2684 Collections.sort(list);
2685
2686 list = Collections.unmodifiableList(list);
2687 }
2688 else {
2689 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
2690 getDialect(), start, end);
2691 }
2692
2693 cacheResult(list);
2694
2695 finderCache.putResult(finderPath, finderArgs, list);
2696 }
2697 catch (Exception e) {
2698 finderCache.removeResult(finderPath, finderArgs);
2699
2700 throw processException(e);
2701 }
2702 finally {
2703 closeSession(session);
2704 }
2705 }
2706
2707 return list;
2708 }
2709
2710
2714 @Override
2715 public void removeAll() {
2716 for (AssetCategoryProperty assetCategoryProperty : findAll()) {
2717 remove(assetCategoryProperty);
2718 }
2719 }
2720
2721
2726 @Override
2727 public int countAll() {
2728 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
2729 FINDER_ARGS_EMPTY, this);
2730
2731 if (count == null) {
2732 Session session = null;
2733
2734 try {
2735 session = openSession();
2736
2737 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORYPROPERTY);
2738
2739 count = (Long)q.uniqueResult();
2740
2741 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
2742 count);
2743 }
2744 catch (Exception e) {
2745 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
2746 FINDER_ARGS_EMPTY);
2747
2748 throw processException(e);
2749 }
2750 finally {
2751 closeSession(session);
2752 }
2753 }
2754
2755 return count.intValue();
2756 }
2757
2758 @Override
2759 public Set<String> getBadColumnNames() {
2760 return _badColumnNames;
2761 }
2762
2763 @Override
2764 protected Map<String, Integer> getTableColumnsMap() {
2765 return AssetCategoryPropertyModelImpl.TABLE_COLUMNS_MAP;
2766 }
2767
2768
2771 public void afterPropertiesSet() {
2772 }
2773
2774 public void destroy() {
2775 entityCache.removeCache(AssetCategoryPropertyImpl.class.getName());
2776 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
2777 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2778 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2779 }
2780
2781 @BeanReference(type = CompanyProviderWrapper.class)
2782 protected CompanyProvider companyProvider;
2783 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
2784 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
2785 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty";
2786 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE_PKS_IN = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE categoryPropertyId IN (";
2787 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2788 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty";
2789 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2790 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategoryProperty.";
2791 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategoryProperty exists with the primary key ";
2792 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategoryProperty exists with the key {";
2793 private static final Log _log = LogFactoryUtil.getLog(AssetCategoryPropertyPersistenceImpl.class);
2794 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2795 "key"
2796 });
2797 private static final AssetCategoryProperty _nullAssetCategoryProperty = new AssetCategoryPropertyImpl() {
2798 @Override
2799 public Object clone() {
2800 return this;
2801 }
2802
2803 @Override
2804 public CacheModel<AssetCategoryProperty> toCacheModel() {
2805 return _nullAssetCategoryPropertyCacheModel;
2806 }
2807 };
2808
2809 private static final CacheModel<AssetCategoryProperty> _nullAssetCategoryPropertyCacheModel =
2810 new CacheModel<AssetCategoryProperty>() {
2811 @Override
2812 public AssetCategoryProperty toEntityModel() {
2813 return _nullAssetCategoryProperty;
2814 }
2815 };
2816 }