001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.BatchSessionUtil;
039 import com.liferay.portal.service.persistence.ResourcePersistence;
040 import com.liferay.portal.service.persistence.UserPersistence;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import com.liferay.portlet.asset.NoSuchCategoryPropertyException;
044 import com.liferay.portlet.asset.model.AssetCategoryProperty;
045 import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyImpl;
046 import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyModelImpl;
047
048 import java.io.Serializable;
049
050 import java.util.ArrayList;
051 import java.util.Collections;
052 import java.util.List;
053
054
070 public class AssetCategoryPropertyPersistenceImpl extends BasePersistenceImpl<AssetCategoryProperty>
071 implements AssetCategoryPropertyPersistence {
072 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryPropertyImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
074 ".List";
075 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
076 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
077 FINDER_CLASS_NAME_LIST, "findByCompanyId",
078 new String[] {
079 Long.class.getName(),
080
081 "java.lang.Integer", "java.lang.Integer",
082 "com.liferay.portal.kernel.util.OrderByComparator"
083 });
084 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
085 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
086 FINDER_CLASS_NAME_LIST, "countByCompanyId",
087 new String[] { Long.class.getName() });
088 public static final FinderPath FINDER_PATH_FIND_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
089 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
090 FINDER_CLASS_NAME_LIST, "findByCategoryId",
091 new String[] {
092 Long.class.getName(),
093
094 "java.lang.Integer", "java.lang.Integer",
095 "com.liferay.portal.kernel.util.OrderByComparator"
096 });
097 public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
098 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
099 FINDER_CLASS_NAME_LIST, "countByCategoryId",
100 new String[] { Long.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
102 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
103 FINDER_CLASS_NAME_LIST, "findByC_K",
104 new String[] {
105 Long.class.getName(), String.class.getName(),
106
107 "java.lang.Integer", "java.lang.Integer",
108 "com.liferay.portal.kernel.util.OrderByComparator"
109 });
110 public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
111 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
112 FINDER_CLASS_NAME_LIST, "countByC_K",
113 new String[] { Long.class.getName(), String.class.getName() });
114 public static final FinderPath FINDER_PATH_FETCH_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
115 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
116 FINDER_CLASS_NAME_ENTITY, "fetchByCA_K",
117 new String[] { Long.class.getName(), String.class.getName() });
118 public static final FinderPath FINDER_PATH_COUNT_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
119 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
120 FINDER_CLASS_NAME_LIST, "countByCA_K",
121 new String[] { Long.class.getName(), String.class.getName() });
122 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
123 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
124 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
125 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
126 AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
127 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
128
129
134 public void cacheResult(AssetCategoryProperty assetCategoryProperty) {
135 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
136 AssetCategoryPropertyImpl.class,
137 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
138
139 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
140 new Object[] {
141 new Long(assetCategoryProperty.getCategoryId()),
142
143 assetCategoryProperty.getKey()
144 }, assetCategoryProperty);
145 }
146
147
152 public void cacheResult(List<AssetCategoryProperty> assetCategoryProperties) {
153 for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
154 if (EntityCacheUtil.getResult(
155 AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
156 AssetCategoryPropertyImpl.class,
157 assetCategoryProperty.getPrimaryKey(), this) == null) {
158 cacheResult(assetCategoryProperty);
159 }
160 }
161 }
162
163
170 public void clearCache() {
171 CacheRegistryUtil.clear(AssetCategoryPropertyImpl.class.getName());
172 EntityCacheUtil.clearCache(AssetCategoryPropertyImpl.class.getName());
173 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
174 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
175 }
176
177
184 public void clearCache(AssetCategoryProperty assetCategoryProperty) {
185 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
186 AssetCategoryPropertyImpl.class,
187 assetCategoryProperty.getPrimaryKey());
188
189 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
190 new Object[] {
191 new Long(assetCategoryProperty.getCategoryId()),
192
193 assetCategoryProperty.getKey()
194 });
195 }
196
197
203 public AssetCategoryProperty create(long categoryPropertyId) {
204 AssetCategoryProperty assetCategoryProperty = new AssetCategoryPropertyImpl();
205
206 assetCategoryProperty.setNew(true);
207 assetCategoryProperty.setPrimaryKey(categoryPropertyId);
208
209 return assetCategoryProperty;
210 }
211
212
220 public AssetCategoryProperty remove(Serializable primaryKey)
221 throws NoSuchModelException, SystemException {
222 return remove(((Long)primaryKey).longValue());
223 }
224
225
233 public AssetCategoryProperty remove(long categoryPropertyId)
234 throws NoSuchCategoryPropertyException, SystemException {
235 Session session = null;
236
237 try {
238 session = openSession();
239
240 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
241 new Long(categoryPropertyId));
242
243 if (assetCategoryProperty == null) {
244 if (_log.isWarnEnabled()) {
245 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
246 categoryPropertyId);
247 }
248
249 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
250 categoryPropertyId);
251 }
252
253 return remove(assetCategoryProperty);
254 }
255 catch (NoSuchCategoryPropertyException nsee) {
256 throw nsee;
257 }
258 catch (Exception e) {
259 throw processException(e);
260 }
261 finally {
262 closeSession(session);
263 }
264 }
265
266 protected AssetCategoryProperty removeImpl(
267 AssetCategoryProperty assetCategoryProperty) throws SystemException {
268 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
269
270 Session session = null;
271
272 try {
273 session = openSession();
274
275 BatchSessionUtil.delete(session, assetCategoryProperty);
276 }
277 catch (Exception e) {
278 throw processException(e);
279 }
280 finally {
281 closeSession(session);
282 }
283
284 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
285
286 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
287
288 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
289 new Object[] {
290 new Long(assetCategoryPropertyModelImpl.getCategoryId()),
291
292 assetCategoryPropertyModelImpl.getKey()
293 });
294
295 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
296 AssetCategoryPropertyImpl.class,
297 assetCategoryProperty.getPrimaryKey());
298
299 return assetCategoryProperty;
300 }
301
302 public AssetCategoryProperty updateImpl(
303 com.liferay.portlet.asset.model.AssetCategoryProperty assetCategoryProperty,
304 boolean merge) throws SystemException {
305 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
306
307 boolean isNew = assetCategoryProperty.isNew();
308
309 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
310
311 Session session = null;
312
313 try {
314 session = openSession();
315
316 BatchSessionUtil.update(session, assetCategoryProperty, merge);
317
318 assetCategoryProperty.setNew(false);
319 }
320 catch (Exception e) {
321 throw processException(e);
322 }
323 finally {
324 closeSession(session);
325 }
326
327 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
328
329 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
330 AssetCategoryPropertyImpl.class,
331 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
332
333 if (!isNew &&
334 ((assetCategoryProperty.getCategoryId() != assetCategoryPropertyModelImpl.getOriginalCategoryId()) ||
335 !Validator.equals(assetCategoryProperty.getKey(),
336 assetCategoryPropertyModelImpl.getOriginalKey()))) {
337 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
338 new Object[] {
339 new Long(assetCategoryPropertyModelImpl.getOriginalCategoryId()),
340
341 assetCategoryPropertyModelImpl.getOriginalKey()
342 });
343 }
344
345 if (isNew ||
346 ((assetCategoryProperty.getCategoryId() != assetCategoryPropertyModelImpl.getOriginalCategoryId()) ||
347 !Validator.equals(assetCategoryProperty.getKey(),
348 assetCategoryPropertyModelImpl.getOriginalKey()))) {
349 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
350 new Object[] {
351 new Long(assetCategoryProperty.getCategoryId()),
352
353 assetCategoryProperty.getKey()
354 }, assetCategoryProperty);
355 }
356
357 return assetCategoryProperty;
358 }
359
360 protected AssetCategoryProperty toUnwrappedModel(
361 AssetCategoryProperty assetCategoryProperty) {
362 if (assetCategoryProperty instanceof AssetCategoryPropertyImpl) {
363 return assetCategoryProperty;
364 }
365
366 AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
367
368 assetCategoryPropertyImpl.setNew(assetCategoryProperty.isNew());
369 assetCategoryPropertyImpl.setPrimaryKey(assetCategoryProperty.getPrimaryKey());
370
371 assetCategoryPropertyImpl.setCategoryPropertyId(assetCategoryProperty.getCategoryPropertyId());
372 assetCategoryPropertyImpl.setCompanyId(assetCategoryProperty.getCompanyId());
373 assetCategoryPropertyImpl.setUserId(assetCategoryProperty.getUserId());
374 assetCategoryPropertyImpl.setUserName(assetCategoryProperty.getUserName());
375 assetCategoryPropertyImpl.setCreateDate(assetCategoryProperty.getCreateDate());
376 assetCategoryPropertyImpl.setModifiedDate(assetCategoryProperty.getModifiedDate());
377 assetCategoryPropertyImpl.setCategoryId(assetCategoryProperty.getCategoryId());
378 assetCategoryPropertyImpl.setKey(assetCategoryProperty.getKey());
379 assetCategoryPropertyImpl.setValue(assetCategoryProperty.getValue());
380
381 return assetCategoryPropertyImpl;
382 }
383
384
392 public AssetCategoryProperty findByPrimaryKey(Serializable primaryKey)
393 throws NoSuchModelException, SystemException {
394 return findByPrimaryKey(((Long)primaryKey).longValue());
395 }
396
397
405 public AssetCategoryProperty findByPrimaryKey(long categoryPropertyId)
406 throws NoSuchCategoryPropertyException, SystemException {
407 AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(categoryPropertyId);
408
409 if (assetCategoryProperty == null) {
410 if (_log.isWarnEnabled()) {
411 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
412 categoryPropertyId);
413 }
414
415 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
416 categoryPropertyId);
417 }
418
419 return assetCategoryProperty;
420 }
421
422
429 public AssetCategoryProperty fetchByPrimaryKey(Serializable primaryKey)
430 throws SystemException {
431 return fetchByPrimaryKey(((Long)primaryKey).longValue());
432 }
433
434
441 public AssetCategoryProperty fetchByPrimaryKey(long categoryPropertyId)
442 throws SystemException {
443 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)EntityCacheUtil.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
444 AssetCategoryPropertyImpl.class, categoryPropertyId, this);
445
446 if (assetCategoryProperty == null) {
447 Session session = null;
448
449 try {
450 session = openSession();
451
452 assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
453 new Long(categoryPropertyId));
454 }
455 catch (Exception e) {
456 throw processException(e);
457 }
458 finally {
459 if (assetCategoryProperty != null) {
460 cacheResult(assetCategoryProperty);
461 }
462
463 closeSession(session);
464 }
465 }
466
467 return assetCategoryProperty;
468 }
469
470
477 public List<AssetCategoryProperty> findByCompanyId(long companyId)
478 throws SystemException {
479 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
480 null);
481 }
482
483
496 public List<AssetCategoryProperty> findByCompanyId(long companyId,
497 int start, int end) throws SystemException {
498 return findByCompanyId(companyId, start, end, null);
499 }
500
501
515 public List<AssetCategoryProperty> findByCompanyId(long companyId,
516 int start, int end, OrderByComparator orderByComparator)
517 throws SystemException {
518 Object[] finderArgs = new Object[] {
519 companyId,
520
521 String.valueOf(start), String.valueOf(end),
522 String.valueOf(orderByComparator)
523 };
524
525 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
526 finderArgs, this);
527
528 if (list == null) {
529 StringBundler query = null;
530
531 if (orderByComparator != null) {
532 query = new StringBundler(3 +
533 (orderByComparator.getOrderByFields().length * 3));
534 }
535 else {
536 query = new StringBundler(3);
537 }
538
539 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
540
541 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
542
543 if (orderByComparator != null) {
544 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
545 orderByComparator);
546 }
547
548 else {
549 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
550 }
551
552 String sql = query.toString();
553
554 Session session = null;
555
556 try {
557 session = openSession();
558
559 Query q = session.createQuery(sql);
560
561 QueryPos qPos = QueryPos.getInstance(q);
562
563 qPos.add(companyId);
564
565 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
566 getDialect(), start, end);
567 }
568 catch (Exception e) {
569 throw processException(e);
570 }
571 finally {
572 if (list == null) {
573 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_COMPANYID,
574 finderArgs);
575 }
576 else {
577 cacheResult(list);
578
579 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
580 finderArgs, list);
581 }
582
583 closeSession(session);
584 }
585 }
586
587 return list;
588 }
589
590
603 public AssetCategoryProperty findByCompanyId_First(long companyId,
604 OrderByComparator orderByComparator)
605 throws NoSuchCategoryPropertyException, SystemException {
606 List<AssetCategoryProperty> list = findByCompanyId(companyId, 0, 1,
607 orderByComparator);
608
609 if (list.isEmpty()) {
610 StringBundler msg = new StringBundler(4);
611
612 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
613
614 msg.append("companyId=");
615 msg.append(companyId);
616
617 msg.append(StringPool.CLOSE_CURLY_BRACE);
618
619 throw new NoSuchCategoryPropertyException(msg.toString());
620 }
621 else {
622 return list.get(0);
623 }
624 }
625
626
639 public AssetCategoryProperty findByCompanyId_Last(long companyId,
640 OrderByComparator orderByComparator)
641 throws NoSuchCategoryPropertyException, SystemException {
642 int count = countByCompanyId(companyId);
643
644 List<AssetCategoryProperty> list = findByCompanyId(companyId,
645 count - 1, count, orderByComparator);
646
647 if (list.isEmpty()) {
648 StringBundler msg = new StringBundler(4);
649
650 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
651
652 msg.append("companyId=");
653 msg.append(companyId);
654
655 msg.append(StringPool.CLOSE_CURLY_BRACE);
656
657 throw new NoSuchCategoryPropertyException(msg.toString());
658 }
659 else {
660 return list.get(0);
661 }
662 }
663
664
678 public AssetCategoryProperty[] findByCompanyId_PrevAndNext(
679 long categoryPropertyId, long companyId,
680 OrderByComparator orderByComparator)
681 throws NoSuchCategoryPropertyException, SystemException {
682 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
683
684 Session session = null;
685
686 try {
687 session = openSession();
688
689 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
690
691 array[0] = getByCompanyId_PrevAndNext(session,
692 assetCategoryProperty, companyId, orderByComparator, true);
693
694 array[1] = assetCategoryProperty;
695
696 array[2] = getByCompanyId_PrevAndNext(session,
697 assetCategoryProperty, companyId, orderByComparator, false);
698
699 return array;
700 }
701 catch (Exception e) {
702 throw processException(e);
703 }
704 finally {
705 closeSession(session);
706 }
707 }
708
709 protected AssetCategoryProperty getByCompanyId_PrevAndNext(
710 Session session, AssetCategoryProperty assetCategoryProperty,
711 long companyId, OrderByComparator orderByComparator, boolean previous) {
712 StringBundler query = null;
713
714 if (orderByComparator != null) {
715 query = new StringBundler(6 +
716 (orderByComparator.getOrderByFields().length * 6));
717 }
718 else {
719 query = new StringBundler(3);
720 }
721
722 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
723
724 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
725
726 if (orderByComparator != null) {
727 String[] orderByFields = orderByComparator.getOrderByFields();
728
729 if (orderByFields.length > 0) {
730 query.append(WHERE_AND);
731 }
732
733 for (int i = 0; i < orderByFields.length; i++) {
734 query.append(_ORDER_BY_ENTITY_ALIAS);
735 query.append(orderByFields[i]);
736
737 if ((i + 1) < orderByFields.length) {
738 if (orderByComparator.isAscending() ^ previous) {
739 query.append(WHERE_GREATER_THAN_HAS_NEXT);
740 }
741 else {
742 query.append(WHERE_LESSER_THAN_HAS_NEXT);
743 }
744 }
745 else {
746 if (orderByComparator.isAscending() ^ previous) {
747 query.append(WHERE_GREATER_THAN);
748 }
749 else {
750 query.append(WHERE_LESSER_THAN);
751 }
752 }
753 }
754
755 query.append(ORDER_BY_CLAUSE);
756
757 for (int i = 0; i < orderByFields.length; i++) {
758 query.append(_ORDER_BY_ENTITY_ALIAS);
759 query.append(orderByFields[i]);
760
761 if ((i + 1) < orderByFields.length) {
762 if (orderByComparator.isAscending() ^ previous) {
763 query.append(ORDER_BY_ASC_HAS_NEXT);
764 }
765 else {
766 query.append(ORDER_BY_DESC_HAS_NEXT);
767 }
768 }
769 else {
770 if (orderByComparator.isAscending() ^ previous) {
771 query.append(ORDER_BY_ASC);
772 }
773 else {
774 query.append(ORDER_BY_DESC);
775 }
776 }
777 }
778 }
779
780 else {
781 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
782 }
783
784 String sql = query.toString();
785
786 Query q = session.createQuery(sql);
787
788 q.setFirstResult(0);
789 q.setMaxResults(2);
790
791 QueryPos qPos = QueryPos.getInstance(q);
792
793 qPos.add(companyId);
794
795 if (orderByComparator != null) {
796 Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
797
798 for (Object value : values) {
799 qPos.add(value);
800 }
801 }
802
803 List<AssetCategoryProperty> list = q.list();
804
805 if (list.size() == 2) {
806 return list.get(1);
807 }
808 else {
809 return null;
810 }
811 }
812
813
820 public List<AssetCategoryProperty> findByCategoryId(long categoryId)
821 throws SystemException {
822 return findByCategoryId(categoryId, QueryUtil.ALL_POS,
823 QueryUtil.ALL_POS, null);
824 }
825
826
839 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
840 int start, int end) throws SystemException {
841 return findByCategoryId(categoryId, start, end, null);
842 }
843
844
858 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
859 int start, int end, OrderByComparator orderByComparator)
860 throws SystemException {
861 Object[] finderArgs = new Object[] {
862 categoryId,
863
864 String.valueOf(start), String.valueOf(end),
865 String.valueOf(orderByComparator)
866 };
867
868 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_CATEGORYID,
869 finderArgs, this);
870
871 if (list == null) {
872 StringBundler query = null;
873
874 if (orderByComparator != null) {
875 query = new StringBundler(3 +
876 (orderByComparator.getOrderByFields().length * 3));
877 }
878 else {
879 query = new StringBundler(3);
880 }
881
882 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
883
884 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
885
886 if (orderByComparator != null) {
887 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
888 orderByComparator);
889 }
890
891 else {
892 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
893 }
894
895 String sql = query.toString();
896
897 Session session = null;
898
899 try {
900 session = openSession();
901
902 Query q = session.createQuery(sql);
903
904 QueryPos qPos = QueryPos.getInstance(q);
905
906 qPos.add(categoryId);
907
908 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
909 getDialect(), start, end);
910 }
911 catch (Exception e) {
912 throw processException(e);
913 }
914 finally {
915 if (list == null) {
916 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_CATEGORYID,
917 finderArgs);
918 }
919 else {
920 cacheResult(list);
921
922 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_CATEGORYID,
923 finderArgs, list);
924 }
925
926 closeSession(session);
927 }
928 }
929
930 return list;
931 }
932
933
946 public AssetCategoryProperty findByCategoryId_First(long categoryId,
947 OrderByComparator orderByComparator)
948 throws NoSuchCategoryPropertyException, SystemException {
949 List<AssetCategoryProperty> list = findByCategoryId(categoryId, 0, 1,
950 orderByComparator);
951
952 if (list.isEmpty()) {
953 StringBundler msg = new StringBundler(4);
954
955 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
956
957 msg.append("categoryId=");
958 msg.append(categoryId);
959
960 msg.append(StringPool.CLOSE_CURLY_BRACE);
961
962 throw new NoSuchCategoryPropertyException(msg.toString());
963 }
964 else {
965 return list.get(0);
966 }
967 }
968
969
982 public AssetCategoryProperty findByCategoryId_Last(long categoryId,
983 OrderByComparator orderByComparator)
984 throws NoSuchCategoryPropertyException, SystemException {
985 int count = countByCategoryId(categoryId);
986
987 List<AssetCategoryProperty> list = findByCategoryId(categoryId,
988 count - 1, count, orderByComparator);
989
990 if (list.isEmpty()) {
991 StringBundler msg = new StringBundler(4);
992
993 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
994
995 msg.append("categoryId=");
996 msg.append(categoryId);
997
998 msg.append(StringPool.CLOSE_CURLY_BRACE);
999
1000 throw new NoSuchCategoryPropertyException(msg.toString());
1001 }
1002 else {
1003 return list.get(0);
1004 }
1005 }
1006
1007
1021 public AssetCategoryProperty[] findByCategoryId_PrevAndNext(
1022 long categoryPropertyId, long categoryId,
1023 OrderByComparator orderByComparator)
1024 throws NoSuchCategoryPropertyException, SystemException {
1025 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1026
1027 Session session = null;
1028
1029 try {
1030 session = openSession();
1031
1032 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1033
1034 array[0] = getByCategoryId_PrevAndNext(session,
1035 assetCategoryProperty, categoryId, orderByComparator, true);
1036
1037 array[1] = assetCategoryProperty;
1038
1039 array[2] = getByCategoryId_PrevAndNext(session,
1040 assetCategoryProperty, categoryId, orderByComparator, false);
1041
1042 return array;
1043 }
1044 catch (Exception e) {
1045 throw processException(e);
1046 }
1047 finally {
1048 closeSession(session);
1049 }
1050 }
1051
1052 protected AssetCategoryProperty getByCategoryId_PrevAndNext(
1053 Session session, AssetCategoryProperty assetCategoryProperty,
1054 long categoryId, OrderByComparator orderByComparator, boolean previous) {
1055 StringBundler query = null;
1056
1057 if (orderByComparator != null) {
1058 query = new StringBundler(6 +
1059 (orderByComparator.getOrderByFields().length * 6));
1060 }
1061 else {
1062 query = new StringBundler(3);
1063 }
1064
1065 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1066
1067 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1068
1069 if (orderByComparator != null) {
1070 String[] orderByFields = orderByComparator.getOrderByFields();
1071
1072 if (orderByFields.length > 0) {
1073 query.append(WHERE_AND);
1074 }
1075
1076 for (int i = 0; i < orderByFields.length; i++) {
1077 query.append(_ORDER_BY_ENTITY_ALIAS);
1078 query.append(orderByFields[i]);
1079
1080 if ((i + 1) < orderByFields.length) {
1081 if (orderByComparator.isAscending() ^ previous) {
1082 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1083 }
1084 else {
1085 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1086 }
1087 }
1088 else {
1089 if (orderByComparator.isAscending() ^ previous) {
1090 query.append(WHERE_GREATER_THAN);
1091 }
1092 else {
1093 query.append(WHERE_LESSER_THAN);
1094 }
1095 }
1096 }
1097
1098 query.append(ORDER_BY_CLAUSE);
1099
1100 for (int i = 0; i < orderByFields.length; i++) {
1101 query.append(_ORDER_BY_ENTITY_ALIAS);
1102 query.append(orderByFields[i]);
1103
1104 if ((i + 1) < orderByFields.length) {
1105 if (orderByComparator.isAscending() ^ previous) {
1106 query.append(ORDER_BY_ASC_HAS_NEXT);
1107 }
1108 else {
1109 query.append(ORDER_BY_DESC_HAS_NEXT);
1110 }
1111 }
1112 else {
1113 if (orderByComparator.isAscending() ^ previous) {
1114 query.append(ORDER_BY_ASC);
1115 }
1116 else {
1117 query.append(ORDER_BY_DESC);
1118 }
1119 }
1120 }
1121 }
1122
1123 else {
1124 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1125 }
1126
1127 String sql = query.toString();
1128
1129 Query q = session.createQuery(sql);
1130
1131 q.setFirstResult(0);
1132 q.setMaxResults(2);
1133
1134 QueryPos qPos = QueryPos.getInstance(q);
1135
1136 qPos.add(categoryId);
1137
1138 if (orderByComparator != null) {
1139 Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
1140
1141 for (Object value : values) {
1142 qPos.add(value);
1143 }
1144 }
1145
1146 List<AssetCategoryProperty> list = q.list();
1147
1148 if (list.size() == 2) {
1149 return list.get(1);
1150 }
1151 else {
1152 return null;
1153 }
1154 }
1155
1156
1164 public List<AssetCategoryProperty> findByC_K(long companyId, String key)
1165 throws SystemException {
1166 return findByC_K(companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1167 null);
1168 }
1169
1170
1184 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1185 int start, int end) throws SystemException {
1186 return findByC_K(companyId, key, start, end, null);
1187 }
1188
1189
1204 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1205 int start, int end, OrderByComparator orderByComparator)
1206 throws SystemException {
1207 Object[] finderArgs = new Object[] {
1208 companyId, key,
1209
1210 String.valueOf(start), String.valueOf(end),
1211 String.valueOf(orderByComparator)
1212 };
1213
1214 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_K,
1215 finderArgs, this);
1216
1217 if (list == null) {
1218 StringBundler query = null;
1219
1220 if (orderByComparator != null) {
1221 query = new StringBundler(4 +
1222 (orderByComparator.getOrderByFields().length * 3));
1223 }
1224 else {
1225 query = new StringBundler(4);
1226 }
1227
1228 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1229
1230 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1231
1232 if (key == null) {
1233 query.append(_FINDER_COLUMN_C_K_KEY_1);
1234 }
1235 else {
1236 if (key.equals(StringPool.BLANK)) {
1237 query.append(_FINDER_COLUMN_C_K_KEY_3);
1238 }
1239 else {
1240 query.append(_FINDER_COLUMN_C_K_KEY_2);
1241 }
1242 }
1243
1244 if (orderByComparator != null) {
1245 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1246 orderByComparator);
1247 }
1248
1249 else {
1250 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1251 }
1252
1253 String sql = query.toString();
1254
1255 Session session = null;
1256
1257 try {
1258 session = openSession();
1259
1260 Query q = session.createQuery(sql);
1261
1262 QueryPos qPos = QueryPos.getInstance(q);
1263
1264 qPos.add(companyId);
1265
1266 if (key != null) {
1267 qPos.add(key);
1268 }
1269
1270 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1271 getDialect(), start, end);
1272 }
1273 catch (Exception e) {
1274 throw processException(e);
1275 }
1276 finally {
1277 if (list == null) {
1278 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_C_K,
1279 finderArgs);
1280 }
1281 else {
1282 cacheResult(list);
1283
1284 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_K,
1285 finderArgs, list);
1286 }
1287
1288 closeSession(session);
1289 }
1290 }
1291
1292 return list;
1293 }
1294
1295
1309 public AssetCategoryProperty findByC_K_First(long companyId, String key,
1310 OrderByComparator orderByComparator)
1311 throws NoSuchCategoryPropertyException, SystemException {
1312 List<AssetCategoryProperty> list = findByC_K(companyId, key, 0, 1,
1313 orderByComparator);
1314
1315 if (list.isEmpty()) {
1316 StringBundler msg = new StringBundler(6);
1317
1318 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1319
1320 msg.append("companyId=");
1321 msg.append(companyId);
1322
1323 msg.append(", key=");
1324 msg.append(key);
1325
1326 msg.append(StringPool.CLOSE_CURLY_BRACE);
1327
1328 throw new NoSuchCategoryPropertyException(msg.toString());
1329 }
1330 else {
1331 return list.get(0);
1332 }
1333 }
1334
1335
1349 public AssetCategoryProperty findByC_K_Last(long companyId, String key,
1350 OrderByComparator orderByComparator)
1351 throws NoSuchCategoryPropertyException, SystemException {
1352 int count = countByC_K(companyId, key);
1353
1354 List<AssetCategoryProperty> list = findByC_K(companyId, key, count - 1,
1355 count, orderByComparator);
1356
1357 if (list.isEmpty()) {
1358 StringBundler msg = new StringBundler(6);
1359
1360 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1361
1362 msg.append("companyId=");
1363 msg.append(companyId);
1364
1365 msg.append(", key=");
1366 msg.append(key);
1367
1368 msg.append(StringPool.CLOSE_CURLY_BRACE);
1369
1370 throw new NoSuchCategoryPropertyException(msg.toString());
1371 }
1372 else {
1373 return list.get(0);
1374 }
1375 }
1376
1377
1392 public AssetCategoryProperty[] findByC_K_PrevAndNext(
1393 long categoryPropertyId, long companyId, String key,
1394 OrderByComparator orderByComparator)
1395 throws NoSuchCategoryPropertyException, SystemException {
1396 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1397
1398 Session session = null;
1399
1400 try {
1401 session = openSession();
1402
1403 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1404
1405 array[0] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1406 companyId, key, orderByComparator, true);
1407
1408 array[1] = assetCategoryProperty;
1409
1410 array[2] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1411 companyId, key, orderByComparator, false);
1412
1413 return array;
1414 }
1415 catch (Exception e) {
1416 throw processException(e);
1417 }
1418 finally {
1419 closeSession(session);
1420 }
1421 }
1422
1423 protected AssetCategoryProperty getByC_K_PrevAndNext(Session session,
1424 AssetCategoryProperty assetCategoryProperty, long companyId,
1425 String key, OrderByComparator orderByComparator, boolean previous) {
1426 StringBundler query = null;
1427
1428 if (orderByComparator != null) {
1429 query = new StringBundler(6 +
1430 (orderByComparator.getOrderByFields().length * 6));
1431 }
1432 else {
1433 query = new StringBundler(3);
1434 }
1435
1436 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1437
1438 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1439
1440 if (key == null) {
1441 query.append(_FINDER_COLUMN_C_K_KEY_1);
1442 }
1443 else {
1444 if (key.equals(StringPool.BLANK)) {
1445 query.append(_FINDER_COLUMN_C_K_KEY_3);
1446 }
1447 else {
1448 query.append(_FINDER_COLUMN_C_K_KEY_2);
1449 }
1450 }
1451
1452 if (orderByComparator != null) {
1453 String[] orderByFields = orderByComparator.getOrderByFields();
1454
1455 if (orderByFields.length > 0) {
1456 query.append(WHERE_AND);
1457 }
1458
1459 for (int i = 0; i < orderByFields.length; i++) {
1460 query.append(_ORDER_BY_ENTITY_ALIAS);
1461 query.append(orderByFields[i]);
1462
1463 if ((i + 1) < orderByFields.length) {
1464 if (orderByComparator.isAscending() ^ previous) {
1465 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1466 }
1467 else {
1468 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1469 }
1470 }
1471 else {
1472 if (orderByComparator.isAscending() ^ previous) {
1473 query.append(WHERE_GREATER_THAN);
1474 }
1475 else {
1476 query.append(WHERE_LESSER_THAN);
1477 }
1478 }
1479 }
1480
1481 query.append(ORDER_BY_CLAUSE);
1482
1483 for (int i = 0; i < orderByFields.length; i++) {
1484 query.append(_ORDER_BY_ENTITY_ALIAS);
1485 query.append(orderByFields[i]);
1486
1487 if ((i + 1) < orderByFields.length) {
1488 if (orderByComparator.isAscending() ^ previous) {
1489 query.append(ORDER_BY_ASC_HAS_NEXT);
1490 }
1491 else {
1492 query.append(ORDER_BY_DESC_HAS_NEXT);
1493 }
1494 }
1495 else {
1496 if (orderByComparator.isAscending() ^ previous) {
1497 query.append(ORDER_BY_ASC);
1498 }
1499 else {
1500 query.append(ORDER_BY_DESC);
1501 }
1502 }
1503 }
1504 }
1505
1506 else {
1507 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1508 }
1509
1510 String sql = query.toString();
1511
1512 Query q = session.createQuery(sql);
1513
1514 q.setFirstResult(0);
1515 q.setMaxResults(2);
1516
1517 QueryPos qPos = QueryPos.getInstance(q);
1518
1519 qPos.add(companyId);
1520
1521 if (key != null) {
1522 qPos.add(key);
1523 }
1524
1525 if (orderByComparator != null) {
1526 Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
1527
1528 for (Object value : values) {
1529 qPos.add(value);
1530 }
1531 }
1532
1533 List<AssetCategoryProperty> list = q.list();
1534
1535 if (list.size() == 2) {
1536 return list.get(1);
1537 }
1538 else {
1539 return null;
1540 }
1541 }
1542
1543
1552 public AssetCategoryProperty findByCA_K(long categoryId, String key)
1553 throws NoSuchCategoryPropertyException, SystemException {
1554 AssetCategoryProperty assetCategoryProperty = fetchByCA_K(categoryId,
1555 key);
1556
1557 if (assetCategoryProperty == null) {
1558 StringBundler msg = new StringBundler(6);
1559
1560 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1561
1562 msg.append("categoryId=");
1563 msg.append(categoryId);
1564
1565 msg.append(", key=");
1566 msg.append(key);
1567
1568 msg.append(StringPool.CLOSE_CURLY_BRACE);
1569
1570 if (_log.isWarnEnabled()) {
1571 _log.warn(msg.toString());
1572 }
1573
1574 throw new NoSuchCategoryPropertyException(msg.toString());
1575 }
1576
1577 return assetCategoryProperty;
1578 }
1579
1580
1588 public AssetCategoryProperty fetchByCA_K(long categoryId, String key)
1589 throws SystemException {
1590 return fetchByCA_K(categoryId, key, true);
1591 }
1592
1593
1601 public AssetCategoryProperty fetchByCA_K(long categoryId, String key,
1602 boolean retrieveFromCache) throws SystemException {
1603 Object[] finderArgs = new Object[] { categoryId, key };
1604
1605 Object result = null;
1606
1607 if (retrieveFromCache) {
1608 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CA_K,
1609 finderArgs, this);
1610 }
1611
1612 if (result == null) {
1613 StringBundler query = new StringBundler(4);
1614
1615 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1616
1617 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1618
1619 if (key == null) {
1620 query.append(_FINDER_COLUMN_CA_K_KEY_1);
1621 }
1622 else {
1623 if (key.equals(StringPool.BLANK)) {
1624 query.append(_FINDER_COLUMN_CA_K_KEY_3);
1625 }
1626 else {
1627 query.append(_FINDER_COLUMN_CA_K_KEY_2);
1628 }
1629 }
1630
1631 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1632
1633 String sql = query.toString();
1634
1635 Session session = null;
1636
1637 try {
1638 session = openSession();
1639
1640 Query q = session.createQuery(sql);
1641
1642 QueryPos qPos = QueryPos.getInstance(q);
1643
1644 qPos.add(categoryId);
1645
1646 if (key != null) {
1647 qPos.add(key);
1648 }
1649
1650 List<AssetCategoryProperty> list = q.list();
1651
1652 result = list;
1653
1654 AssetCategoryProperty assetCategoryProperty = null;
1655
1656 if (list.isEmpty()) {
1657 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1658 finderArgs, list);
1659 }
1660 else {
1661 assetCategoryProperty = list.get(0);
1662
1663 cacheResult(assetCategoryProperty);
1664
1665 if ((assetCategoryProperty.getCategoryId() != categoryId) ||
1666 (assetCategoryProperty.getKey() == null) ||
1667 !assetCategoryProperty.getKey().equals(key)) {
1668 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1669 finderArgs, assetCategoryProperty);
1670 }
1671 }
1672
1673 return assetCategoryProperty;
1674 }
1675 catch (Exception e) {
1676 throw processException(e);
1677 }
1678 finally {
1679 if (result == null) {
1680 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
1681 finderArgs);
1682 }
1683
1684 closeSession(session);
1685 }
1686 }
1687 else {
1688 if (result instanceof List<?>) {
1689 return null;
1690 }
1691 else {
1692 return (AssetCategoryProperty)result;
1693 }
1694 }
1695 }
1696
1697
1703 public List<AssetCategoryProperty> findAll() throws SystemException {
1704 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1705 }
1706
1707
1719 public List<AssetCategoryProperty> findAll(int start, int end)
1720 throws SystemException {
1721 return findAll(start, end, null);
1722 }
1723
1724
1737 public List<AssetCategoryProperty> findAll(int start, int end,
1738 OrderByComparator orderByComparator) throws SystemException {
1739 Object[] finderArgs = new Object[] {
1740 String.valueOf(start), String.valueOf(end),
1741 String.valueOf(orderByComparator)
1742 };
1743
1744 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1745 finderArgs, this);
1746
1747 if (list == null) {
1748 StringBundler query = null;
1749 String sql = null;
1750
1751 if (orderByComparator != null) {
1752 query = new StringBundler(2 +
1753 (orderByComparator.getOrderByFields().length * 3));
1754
1755 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY);
1756
1757 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1758 orderByComparator);
1759
1760 sql = query.toString();
1761 }
1762 else {
1763 sql = _SQL_SELECT_ASSETCATEGORYPROPERTY.concat(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1764 }
1765
1766 Session session = null;
1767
1768 try {
1769 session = openSession();
1770
1771 Query q = session.createQuery(sql);
1772
1773 if (orderByComparator == null) {
1774 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1775 getDialect(), start, end, false);
1776
1777 Collections.sort(list);
1778 }
1779 else {
1780 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1781 getDialect(), start, end);
1782 }
1783 }
1784 catch (Exception e) {
1785 throw processException(e);
1786 }
1787 finally {
1788 if (list == null) {
1789 FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
1790 finderArgs);
1791 }
1792 else {
1793 cacheResult(list);
1794
1795 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
1796 list);
1797 }
1798
1799 closeSession(session);
1800 }
1801 }
1802
1803 return list;
1804 }
1805
1806
1812 public void removeByCompanyId(long companyId) throws SystemException {
1813 for (AssetCategoryProperty assetCategoryProperty : findByCompanyId(
1814 companyId)) {
1815 remove(assetCategoryProperty);
1816 }
1817 }
1818
1819
1825 public void removeByCategoryId(long categoryId) throws SystemException {
1826 for (AssetCategoryProperty assetCategoryProperty : findByCategoryId(
1827 categoryId)) {
1828 remove(assetCategoryProperty);
1829 }
1830 }
1831
1832
1839 public void removeByC_K(long companyId, String key)
1840 throws SystemException {
1841 for (AssetCategoryProperty assetCategoryProperty : findByC_K(
1842 companyId, key)) {
1843 remove(assetCategoryProperty);
1844 }
1845 }
1846
1847
1854 public void removeByCA_K(long categoryId, String key)
1855 throws NoSuchCategoryPropertyException, SystemException {
1856 AssetCategoryProperty assetCategoryProperty = findByCA_K(categoryId, key);
1857
1858 remove(assetCategoryProperty);
1859 }
1860
1861
1866 public void removeAll() throws SystemException {
1867 for (AssetCategoryProperty assetCategoryProperty : findAll()) {
1868 remove(assetCategoryProperty);
1869 }
1870 }
1871
1872
1879 public int countByCompanyId(long companyId) throws SystemException {
1880 Object[] finderArgs = new Object[] { companyId };
1881
1882 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1883 finderArgs, this);
1884
1885 if (count == null) {
1886 StringBundler query = new StringBundler(2);
1887
1888 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1889
1890 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1891
1892 String sql = query.toString();
1893
1894 Session session = null;
1895
1896 try {
1897 session = openSession();
1898
1899 Query q = session.createQuery(sql);
1900
1901 QueryPos qPos = QueryPos.getInstance(q);
1902
1903 qPos.add(companyId);
1904
1905 count = (Long)q.uniqueResult();
1906 }
1907 catch (Exception e) {
1908 throw processException(e);
1909 }
1910 finally {
1911 if (count == null) {
1912 count = Long.valueOf(0);
1913 }
1914
1915 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1916 finderArgs, count);
1917
1918 closeSession(session);
1919 }
1920 }
1921
1922 return count.intValue();
1923 }
1924
1925
1932 public int countByCategoryId(long categoryId) throws SystemException {
1933 Object[] finderArgs = new Object[] { categoryId };
1934
1935 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1936 finderArgs, this);
1937
1938 if (count == null) {
1939 StringBundler query = new StringBundler(2);
1940
1941 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1942
1943 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1944
1945 String sql = query.toString();
1946
1947 Session session = null;
1948
1949 try {
1950 session = openSession();
1951
1952 Query q = session.createQuery(sql);
1953
1954 QueryPos qPos = QueryPos.getInstance(q);
1955
1956 qPos.add(categoryId);
1957
1958 count = (Long)q.uniqueResult();
1959 }
1960 catch (Exception e) {
1961 throw processException(e);
1962 }
1963 finally {
1964 if (count == null) {
1965 count = Long.valueOf(0);
1966 }
1967
1968 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1969 finderArgs, count);
1970
1971 closeSession(session);
1972 }
1973 }
1974
1975 return count.intValue();
1976 }
1977
1978
1986 public int countByC_K(long companyId, String key) throws SystemException {
1987 Object[] finderArgs = new Object[] { companyId, key };
1988
1989 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_K,
1990 finderArgs, this);
1991
1992 if (count == null) {
1993 StringBundler query = new StringBundler(3);
1994
1995 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1996
1997 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1998
1999 if (key == null) {
2000 query.append(_FINDER_COLUMN_C_K_KEY_1);
2001 }
2002 else {
2003 if (key.equals(StringPool.BLANK)) {
2004 query.append(_FINDER_COLUMN_C_K_KEY_3);
2005 }
2006 else {
2007 query.append(_FINDER_COLUMN_C_K_KEY_2);
2008 }
2009 }
2010
2011 String sql = query.toString();
2012
2013 Session session = null;
2014
2015 try {
2016 session = openSession();
2017
2018 Query q = session.createQuery(sql);
2019
2020 QueryPos qPos = QueryPos.getInstance(q);
2021
2022 qPos.add(companyId);
2023
2024 if (key != null) {
2025 qPos.add(key);
2026 }
2027
2028 count = (Long)q.uniqueResult();
2029 }
2030 catch (Exception e) {
2031 throw processException(e);
2032 }
2033 finally {
2034 if (count == null) {
2035 count = Long.valueOf(0);
2036 }
2037
2038 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, finderArgs,
2039 count);
2040
2041 closeSession(session);
2042 }
2043 }
2044
2045 return count.intValue();
2046 }
2047
2048
2056 public int countByCA_K(long categoryId, String key)
2057 throws SystemException {
2058 Object[] finderArgs = new Object[] { categoryId, key };
2059
2060 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CA_K,
2061 finderArgs, this);
2062
2063 if (count == null) {
2064 StringBundler query = new StringBundler(3);
2065
2066 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
2067
2068 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
2069
2070 if (key == null) {
2071 query.append(_FINDER_COLUMN_CA_K_KEY_1);
2072 }
2073 else {
2074 if (key.equals(StringPool.BLANK)) {
2075 query.append(_FINDER_COLUMN_CA_K_KEY_3);
2076 }
2077 else {
2078 query.append(_FINDER_COLUMN_CA_K_KEY_2);
2079 }
2080 }
2081
2082 String sql = query.toString();
2083
2084 Session session = null;
2085
2086 try {
2087 session = openSession();
2088
2089 Query q = session.createQuery(sql);
2090
2091 QueryPos qPos = QueryPos.getInstance(q);
2092
2093 qPos.add(categoryId);
2094
2095 if (key != null) {
2096 qPos.add(key);
2097 }
2098
2099 count = (Long)q.uniqueResult();
2100 }
2101 catch (Exception e) {
2102 throw processException(e);
2103 }
2104 finally {
2105 if (count == null) {
2106 count = Long.valueOf(0);
2107 }
2108
2109 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K,
2110 finderArgs, count);
2111
2112 closeSession(session);
2113 }
2114 }
2115
2116 return count.intValue();
2117 }
2118
2119
2125 public int countAll() throws SystemException {
2126 Object[] finderArgs = new Object[0];
2127
2128 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2129 finderArgs, this);
2130
2131 if (count == null) {
2132 Session session = null;
2133
2134 try {
2135 session = openSession();
2136
2137 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORYPROPERTY);
2138
2139 count = (Long)q.uniqueResult();
2140 }
2141 catch (Exception e) {
2142 throw processException(e);
2143 }
2144 finally {
2145 if (count == null) {
2146 count = Long.valueOf(0);
2147 }
2148
2149 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2150 count);
2151
2152 closeSession(session);
2153 }
2154 }
2155
2156 return count.intValue();
2157 }
2158
2159
2162 public void afterPropertiesSet() {
2163 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2164 com.liferay.portal.util.PropsUtil.get(
2165 "value.object.listener.com.liferay.portlet.asset.model.AssetCategoryProperty")));
2166
2167 if (listenerClassNames.length > 0) {
2168 try {
2169 List<ModelListener<AssetCategoryProperty>> listenersList = new ArrayList<ModelListener<AssetCategoryProperty>>();
2170
2171 for (String listenerClassName : listenerClassNames) {
2172 listenersList.add((ModelListener<AssetCategoryProperty>)InstanceFactory.newInstance(
2173 listenerClassName));
2174 }
2175
2176 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2177 }
2178 catch (Exception e) {
2179 _log.error(e);
2180 }
2181 }
2182 }
2183
2184 public void destroy() {
2185 EntityCacheUtil.removeCache(AssetCategoryPropertyImpl.class.getName());
2186 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2187 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
2188 }
2189
2190 @BeanReference(type = AssetCategoryPersistence.class)
2191 protected AssetCategoryPersistence assetCategoryPersistence;
2192 @BeanReference(type = AssetCategoryPropertyPersistence.class)
2193 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
2194 @BeanReference(type = AssetEntryPersistence.class)
2195 protected AssetEntryPersistence assetEntryPersistence;
2196 @BeanReference(type = AssetLinkPersistence.class)
2197 protected AssetLinkPersistence assetLinkPersistence;
2198 @BeanReference(type = AssetTagPersistence.class)
2199 protected AssetTagPersistence assetTagPersistence;
2200 @BeanReference(type = AssetTagPropertyPersistence.class)
2201 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
2202 @BeanReference(type = AssetTagStatsPersistence.class)
2203 protected AssetTagStatsPersistence assetTagStatsPersistence;
2204 @BeanReference(type = AssetVocabularyPersistence.class)
2205 protected AssetVocabularyPersistence assetVocabularyPersistence;
2206 @BeanReference(type = ResourcePersistence.class)
2207 protected ResourcePersistence resourcePersistence;
2208 @BeanReference(type = UserPersistence.class)
2209 protected UserPersistence userPersistence;
2210 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty";
2211 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2212 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty";
2213 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2214 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetCategoryProperty.companyId = ?";
2215 private static final String _FINDER_COLUMN_CATEGORYID_CATEGORYID_2 = "assetCategoryProperty.categoryId = ?";
2216 private static final String _FINDER_COLUMN_C_K_COMPANYID_2 = "assetCategoryProperty.companyId = ? AND ";
2217 private static final String _FINDER_COLUMN_C_K_KEY_1 = "assetCategoryProperty.key IS NULL";
2218 private static final String _FINDER_COLUMN_C_K_KEY_2 = "assetCategoryProperty.key = ?";
2219 private static final String _FINDER_COLUMN_C_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = ?)";
2220 private static final String _FINDER_COLUMN_CA_K_CATEGORYID_2 = "assetCategoryProperty.categoryId = ? AND ";
2221 private static final String _FINDER_COLUMN_CA_K_KEY_1 = "assetCategoryProperty.key IS NULL";
2222 private static final String _FINDER_COLUMN_CA_K_KEY_2 = "assetCategoryProperty.key = ?";
2223 private static final String _FINDER_COLUMN_CA_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = ?)";
2224 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategoryProperty.";
2225 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategoryProperty exists with the primary key ";
2226 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategoryProperty exists with the key {";
2227 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPropertyPersistenceImpl.class);
2228 }