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 if (assetCategoryProperty.isCachedModel() ||
276 BatchSessionUtil.isEnabled()) {
277 Object staleObject = session.get(AssetCategoryPropertyImpl.class,
278 assetCategoryProperty.getPrimaryKeyObj());
279
280 if (staleObject != null) {
281 session.evict(staleObject);
282 }
283 }
284
285 session.delete(assetCategoryProperty);
286
287 session.flush();
288 }
289 catch (Exception e) {
290 throw processException(e);
291 }
292 finally {
293 closeSession(session);
294 }
295
296 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
297
298 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
299
300 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
301 new Object[] {
302 new Long(assetCategoryPropertyModelImpl.getOriginalCategoryId()),
303
304 assetCategoryPropertyModelImpl.getOriginalKey()
305 });
306
307 EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
308 AssetCategoryPropertyImpl.class,
309 assetCategoryProperty.getPrimaryKey());
310
311 return assetCategoryProperty;
312 }
313
314 public AssetCategoryProperty updateImpl(
315 com.liferay.portlet.asset.model.AssetCategoryProperty assetCategoryProperty,
316 boolean merge) throws SystemException {
317 assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
318
319 boolean isNew = assetCategoryProperty.isNew();
320
321 AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
322
323 Session session = null;
324
325 try {
326 session = openSession();
327
328 BatchSessionUtil.update(session, assetCategoryProperty, merge);
329
330 assetCategoryProperty.setNew(false);
331 }
332 catch (Exception e) {
333 throw processException(e);
334 }
335 finally {
336 closeSession(session);
337 }
338
339 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
340
341 EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
342 AssetCategoryPropertyImpl.class,
343 assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
344
345 if (!isNew &&
346 ((assetCategoryProperty.getCategoryId() != assetCategoryPropertyModelImpl.getOriginalCategoryId()) ||
347 !Validator.equals(assetCategoryProperty.getKey(),
348 assetCategoryPropertyModelImpl.getOriginalKey()))) {
349 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
350 new Object[] {
351 new Long(assetCategoryPropertyModelImpl.getOriginalCategoryId()),
352
353 assetCategoryPropertyModelImpl.getOriginalKey()
354 });
355 }
356
357 if (isNew ||
358 ((assetCategoryProperty.getCategoryId() != assetCategoryPropertyModelImpl.getOriginalCategoryId()) ||
359 !Validator.equals(assetCategoryProperty.getKey(),
360 assetCategoryPropertyModelImpl.getOriginalKey()))) {
361 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
362 new Object[] {
363 new Long(assetCategoryProperty.getCategoryId()),
364
365 assetCategoryProperty.getKey()
366 }, assetCategoryProperty);
367 }
368
369 return assetCategoryProperty;
370 }
371
372 protected AssetCategoryProperty toUnwrappedModel(
373 AssetCategoryProperty assetCategoryProperty) {
374 if (assetCategoryProperty instanceof AssetCategoryPropertyImpl) {
375 return assetCategoryProperty;
376 }
377
378 AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
379
380 assetCategoryPropertyImpl.setNew(assetCategoryProperty.isNew());
381 assetCategoryPropertyImpl.setPrimaryKey(assetCategoryProperty.getPrimaryKey());
382
383 assetCategoryPropertyImpl.setCategoryPropertyId(assetCategoryProperty.getCategoryPropertyId());
384 assetCategoryPropertyImpl.setCompanyId(assetCategoryProperty.getCompanyId());
385 assetCategoryPropertyImpl.setUserId(assetCategoryProperty.getUserId());
386 assetCategoryPropertyImpl.setUserName(assetCategoryProperty.getUserName());
387 assetCategoryPropertyImpl.setCreateDate(assetCategoryProperty.getCreateDate());
388 assetCategoryPropertyImpl.setModifiedDate(assetCategoryProperty.getModifiedDate());
389 assetCategoryPropertyImpl.setCategoryId(assetCategoryProperty.getCategoryId());
390 assetCategoryPropertyImpl.setKey(assetCategoryProperty.getKey());
391 assetCategoryPropertyImpl.setValue(assetCategoryProperty.getValue());
392
393 return assetCategoryPropertyImpl;
394 }
395
396
404 public AssetCategoryProperty findByPrimaryKey(Serializable primaryKey)
405 throws NoSuchModelException, SystemException {
406 return findByPrimaryKey(((Long)primaryKey).longValue());
407 }
408
409
417 public AssetCategoryProperty findByPrimaryKey(long categoryPropertyId)
418 throws NoSuchCategoryPropertyException, SystemException {
419 AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(categoryPropertyId);
420
421 if (assetCategoryProperty == null) {
422 if (_log.isWarnEnabled()) {
423 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
424 categoryPropertyId);
425 }
426
427 throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
428 categoryPropertyId);
429 }
430
431 return assetCategoryProperty;
432 }
433
434
441 public AssetCategoryProperty fetchByPrimaryKey(Serializable primaryKey)
442 throws SystemException {
443 return fetchByPrimaryKey(((Long)primaryKey).longValue());
444 }
445
446
453 public AssetCategoryProperty fetchByPrimaryKey(long categoryPropertyId)
454 throws SystemException {
455 AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)EntityCacheUtil.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
456 AssetCategoryPropertyImpl.class, categoryPropertyId, this);
457
458 if (assetCategoryProperty == null) {
459 Session session = null;
460
461 try {
462 session = openSession();
463
464 assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
465 new Long(categoryPropertyId));
466 }
467 catch (Exception e) {
468 throw processException(e);
469 }
470 finally {
471 if (assetCategoryProperty != null) {
472 cacheResult(assetCategoryProperty);
473 }
474
475 closeSession(session);
476 }
477 }
478
479 return assetCategoryProperty;
480 }
481
482
489 public List<AssetCategoryProperty> findByCompanyId(long companyId)
490 throws SystemException {
491 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
492 null);
493 }
494
495
508 public List<AssetCategoryProperty> findByCompanyId(long companyId,
509 int start, int end) throws SystemException {
510 return findByCompanyId(companyId, start, end, null);
511 }
512
513
527 public List<AssetCategoryProperty> findByCompanyId(long companyId,
528 int start, int end, OrderByComparator orderByComparator)
529 throws SystemException {
530 Object[] finderArgs = new Object[] {
531 companyId,
532
533 String.valueOf(start), String.valueOf(end),
534 String.valueOf(orderByComparator)
535 };
536
537 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
538 finderArgs, this);
539
540 if (list == null) {
541 Session session = null;
542
543 try {
544 session = openSession();
545
546 StringBundler query = null;
547
548 if (orderByComparator != null) {
549 query = new StringBundler(3 +
550 (orderByComparator.getOrderByFields().length * 3));
551 }
552 else {
553 query = new StringBundler(3);
554 }
555
556 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
557
558 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
559
560 if (orderByComparator != null) {
561 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
562 orderByComparator);
563 }
564
565 else {
566 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
567 }
568
569 String sql = query.toString();
570
571 Query q = session.createQuery(sql);
572
573 QueryPos qPos = QueryPos.getInstance(q);
574
575 qPos.add(companyId);
576
577 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
578 getDialect(), start, end);
579 }
580 catch (Exception e) {
581 throw processException(e);
582 }
583 finally {
584 if (list == null) {
585 list = new ArrayList<AssetCategoryProperty>();
586 }
587
588 cacheResult(list);
589
590 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
591 finderArgs, list);
592
593 closeSession(session);
594 }
595 }
596
597 return list;
598 }
599
600
613 public AssetCategoryProperty findByCompanyId_First(long companyId,
614 OrderByComparator orderByComparator)
615 throws NoSuchCategoryPropertyException, SystemException {
616 List<AssetCategoryProperty> list = findByCompanyId(companyId, 0, 1,
617 orderByComparator);
618
619 if (list.isEmpty()) {
620 StringBundler msg = new StringBundler(4);
621
622 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
623
624 msg.append("companyId=");
625 msg.append(companyId);
626
627 msg.append(StringPool.CLOSE_CURLY_BRACE);
628
629 throw new NoSuchCategoryPropertyException(msg.toString());
630 }
631 else {
632 return list.get(0);
633 }
634 }
635
636
649 public AssetCategoryProperty findByCompanyId_Last(long companyId,
650 OrderByComparator orderByComparator)
651 throws NoSuchCategoryPropertyException, SystemException {
652 int count = countByCompanyId(companyId);
653
654 List<AssetCategoryProperty> list = findByCompanyId(companyId,
655 count - 1, count, orderByComparator);
656
657 if (list.isEmpty()) {
658 StringBundler msg = new StringBundler(4);
659
660 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
661
662 msg.append("companyId=");
663 msg.append(companyId);
664
665 msg.append(StringPool.CLOSE_CURLY_BRACE);
666
667 throw new NoSuchCategoryPropertyException(msg.toString());
668 }
669 else {
670 return list.get(0);
671 }
672 }
673
674
688 public AssetCategoryProperty[] findByCompanyId_PrevAndNext(
689 long categoryPropertyId, long companyId,
690 OrderByComparator orderByComparator)
691 throws NoSuchCategoryPropertyException, SystemException {
692 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
693
694 Session session = null;
695
696 try {
697 session = openSession();
698
699 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
700
701 array[0] = getByCompanyId_PrevAndNext(session,
702 assetCategoryProperty, companyId, orderByComparator, true);
703
704 array[1] = assetCategoryProperty;
705
706 array[2] = getByCompanyId_PrevAndNext(session,
707 assetCategoryProperty, companyId, orderByComparator, false);
708
709 return array;
710 }
711 catch (Exception e) {
712 throw processException(e);
713 }
714 finally {
715 closeSession(session);
716 }
717 }
718
719 protected AssetCategoryProperty getByCompanyId_PrevAndNext(
720 Session session, AssetCategoryProperty assetCategoryProperty,
721 long companyId, OrderByComparator orderByComparator, boolean previous) {
722 StringBundler query = null;
723
724 if (orderByComparator != null) {
725 query = new StringBundler(6 +
726 (orderByComparator.getOrderByFields().length * 6));
727 }
728 else {
729 query = new StringBundler(3);
730 }
731
732 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
733
734 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
735
736 if (orderByComparator != null) {
737 String[] orderByFields = orderByComparator.getOrderByFields();
738
739 if (orderByFields.length > 0) {
740 query.append(WHERE_AND);
741 }
742
743 for (int i = 0; i < orderByFields.length; i++) {
744 query.append(_ORDER_BY_ENTITY_ALIAS);
745 query.append(orderByFields[i]);
746
747 if ((i + 1) < orderByFields.length) {
748 if (orderByComparator.isAscending() ^ previous) {
749 query.append(WHERE_GREATER_THAN_HAS_NEXT);
750 }
751 else {
752 query.append(WHERE_LESSER_THAN_HAS_NEXT);
753 }
754 }
755 else {
756 if (orderByComparator.isAscending() ^ previous) {
757 query.append(WHERE_GREATER_THAN);
758 }
759 else {
760 query.append(WHERE_LESSER_THAN);
761 }
762 }
763 }
764
765 query.append(ORDER_BY_CLAUSE);
766
767 for (int i = 0; i < orderByFields.length; i++) {
768 query.append(_ORDER_BY_ENTITY_ALIAS);
769 query.append(orderByFields[i]);
770
771 if ((i + 1) < orderByFields.length) {
772 if (orderByComparator.isAscending() ^ previous) {
773 query.append(ORDER_BY_ASC_HAS_NEXT);
774 }
775 else {
776 query.append(ORDER_BY_DESC_HAS_NEXT);
777 }
778 }
779 else {
780 if (orderByComparator.isAscending() ^ previous) {
781 query.append(ORDER_BY_ASC);
782 }
783 else {
784 query.append(ORDER_BY_DESC);
785 }
786 }
787 }
788 }
789
790 else {
791 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
792 }
793
794 String sql = query.toString();
795
796 Query q = session.createQuery(sql);
797
798 q.setFirstResult(0);
799 q.setMaxResults(2);
800
801 QueryPos qPos = QueryPos.getInstance(q);
802
803 qPos.add(companyId);
804
805 if (orderByComparator != null) {
806 Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
807
808 for (Object value : values) {
809 qPos.add(value);
810 }
811 }
812
813 List<AssetCategoryProperty> list = q.list();
814
815 if (list.size() == 2) {
816 return list.get(1);
817 }
818 else {
819 return null;
820 }
821 }
822
823
830 public List<AssetCategoryProperty> findByCategoryId(long categoryId)
831 throws SystemException {
832 return findByCategoryId(categoryId, QueryUtil.ALL_POS,
833 QueryUtil.ALL_POS, null);
834 }
835
836
849 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
850 int start, int end) throws SystemException {
851 return findByCategoryId(categoryId, start, end, null);
852 }
853
854
868 public List<AssetCategoryProperty> findByCategoryId(long categoryId,
869 int start, int end, OrderByComparator orderByComparator)
870 throws SystemException {
871 Object[] finderArgs = new Object[] {
872 categoryId,
873
874 String.valueOf(start), String.valueOf(end),
875 String.valueOf(orderByComparator)
876 };
877
878 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_CATEGORYID,
879 finderArgs, this);
880
881 if (list == null) {
882 Session session = null;
883
884 try {
885 session = openSession();
886
887 StringBundler query = null;
888
889 if (orderByComparator != null) {
890 query = new StringBundler(3 +
891 (orderByComparator.getOrderByFields().length * 3));
892 }
893 else {
894 query = new StringBundler(3);
895 }
896
897 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
898
899 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
900
901 if (orderByComparator != null) {
902 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
903 orderByComparator);
904 }
905
906 else {
907 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
908 }
909
910 String sql = query.toString();
911
912 Query q = session.createQuery(sql);
913
914 QueryPos qPos = QueryPos.getInstance(q);
915
916 qPos.add(categoryId);
917
918 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
919 getDialect(), start, end);
920 }
921 catch (Exception e) {
922 throw processException(e);
923 }
924 finally {
925 if (list == null) {
926 list = new ArrayList<AssetCategoryProperty>();
927 }
928
929 cacheResult(list);
930
931 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_CATEGORYID,
932 finderArgs, list);
933
934 closeSession(session);
935 }
936 }
937
938 return list;
939 }
940
941
954 public AssetCategoryProperty findByCategoryId_First(long categoryId,
955 OrderByComparator orderByComparator)
956 throws NoSuchCategoryPropertyException, SystemException {
957 List<AssetCategoryProperty> list = findByCategoryId(categoryId, 0, 1,
958 orderByComparator);
959
960 if (list.isEmpty()) {
961 StringBundler msg = new StringBundler(4);
962
963 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
964
965 msg.append("categoryId=");
966 msg.append(categoryId);
967
968 msg.append(StringPool.CLOSE_CURLY_BRACE);
969
970 throw new NoSuchCategoryPropertyException(msg.toString());
971 }
972 else {
973 return list.get(0);
974 }
975 }
976
977
990 public AssetCategoryProperty findByCategoryId_Last(long categoryId,
991 OrderByComparator orderByComparator)
992 throws NoSuchCategoryPropertyException, SystemException {
993 int count = countByCategoryId(categoryId);
994
995 List<AssetCategoryProperty> list = findByCategoryId(categoryId,
996 count - 1, count, orderByComparator);
997
998 if (list.isEmpty()) {
999 StringBundler msg = new StringBundler(4);
1000
1001 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1002
1003 msg.append("categoryId=");
1004 msg.append(categoryId);
1005
1006 msg.append(StringPool.CLOSE_CURLY_BRACE);
1007
1008 throw new NoSuchCategoryPropertyException(msg.toString());
1009 }
1010 else {
1011 return list.get(0);
1012 }
1013 }
1014
1015
1029 public AssetCategoryProperty[] findByCategoryId_PrevAndNext(
1030 long categoryPropertyId, long categoryId,
1031 OrderByComparator orderByComparator)
1032 throws NoSuchCategoryPropertyException, SystemException {
1033 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1034
1035 Session session = null;
1036
1037 try {
1038 session = openSession();
1039
1040 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1041
1042 array[0] = getByCategoryId_PrevAndNext(session,
1043 assetCategoryProperty, categoryId, orderByComparator, true);
1044
1045 array[1] = assetCategoryProperty;
1046
1047 array[2] = getByCategoryId_PrevAndNext(session,
1048 assetCategoryProperty, categoryId, orderByComparator, false);
1049
1050 return array;
1051 }
1052 catch (Exception e) {
1053 throw processException(e);
1054 }
1055 finally {
1056 closeSession(session);
1057 }
1058 }
1059
1060 protected AssetCategoryProperty getByCategoryId_PrevAndNext(
1061 Session session, AssetCategoryProperty assetCategoryProperty,
1062 long categoryId, OrderByComparator orderByComparator, boolean previous) {
1063 StringBundler query = null;
1064
1065 if (orderByComparator != null) {
1066 query = new StringBundler(6 +
1067 (orderByComparator.getOrderByFields().length * 6));
1068 }
1069 else {
1070 query = new StringBundler(3);
1071 }
1072
1073 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1074
1075 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1076
1077 if (orderByComparator != null) {
1078 String[] orderByFields = orderByComparator.getOrderByFields();
1079
1080 if (orderByFields.length > 0) {
1081 query.append(WHERE_AND);
1082 }
1083
1084 for (int i = 0; i < orderByFields.length; i++) {
1085 query.append(_ORDER_BY_ENTITY_ALIAS);
1086 query.append(orderByFields[i]);
1087
1088 if ((i + 1) < orderByFields.length) {
1089 if (orderByComparator.isAscending() ^ previous) {
1090 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1091 }
1092 else {
1093 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1094 }
1095 }
1096 else {
1097 if (orderByComparator.isAscending() ^ previous) {
1098 query.append(WHERE_GREATER_THAN);
1099 }
1100 else {
1101 query.append(WHERE_LESSER_THAN);
1102 }
1103 }
1104 }
1105
1106 query.append(ORDER_BY_CLAUSE);
1107
1108 for (int i = 0; i < orderByFields.length; i++) {
1109 query.append(_ORDER_BY_ENTITY_ALIAS);
1110 query.append(orderByFields[i]);
1111
1112 if ((i + 1) < orderByFields.length) {
1113 if (orderByComparator.isAscending() ^ previous) {
1114 query.append(ORDER_BY_ASC_HAS_NEXT);
1115 }
1116 else {
1117 query.append(ORDER_BY_DESC_HAS_NEXT);
1118 }
1119 }
1120 else {
1121 if (orderByComparator.isAscending() ^ previous) {
1122 query.append(ORDER_BY_ASC);
1123 }
1124 else {
1125 query.append(ORDER_BY_DESC);
1126 }
1127 }
1128 }
1129 }
1130
1131 else {
1132 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1133 }
1134
1135 String sql = query.toString();
1136
1137 Query q = session.createQuery(sql);
1138
1139 q.setFirstResult(0);
1140 q.setMaxResults(2);
1141
1142 QueryPos qPos = QueryPos.getInstance(q);
1143
1144 qPos.add(categoryId);
1145
1146 if (orderByComparator != null) {
1147 Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
1148
1149 for (Object value : values) {
1150 qPos.add(value);
1151 }
1152 }
1153
1154 List<AssetCategoryProperty> list = q.list();
1155
1156 if (list.size() == 2) {
1157 return list.get(1);
1158 }
1159 else {
1160 return null;
1161 }
1162 }
1163
1164
1172 public List<AssetCategoryProperty> findByC_K(long companyId, String key)
1173 throws SystemException {
1174 return findByC_K(companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1175 null);
1176 }
1177
1178
1192 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1193 int start, int end) throws SystemException {
1194 return findByC_K(companyId, key, start, end, null);
1195 }
1196
1197
1212 public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1213 int start, int end, OrderByComparator orderByComparator)
1214 throws SystemException {
1215 Object[] finderArgs = new Object[] {
1216 companyId, key,
1217
1218 String.valueOf(start), String.valueOf(end),
1219 String.valueOf(orderByComparator)
1220 };
1221
1222 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_K,
1223 finderArgs, this);
1224
1225 if (list == null) {
1226 Session session = null;
1227
1228 try {
1229 session = openSession();
1230
1231 StringBundler query = null;
1232
1233 if (orderByComparator != null) {
1234 query = new StringBundler(4 +
1235 (orderByComparator.getOrderByFields().length * 3));
1236 }
1237 else {
1238 query = new StringBundler(4);
1239 }
1240
1241 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1242
1243 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1244
1245 if (key == null) {
1246 query.append(_FINDER_COLUMN_C_K_KEY_1);
1247 }
1248 else {
1249 if (key.equals(StringPool.BLANK)) {
1250 query.append(_FINDER_COLUMN_C_K_KEY_3);
1251 }
1252 else {
1253 query.append(_FINDER_COLUMN_C_K_KEY_2);
1254 }
1255 }
1256
1257 if (orderByComparator != null) {
1258 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1259 orderByComparator);
1260 }
1261
1262 else {
1263 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1264 }
1265
1266 String sql = query.toString();
1267
1268 Query q = session.createQuery(sql);
1269
1270 QueryPos qPos = QueryPos.getInstance(q);
1271
1272 qPos.add(companyId);
1273
1274 if (key != null) {
1275 qPos.add(key);
1276 }
1277
1278 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1279 getDialect(), start, end);
1280 }
1281 catch (Exception e) {
1282 throw processException(e);
1283 }
1284 finally {
1285 if (list == null) {
1286 list = new ArrayList<AssetCategoryProperty>();
1287 }
1288
1289 cacheResult(list);
1290
1291 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_K, finderArgs,
1292 list);
1293
1294 closeSession(session);
1295 }
1296 }
1297
1298 return list;
1299 }
1300
1301
1315 public AssetCategoryProperty findByC_K_First(long companyId, String key,
1316 OrderByComparator orderByComparator)
1317 throws NoSuchCategoryPropertyException, SystemException {
1318 List<AssetCategoryProperty> list = findByC_K(companyId, key, 0, 1,
1319 orderByComparator);
1320
1321 if (list.isEmpty()) {
1322 StringBundler msg = new StringBundler(6);
1323
1324 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1325
1326 msg.append("companyId=");
1327 msg.append(companyId);
1328
1329 msg.append(", key=");
1330 msg.append(key);
1331
1332 msg.append(StringPool.CLOSE_CURLY_BRACE);
1333
1334 throw new NoSuchCategoryPropertyException(msg.toString());
1335 }
1336 else {
1337 return list.get(0);
1338 }
1339 }
1340
1341
1355 public AssetCategoryProperty findByC_K_Last(long companyId, String key,
1356 OrderByComparator orderByComparator)
1357 throws NoSuchCategoryPropertyException, SystemException {
1358 int count = countByC_K(companyId, key);
1359
1360 List<AssetCategoryProperty> list = findByC_K(companyId, key, count - 1,
1361 count, orderByComparator);
1362
1363 if (list.isEmpty()) {
1364 StringBundler msg = new StringBundler(6);
1365
1366 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1367
1368 msg.append("companyId=");
1369 msg.append(companyId);
1370
1371 msg.append(", key=");
1372 msg.append(key);
1373
1374 msg.append(StringPool.CLOSE_CURLY_BRACE);
1375
1376 throw new NoSuchCategoryPropertyException(msg.toString());
1377 }
1378 else {
1379 return list.get(0);
1380 }
1381 }
1382
1383
1398 public AssetCategoryProperty[] findByC_K_PrevAndNext(
1399 long categoryPropertyId, long companyId, String key,
1400 OrderByComparator orderByComparator)
1401 throws NoSuchCategoryPropertyException, SystemException {
1402 AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1403
1404 Session session = null;
1405
1406 try {
1407 session = openSession();
1408
1409 AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1410
1411 array[0] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1412 companyId, key, orderByComparator, true);
1413
1414 array[1] = assetCategoryProperty;
1415
1416 array[2] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1417 companyId, key, orderByComparator, false);
1418
1419 return array;
1420 }
1421 catch (Exception e) {
1422 throw processException(e);
1423 }
1424 finally {
1425 closeSession(session);
1426 }
1427 }
1428
1429 protected AssetCategoryProperty getByC_K_PrevAndNext(Session session,
1430 AssetCategoryProperty assetCategoryProperty, long companyId,
1431 String key, OrderByComparator orderByComparator, boolean previous) {
1432 StringBundler query = null;
1433
1434 if (orderByComparator != null) {
1435 query = new StringBundler(6 +
1436 (orderByComparator.getOrderByFields().length * 6));
1437 }
1438 else {
1439 query = new StringBundler(3);
1440 }
1441
1442 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1443
1444 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1445
1446 if (key == null) {
1447 query.append(_FINDER_COLUMN_C_K_KEY_1);
1448 }
1449 else {
1450 if (key.equals(StringPool.BLANK)) {
1451 query.append(_FINDER_COLUMN_C_K_KEY_3);
1452 }
1453 else {
1454 query.append(_FINDER_COLUMN_C_K_KEY_2);
1455 }
1456 }
1457
1458 if (orderByComparator != null) {
1459 String[] orderByFields = orderByComparator.getOrderByFields();
1460
1461 if (orderByFields.length > 0) {
1462 query.append(WHERE_AND);
1463 }
1464
1465 for (int i = 0; i < orderByFields.length; i++) {
1466 query.append(_ORDER_BY_ENTITY_ALIAS);
1467 query.append(orderByFields[i]);
1468
1469 if ((i + 1) < orderByFields.length) {
1470 if (orderByComparator.isAscending() ^ previous) {
1471 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1472 }
1473 else {
1474 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1475 }
1476 }
1477 else {
1478 if (orderByComparator.isAscending() ^ previous) {
1479 query.append(WHERE_GREATER_THAN);
1480 }
1481 else {
1482 query.append(WHERE_LESSER_THAN);
1483 }
1484 }
1485 }
1486
1487 query.append(ORDER_BY_CLAUSE);
1488
1489 for (int i = 0; i < orderByFields.length; i++) {
1490 query.append(_ORDER_BY_ENTITY_ALIAS);
1491 query.append(orderByFields[i]);
1492
1493 if ((i + 1) < orderByFields.length) {
1494 if (orderByComparator.isAscending() ^ previous) {
1495 query.append(ORDER_BY_ASC_HAS_NEXT);
1496 }
1497 else {
1498 query.append(ORDER_BY_DESC_HAS_NEXT);
1499 }
1500 }
1501 else {
1502 if (orderByComparator.isAscending() ^ previous) {
1503 query.append(ORDER_BY_ASC);
1504 }
1505 else {
1506 query.append(ORDER_BY_DESC);
1507 }
1508 }
1509 }
1510 }
1511
1512 else {
1513 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1514 }
1515
1516 String sql = query.toString();
1517
1518 Query q = session.createQuery(sql);
1519
1520 q.setFirstResult(0);
1521 q.setMaxResults(2);
1522
1523 QueryPos qPos = QueryPos.getInstance(q);
1524
1525 qPos.add(companyId);
1526
1527 if (key != null) {
1528 qPos.add(key);
1529 }
1530
1531 if (orderByComparator != null) {
1532 Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
1533
1534 for (Object value : values) {
1535 qPos.add(value);
1536 }
1537 }
1538
1539 List<AssetCategoryProperty> list = q.list();
1540
1541 if (list.size() == 2) {
1542 return list.get(1);
1543 }
1544 else {
1545 return null;
1546 }
1547 }
1548
1549
1558 public AssetCategoryProperty findByCA_K(long categoryId, String key)
1559 throws NoSuchCategoryPropertyException, SystemException {
1560 AssetCategoryProperty assetCategoryProperty = fetchByCA_K(categoryId,
1561 key);
1562
1563 if (assetCategoryProperty == null) {
1564 StringBundler msg = new StringBundler(6);
1565
1566 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1567
1568 msg.append("categoryId=");
1569 msg.append(categoryId);
1570
1571 msg.append(", key=");
1572 msg.append(key);
1573
1574 msg.append(StringPool.CLOSE_CURLY_BRACE);
1575
1576 if (_log.isWarnEnabled()) {
1577 _log.warn(msg.toString());
1578 }
1579
1580 throw new NoSuchCategoryPropertyException(msg.toString());
1581 }
1582
1583 return assetCategoryProperty;
1584 }
1585
1586
1594 public AssetCategoryProperty fetchByCA_K(long categoryId, String key)
1595 throws SystemException {
1596 return fetchByCA_K(categoryId, key, true);
1597 }
1598
1599
1607 public AssetCategoryProperty fetchByCA_K(long categoryId, String key,
1608 boolean retrieveFromCache) throws SystemException {
1609 Object[] finderArgs = new Object[] { categoryId, key };
1610
1611 Object result = null;
1612
1613 if (retrieveFromCache) {
1614 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CA_K,
1615 finderArgs, this);
1616 }
1617
1618 if (result == null) {
1619 Session session = null;
1620
1621 try {
1622 session = openSession();
1623
1624 StringBundler query = new StringBundler(4);
1625
1626 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1627
1628 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1629
1630 if (key == null) {
1631 query.append(_FINDER_COLUMN_CA_K_KEY_1);
1632 }
1633 else {
1634 if (key.equals(StringPool.BLANK)) {
1635 query.append(_FINDER_COLUMN_CA_K_KEY_3);
1636 }
1637 else {
1638 query.append(_FINDER_COLUMN_CA_K_KEY_2);
1639 }
1640 }
1641
1642 query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1643
1644 String sql = query.toString();
1645
1646 Query q = session.createQuery(sql);
1647
1648 QueryPos qPos = QueryPos.getInstance(q);
1649
1650 qPos.add(categoryId);
1651
1652 if (key != null) {
1653 qPos.add(key);
1654 }
1655
1656 List<AssetCategoryProperty> list = q.list();
1657
1658 result = list;
1659
1660 AssetCategoryProperty assetCategoryProperty = null;
1661
1662 if (list.isEmpty()) {
1663 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1664 finderArgs, list);
1665 }
1666 else {
1667 assetCategoryProperty = list.get(0);
1668
1669 cacheResult(assetCategoryProperty);
1670
1671 if ((assetCategoryProperty.getCategoryId() != categoryId) ||
1672 (assetCategoryProperty.getKey() == null) ||
1673 !assetCategoryProperty.getKey().equals(key)) {
1674 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1675 finderArgs, assetCategoryProperty);
1676 }
1677 }
1678
1679 return assetCategoryProperty;
1680 }
1681 catch (Exception e) {
1682 throw processException(e);
1683 }
1684 finally {
1685 if (result == null) {
1686 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1687 finderArgs, new ArrayList<AssetCategoryProperty>());
1688 }
1689
1690 closeSession(session);
1691 }
1692 }
1693 else {
1694 if (result instanceof List<?>) {
1695 return null;
1696 }
1697 else {
1698 return (AssetCategoryProperty)result;
1699 }
1700 }
1701 }
1702
1703
1709 public List<AssetCategoryProperty> findAll() throws SystemException {
1710 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1711 }
1712
1713
1725 public List<AssetCategoryProperty> findAll(int start, int end)
1726 throws SystemException {
1727 return findAll(start, end, null);
1728 }
1729
1730
1743 public List<AssetCategoryProperty> findAll(int start, int end,
1744 OrderByComparator orderByComparator) throws SystemException {
1745 Object[] finderArgs = new Object[] {
1746 String.valueOf(start), String.valueOf(end),
1747 String.valueOf(orderByComparator)
1748 };
1749
1750 List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1751 finderArgs, this);
1752
1753 if (list == null) {
1754 Session session = null;
1755
1756 try {
1757 session = openSession();
1758
1759 StringBundler query = null;
1760 String sql = null;
1761
1762 if (orderByComparator != null) {
1763 query = new StringBundler(2 +
1764 (orderByComparator.getOrderByFields().length * 3));
1765
1766 query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY);
1767
1768 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1769 orderByComparator);
1770
1771 sql = query.toString();
1772 }
1773 else {
1774 sql = _SQL_SELECT_ASSETCATEGORYPROPERTY.concat(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1775 }
1776
1777 Query q = session.createQuery(sql);
1778
1779 if (orderByComparator == null) {
1780 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1781 getDialect(), start, end, false);
1782
1783 Collections.sort(list);
1784 }
1785 else {
1786 list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1787 getDialect(), start, end);
1788 }
1789 }
1790 catch (Exception e) {
1791 throw processException(e);
1792 }
1793 finally {
1794 if (list == null) {
1795 list = new ArrayList<AssetCategoryProperty>();
1796 }
1797
1798 cacheResult(list);
1799
1800 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1801
1802 closeSession(session);
1803 }
1804 }
1805
1806 return list;
1807 }
1808
1809
1815 public void removeByCompanyId(long companyId) throws SystemException {
1816 for (AssetCategoryProperty assetCategoryProperty : findByCompanyId(
1817 companyId)) {
1818 remove(assetCategoryProperty);
1819 }
1820 }
1821
1822
1828 public void removeByCategoryId(long categoryId) throws SystemException {
1829 for (AssetCategoryProperty assetCategoryProperty : findByCategoryId(
1830 categoryId)) {
1831 remove(assetCategoryProperty);
1832 }
1833 }
1834
1835
1842 public void removeByC_K(long companyId, String key)
1843 throws SystemException {
1844 for (AssetCategoryProperty assetCategoryProperty : findByC_K(
1845 companyId, key)) {
1846 remove(assetCategoryProperty);
1847 }
1848 }
1849
1850
1857 public void removeByCA_K(long categoryId, String key)
1858 throws NoSuchCategoryPropertyException, SystemException {
1859 AssetCategoryProperty assetCategoryProperty = findByCA_K(categoryId, key);
1860
1861 remove(assetCategoryProperty);
1862 }
1863
1864
1869 public void removeAll() throws SystemException {
1870 for (AssetCategoryProperty assetCategoryProperty : findAll()) {
1871 remove(assetCategoryProperty);
1872 }
1873 }
1874
1875
1882 public int countByCompanyId(long companyId) throws SystemException {
1883 Object[] finderArgs = new Object[] { companyId };
1884
1885 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1886 finderArgs, this);
1887
1888 if (count == null) {
1889 Session session = null;
1890
1891 try {
1892 session = openSession();
1893
1894 StringBundler query = new StringBundler(2);
1895
1896 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1897
1898 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1899
1900 String sql = query.toString();
1901
1902 Query q = session.createQuery(sql);
1903
1904 QueryPos qPos = QueryPos.getInstance(q);
1905
1906 qPos.add(companyId);
1907
1908 count = (Long)q.uniqueResult();
1909 }
1910 catch (Exception e) {
1911 throw processException(e);
1912 }
1913 finally {
1914 if (count == null) {
1915 count = Long.valueOf(0);
1916 }
1917
1918 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1919 finderArgs, count);
1920
1921 closeSession(session);
1922 }
1923 }
1924
1925 return count.intValue();
1926 }
1927
1928
1935 public int countByCategoryId(long categoryId) throws SystemException {
1936 Object[] finderArgs = new Object[] { categoryId };
1937
1938 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1939 finderArgs, this);
1940
1941 if (count == null) {
1942 Session session = null;
1943
1944 try {
1945 session = openSession();
1946
1947 StringBundler query = new StringBundler(2);
1948
1949 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1950
1951 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1952
1953 String sql = query.toString();
1954
1955 Query q = session.createQuery(sql);
1956
1957 QueryPos qPos = QueryPos.getInstance(q);
1958
1959 qPos.add(categoryId);
1960
1961 count = (Long)q.uniqueResult();
1962 }
1963 catch (Exception e) {
1964 throw processException(e);
1965 }
1966 finally {
1967 if (count == null) {
1968 count = Long.valueOf(0);
1969 }
1970
1971 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1972 finderArgs, count);
1973
1974 closeSession(session);
1975 }
1976 }
1977
1978 return count.intValue();
1979 }
1980
1981
1989 public int countByC_K(long companyId, String key) throws SystemException {
1990 Object[] finderArgs = new Object[] { companyId, key };
1991
1992 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_K,
1993 finderArgs, this);
1994
1995 if (count == null) {
1996 Session session = null;
1997
1998 try {
1999 session = openSession();
2000
2001 StringBundler query = new StringBundler(3);
2002
2003 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
2004
2005 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
2006
2007 if (key == null) {
2008 query.append(_FINDER_COLUMN_C_K_KEY_1);
2009 }
2010 else {
2011 if (key.equals(StringPool.BLANK)) {
2012 query.append(_FINDER_COLUMN_C_K_KEY_3);
2013 }
2014 else {
2015 query.append(_FINDER_COLUMN_C_K_KEY_2);
2016 }
2017 }
2018
2019 String sql = query.toString();
2020
2021 Query q = session.createQuery(sql);
2022
2023 QueryPos qPos = QueryPos.getInstance(q);
2024
2025 qPos.add(companyId);
2026
2027 if (key != null) {
2028 qPos.add(key);
2029 }
2030
2031 count = (Long)q.uniqueResult();
2032 }
2033 catch (Exception e) {
2034 throw processException(e);
2035 }
2036 finally {
2037 if (count == null) {
2038 count = Long.valueOf(0);
2039 }
2040
2041 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, finderArgs,
2042 count);
2043
2044 closeSession(session);
2045 }
2046 }
2047
2048 return count.intValue();
2049 }
2050
2051
2059 public int countByCA_K(long categoryId, String key)
2060 throws SystemException {
2061 Object[] finderArgs = new Object[] { categoryId, key };
2062
2063 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CA_K,
2064 finderArgs, this);
2065
2066 if (count == null) {
2067 Session session = null;
2068
2069 try {
2070 session = openSession();
2071
2072 StringBundler query = new StringBundler(3);
2073
2074 query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
2075
2076 query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
2077
2078 if (key == null) {
2079 query.append(_FINDER_COLUMN_CA_K_KEY_1);
2080 }
2081 else {
2082 if (key.equals(StringPool.BLANK)) {
2083 query.append(_FINDER_COLUMN_CA_K_KEY_3);
2084 }
2085 else {
2086 query.append(_FINDER_COLUMN_CA_K_KEY_2);
2087 }
2088 }
2089
2090 String sql = query.toString();
2091
2092 Query q = session.createQuery(sql);
2093
2094 QueryPos qPos = QueryPos.getInstance(q);
2095
2096 qPos.add(categoryId);
2097
2098 if (key != null) {
2099 qPos.add(key);
2100 }
2101
2102 count = (Long)q.uniqueResult();
2103 }
2104 catch (Exception e) {
2105 throw processException(e);
2106 }
2107 finally {
2108 if (count == null) {
2109 count = Long.valueOf(0);
2110 }
2111
2112 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K,
2113 finderArgs, count);
2114
2115 closeSession(session);
2116 }
2117 }
2118
2119 return count.intValue();
2120 }
2121
2122
2128 public int countAll() throws SystemException {
2129 Object[] finderArgs = new Object[0];
2130
2131 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2132 finderArgs, this);
2133
2134 if (count == null) {
2135 Session session = null;
2136
2137 try {
2138 session = openSession();
2139
2140 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORYPROPERTY);
2141
2142 count = (Long)q.uniqueResult();
2143 }
2144 catch (Exception e) {
2145 throw processException(e);
2146 }
2147 finally {
2148 if (count == null) {
2149 count = Long.valueOf(0);
2150 }
2151
2152 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2153 count);
2154
2155 closeSession(session);
2156 }
2157 }
2158
2159 return count.intValue();
2160 }
2161
2162
2165 public void afterPropertiesSet() {
2166 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2167 com.liferay.portal.util.PropsUtil.get(
2168 "value.object.listener.com.liferay.portlet.asset.model.AssetCategoryProperty")));
2169
2170 if (listenerClassNames.length > 0) {
2171 try {
2172 List<ModelListener<AssetCategoryProperty>> listenersList = new ArrayList<ModelListener<AssetCategoryProperty>>();
2173
2174 for (String listenerClassName : listenerClassNames) {
2175 listenersList.add((ModelListener<AssetCategoryProperty>)InstanceFactory.newInstance(
2176 listenerClassName));
2177 }
2178
2179 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2180 }
2181 catch (Exception e) {
2182 _log.error(e);
2183 }
2184 }
2185 }
2186
2187 @BeanReference(type = AssetCategoryPersistence.class)
2188 protected AssetCategoryPersistence assetCategoryPersistence;
2189 @BeanReference(type = AssetCategoryPropertyPersistence.class)
2190 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
2191 @BeanReference(type = AssetEntryPersistence.class)
2192 protected AssetEntryPersistence assetEntryPersistence;
2193 @BeanReference(type = AssetLinkPersistence.class)
2194 protected AssetLinkPersistence assetLinkPersistence;
2195 @BeanReference(type = AssetTagPersistence.class)
2196 protected AssetTagPersistence assetTagPersistence;
2197 @BeanReference(type = AssetTagPropertyPersistence.class)
2198 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
2199 @BeanReference(type = AssetTagStatsPersistence.class)
2200 protected AssetTagStatsPersistence assetTagStatsPersistence;
2201 @BeanReference(type = AssetVocabularyPersistence.class)
2202 protected AssetVocabularyPersistence assetVocabularyPersistence;
2203 @BeanReference(type = ResourcePersistence.class)
2204 protected ResourcePersistence resourcePersistence;
2205 @BeanReference(type = UserPersistence.class)
2206 protected UserPersistence userPersistence;
2207 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty";
2208 private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2209 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty";
2210 private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2211 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetCategoryProperty.companyId = ?";
2212 private static final String _FINDER_COLUMN_CATEGORYID_CATEGORYID_2 = "assetCategoryProperty.categoryId = ?";
2213 private static final String _FINDER_COLUMN_C_K_COMPANYID_2 = "assetCategoryProperty.companyId = ? AND ";
2214 private static final String _FINDER_COLUMN_C_K_KEY_1 = "assetCategoryProperty.key IS NULL";
2215 private static final String _FINDER_COLUMN_C_K_KEY_2 = "assetCategoryProperty.key = ?";
2216 private static final String _FINDER_COLUMN_C_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = ?)";
2217 private static final String _FINDER_COLUMN_CA_K_CATEGORYID_2 = "assetCategoryProperty.categoryId = ? AND ";
2218 private static final String _FINDER_COLUMN_CA_K_KEY_1 = "assetCategoryProperty.key IS NULL";
2219 private static final String _FINDER_COLUMN_CA_K_KEY_2 = "assetCategoryProperty.key = ?";
2220 private static final String _FINDER_COLUMN_CA_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = ?)";
2221 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategoryProperty.";
2222 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategoryProperty exists with the primary key ";
2223 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategoryProperty exists with the key {";
2224 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPropertyPersistenceImpl.class);
2225 }