001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.CalendarUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.kernel.util.UnmodifiableList;
045 import com.liferay.portal.kernel.util.Validator;
046 import com.liferay.portal.model.CacheModel;
047 import com.liferay.portal.model.ModelListener;
048 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049
050 import com.liferay.portlet.asset.NoSuchEntryException;
051 import com.liferay.portlet.asset.model.AssetEntry;
052 import com.liferay.portlet.asset.model.impl.AssetEntryImpl;
053 import com.liferay.portlet.asset.model.impl.AssetEntryModelImpl;
054
055 import java.io.Serializable;
056
057 import java.util.ArrayList;
058 import java.util.Collections;
059 import java.util.Date;
060 import java.util.List;
061 import java.util.Set;
062
063
075 public class AssetEntryPersistenceImpl extends BasePersistenceImpl<AssetEntry>
076 implements AssetEntryPersistence {
077
082 public static final String FINDER_CLASS_NAME_ENTITY = AssetEntryImpl.class.getName();
083 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List1";
085 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086 ".List2";
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
088 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
089 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
091 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
093 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
094 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
096 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
097 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
098 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
099 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
100 new String[] {
101 Long.class.getName(),
102
103 Integer.class.getName(), Integer.class.getName(),
104 OrderByComparator.class.getName()
105 });
106 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
107 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
108 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
109 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
110 new String[] { Long.class.getName() },
111 AssetEntryModelImpl.COMPANYID_COLUMN_BITMASK);
112 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
113 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
115 new String[] { Long.class.getName() });
116
117
124 public List<AssetEntry> findByCompanyId(long companyId)
125 throws SystemException {
126 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
127 null);
128 }
129
130
143 public List<AssetEntry> findByCompanyId(long companyId, int start, int end)
144 throws SystemException {
145 return findByCompanyId(companyId, start, end, null);
146 }
147
148
162 public List<AssetEntry> findByCompanyId(long companyId, int start, int end,
163 OrderByComparator orderByComparator) throws SystemException {
164 boolean pagination = true;
165 FinderPath finderPath = null;
166 Object[] finderArgs = null;
167
168 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
169 (orderByComparator == null)) {
170 pagination = false;
171 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
172 finderArgs = new Object[] { companyId };
173 }
174 else {
175 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
176 finderArgs = new Object[] { companyId, start, end, orderByComparator };
177 }
178
179 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
180 finderArgs, this);
181
182 if ((list != null) && !list.isEmpty()) {
183 for (AssetEntry assetEntry : list) {
184 if ((companyId != assetEntry.getCompanyId())) {
185 list = null;
186
187 break;
188 }
189 }
190 }
191
192 if (list == null) {
193 StringBundler query = null;
194
195 if (orderByComparator != null) {
196 query = new StringBundler(3 +
197 (orderByComparator.getOrderByFields().length * 3));
198 }
199 else {
200 query = new StringBundler(3);
201 }
202
203 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
204
205 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
206
207 if (orderByComparator != null) {
208 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
209 orderByComparator);
210 }
211 else
212 if (pagination) {
213 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
214 }
215
216 String sql = query.toString();
217
218 Session session = null;
219
220 try {
221 session = openSession();
222
223 Query q = session.createQuery(sql);
224
225 QueryPos qPos = QueryPos.getInstance(q);
226
227 qPos.add(companyId);
228
229 if (!pagination) {
230 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
231 start, end, false);
232
233 Collections.sort(list);
234
235 list = new UnmodifiableList<AssetEntry>(list);
236 }
237 else {
238 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
239 start, end);
240 }
241
242 cacheResult(list);
243
244 FinderCacheUtil.putResult(finderPath, finderArgs, list);
245 }
246 catch (Exception e) {
247 FinderCacheUtil.removeResult(finderPath, finderArgs);
248
249 throw processException(e);
250 }
251 finally {
252 closeSession(session);
253 }
254 }
255
256 return list;
257 }
258
259
268 public AssetEntry findByCompanyId_First(long companyId,
269 OrderByComparator orderByComparator)
270 throws NoSuchEntryException, SystemException {
271 AssetEntry assetEntry = fetchByCompanyId_First(companyId,
272 orderByComparator);
273
274 if (assetEntry != null) {
275 return assetEntry;
276 }
277
278 StringBundler msg = new StringBundler(4);
279
280 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
281
282 msg.append("companyId=");
283 msg.append(companyId);
284
285 msg.append(StringPool.CLOSE_CURLY_BRACE);
286
287 throw new NoSuchEntryException(msg.toString());
288 }
289
290
298 public AssetEntry fetchByCompanyId_First(long companyId,
299 OrderByComparator orderByComparator) throws SystemException {
300 List<AssetEntry> list = findByCompanyId(companyId, 0, 1,
301 orderByComparator);
302
303 if (!list.isEmpty()) {
304 return list.get(0);
305 }
306
307 return null;
308 }
309
310
319 public AssetEntry findByCompanyId_Last(long companyId,
320 OrderByComparator orderByComparator)
321 throws NoSuchEntryException, SystemException {
322 AssetEntry assetEntry = fetchByCompanyId_Last(companyId,
323 orderByComparator);
324
325 if (assetEntry != null) {
326 return assetEntry;
327 }
328
329 StringBundler msg = new StringBundler(4);
330
331 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
332
333 msg.append("companyId=");
334 msg.append(companyId);
335
336 msg.append(StringPool.CLOSE_CURLY_BRACE);
337
338 throw new NoSuchEntryException(msg.toString());
339 }
340
341
349 public AssetEntry fetchByCompanyId_Last(long companyId,
350 OrderByComparator orderByComparator) throws SystemException {
351 int count = countByCompanyId(companyId);
352
353 List<AssetEntry> list = findByCompanyId(companyId, count - 1, count,
354 orderByComparator);
355
356 if (!list.isEmpty()) {
357 return list.get(0);
358 }
359
360 return null;
361 }
362
363
373 public AssetEntry[] findByCompanyId_PrevAndNext(long entryId,
374 long companyId, OrderByComparator orderByComparator)
375 throws NoSuchEntryException, SystemException {
376 AssetEntry assetEntry = findByPrimaryKey(entryId);
377
378 Session session = null;
379
380 try {
381 session = openSession();
382
383 AssetEntry[] array = new AssetEntryImpl[3];
384
385 array[0] = getByCompanyId_PrevAndNext(session, assetEntry,
386 companyId, orderByComparator, true);
387
388 array[1] = assetEntry;
389
390 array[2] = getByCompanyId_PrevAndNext(session, assetEntry,
391 companyId, orderByComparator, false);
392
393 return array;
394 }
395 catch (Exception e) {
396 throw processException(e);
397 }
398 finally {
399 closeSession(session);
400 }
401 }
402
403 protected AssetEntry getByCompanyId_PrevAndNext(Session session,
404 AssetEntry assetEntry, long companyId,
405 OrderByComparator orderByComparator, boolean previous) {
406 StringBundler query = null;
407
408 if (orderByComparator != null) {
409 query = new StringBundler(6 +
410 (orderByComparator.getOrderByFields().length * 6));
411 }
412 else {
413 query = new StringBundler(3);
414 }
415
416 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
417
418 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
419
420 if (orderByComparator != null) {
421 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
422
423 if (orderByConditionFields.length > 0) {
424 query.append(WHERE_AND);
425 }
426
427 for (int i = 0; i < orderByConditionFields.length; i++) {
428 query.append(_ORDER_BY_ENTITY_ALIAS);
429 query.append(orderByConditionFields[i]);
430
431 if ((i + 1) < orderByConditionFields.length) {
432 if (orderByComparator.isAscending() ^ previous) {
433 query.append(WHERE_GREATER_THAN_HAS_NEXT);
434 }
435 else {
436 query.append(WHERE_LESSER_THAN_HAS_NEXT);
437 }
438 }
439 else {
440 if (orderByComparator.isAscending() ^ previous) {
441 query.append(WHERE_GREATER_THAN);
442 }
443 else {
444 query.append(WHERE_LESSER_THAN);
445 }
446 }
447 }
448
449 query.append(ORDER_BY_CLAUSE);
450
451 String[] orderByFields = orderByComparator.getOrderByFields();
452
453 for (int i = 0; i < orderByFields.length; i++) {
454 query.append(_ORDER_BY_ENTITY_ALIAS);
455 query.append(orderByFields[i]);
456
457 if ((i + 1) < orderByFields.length) {
458 if (orderByComparator.isAscending() ^ previous) {
459 query.append(ORDER_BY_ASC_HAS_NEXT);
460 }
461 else {
462 query.append(ORDER_BY_DESC_HAS_NEXT);
463 }
464 }
465 else {
466 if (orderByComparator.isAscending() ^ previous) {
467 query.append(ORDER_BY_ASC);
468 }
469 else {
470 query.append(ORDER_BY_DESC);
471 }
472 }
473 }
474 }
475 else {
476 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
477 }
478
479 String sql = query.toString();
480
481 Query q = session.createQuery(sql);
482
483 q.setFirstResult(0);
484 q.setMaxResults(2);
485
486 QueryPos qPos = QueryPos.getInstance(q);
487
488 qPos.add(companyId);
489
490 if (orderByComparator != null) {
491 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
492
493 for (Object value : values) {
494 qPos.add(value);
495 }
496 }
497
498 List<AssetEntry> list = q.list();
499
500 if (list.size() == 2) {
501 return list.get(1);
502 }
503 else {
504 return null;
505 }
506 }
507
508
514 public void removeByCompanyId(long companyId) throws SystemException {
515 for (AssetEntry assetEntry : findByCompanyId(companyId,
516 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
517 remove(assetEntry);
518 }
519 }
520
521
528 public int countByCompanyId(long companyId) throws SystemException {
529 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
530
531 Object[] finderArgs = new Object[] { companyId };
532
533 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
534 this);
535
536 if (count == null) {
537 StringBundler query = new StringBundler(2);
538
539 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
540
541 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
542
543 String sql = query.toString();
544
545 Session session = null;
546
547 try {
548 session = openSession();
549
550 Query q = session.createQuery(sql);
551
552 QueryPos qPos = QueryPos.getInstance(q);
553
554 qPos.add(companyId);
555
556 count = (Long)q.uniqueResult();
557
558 FinderCacheUtil.putResult(finderPath, finderArgs, count);
559 }
560 catch (Exception e) {
561 FinderCacheUtil.removeResult(finderPath, finderArgs);
562
563 throw processException(e);
564 }
565 finally {
566 closeSession(session);
567 }
568 }
569
570 return count.intValue();
571 }
572
573 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetEntry.companyId = ?";
574 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
575 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
576 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByVisible",
577 new String[] {
578 Boolean.class.getName(),
579
580 Integer.class.getName(), Integer.class.getName(),
581 OrderByComparator.class.getName()
582 });
583 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE =
584 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
585 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
586 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByVisible",
587 new String[] { Boolean.class.getName() },
588 AssetEntryModelImpl.VISIBLE_COLUMN_BITMASK);
589 public static final FinderPath FINDER_PATH_COUNT_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
590 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
591 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVisible",
592 new String[] { Boolean.class.getName() });
593
594
601 public List<AssetEntry> findByVisible(boolean visible)
602 throws SystemException {
603 return findByVisible(visible, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
604 }
605
606
619 public List<AssetEntry> findByVisible(boolean visible, int start, int end)
620 throws SystemException {
621 return findByVisible(visible, start, end, null);
622 }
623
624
638 public List<AssetEntry> findByVisible(boolean visible, int start, int end,
639 OrderByComparator orderByComparator) throws SystemException {
640 boolean pagination = true;
641 FinderPath finderPath = null;
642 Object[] finderArgs = null;
643
644 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
645 (orderByComparator == null)) {
646 pagination = false;
647 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE;
648 finderArgs = new Object[] { visible };
649 }
650 else {
651 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE;
652 finderArgs = new Object[] { visible, start, end, orderByComparator };
653 }
654
655 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
656 finderArgs, this);
657
658 if ((list != null) && !list.isEmpty()) {
659 for (AssetEntry assetEntry : list) {
660 if ((visible != assetEntry.getVisible())) {
661 list = null;
662
663 break;
664 }
665 }
666 }
667
668 if (list == null) {
669 StringBundler query = null;
670
671 if (orderByComparator != null) {
672 query = new StringBundler(3 +
673 (orderByComparator.getOrderByFields().length * 3));
674 }
675 else {
676 query = new StringBundler(3);
677 }
678
679 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
680
681 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
682
683 if (orderByComparator != null) {
684 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
685 orderByComparator);
686 }
687 else
688 if (pagination) {
689 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
690 }
691
692 String sql = query.toString();
693
694 Session session = null;
695
696 try {
697 session = openSession();
698
699 Query q = session.createQuery(sql);
700
701 QueryPos qPos = QueryPos.getInstance(q);
702
703 qPos.add(visible);
704
705 if (!pagination) {
706 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
707 start, end, false);
708
709 Collections.sort(list);
710
711 list = new UnmodifiableList<AssetEntry>(list);
712 }
713 else {
714 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
715 start, end);
716 }
717
718 cacheResult(list);
719
720 FinderCacheUtil.putResult(finderPath, finderArgs, list);
721 }
722 catch (Exception e) {
723 FinderCacheUtil.removeResult(finderPath, finderArgs);
724
725 throw processException(e);
726 }
727 finally {
728 closeSession(session);
729 }
730 }
731
732 return list;
733 }
734
735
744 public AssetEntry findByVisible_First(boolean visible,
745 OrderByComparator orderByComparator)
746 throws NoSuchEntryException, SystemException {
747 AssetEntry assetEntry = fetchByVisible_First(visible, orderByComparator);
748
749 if (assetEntry != null) {
750 return assetEntry;
751 }
752
753 StringBundler msg = new StringBundler(4);
754
755 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
756
757 msg.append("visible=");
758 msg.append(visible);
759
760 msg.append(StringPool.CLOSE_CURLY_BRACE);
761
762 throw new NoSuchEntryException(msg.toString());
763 }
764
765
773 public AssetEntry fetchByVisible_First(boolean visible,
774 OrderByComparator orderByComparator) throws SystemException {
775 List<AssetEntry> list = findByVisible(visible, 0, 1, orderByComparator);
776
777 if (!list.isEmpty()) {
778 return list.get(0);
779 }
780
781 return null;
782 }
783
784
793 public AssetEntry findByVisible_Last(boolean visible,
794 OrderByComparator orderByComparator)
795 throws NoSuchEntryException, SystemException {
796 AssetEntry assetEntry = fetchByVisible_Last(visible, orderByComparator);
797
798 if (assetEntry != null) {
799 return assetEntry;
800 }
801
802 StringBundler msg = new StringBundler(4);
803
804 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
805
806 msg.append("visible=");
807 msg.append(visible);
808
809 msg.append(StringPool.CLOSE_CURLY_BRACE);
810
811 throw new NoSuchEntryException(msg.toString());
812 }
813
814
822 public AssetEntry fetchByVisible_Last(boolean visible,
823 OrderByComparator orderByComparator) throws SystemException {
824 int count = countByVisible(visible);
825
826 List<AssetEntry> list = findByVisible(visible, count - 1, count,
827 orderByComparator);
828
829 if (!list.isEmpty()) {
830 return list.get(0);
831 }
832
833 return null;
834 }
835
836
846 public AssetEntry[] findByVisible_PrevAndNext(long entryId,
847 boolean visible, OrderByComparator orderByComparator)
848 throws NoSuchEntryException, SystemException {
849 AssetEntry assetEntry = findByPrimaryKey(entryId);
850
851 Session session = null;
852
853 try {
854 session = openSession();
855
856 AssetEntry[] array = new AssetEntryImpl[3];
857
858 array[0] = getByVisible_PrevAndNext(session, assetEntry, visible,
859 orderByComparator, true);
860
861 array[1] = assetEntry;
862
863 array[2] = getByVisible_PrevAndNext(session, assetEntry, visible,
864 orderByComparator, false);
865
866 return array;
867 }
868 catch (Exception e) {
869 throw processException(e);
870 }
871 finally {
872 closeSession(session);
873 }
874 }
875
876 protected AssetEntry getByVisible_PrevAndNext(Session session,
877 AssetEntry assetEntry, boolean visible,
878 OrderByComparator orderByComparator, boolean previous) {
879 StringBundler query = null;
880
881 if (orderByComparator != null) {
882 query = new StringBundler(6 +
883 (orderByComparator.getOrderByFields().length * 6));
884 }
885 else {
886 query = new StringBundler(3);
887 }
888
889 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
890
891 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
892
893 if (orderByComparator != null) {
894 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
895
896 if (orderByConditionFields.length > 0) {
897 query.append(WHERE_AND);
898 }
899
900 for (int i = 0; i < orderByConditionFields.length; i++) {
901 query.append(_ORDER_BY_ENTITY_ALIAS);
902 query.append(orderByConditionFields[i]);
903
904 if ((i + 1) < orderByConditionFields.length) {
905 if (orderByComparator.isAscending() ^ previous) {
906 query.append(WHERE_GREATER_THAN_HAS_NEXT);
907 }
908 else {
909 query.append(WHERE_LESSER_THAN_HAS_NEXT);
910 }
911 }
912 else {
913 if (orderByComparator.isAscending() ^ previous) {
914 query.append(WHERE_GREATER_THAN);
915 }
916 else {
917 query.append(WHERE_LESSER_THAN);
918 }
919 }
920 }
921
922 query.append(ORDER_BY_CLAUSE);
923
924 String[] orderByFields = orderByComparator.getOrderByFields();
925
926 for (int i = 0; i < orderByFields.length; i++) {
927 query.append(_ORDER_BY_ENTITY_ALIAS);
928 query.append(orderByFields[i]);
929
930 if ((i + 1) < orderByFields.length) {
931 if (orderByComparator.isAscending() ^ previous) {
932 query.append(ORDER_BY_ASC_HAS_NEXT);
933 }
934 else {
935 query.append(ORDER_BY_DESC_HAS_NEXT);
936 }
937 }
938 else {
939 if (orderByComparator.isAscending() ^ previous) {
940 query.append(ORDER_BY_ASC);
941 }
942 else {
943 query.append(ORDER_BY_DESC);
944 }
945 }
946 }
947 }
948 else {
949 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
950 }
951
952 String sql = query.toString();
953
954 Query q = session.createQuery(sql);
955
956 q.setFirstResult(0);
957 q.setMaxResults(2);
958
959 QueryPos qPos = QueryPos.getInstance(q);
960
961 qPos.add(visible);
962
963 if (orderByComparator != null) {
964 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
965
966 for (Object value : values) {
967 qPos.add(value);
968 }
969 }
970
971 List<AssetEntry> list = q.list();
972
973 if (list.size() == 2) {
974 return list.get(1);
975 }
976 else {
977 return null;
978 }
979 }
980
981
987 public void removeByVisible(boolean visible) throws SystemException {
988 for (AssetEntry assetEntry : findByVisible(visible, QueryUtil.ALL_POS,
989 QueryUtil.ALL_POS, null)) {
990 remove(assetEntry);
991 }
992 }
993
994
1001 public int countByVisible(boolean visible) throws SystemException {
1002 FinderPath finderPath = FINDER_PATH_COUNT_BY_VISIBLE;
1003
1004 Object[] finderArgs = new Object[] { visible };
1005
1006 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1007 this);
1008
1009 if (count == null) {
1010 StringBundler query = new StringBundler(2);
1011
1012 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1013
1014 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1015
1016 String sql = query.toString();
1017
1018 Session session = null;
1019
1020 try {
1021 session = openSession();
1022
1023 Query q = session.createQuery(sql);
1024
1025 QueryPos qPos = QueryPos.getInstance(q);
1026
1027 qPos.add(visible);
1028
1029 count = (Long)q.uniqueResult();
1030
1031 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1032 }
1033 catch (Exception e) {
1034 FinderCacheUtil.removeResult(finderPath, finderArgs);
1035
1036 throw processException(e);
1037 }
1038 finally {
1039 closeSession(session);
1040 }
1041 }
1042
1043 return count.intValue();
1044 }
1045
1046 private static final String _FINDER_COLUMN_VISIBLE_VISIBLE_2 = "assetEntry.visible = ?";
1047 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE =
1048 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1049 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1050 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByPublishDate",
1051 new String[] {
1052 Date.class.getName(),
1053
1054 Integer.class.getName(), Integer.class.getName(),
1055 OrderByComparator.class.getName()
1056 });
1057 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE =
1058 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1059 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1060 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPublishDate",
1061 new String[] { Date.class.getName() },
1062 AssetEntryModelImpl.PUBLISHDATE_COLUMN_BITMASK);
1063 public static final FinderPath FINDER_PATH_COUNT_BY_PUBLISHDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1064 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1065 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPublishDate",
1066 new String[] { Date.class.getName() });
1067
1068
1075 public List<AssetEntry> findByPublishDate(Date publishDate)
1076 throws SystemException {
1077 return findByPublishDate(publishDate, QueryUtil.ALL_POS,
1078 QueryUtil.ALL_POS, null);
1079 }
1080
1081
1094 public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1095 int end) throws SystemException {
1096 return findByPublishDate(publishDate, start, end, null);
1097 }
1098
1099
1113 public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1114 int end, OrderByComparator orderByComparator) throws SystemException {
1115 boolean pagination = true;
1116 FinderPath finderPath = null;
1117 Object[] finderArgs = null;
1118
1119 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1120 (orderByComparator == null)) {
1121 pagination = false;
1122 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE;
1123 finderArgs = new Object[] { publishDate };
1124 }
1125 else {
1126 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE;
1127 finderArgs = new Object[] { publishDate, start, end, orderByComparator };
1128 }
1129
1130 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1131 finderArgs, this);
1132
1133 if ((list != null) && !list.isEmpty()) {
1134 for (AssetEntry assetEntry : list) {
1135 if (!Validator.equals(publishDate, assetEntry.getPublishDate())) {
1136 list = null;
1137
1138 break;
1139 }
1140 }
1141 }
1142
1143 if (list == null) {
1144 StringBundler query = null;
1145
1146 if (orderByComparator != null) {
1147 query = new StringBundler(3 +
1148 (orderByComparator.getOrderByFields().length * 3));
1149 }
1150 else {
1151 query = new StringBundler(3);
1152 }
1153
1154 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1155
1156 if (publishDate == null) {
1157 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1158 }
1159 else {
1160 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1161 }
1162
1163 if (orderByComparator != null) {
1164 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1165 orderByComparator);
1166 }
1167 else
1168 if (pagination) {
1169 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1170 }
1171
1172 String sql = query.toString();
1173
1174 Session session = null;
1175
1176 try {
1177 session = openSession();
1178
1179 Query q = session.createQuery(sql);
1180
1181 QueryPos qPos = QueryPos.getInstance(q);
1182
1183 if (publishDate != null) {
1184 qPos.add(CalendarUtil.getTimestamp(publishDate));
1185 }
1186
1187 if (!pagination) {
1188 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1189 start, end, false);
1190
1191 Collections.sort(list);
1192
1193 list = new UnmodifiableList<AssetEntry>(list);
1194 }
1195 else {
1196 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1197 start, end);
1198 }
1199
1200 cacheResult(list);
1201
1202 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1203 }
1204 catch (Exception e) {
1205 FinderCacheUtil.removeResult(finderPath, finderArgs);
1206
1207 throw processException(e);
1208 }
1209 finally {
1210 closeSession(session);
1211 }
1212 }
1213
1214 return list;
1215 }
1216
1217
1226 public AssetEntry findByPublishDate_First(Date publishDate,
1227 OrderByComparator orderByComparator)
1228 throws NoSuchEntryException, SystemException {
1229 AssetEntry assetEntry = fetchByPublishDate_First(publishDate,
1230 orderByComparator);
1231
1232 if (assetEntry != null) {
1233 return assetEntry;
1234 }
1235
1236 StringBundler msg = new StringBundler(4);
1237
1238 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1239
1240 msg.append("publishDate=");
1241 msg.append(publishDate);
1242
1243 msg.append(StringPool.CLOSE_CURLY_BRACE);
1244
1245 throw new NoSuchEntryException(msg.toString());
1246 }
1247
1248
1256 public AssetEntry fetchByPublishDate_First(Date publishDate,
1257 OrderByComparator orderByComparator) throws SystemException {
1258 List<AssetEntry> list = findByPublishDate(publishDate, 0, 1,
1259 orderByComparator);
1260
1261 if (!list.isEmpty()) {
1262 return list.get(0);
1263 }
1264
1265 return null;
1266 }
1267
1268
1277 public AssetEntry findByPublishDate_Last(Date publishDate,
1278 OrderByComparator orderByComparator)
1279 throws NoSuchEntryException, SystemException {
1280 AssetEntry assetEntry = fetchByPublishDate_Last(publishDate,
1281 orderByComparator);
1282
1283 if (assetEntry != null) {
1284 return assetEntry;
1285 }
1286
1287 StringBundler msg = new StringBundler(4);
1288
1289 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1290
1291 msg.append("publishDate=");
1292 msg.append(publishDate);
1293
1294 msg.append(StringPool.CLOSE_CURLY_BRACE);
1295
1296 throw new NoSuchEntryException(msg.toString());
1297 }
1298
1299
1307 public AssetEntry fetchByPublishDate_Last(Date publishDate,
1308 OrderByComparator orderByComparator) throws SystemException {
1309 int count = countByPublishDate(publishDate);
1310
1311 List<AssetEntry> list = findByPublishDate(publishDate, count - 1,
1312 count, orderByComparator);
1313
1314 if (!list.isEmpty()) {
1315 return list.get(0);
1316 }
1317
1318 return null;
1319 }
1320
1321
1331 public AssetEntry[] findByPublishDate_PrevAndNext(long entryId,
1332 Date publishDate, OrderByComparator orderByComparator)
1333 throws NoSuchEntryException, SystemException {
1334 AssetEntry assetEntry = findByPrimaryKey(entryId);
1335
1336 Session session = null;
1337
1338 try {
1339 session = openSession();
1340
1341 AssetEntry[] array = new AssetEntryImpl[3];
1342
1343 array[0] = getByPublishDate_PrevAndNext(session, assetEntry,
1344 publishDate, orderByComparator, true);
1345
1346 array[1] = assetEntry;
1347
1348 array[2] = getByPublishDate_PrevAndNext(session, assetEntry,
1349 publishDate, orderByComparator, false);
1350
1351 return array;
1352 }
1353 catch (Exception e) {
1354 throw processException(e);
1355 }
1356 finally {
1357 closeSession(session);
1358 }
1359 }
1360
1361 protected AssetEntry getByPublishDate_PrevAndNext(Session session,
1362 AssetEntry assetEntry, Date publishDate,
1363 OrderByComparator orderByComparator, boolean previous) {
1364 StringBundler query = null;
1365
1366 if (orderByComparator != null) {
1367 query = new StringBundler(6 +
1368 (orderByComparator.getOrderByFields().length * 6));
1369 }
1370 else {
1371 query = new StringBundler(3);
1372 }
1373
1374 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1375
1376 if (publishDate == null) {
1377 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1378 }
1379 else {
1380 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1381 }
1382
1383 if (orderByComparator != null) {
1384 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1385
1386 if (orderByConditionFields.length > 0) {
1387 query.append(WHERE_AND);
1388 }
1389
1390 for (int i = 0; i < orderByConditionFields.length; i++) {
1391 query.append(_ORDER_BY_ENTITY_ALIAS);
1392 query.append(orderByConditionFields[i]);
1393
1394 if ((i + 1) < orderByConditionFields.length) {
1395 if (orderByComparator.isAscending() ^ previous) {
1396 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1397 }
1398 else {
1399 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1400 }
1401 }
1402 else {
1403 if (orderByComparator.isAscending() ^ previous) {
1404 query.append(WHERE_GREATER_THAN);
1405 }
1406 else {
1407 query.append(WHERE_LESSER_THAN);
1408 }
1409 }
1410 }
1411
1412 query.append(ORDER_BY_CLAUSE);
1413
1414 String[] orderByFields = orderByComparator.getOrderByFields();
1415
1416 for (int i = 0; i < orderByFields.length; i++) {
1417 query.append(_ORDER_BY_ENTITY_ALIAS);
1418 query.append(orderByFields[i]);
1419
1420 if ((i + 1) < orderByFields.length) {
1421 if (orderByComparator.isAscending() ^ previous) {
1422 query.append(ORDER_BY_ASC_HAS_NEXT);
1423 }
1424 else {
1425 query.append(ORDER_BY_DESC_HAS_NEXT);
1426 }
1427 }
1428 else {
1429 if (orderByComparator.isAscending() ^ previous) {
1430 query.append(ORDER_BY_ASC);
1431 }
1432 else {
1433 query.append(ORDER_BY_DESC);
1434 }
1435 }
1436 }
1437 }
1438 else {
1439 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1440 }
1441
1442 String sql = query.toString();
1443
1444 Query q = session.createQuery(sql);
1445
1446 q.setFirstResult(0);
1447 q.setMaxResults(2);
1448
1449 QueryPos qPos = QueryPos.getInstance(q);
1450
1451 if (publishDate != null) {
1452 qPos.add(CalendarUtil.getTimestamp(publishDate));
1453 }
1454
1455 if (orderByComparator != null) {
1456 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1457
1458 for (Object value : values) {
1459 qPos.add(value);
1460 }
1461 }
1462
1463 List<AssetEntry> list = q.list();
1464
1465 if (list.size() == 2) {
1466 return list.get(1);
1467 }
1468 else {
1469 return null;
1470 }
1471 }
1472
1473
1479 public void removeByPublishDate(Date publishDate) throws SystemException {
1480 for (AssetEntry assetEntry : findByPublishDate(publishDate,
1481 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1482 remove(assetEntry);
1483 }
1484 }
1485
1486
1493 public int countByPublishDate(Date publishDate) throws SystemException {
1494 FinderPath finderPath = FINDER_PATH_COUNT_BY_PUBLISHDATE;
1495
1496 Object[] finderArgs = new Object[] { publishDate };
1497
1498 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1499 this);
1500
1501 if (count == null) {
1502 StringBundler query = new StringBundler(2);
1503
1504 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1505
1506 if (publishDate == null) {
1507 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1508 }
1509 else {
1510 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1511 }
1512
1513 String sql = query.toString();
1514
1515 Session session = null;
1516
1517 try {
1518 session = openSession();
1519
1520 Query q = session.createQuery(sql);
1521
1522 QueryPos qPos = QueryPos.getInstance(q);
1523
1524 if (publishDate != null) {
1525 qPos.add(CalendarUtil.getTimestamp(publishDate));
1526 }
1527
1528 count = (Long)q.uniqueResult();
1529
1530 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1531 }
1532 catch (Exception e) {
1533 FinderCacheUtil.removeResult(finderPath, finderArgs);
1534
1535 throw processException(e);
1536 }
1537 finally {
1538 closeSession(session);
1539 }
1540 }
1541
1542 return count.intValue();
1543 }
1544
1545 private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1 = "assetEntry.publishDate IS NULL";
1546 private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2 = "assetEntry.publishDate = ?";
1547 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE =
1548 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1549 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1550 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByExpirationDate",
1551 new String[] {
1552 Date.class.getName(),
1553
1554 Integer.class.getName(), Integer.class.getName(),
1555 OrderByComparator.class.getName()
1556 });
1557 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE =
1558 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1559 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1560 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByExpirationDate",
1561 new String[] { Date.class.getName() },
1562 AssetEntryModelImpl.EXPIRATIONDATE_COLUMN_BITMASK);
1563 public static final FinderPath FINDER_PATH_COUNT_BY_EXPIRATIONDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1564 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1565 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByExpirationDate",
1566 new String[] { Date.class.getName() });
1567
1568
1575 public List<AssetEntry> findByExpirationDate(Date expirationDate)
1576 throws SystemException {
1577 return findByExpirationDate(expirationDate, QueryUtil.ALL_POS,
1578 QueryUtil.ALL_POS, null);
1579 }
1580
1581
1594 public List<AssetEntry> findByExpirationDate(Date expirationDate,
1595 int start, int end) throws SystemException {
1596 return findByExpirationDate(expirationDate, start, end, null);
1597 }
1598
1599
1613 public List<AssetEntry> findByExpirationDate(Date expirationDate,
1614 int start, int end, OrderByComparator orderByComparator)
1615 throws SystemException {
1616 boolean pagination = true;
1617 FinderPath finderPath = null;
1618 Object[] finderArgs = null;
1619
1620 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1621 (orderByComparator == null)) {
1622 pagination = false;
1623 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE;
1624 finderArgs = new Object[] { expirationDate };
1625 }
1626 else {
1627 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE;
1628 finderArgs = new Object[] {
1629 expirationDate,
1630
1631 start, end, orderByComparator
1632 };
1633 }
1634
1635 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1636 finderArgs, this);
1637
1638 if ((list != null) && !list.isEmpty()) {
1639 for (AssetEntry assetEntry : list) {
1640 if (!Validator.equals(expirationDate,
1641 assetEntry.getExpirationDate())) {
1642 list = null;
1643
1644 break;
1645 }
1646 }
1647 }
1648
1649 if (list == null) {
1650 StringBundler query = null;
1651
1652 if (orderByComparator != null) {
1653 query = new StringBundler(3 +
1654 (orderByComparator.getOrderByFields().length * 3));
1655 }
1656 else {
1657 query = new StringBundler(3);
1658 }
1659
1660 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1661
1662 if (expirationDate == null) {
1663 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
1664 }
1665 else {
1666 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
1667 }
1668
1669 if (orderByComparator != null) {
1670 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1671 orderByComparator);
1672 }
1673 else
1674 if (pagination) {
1675 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1676 }
1677
1678 String sql = query.toString();
1679
1680 Session session = null;
1681
1682 try {
1683 session = openSession();
1684
1685 Query q = session.createQuery(sql);
1686
1687 QueryPos qPos = QueryPos.getInstance(q);
1688
1689 if (expirationDate != null) {
1690 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1691 }
1692
1693 if (!pagination) {
1694 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1695 start, end, false);
1696
1697 Collections.sort(list);
1698
1699 list = new UnmodifiableList<AssetEntry>(list);
1700 }
1701 else {
1702 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1703 start, end);
1704 }
1705
1706 cacheResult(list);
1707
1708 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1709 }
1710 catch (Exception e) {
1711 FinderCacheUtil.removeResult(finderPath, finderArgs);
1712
1713 throw processException(e);
1714 }
1715 finally {
1716 closeSession(session);
1717 }
1718 }
1719
1720 return list;
1721 }
1722
1723
1732 public AssetEntry findByExpirationDate_First(Date expirationDate,
1733 OrderByComparator orderByComparator)
1734 throws NoSuchEntryException, SystemException {
1735 AssetEntry assetEntry = fetchByExpirationDate_First(expirationDate,
1736 orderByComparator);
1737
1738 if (assetEntry != null) {
1739 return assetEntry;
1740 }
1741
1742 StringBundler msg = new StringBundler(4);
1743
1744 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1745
1746 msg.append("expirationDate=");
1747 msg.append(expirationDate);
1748
1749 msg.append(StringPool.CLOSE_CURLY_BRACE);
1750
1751 throw new NoSuchEntryException(msg.toString());
1752 }
1753
1754
1762 public AssetEntry fetchByExpirationDate_First(Date expirationDate,
1763 OrderByComparator orderByComparator) throws SystemException {
1764 List<AssetEntry> list = findByExpirationDate(expirationDate, 0, 1,
1765 orderByComparator);
1766
1767 if (!list.isEmpty()) {
1768 return list.get(0);
1769 }
1770
1771 return null;
1772 }
1773
1774
1783 public AssetEntry findByExpirationDate_Last(Date expirationDate,
1784 OrderByComparator orderByComparator)
1785 throws NoSuchEntryException, SystemException {
1786 AssetEntry assetEntry = fetchByExpirationDate_Last(expirationDate,
1787 orderByComparator);
1788
1789 if (assetEntry != null) {
1790 return assetEntry;
1791 }
1792
1793 StringBundler msg = new StringBundler(4);
1794
1795 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1796
1797 msg.append("expirationDate=");
1798 msg.append(expirationDate);
1799
1800 msg.append(StringPool.CLOSE_CURLY_BRACE);
1801
1802 throw new NoSuchEntryException(msg.toString());
1803 }
1804
1805
1813 public AssetEntry fetchByExpirationDate_Last(Date expirationDate,
1814 OrderByComparator orderByComparator) throws SystemException {
1815 int count = countByExpirationDate(expirationDate);
1816
1817 List<AssetEntry> list = findByExpirationDate(expirationDate, count - 1,
1818 count, orderByComparator);
1819
1820 if (!list.isEmpty()) {
1821 return list.get(0);
1822 }
1823
1824 return null;
1825 }
1826
1827
1837 public AssetEntry[] findByExpirationDate_PrevAndNext(long entryId,
1838 Date expirationDate, OrderByComparator orderByComparator)
1839 throws NoSuchEntryException, SystemException {
1840 AssetEntry assetEntry = findByPrimaryKey(entryId);
1841
1842 Session session = null;
1843
1844 try {
1845 session = openSession();
1846
1847 AssetEntry[] array = new AssetEntryImpl[3];
1848
1849 array[0] = getByExpirationDate_PrevAndNext(session, assetEntry,
1850 expirationDate, orderByComparator, true);
1851
1852 array[1] = assetEntry;
1853
1854 array[2] = getByExpirationDate_PrevAndNext(session, assetEntry,
1855 expirationDate, orderByComparator, false);
1856
1857 return array;
1858 }
1859 catch (Exception e) {
1860 throw processException(e);
1861 }
1862 finally {
1863 closeSession(session);
1864 }
1865 }
1866
1867 protected AssetEntry getByExpirationDate_PrevAndNext(Session session,
1868 AssetEntry assetEntry, Date expirationDate,
1869 OrderByComparator orderByComparator, boolean previous) {
1870 StringBundler query = null;
1871
1872 if (orderByComparator != null) {
1873 query = new StringBundler(6 +
1874 (orderByComparator.getOrderByFields().length * 6));
1875 }
1876 else {
1877 query = new StringBundler(3);
1878 }
1879
1880 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1881
1882 if (expirationDate == null) {
1883 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
1884 }
1885 else {
1886 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
1887 }
1888
1889 if (orderByComparator != null) {
1890 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1891
1892 if (orderByConditionFields.length > 0) {
1893 query.append(WHERE_AND);
1894 }
1895
1896 for (int i = 0; i < orderByConditionFields.length; i++) {
1897 query.append(_ORDER_BY_ENTITY_ALIAS);
1898 query.append(orderByConditionFields[i]);
1899
1900 if ((i + 1) < orderByConditionFields.length) {
1901 if (orderByComparator.isAscending() ^ previous) {
1902 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1903 }
1904 else {
1905 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1906 }
1907 }
1908 else {
1909 if (orderByComparator.isAscending() ^ previous) {
1910 query.append(WHERE_GREATER_THAN);
1911 }
1912 else {
1913 query.append(WHERE_LESSER_THAN);
1914 }
1915 }
1916 }
1917
1918 query.append(ORDER_BY_CLAUSE);
1919
1920 String[] orderByFields = orderByComparator.getOrderByFields();
1921
1922 for (int i = 0; i < orderByFields.length; i++) {
1923 query.append(_ORDER_BY_ENTITY_ALIAS);
1924 query.append(orderByFields[i]);
1925
1926 if ((i + 1) < orderByFields.length) {
1927 if (orderByComparator.isAscending() ^ previous) {
1928 query.append(ORDER_BY_ASC_HAS_NEXT);
1929 }
1930 else {
1931 query.append(ORDER_BY_DESC_HAS_NEXT);
1932 }
1933 }
1934 else {
1935 if (orderByComparator.isAscending() ^ previous) {
1936 query.append(ORDER_BY_ASC);
1937 }
1938 else {
1939 query.append(ORDER_BY_DESC);
1940 }
1941 }
1942 }
1943 }
1944 else {
1945 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1946 }
1947
1948 String sql = query.toString();
1949
1950 Query q = session.createQuery(sql);
1951
1952 q.setFirstResult(0);
1953 q.setMaxResults(2);
1954
1955 QueryPos qPos = QueryPos.getInstance(q);
1956
1957 if (expirationDate != null) {
1958 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1959 }
1960
1961 if (orderByComparator != null) {
1962 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1963
1964 for (Object value : values) {
1965 qPos.add(value);
1966 }
1967 }
1968
1969 List<AssetEntry> list = q.list();
1970
1971 if (list.size() == 2) {
1972 return list.get(1);
1973 }
1974 else {
1975 return null;
1976 }
1977 }
1978
1979
1985 public void removeByExpirationDate(Date expirationDate)
1986 throws SystemException {
1987 for (AssetEntry assetEntry : findByExpirationDate(expirationDate,
1988 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1989 remove(assetEntry);
1990 }
1991 }
1992
1993
2000 public int countByExpirationDate(Date expirationDate)
2001 throws SystemException {
2002 FinderPath finderPath = FINDER_PATH_COUNT_BY_EXPIRATIONDATE;
2003
2004 Object[] finderArgs = new Object[] { expirationDate };
2005
2006 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2007 this);
2008
2009 if (count == null) {
2010 StringBundler query = new StringBundler(2);
2011
2012 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2013
2014 if (expirationDate == null) {
2015 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2016 }
2017 else {
2018 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2019 }
2020
2021 String sql = query.toString();
2022
2023 Session session = null;
2024
2025 try {
2026 session = openSession();
2027
2028 Query q = session.createQuery(sql);
2029
2030 QueryPos qPos = QueryPos.getInstance(q);
2031
2032 if (expirationDate != null) {
2033 qPos.add(CalendarUtil.getTimestamp(expirationDate));
2034 }
2035
2036 count = (Long)q.uniqueResult();
2037
2038 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2039 }
2040 catch (Exception e) {
2041 FinderCacheUtil.removeResult(finderPath, finderArgs);
2042
2043 throw processException(e);
2044 }
2045 finally {
2046 closeSession(session);
2047 }
2048 }
2049
2050 return count.intValue();
2051 }
2052
2053 private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1 = "assetEntry.expirationDate IS NULL";
2054 private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2 = "assetEntry.expirationDate = ?";
2055 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
2056 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2057 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2058 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLayoutUuid",
2059 new String[] {
2060 String.class.getName(),
2061
2062 Integer.class.getName(), Integer.class.getName(),
2063 OrderByComparator.class.getName()
2064 });
2065 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
2066 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2067 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2068 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
2069 new String[] { String.class.getName() },
2070 AssetEntryModelImpl.LAYOUTUUID_COLUMN_BITMASK);
2071 public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2072 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2073 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
2074 new String[] { String.class.getName() });
2075
2076
2083 public List<AssetEntry> findByLayoutUuid(String layoutUuid)
2084 throws SystemException {
2085 return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
2086 QueryUtil.ALL_POS, null);
2087 }
2088
2089
2102 public List<AssetEntry> findByLayoutUuid(String layoutUuid, int start,
2103 int end) throws SystemException {
2104 return findByLayoutUuid(layoutUuid, start, end, null);
2105 }
2106
2107
2121 public List<AssetEntry> findByLayoutUuid(String layoutUuid, int start,
2122 int end, OrderByComparator orderByComparator) throws SystemException {
2123 boolean pagination = true;
2124 FinderPath finderPath = null;
2125 Object[] finderArgs = null;
2126
2127 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2128 (orderByComparator == null)) {
2129 pagination = false;
2130 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
2131 finderArgs = new Object[] { layoutUuid };
2132 }
2133 else {
2134 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
2135 finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
2136 }
2137
2138 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
2139 finderArgs, this);
2140
2141 if ((list != null) && !list.isEmpty()) {
2142 for (AssetEntry assetEntry : list) {
2143 if (!Validator.equals(layoutUuid, assetEntry.getLayoutUuid())) {
2144 list = null;
2145
2146 break;
2147 }
2148 }
2149 }
2150
2151 if (list == null) {
2152 StringBundler query = null;
2153
2154 if (orderByComparator != null) {
2155 query = new StringBundler(3 +
2156 (orderByComparator.getOrderByFields().length * 3));
2157 }
2158 else {
2159 query = new StringBundler(3);
2160 }
2161
2162 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2163
2164 if (layoutUuid == null) {
2165 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
2166 }
2167 else {
2168 if (layoutUuid.equals(StringPool.BLANK)) {
2169 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
2170 }
2171 else {
2172 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
2173 }
2174 }
2175
2176 if (orderByComparator != null) {
2177 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2178 orderByComparator);
2179 }
2180 else
2181 if (pagination) {
2182 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
2183 }
2184
2185 String sql = query.toString();
2186
2187 Session session = null;
2188
2189 try {
2190 session = openSession();
2191
2192 Query q = session.createQuery(sql);
2193
2194 QueryPos qPos = QueryPos.getInstance(q);
2195
2196 if (layoutUuid != null) {
2197 qPos.add(layoutUuid);
2198 }
2199
2200 if (!pagination) {
2201 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2202 start, end, false);
2203
2204 Collections.sort(list);
2205
2206 list = new UnmodifiableList<AssetEntry>(list);
2207 }
2208 else {
2209 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2210 start, end);
2211 }
2212
2213 cacheResult(list);
2214
2215 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2216 }
2217 catch (Exception e) {
2218 FinderCacheUtil.removeResult(finderPath, finderArgs);
2219
2220 throw processException(e);
2221 }
2222 finally {
2223 closeSession(session);
2224 }
2225 }
2226
2227 return list;
2228 }
2229
2230
2239 public AssetEntry findByLayoutUuid_First(String layoutUuid,
2240 OrderByComparator orderByComparator)
2241 throws NoSuchEntryException, SystemException {
2242 AssetEntry assetEntry = fetchByLayoutUuid_First(layoutUuid,
2243 orderByComparator);
2244
2245 if (assetEntry != null) {
2246 return assetEntry;
2247 }
2248
2249 StringBundler msg = new StringBundler(4);
2250
2251 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2252
2253 msg.append("layoutUuid=");
2254 msg.append(layoutUuid);
2255
2256 msg.append(StringPool.CLOSE_CURLY_BRACE);
2257
2258 throw new NoSuchEntryException(msg.toString());
2259 }
2260
2261
2269 public AssetEntry fetchByLayoutUuid_First(String layoutUuid,
2270 OrderByComparator orderByComparator) throws SystemException {
2271 List<AssetEntry> list = findByLayoutUuid(layoutUuid, 0, 1,
2272 orderByComparator);
2273
2274 if (!list.isEmpty()) {
2275 return list.get(0);
2276 }
2277
2278 return null;
2279 }
2280
2281
2290 public AssetEntry findByLayoutUuid_Last(String layoutUuid,
2291 OrderByComparator orderByComparator)
2292 throws NoSuchEntryException, SystemException {
2293 AssetEntry assetEntry = fetchByLayoutUuid_Last(layoutUuid,
2294 orderByComparator);
2295
2296 if (assetEntry != null) {
2297 return assetEntry;
2298 }
2299
2300 StringBundler msg = new StringBundler(4);
2301
2302 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2303
2304 msg.append("layoutUuid=");
2305 msg.append(layoutUuid);
2306
2307 msg.append(StringPool.CLOSE_CURLY_BRACE);
2308
2309 throw new NoSuchEntryException(msg.toString());
2310 }
2311
2312
2320 public AssetEntry fetchByLayoutUuid_Last(String layoutUuid,
2321 OrderByComparator orderByComparator) throws SystemException {
2322 int count = countByLayoutUuid(layoutUuid);
2323
2324 List<AssetEntry> list = findByLayoutUuid(layoutUuid, count - 1, count,
2325 orderByComparator);
2326
2327 if (!list.isEmpty()) {
2328 return list.get(0);
2329 }
2330
2331 return null;
2332 }
2333
2334
2344 public AssetEntry[] findByLayoutUuid_PrevAndNext(long entryId,
2345 String layoutUuid, OrderByComparator orderByComparator)
2346 throws NoSuchEntryException, SystemException {
2347 AssetEntry assetEntry = findByPrimaryKey(entryId);
2348
2349 Session session = null;
2350
2351 try {
2352 session = openSession();
2353
2354 AssetEntry[] array = new AssetEntryImpl[3];
2355
2356 array[0] = getByLayoutUuid_PrevAndNext(session, assetEntry,
2357 layoutUuid, orderByComparator, true);
2358
2359 array[1] = assetEntry;
2360
2361 array[2] = getByLayoutUuid_PrevAndNext(session, assetEntry,
2362 layoutUuid, orderByComparator, false);
2363
2364 return array;
2365 }
2366 catch (Exception e) {
2367 throw processException(e);
2368 }
2369 finally {
2370 closeSession(session);
2371 }
2372 }
2373
2374 protected AssetEntry getByLayoutUuid_PrevAndNext(Session session,
2375 AssetEntry assetEntry, String layoutUuid,
2376 OrderByComparator orderByComparator, boolean previous) {
2377 StringBundler query = null;
2378
2379 if (orderByComparator != null) {
2380 query = new StringBundler(6 +
2381 (orderByComparator.getOrderByFields().length * 6));
2382 }
2383 else {
2384 query = new StringBundler(3);
2385 }
2386
2387 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2388
2389 if (layoutUuid == null) {
2390 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
2391 }
2392 else {
2393 if (layoutUuid.equals(StringPool.BLANK)) {
2394 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
2395 }
2396 else {
2397 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
2398 }
2399 }
2400
2401 if (orderByComparator != null) {
2402 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2403
2404 if (orderByConditionFields.length > 0) {
2405 query.append(WHERE_AND);
2406 }
2407
2408 for (int i = 0; i < orderByConditionFields.length; i++) {
2409 query.append(_ORDER_BY_ENTITY_ALIAS);
2410 query.append(orderByConditionFields[i]);
2411
2412 if ((i + 1) < orderByConditionFields.length) {
2413 if (orderByComparator.isAscending() ^ previous) {
2414 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2415 }
2416 else {
2417 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2418 }
2419 }
2420 else {
2421 if (orderByComparator.isAscending() ^ previous) {
2422 query.append(WHERE_GREATER_THAN);
2423 }
2424 else {
2425 query.append(WHERE_LESSER_THAN);
2426 }
2427 }
2428 }
2429
2430 query.append(ORDER_BY_CLAUSE);
2431
2432 String[] orderByFields = orderByComparator.getOrderByFields();
2433
2434 for (int i = 0; i < orderByFields.length; i++) {
2435 query.append(_ORDER_BY_ENTITY_ALIAS);
2436 query.append(orderByFields[i]);
2437
2438 if ((i + 1) < orderByFields.length) {
2439 if (orderByComparator.isAscending() ^ previous) {
2440 query.append(ORDER_BY_ASC_HAS_NEXT);
2441 }
2442 else {
2443 query.append(ORDER_BY_DESC_HAS_NEXT);
2444 }
2445 }
2446 else {
2447 if (orderByComparator.isAscending() ^ previous) {
2448 query.append(ORDER_BY_ASC);
2449 }
2450 else {
2451 query.append(ORDER_BY_DESC);
2452 }
2453 }
2454 }
2455 }
2456 else {
2457 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
2458 }
2459
2460 String sql = query.toString();
2461
2462 Query q = session.createQuery(sql);
2463
2464 q.setFirstResult(0);
2465 q.setMaxResults(2);
2466
2467 QueryPos qPos = QueryPos.getInstance(q);
2468
2469 if (layoutUuid != null) {
2470 qPos.add(layoutUuid);
2471 }
2472
2473 if (orderByComparator != null) {
2474 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
2475
2476 for (Object value : values) {
2477 qPos.add(value);
2478 }
2479 }
2480
2481 List<AssetEntry> list = q.list();
2482
2483 if (list.size() == 2) {
2484 return list.get(1);
2485 }
2486 else {
2487 return null;
2488 }
2489 }
2490
2491
2497 public void removeByLayoutUuid(String layoutUuid) throws SystemException {
2498 for (AssetEntry assetEntry : findByLayoutUuid(layoutUuid,
2499 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2500 remove(assetEntry);
2501 }
2502 }
2503
2504
2511 public int countByLayoutUuid(String layoutUuid) throws SystemException {
2512 FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
2513
2514 Object[] finderArgs = new Object[] { layoutUuid };
2515
2516 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2517 this);
2518
2519 if (count == null) {
2520 StringBundler query = new StringBundler(2);
2521
2522 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2523
2524 if (layoutUuid == null) {
2525 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
2526 }
2527 else {
2528 if (layoutUuid.equals(StringPool.BLANK)) {
2529 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
2530 }
2531 else {
2532 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
2533 }
2534 }
2535
2536 String sql = query.toString();
2537
2538 Session session = null;
2539
2540 try {
2541 session = openSession();
2542
2543 Query q = session.createQuery(sql);
2544
2545 QueryPos qPos = QueryPos.getInstance(q);
2546
2547 if (layoutUuid != null) {
2548 qPos.add(layoutUuid);
2549 }
2550
2551 count = (Long)q.uniqueResult();
2552
2553 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2554 }
2555 catch (Exception e) {
2556 FinderCacheUtil.removeResult(finderPath, finderArgs);
2557
2558 throw processException(e);
2559 }
2560 finally {
2561 closeSession(session);
2562 }
2563 }
2564
2565 return count.intValue();
2566 }
2567
2568 private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "assetEntry.layoutUuid IS NULL";
2569 private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "assetEntry.layoutUuid = ?";
2570 private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(assetEntry.layoutUuid IS NULL OR assetEntry.layoutUuid = ?)";
2571 public static final FinderPath FINDER_PATH_FETCH_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2572 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2573 FINDER_CLASS_NAME_ENTITY, "fetchByG_CU",
2574 new String[] { Long.class.getName(), String.class.getName() },
2575 AssetEntryModelImpl.GROUPID_COLUMN_BITMASK |
2576 AssetEntryModelImpl.CLASSUUID_COLUMN_BITMASK);
2577 public static final FinderPath FINDER_PATH_COUNT_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2578 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2579 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_CU",
2580 new String[] { Long.class.getName(), String.class.getName() });
2581
2582
2591 public AssetEntry findByG_CU(long groupId, String classUuid)
2592 throws NoSuchEntryException, SystemException {
2593 AssetEntry assetEntry = fetchByG_CU(groupId, classUuid);
2594
2595 if (assetEntry == null) {
2596 StringBundler msg = new StringBundler(6);
2597
2598 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2599
2600 msg.append("groupId=");
2601 msg.append(groupId);
2602
2603 msg.append(", classUuid=");
2604 msg.append(classUuid);
2605
2606 msg.append(StringPool.CLOSE_CURLY_BRACE);
2607
2608 if (_log.isWarnEnabled()) {
2609 _log.warn(msg.toString());
2610 }
2611
2612 throw new NoSuchEntryException(msg.toString());
2613 }
2614
2615 return assetEntry;
2616 }
2617
2618
2626 public AssetEntry fetchByG_CU(long groupId, String classUuid)
2627 throws SystemException {
2628 return fetchByG_CU(groupId, classUuid, true);
2629 }
2630
2631
2640 public AssetEntry fetchByG_CU(long groupId, String classUuid,
2641 boolean retrieveFromCache) throws SystemException {
2642 Object[] finderArgs = new Object[] { groupId, classUuid };
2643
2644 Object result = null;
2645
2646 if (retrieveFromCache) {
2647 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_CU,
2648 finderArgs, this);
2649 }
2650
2651 if (result instanceof AssetEntry) {
2652 AssetEntry assetEntry = (AssetEntry)result;
2653
2654 if ((groupId != assetEntry.getGroupId()) ||
2655 !Validator.equals(classUuid, assetEntry.getClassUuid())) {
2656 result = null;
2657 }
2658 }
2659
2660 if (result == null) {
2661 StringBundler query = new StringBundler(4);
2662
2663 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2664
2665 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
2666
2667 if (classUuid == null) {
2668 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
2669 }
2670 else {
2671 if (classUuid.equals(StringPool.BLANK)) {
2672 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
2673 }
2674 else {
2675 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
2676 }
2677 }
2678
2679 String sql = query.toString();
2680
2681 Session session = null;
2682
2683 try {
2684 session = openSession();
2685
2686 Query q = session.createQuery(sql);
2687
2688 QueryPos qPos = QueryPos.getInstance(q);
2689
2690 qPos.add(groupId);
2691
2692 if (classUuid != null) {
2693 qPos.add(classUuid);
2694 }
2695
2696 List<AssetEntry> list = q.list();
2697
2698 if (list.isEmpty()) {
2699 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
2700 finderArgs, list);
2701 }
2702 else {
2703 if ((list.size() > 1) && _log.isWarnEnabled()) {
2704 _log.warn(
2705 "AssetEntryPersistenceImpl.fetchByG_CU(long, String, boolean) with parameters (" +
2706 StringUtil.merge(finderArgs) +
2707 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
2708 }
2709
2710 AssetEntry assetEntry = list.get(0);
2711
2712 result = assetEntry;
2713
2714 cacheResult(assetEntry);
2715
2716 if ((assetEntry.getGroupId() != groupId) ||
2717 (assetEntry.getClassUuid() == null) ||
2718 !assetEntry.getClassUuid().equals(classUuid)) {
2719 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
2720 finderArgs, assetEntry);
2721 }
2722 }
2723 }
2724 catch (Exception e) {
2725 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
2726 finderArgs);
2727
2728 throw processException(e);
2729 }
2730 finally {
2731 closeSession(session);
2732 }
2733 }
2734
2735 if (result instanceof List<?>) {
2736 return null;
2737 }
2738 else {
2739 return (AssetEntry)result;
2740 }
2741 }
2742
2743
2751 public AssetEntry removeByG_CU(long groupId, String classUuid)
2752 throws NoSuchEntryException, SystemException {
2753 AssetEntry assetEntry = findByG_CU(groupId, classUuid);
2754
2755 return remove(assetEntry);
2756 }
2757
2758
2766 public int countByG_CU(long groupId, String classUuid)
2767 throws SystemException {
2768 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_CU;
2769
2770 Object[] finderArgs = new Object[] { groupId, classUuid };
2771
2772 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2773 this);
2774
2775 if (count == null) {
2776 StringBundler query = new StringBundler(3);
2777
2778 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2779
2780 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
2781
2782 if (classUuid == null) {
2783 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
2784 }
2785 else {
2786 if (classUuid.equals(StringPool.BLANK)) {
2787 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
2788 }
2789 else {
2790 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
2791 }
2792 }
2793
2794 String sql = query.toString();
2795
2796 Session session = null;
2797
2798 try {
2799 session = openSession();
2800
2801 Query q = session.createQuery(sql);
2802
2803 QueryPos qPos = QueryPos.getInstance(q);
2804
2805 qPos.add(groupId);
2806
2807 if (classUuid != null) {
2808 qPos.add(classUuid);
2809 }
2810
2811 count = (Long)q.uniqueResult();
2812
2813 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2814 }
2815 catch (Exception e) {
2816 FinderCacheUtil.removeResult(finderPath, finderArgs);
2817
2818 throw processException(e);
2819 }
2820 finally {
2821 closeSession(session);
2822 }
2823 }
2824
2825 return count.intValue();
2826 }
2827
2828 private static final String _FINDER_COLUMN_G_CU_GROUPID_2 = "assetEntry.groupId = ? AND ";
2829 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_1 = "assetEntry.classUuid IS NULL";
2830 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_2 = "assetEntry.classUuid = ?";
2831 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_3 = "(assetEntry.classUuid IS NULL OR assetEntry.classUuid = ?)";
2832 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2833 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2834 FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
2835 new String[] { Long.class.getName(), Long.class.getName() },
2836 AssetEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2837 AssetEntryModelImpl.CLASSPK_COLUMN_BITMASK);
2838 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2839 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2840 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
2841 new String[] { Long.class.getName(), Long.class.getName() });
2842
2843
2852 public AssetEntry findByC_C(long classNameId, long classPK)
2853 throws NoSuchEntryException, SystemException {
2854 AssetEntry assetEntry = fetchByC_C(classNameId, classPK);
2855
2856 if (assetEntry == null) {
2857 StringBundler msg = new StringBundler(6);
2858
2859 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2860
2861 msg.append("classNameId=");
2862 msg.append(classNameId);
2863
2864 msg.append(", classPK=");
2865 msg.append(classPK);
2866
2867 msg.append(StringPool.CLOSE_CURLY_BRACE);
2868
2869 if (_log.isWarnEnabled()) {
2870 _log.warn(msg.toString());
2871 }
2872
2873 throw new NoSuchEntryException(msg.toString());
2874 }
2875
2876 return assetEntry;
2877 }
2878
2879
2887 public AssetEntry fetchByC_C(long classNameId, long classPK)
2888 throws SystemException {
2889 return fetchByC_C(classNameId, classPK, true);
2890 }
2891
2892
2901 public AssetEntry fetchByC_C(long classNameId, long classPK,
2902 boolean retrieveFromCache) throws SystemException {
2903 Object[] finderArgs = new Object[] { classNameId, classPK };
2904
2905 Object result = null;
2906
2907 if (retrieveFromCache) {
2908 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
2909 finderArgs, this);
2910 }
2911
2912 if (result instanceof AssetEntry) {
2913 AssetEntry assetEntry = (AssetEntry)result;
2914
2915 if ((classNameId != assetEntry.getClassNameId()) ||
2916 (classPK != assetEntry.getClassPK())) {
2917 result = null;
2918 }
2919 }
2920
2921 if (result == null) {
2922 StringBundler query = new StringBundler(4);
2923
2924 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2925
2926 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2927
2928 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2929
2930 String sql = query.toString();
2931
2932 Session session = null;
2933
2934 try {
2935 session = openSession();
2936
2937 Query q = session.createQuery(sql);
2938
2939 QueryPos qPos = QueryPos.getInstance(q);
2940
2941 qPos.add(classNameId);
2942
2943 qPos.add(classPK);
2944
2945 List<AssetEntry> list = q.list();
2946
2947 if (list.isEmpty()) {
2948 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2949 finderArgs, list);
2950 }
2951 else {
2952 AssetEntry assetEntry = list.get(0);
2953
2954 result = assetEntry;
2955
2956 cacheResult(assetEntry);
2957
2958 if ((assetEntry.getClassNameId() != classNameId) ||
2959 (assetEntry.getClassPK() != classPK)) {
2960 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2961 finderArgs, assetEntry);
2962 }
2963 }
2964 }
2965 catch (Exception e) {
2966 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
2967 finderArgs);
2968
2969 throw processException(e);
2970 }
2971 finally {
2972 closeSession(session);
2973 }
2974 }
2975
2976 if (result instanceof List<?>) {
2977 return null;
2978 }
2979 else {
2980 return (AssetEntry)result;
2981 }
2982 }
2983
2984
2992 public AssetEntry removeByC_C(long classNameId, long classPK)
2993 throws NoSuchEntryException, SystemException {
2994 AssetEntry assetEntry = findByC_C(classNameId, classPK);
2995
2996 return remove(assetEntry);
2997 }
2998
2999
3007 public int countByC_C(long classNameId, long classPK)
3008 throws SystemException {
3009 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
3010
3011 Object[] finderArgs = new Object[] { classNameId, classPK };
3012
3013 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3014 this);
3015
3016 if (count == null) {
3017 StringBundler query = new StringBundler(3);
3018
3019 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
3020
3021 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3022
3023 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3024
3025 String sql = query.toString();
3026
3027 Session session = null;
3028
3029 try {
3030 session = openSession();
3031
3032 Query q = session.createQuery(sql);
3033
3034 QueryPos qPos = QueryPos.getInstance(q);
3035
3036 qPos.add(classNameId);
3037
3038 qPos.add(classPK);
3039
3040 count = (Long)q.uniqueResult();
3041
3042 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3043 }
3044 catch (Exception e) {
3045 FinderCacheUtil.removeResult(finderPath, finderArgs);
3046
3047 throw processException(e);
3048 }
3049 finally {
3050 closeSession(session);
3051 }
3052 }
3053
3054 return count.intValue();
3055 }
3056
3057 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "assetEntry.classNameId = ? AND ";
3058 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "assetEntry.classPK = ?";
3059
3060
3065 public void cacheResult(AssetEntry assetEntry) {
3066 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3067 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
3068
3069 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
3070 new Object[] {
3071 Long.valueOf(assetEntry.getGroupId()),
3072
3073 assetEntry.getClassUuid()
3074 }, assetEntry);
3075
3076 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
3077 new Object[] {
3078 Long.valueOf(assetEntry.getClassNameId()),
3079 Long.valueOf(assetEntry.getClassPK())
3080 }, assetEntry);
3081
3082 assetEntry.resetOriginalValues();
3083 }
3084
3085
3090 public void cacheResult(List<AssetEntry> assetEntries) {
3091 for (AssetEntry assetEntry : assetEntries) {
3092 if (EntityCacheUtil.getResult(
3093 AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3094 AssetEntryImpl.class, assetEntry.getPrimaryKey()) == null) {
3095 cacheResult(assetEntry);
3096 }
3097 else {
3098 assetEntry.resetOriginalValues();
3099 }
3100 }
3101 }
3102
3103
3110 @Override
3111 public void clearCache() {
3112 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
3113 CacheRegistryUtil.clear(AssetEntryImpl.class.getName());
3114 }
3115
3116 EntityCacheUtil.clearCache(AssetEntryImpl.class.getName());
3117
3118 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
3119 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3120 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3121 }
3122
3123
3130 @Override
3131 public void clearCache(AssetEntry assetEntry) {
3132 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3133 AssetEntryImpl.class, assetEntry.getPrimaryKey());
3134
3135 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3136 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3137
3138 clearUniqueFindersCache(assetEntry);
3139 }
3140
3141 @Override
3142 public void clearCache(List<AssetEntry> assetEntries) {
3143 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3144 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3145
3146 for (AssetEntry assetEntry : assetEntries) {
3147 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3148 AssetEntryImpl.class, assetEntry.getPrimaryKey());
3149
3150 clearUniqueFindersCache(assetEntry);
3151 }
3152 }
3153
3154 protected void cacheUniqueFindersCache(AssetEntry assetEntry) {
3155 if (assetEntry.isNew()) {
3156 Object[] args = new Object[] {
3157 Long.valueOf(assetEntry.getGroupId()),
3158
3159 assetEntry.getClassUuid()
3160 };
3161
3162 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_CU, args,
3163 Long.valueOf(1));
3164 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU, args,
3165 assetEntry);
3166
3167 args = new Object[] {
3168 Long.valueOf(assetEntry.getClassNameId()),
3169 Long.valueOf(assetEntry.getClassPK())
3170 };
3171
3172 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
3173 Long.valueOf(1));
3174 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args, assetEntry);
3175 }
3176 else {
3177 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
3178
3179 if ((assetEntryModelImpl.getColumnBitmask() &
3180 FINDER_PATH_FETCH_BY_G_CU.getColumnBitmask()) != 0) {
3181 Object[] args = new Object[] {
3182 Long.valueOf(assetEntry.getGroupId()),
3183
3184 assetEntry.getClassUuid()
3185 };
3186
3187 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_CU, args,
3188 Long.valueOf(1));
3189 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU, args,
3190 assetEntry);
3191 }
3192
3193 if ((assetEntryModelImpl.getColumnBitmask() &
3194 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
3195 Object[] args = new Object[] {
3196 Long.valueOf(assetEntry.getClassNameId()),
3197 Long.valueOf(assetEntry.getClassPK())
3198 };
3199
3200 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
3201 Long.valueOf(1));
3202 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
3203 assetEntry);
3204 }
3205 }
3206 }
3207
3208 protected void clearUniqueFindersCache(AssetEntry assetEntry) {
3209 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
3210
3211 Object[] args = new Object[] {
3212 Long.valueOf(assetEntry.getGroupId()),
3213
3214 assetEntry.getClassUuid()
3215 };
3216
3217 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_CU, args);
3218 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU, args);
3219
3220 if ((assetEntryModelImpl.getColumnBitmask() &
3221 FINDER_PATH_FETCH_BY_G_CU.getColumnBitmask()) != 0) {
3222 args = new Object[] {
3223 Long.valueOf(assetEntryModelImpl.getOriginalGroupId()),
3224
3225 assetEntryModelImpl.getOriginalClassUuid()
3226 };
3227
3228 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_CU, args);
3229 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU, args);
3230 }
3231
3232 args = new Object[] {
3233 Long.valueOf(assetEntry.getClassNameId()),
3234 Long.valueOf(assetEntry.getClassPK())
3235 };
3236
3237 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
3238 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
3239
3240 if ((assetEntryModelImpl.getColumnBitmask() &
3241 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
3242 args = new Object[] {
3243 Long.valueOf(assetEntryModelImpl.getOriginalClassNameId()),
3244 Long.valueOf(assetEntryModelImpl.getOriginalClassPK())
3245 };
3246
3247 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
3248 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
3249 }
3250 }
3251
3252
3258 public AssetEntry create(long entryId) {
3259 AssetEntry assetEntry = new AssetEntryImpl();
3260
3261 assetEntry.setNew(true);
3262 assetEntry.setPrimaryKey(entryId);
3263
3264 return assetEntry;
3265 }
3266
3267
3275 public AssetEntry remove(long entryId)
3276 throws NoSuchEntryException, SystemException {
3277 return remove(Long.valueOf(entryId));
3278 }
3279
3280
3288 @Override
3289 public AssetEntry remove(Serializable primaryKey)
3290 throws NoSuchEntryException, SystemException {
3291 Session session = null;
3292
3293 try {
3294 session = openSession();
3295
3296 AssetEntry assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
3297 primaryKey);
3298
3299 if (assetEntry == null) {
3300 if (_log.isWarnEnabled()) {
3301 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3302 }
3303
3304 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3305 primaryKey);
3306 }
3307
3308 return remove(assetEntry);
3309 }
3310 catch (NoSuchEntryException nsee) {
3311 throw nsee;
3312 }
3313 catch (Exception e) {
3314 throw processException(e);
3315 }
3316 finally {
3317 closeSession(session);
3318 }
3319 }
3320
3321 @Override
3322 protected AssetEntry removeImpl(AssetEntry assetEntry)
3323 throws SystemException {
3324 assetEntry = toUnwrappedModel(assetEntry);
3325
3326 try {
3327 clearAssetCategories.clear(assetEntry.getPrimaryKey());
3328 }
3329 catch (Exception e) {
3330 throw processException(e);
3331 }
3332 finally {
3333 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3334 }
3335
3336 try {
3337 clearAssetTags.clear(assetEntry.getPrimaryKey());
3338 }
3339 catch (Exception e) {
3340 throw processException(e);
3341 }
3342 finally {
3343 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3344 }
3345
3346 Session session = null;
3347
3348 try {
3349 session = openSession();
3350
3351 if (!session.contains(assetEntry)) {
3352 assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
3353 assetEntry.getPrimaryKeyObj());
3354 }
3355
3356 if (assetEntry != null) {
3357 session.delete(assetEntry);
3358 }
3359 }
3360 catch (Exception e) {
3361 throw processException(e);
3362 }
3363 finally {
3364 closeSession(session);
3365 }
3366
3367 if (assetEntry != null) {
3368 clearCache(assetEntry);
3369 }
3370
3371 return assetEntry;
3372 }
3373
3374 @Override
3375 public AssetEntry updateImpl(
3376 com.liferay.portlet.asset.model.AssetEntry assetEntry)
3377 throws SystemException {
3378 assetEntry = toUnwrappedModel(assetEntry);
3379
3380 boolean isNew = assetEntry.isNew();
3381
3382 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
3383
3384 Session session = null;
3385
3386 try {
3387 session = openSession();
3388
3389 if (assetEntry.isNew()) {
3390 session.save(assetEntry);
3391
3392 assetEntry.setNew(false);
3393 }
3394 else {
3395 session.merge(assetEntry);
3396 }
3397 }
3398 catch (Exception e) {
3399 throw processException(e);
3400 }
3401 finally {
3402 closeSession(session);
3403 }
3404
3405 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3406
3407 if (isNew || !AssetEntryModelImpl.COLUMN_BITMASK_ENABLED) {
3408 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3409 }
3410
3411 else {
3412 if ((assetEntryModelImpl.getColumnBitmask() &
3413 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
3414 Object[] args = new Object[] {
3415 Long.valueOf(assetEntryModelImpl.getOriginalCompanyId())
3416 };
3417
3418 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3419 args);
3420 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3421 args);
3422
3423 args = new Object[] {
3424 Long.valueOf(assetEntryModelImpl.getCompanyId())
3425 };
3426
3427 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3428 args);
3429 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3430 args);
3431 }
3432
3433 if ((assetEntryModelImpl.getColumnBitmask() &
3434 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE.getColumnBitmask()) != 0) {
3435 Object[] args = new Object[] {
3436 Boolean.valueOf(assetEntryModelImpl.getOriginalVisible())
3437 };
3438
3439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
3440 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
3441 args);
3442
3443 args = new Object[] {
3444 Boolean.valueOf(assetEntryModelImpl.getVisible())
3445 };
3446
3447 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
3448 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
3449 args);
3450 }
3451
3452 if ((assetEntryModelImpl.getColumnBitmask() &
3453 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE.getColumnBitmask()) != 0) {
3454 Object[] args = new Object[] {
3455 assetEntryModelImpl.getOriginalPublishDate()
3456 };
3457
3458 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
3459 args);
3460 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
3461 args);
3462
3463 args = new Object[] { assetEntryModelImpl.getPublishDate() };
3464
3465 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
3466 args);
3467 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
3468 args);
3469 }
3470
3471 if ((assetEntryModelImpl.getColumnBitmask() &
3472 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE.getColumnBitmask()) != 0) {
3473 Object[] args = new Object[] {
3474 assetEntryModelImpl.getOriginalExpirationDate()
3475 };
3476
3477 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
3478 args);
3479 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
3480 args);
3481
3482 args = new Object[] { assetEntryModelImpl.getExpirationDate() };
3483
3484 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
3485 args);
3486 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
3487 args);
3488 }
3489
3490 if ((assetEntryModelImpl.getColumnBitmask() &
3491 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
3492 Object[] args = new Object[] {
3493 assetEntryModelImpl.getOriginalLayoutUuid()
3494 };
3495
3496 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
3497 args);
3498 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
3499 args);
3500
3501 args = new Object[] { assetEntryModelImpl.getLayoutUuid() };
3502
3503 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
3504 args);
3505 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
3506 args);
3507 }
3508 }
3509
3510 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3511 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
3512
3513 clearUniqueFindersCache(assetEntry);
3514 cacheUniqueFindersCache(assetEntry);
3515
3516 return assetEntry;
3517 }
3518
3519 protected AssetEntry toUnwrappedModel(AssetEntry assetEntry) {
3520 if (assetEntry instanceof AssetEntryImpl) {
3521 return assetEntry;
3522 }
3523
3524 AssetEntryImpl assetEntryImpl = new AssetEntryImpl();
3525
3526 assetEntryImpl.setNew(assetEntry.isNew());
3527 assetEntryImpl.setPrimaryKey(assetEntry.getPrimaryKey());
3528
3529 assetEntryImpl.setEntryId(assetEntry.getEntryId());
3530 assetEntryImpl.setGroupId(assetEntry.getGroupId());
3531 assetEntryImpl.setCompanyId(assetEntry.getCompanyId());
3532 assetEntryImpl.setUserId(assetEntry.getUserId());
3533 assetEntryImpl.setUserName(assetEntry.getUserName());
3534 assetEntryImpl.setCreateDate(assetEntry.getCreateDate());
3535 assetEntryImpl.setModifiedDate(assetEntry.getModifiedDate());
3536 assetEntryImpl.setClassNameId(assetEntry.getClassNameId());
3537 assetEntryImpl.setClassPK(assetEntry.getClassPK());
3538 assetEntryImpl.setClassUuid(assetEntry.getClassUuid());
3539 assetEntryImpl.setClassTypeId(assetEntry.getClassTypeId());
3540 assetEntryImpl.setVisible(assetEntry.isVisible());
3541 assetEntryImpl.setStartDate(assetEntry.getStartDate());
3542 assetEntryImpl.setEndDate(assetEntry.getEndDate());
3543 assetEntryImpl.setPublishDate(assetEntry.getPublishDate());
3544 assetEntryImpl.setExpirationDate(assetEntry.getExpirationDate());
3545 assetEntryImpl.setMimeType(assetEntry.getMimeType());
3546 assetEntryImpl.setTitle(assetEntry.getTitle());
3547 assetEntryImpl.setDescription(assetEntry.getDescription());
3548 assetEntryImpl.setSummary(assetEntry.getSummary());
3549 assetEntryImpl.setUrl(assetEntry.getUrl());
3550 assetEntryImpl.setLayoutUuid(assetEntry.getLayoutUuid());
3551 assetEntryImpl.setHeight(assetEntry.getHeight());
3552 assetEntryImpl.setWidth(assetEntry.getWidth());
3553 assetEntryImpl.setPriority(assetEntry.getPriority());
3554 assetEntryImpl.setViewCount(assetEntry.getViewCount());
3555
3556 return assetEntryImpl;
3557 }
3558
3559
3567 @Override
3568 public AssetEntry findByPrimaryKey(Serializable primaryKey)
3569 throws NoSuchModelException, SystemException {
3570 return findByPrimaryKey(((Long)primaryKey).longValue());
3571 }
3572
3573
3581 public AssetEntry findByPrimaryKey(long entryId)
3582 throws NoSuchEntryException, SystemException {
3583 AssetEntry assetEntry = fetchByPrimaryKey(entryId);
3584
3585 if (assetEntry == null) {
3586 if (_log.isWarnEnabled()) {
3587 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
3588 }
3589
3590 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3591 entryId);
3592 }
3593
3594 return assetEntry;
3595 }
3596
3597
3604 @Override
3605 public AssetEntry fetchByPrimaryKey(Serializable primaryKey)
3606 throws SystemException {
3607 return fetchByPrimaryKey(((Long)primaryKey).longValue());
3608 }
3609
3610
3617 public AssetEntry fetchByPrimaryKey(long entryId) throws SystemException {
3618 AssetEntry assetEntry = (AssetEntry)EntityCacheUtil.getResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3619 AssetEntryImpl.class, entryId);
3620
3621 if (assetEntry == _nullAssetEntry) {
3622 return null;
3623 }
3624
3625 if (assetEntry == null) {
3626 Session session = null;
3627
3628 try {
3629 session = openSession();
3630
3631 assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
3632 Long.valueOf(entryId));
3633
3634 if (assetEntry != null) {
3635 cacheResult(assetEntry);
3636 }
3637 else {
3638 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3639 AssetEntryImpl.class, entryId, _nullAssetEntry);
3640 }
3641 }
3642 catch (Exception e) {
3643 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3644 AssetEntryImpl.class, entryId);
3645
3646 throw processException(e);
3647 }
3648 finally {
3649 closeSession(session);
3650 }
3651 }
3652
3653 return assetEntry;
3654 }
3655
3656
3662 public List<AssetEntry> findAll() throws SystemException {
3663 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3664 }
3665
3666
3678 public List<AssetEntry> findAll(int start, int end)
3679 throws SystemException {
3680 return findAll(start, end, null);
3681 }
3682
3683
3696 public List<AssetEntry> findAll(int start, int end,
3697 OrderByComparator orderByComparator) throws SystemException {
3698 boolean pagination = true;
3699 FinderPath finderPath = null;
3700 Object[] finderArgs = null;
3701
3702 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3703 (orderByComparator == null)) {
3704 pagination = false;
3705 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3706 finderArgs = FINDER_ARGS_EMPTY;
3707 }
3708 else {
3709 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3710 finderArgs = new Object[] { start, end, orderByComparator };
3711 }
3712
3713 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
3714 finderArgs, this);
3715
3716 if (list == null) {
3717 StringBundler query = null;
3718 String sql = null;
3719
3720 if (orderByComparator != null) {
3721 query = new StringBundler(2 +
3722 (orderByComparator.getOrderByFields().length * 3));
3723
3724 query.append(_SQL_SELECT_ASSETENTRY);
3725
3726 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3727 orderByComparator);
3728
3729 sql = query.toString();
3730 }
3731 else {
3732 sql = _SQL_SELECT_ASSETENTRY;
3733
3734 if (pagination) {
3735 sql = sql.concat(AssetEntryModelImpl.ORDER_BY_JPQL);
3736 }
3737 }
3738
3739 Session session = null;
3740
3741 try {
3742 session = openSession();
3743
3744 Query q = session.createQuery(sql);
3745
3746 if (!pagination) {
3747 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
3748 start, end, false);
3749
3750 Collections.sort(list);
3751
3752 list = new UnmodifiableList<AssetEntry>(list);
3753 }
3754 else {
3755 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
3756 start, end);
3757 }
3758
3759 cacheResult(list);
3760
3761 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3762 }
3763 catch (Exception e) {
3764 FinderCacheUtil.removeResult(finderPath, finderArgs);
3765
3766 throw processException(e);
3767 }
3768 finally {
3769 closeSession(session);
3770 }
3771 }
3772
3773 return list;
3774 }
3775
3776
3781 public void removeAll() throws SystemException {
3782 for (AssetEntry assetEntry : findAll()) {
3783 remove(assetEntry);
3784 }
3785 }
3786
3787
3793 public int countAll() throws SystemException {
3794 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3795 FINDER_ARGS_EMPTY, this);
3796
3797 if (count == null) {
3798 Session session = null;
3799
3800 try {
3801 session = openSession();
3802
3803 Query q = session.createQuery(_SQL_COUNT_ASSETENTRY);
3804
3805 count = (Long)q.uniqueResult();
3806
3807 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3808 FINDER_ARGS_EMPTY, count);
3809 }
3810 catch (Exception e) {
3811 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3812 FINDER_ARGS_EMPTY);
3813
3814 throw processException(e);
3815 }
3816 finally {
3817 closeSession(session);
3818 }
3819 }
3820
3821 return count.intValue();
3822 }
3823
3824
3831 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3832 long pk) throws SystemException {
3833 return getAssetCategories(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3834 }
3835
3836
3849 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3850 long pk, int start, int end) throws SystemException {
3851 return getAssetCategories(pk, start, end, null);
3852 }
3853
3854 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3855 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3856 com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class,
3857 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3858 "getAssetCategories",
3859 new String[] {
3860 Long.class.getName(), Integer.class.getName(),
3861 Integer.class.getName(), OrderByComparator.class.getName()
3862 });
3863
3864 static {
3865 FINDER_PATH_GET_ASSETCATEGORIES.setCacheKeyGeneratorCacheName(null);
3866 }
3867
3868
3882 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3883 long pk, int start, int end, OrderByComparator orderByComparator)
3884 throws SystemException {
3885 boolean pagination = true;
3886 Object[] finderArgs = null;
3887
3888 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3889 (orderByComparator == null)) {
3890 pagination = false;
3891 finderArgs = new Object[] { pk };
3892 }
3893 else {
3894 finderArgs = new Object[] { pk, start, end, orderByComparator };
3895 }
3896
3897 List<com.liferay.portlet.asset.model.AssetCategory> list = (List<com.liferay.portlet.asset.model.AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES,
3898 finderArgs, this);
3899
3900 if (list == null) {
3901 Session session = null;
3902
3903 try {
3904 session = openSession();
3905
3906 String sql = null;
3907
3908 if (orderByComparator != null) {
3909 sql = _SQL_GETASSETCATEGORIES.concat(ORDER_BY_CLAUSE)
3910 .concat(orderByComparator.getOrderBy());
3911 }
3912 else {
3913 sql = _SQL_GETASSETCATEGORIES;
3914
3915 if (pagination) {
3916 sql = sql.concat(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ORDER_BY_SQL);
3917 }
3918 }
3919
3920 SQLQuery q = session.createSQLQuery(sql);
3921
3922 q.addEntity("AssetCategory",
3923 com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class);
3924
3925 QueryPos qPos = QueryPos.getInstance(q);
3926
3927 qPos.add(pk);
3928
3929 if (!pagination) {
3930 list = (List<com.liferay.portlet.asset.model.AssetCategory>)QueryUtil.list(q,
3931 getDialect(), start, end, false);
3932
3933 Collections.sort(list);
3934
3935 list = new UnmodifiableList<com.liferay.portlet.asset.model.AssetCategory>(list);
3936 }
3937 else {
3938 list = (List<com.liferay.portlet.asset.model.AssetCategory>)QueryUtil.list(q,
3939 getDialect(), start, end);
3940 }
3941
3942 assetCategoryPersistence.cacheResult(list);
3943
3944 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES,
3945 finderArgs, list);
3946 }
3947 catch (Exception e) {
3948 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETCATEGORIES,
3949 finderArgs);
3950
3951 throw processException(e);
3952 }
3953 finally {
3954 closeSession(session);
3955 }
3956 }
3957
3958 return list;
3959 }
3960
3961 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3962 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3963 Long.class,
3964 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3965 "getAssetCategoriesSize", new String[] { Long.class.getName() });
3966
3967 static {
3968 FINDER_PATH_GET_ASSETCATEGORIES_SIZE.setCacheKeyGeneratorCacheName(null);
3969 }
3970
3971
3978 public int getAssetCategoriesSize(long pk) throws SystemException {
3979 Object[] finderArgs = new Object[] { pk };
3980
3981 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
3982 finderArgs, this);
3983
3984 if (count == null) {
3985 Session session = null;
3986
3987 try {
3988 session = openSession();
3989
3990 SQLQuery q = session.createSQLQuery(_SQL_GETASSETCATEGORIESSIZE);
3991
3992 q.addScalar(COUNT_COLUMN_NAME,
3993 com.liferay.portal.kernel.dao.orm.Type.LONG);
3994
3995 QueryPos qPos = QueryPos.getInstance(q);
3996
3997 qPos.add(pk);
3998
3999 count = (Long)q.uniqueResult();
4000
4001 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
4002 finderArgs, count);
4003 }
4004 catch (Exception e) {
4005 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
4006 finderArgs);
4007
4008 throw processException(e);
4009 }
4010 finally {
4011 closeSession(session);
4012 }
4013 }
4014
4015 return count.intValue();
4016 }
4017
4018 public static final FinderPath FINDER_PATH_CONTAINS_ASSETCATEGORY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4019 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
4020 Boolean.class,
4021 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
4022 "containsAssetCategory",
4023 new String[] { Long.class.getName(), Long.class.getName() });
4024
4025
4033 public boolean containsAssetCategory(long pk, long assetCategoryPK)
4034 throws SystemException {
4035 Object[] finderArgs = new Object[] { pk, assetCategoryPK };
4036
4037 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
4038 finderArgs, this);
4039
4040 if (value == null) {
4041 try {
4042 value = Boolean.valueOf(containsAssetCategory.contains(pk,
4043 assetCategoryPK));
4044
4045 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
4046 finderArgs, value);
4047 }
4048 catch (Exception e) {
4049 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
4050 finderArgs);
4051
4052 throw processException(e);
4053 }
4054 }
4055
4056 return value.booleanValue();
4057 }
4058
4059
4066 public boolean containsAssetCategories(long pk) throws SystemException {
4067 if (getAssetCategoriesSize(pk) > 0) {
4068 return true;
4069 }
4070 else {
4071 return false;
4072 }
4073 }
4074
4075
4082 public void addAssetCategory(long pk, long assetCategoryPK)
4083 throws SystemException {
4084 try {
4085 addAssetCategory.add(pk, assetCategoryPK);
4086 }
4087 catch (Exception e) {
4088 throw processException(e);
4089 }
4090 finally {
4091 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4092 }
4093 }
4094
4095
4102 public void addAssetCategory(long pk,
4103 com.liferay.portlet.asset.model.AssetCategory assetCategory)
4104 throws SystemException {
4105 try {
4106 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
4107 }
4108 catch (Exception e) {
4109 throw processException(e);
4110 }
4111 finally {
4112 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4113 }
4114 }
4115
4116
4123 public void addAssetCategories(long pk, long[] assetCategoryPKs)
4124 throws SystemException {
4125 try {
4126 for (long assetCategoryPK : assetCategoryPKs) {
4127 addAssetCategory.add(pk, assetCategoryPK);
4128 }
4129 }
4130 catch (Exception e) {
4131 throw processException(e);
4132 }
4133 finally {
4134 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4135 }
4136 }
4137
4138
4145 public void addAssetCategories(long pk,
4146 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
4147 throws SystemException {
4148 try {
4149 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4150 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
4151 }
4152 }
4153 catch (Exception e) {
4154 throw processException(e);
4155 }
4156 finally {
4157 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4158 }
4159 }
4160
4161
4167 public void clearAssetCategories(long pk) throws SystemException {
4168 try {
4169 clearAssetCategories.clear(pk);
4170 }
4171 catch (Exception e) {
4172 throw processException(e);
4173 }
4174 finally {
4175 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4176 }
4177 }
4178
4179
4186 public void removeAssetCategory(long pk, long assetCategoryPK)
4187 throws SystemException {
4188 try {
4189 removeAssetCategory.remove(pk, assetCategoryPK);
4190 }
4191 catch (Exception e) {
4192 throw processException(e);
4193 }
4194 finally {
4195 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4196 }
4197 }
4198
4199
4206 public void removeAssetCategory(long pk,
4207 com.liferay.portlet.asset.model.AssetCategory assetCategory)
4208 throws SystemException {
4209 try {
4210 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
4211 }
4212 catch (Exception e) {
4213 throw processException(e);
4214 }
4215 finally {
4216 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4217 }
4218 }
4219
4220
4227 public void removeAssetCategories(long pk, long[] assetCategoryPKs)
4228 throws SystemException {
4229 try {
4230 for (long assetCategoryPK : assetCategoryPKs) {
4231 removeAssetCategory.remove(pk, assetCategoryPK);
4232 }
4233 }
4234 catch (Exception e) {
4235 throw processException(e);
4236 }
4237 finally {
4238 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4239 }
4240 }
4241
4242
4249 public void removeAssetCategories(long pk,
4250 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
4251 throws SystemException {
4252 try {
4253 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4254 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
4255 }
4256 }
4257 catch (Exception e) {
4258 throw processException(e);
4259 }
4260 finally {
4261 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4262 }
4263 }
4264
4265
4272 public void setAssetCategories(long pk, long[] assetCategoryPKs)
4273 throws SystemException {
4274 try {
4275 Set<Long> assetCategoryPKSet = SetUtil.fromArray(assetCategoryPKs);
4276
4277 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = getAssetCategories(pk);
4278
4279 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4280 if (!assetCategoryPKSet.remove(assetCategory.getPrimaryKey())) {
4281 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
4282 }
4283 }
4284
4285 for (Long assetCategoryPK : assetCategoryPKSet) {
4286 addAssetCategory.add(pk, assetCategoryPK);
4287 }
4288 }
4289 catch (Exception e) {
4290 throw processException(e);
4291 }
4292 finally {
4293 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4294 }
4295 }
4296
4297
4304 public void setAssetCategories(long pk,
4305 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
4306 throws SystemException {
4307 try {
4308 long[] assetCategoryPKs = new long[assetCategories.size()];
4309
4310 for (int i = 0; i < assetCategories.size(); i++) {
4311 com.liferay.portlet.asset.model.AssetCategory assetCategory = assetCategories.get(i);
4312
4313 assetCategoryPKs[i] = assetCategory.getPrimaryKey();
4314 }
4315
4316 setAssetCategories(pk, assetCategoryPKs);
4317 }
4318 catch (Exception e) {
4319 throw processException(e);
4320 }
4321 finally {
4322 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4323 }
4324 }
4325
4326
4333 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(long pk)
4334 throws SystemException {
4335 return getAssetTags(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4336 }
4337
4338
4351 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
4352 long pk, int start, int end) throws SystemException {
4353 return getAssetTags(pk, start, end, null);
4354 }
4355
4356 public static final FinderPath FINDER_PATH_GET_ASSETTAGS = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
4357 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
4358 com.liferay.portlet.asset.model.impl.AssetTagImpl.class,
4359 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
4360 "getAssetTags",
4361 new String[] {
4362 Long.class.getName(), Integer.class.getName(),
4363 Integer.class.getName(), OrderByComparator.class.getName()
4364 });
4365
4366 static {
4367 FINDER_PATH_GET_ASSETTAGS.setCacheKeyGeneratorCacheName(null);
4368 }
4369
4370
4384 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
4385 long pk, int start, int end, OrderByComparator orderByComparator)
4386 throws SystemException {
4387 boolean pagination = true;
4388 Object[] finderArgs = null;
4389
4390 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4391 (orderByComparator == null)) {
4392 pagination = false;
4393 finderArgs = new Object[] { pk };
4394 }
4395 else {
4396 finderArgs = new Object[] { pk, start, end, orderByComparator };
4397 }
4398
4399 List<com.liferay.portlet.asset.model.AssetTag> list = (List<com.liferay.portlet.asset.model.AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS,
4400 finderArgs, this);
4401
4402 if (list == null) {
4403 Session session = null;
4404
4405 try {
4406 session = openSession();
4407
4408 String sql = null;
4409
4410 if (orderByComparator != null) {
4411 sql = _SQL_GETASSETTAGS.concat(ORDER_BY_CLAUSE)
4412 .concat(orderByComparator.getOrderBy());
4413 }
4414 else {
4415 sql = _SQL_GETASSETTAGS;
4416
4417 if (pagination) {
4418 sql = sql.concat(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ORDER_BY_SQL);
4419 }
4420 }
4421
4422 SQLQuery q = session.createSQLQuery(sql);
4423
4424 q.addEntity("AssetTag",
4425 com.liferay.portlet.asset.model.impl.AssetTagImpl.class);
4426
4427 QueryPos qPos = QueryPos.getInstance(q);
4428
4429 qPos.add(pk);
4430
4431 if (!pagination) {
4432 list = (List<com.liferay.portlet.asset.model.AssetTag>)QueryUtil.list(q,
4433 getDialect(), start, end, false);
4434
4435 Collections.sort(list);
4436
4437 list = new UnmodifiableList<com.liferay.portlet.asset.model.AssetTag>(list);
4438 }
4439 else {
4440 list = (List<com.liferay.portlet.asset.model.AssetTag>)QueryUtil.list(q,
4441 getDialect(), start, end);
4442 }
4443
4444 assetTagPersistence.cacheResult(list);
4445
4446 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS,
4447 finderArgs, list);
4448 }
4449 catch (Exception e) {
4450 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETTAGS,
4451 finderArgs);
4452
4453 throw processException(e);
4454 }
4455 finally {
4456 closeSession(session);
4457 }
4458 }
4459
4460 return list;
4461 }
4462
4463 public static final FinderPath FINDER_PATH_GET_ASSETTAGS_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
4464 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
4465 Long.class,
4466 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
4467 "getAssetTagsSize", new String[] { Long.class.getName() });
4468
4469 static {
4470 FINDER_PATH_GET_ASSETTAGS_SIZE.setCacheKeyGeneratorCacheName(null);
4471 }
4472
4473
4480 public int getAssetTagsSize(long pk) throws SystemException {
4481 Object[] finderArgs = new Object[] { pk };
4482
4483 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
4484 finderArgs, this);
4485
4486 if (count == null) {
4487 Session session = null;
4488
4489 try {
4490 session = openSession();
4491
4492 SQLQuery q = session.createSQLQuery(_SQL_GETASSETTAGSSIZE);
4493
4494 q.addScalar(COUNT_COLUMN_NAME,
4495 com.liferay.portal.kernel.dao.orm.Type.LONG);
4496
4497 QueryPos qPos = QueryPos.getInstance(q);
4498
4499 qPos.add(pk);
4500
4501 count = (Long)q.uniqueResult();
4502
4503 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
4504 finderArgs, count);
4505 }
4506 catch (Exception e) {
4507 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
4508 finderArgs);
4509
4510 throw processException(e);
4511 }
4512 finally {
4513 closeSession(session);
4514 }
4515 }
4516
4517 return count.intValue();
4518 }
4519
4520 public static final FinderPath FINDER_PATH_CONTAINS_ASSETTAG = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
4521 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
4522 Boolean.class,
4523 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
4524 "containsAssetTag",
4525 new String[] { Long.class.getName(), Long.class.getName() });
4526
4527
4535 public boolean containsAssetTag(long pk, long assetTagPK)
4536 throws SystemException {
4537 Object[] finderArgs = new Object[] { pk, assetTagPK };
4538
4539 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETTAG,
4540 finderArgs, this);
4541
4542 if (value == null) {
4543 try {
4544 value = Boolean.valueOf(containsAssetTag.contains(pk, assetTagPK));
4545
4546 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETTAG,
4547 finderArgs, value);
4548 }
4549 catch (Exception e) {
4550 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_ASSETTAG,
4551 finderArgs);
4552
4553 throw processException(e);
4554 }
4555 }
4556
4557 return value.booleanValue();
4558 }
4559
4560
4567 public boolean containsAssetTags(long pk) throws SystemException {
4568 if (getAssetTagsSize(pk) > 0) {
4569 return true;
4570 }
4571 else {
4572 return false;
4573 }
4574 }
4575
4576
4583 public void addAssetTag(long pk, long assetTagPK) throws SystemException {
4584 try {
4585 addAssetTag.add(pk, assetTagPK);
4586 }
4587 catch (Exception e) {
4588 throw processException(e);
4589 }
4590 finally {
4591 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4592 }
4593 }
4594
4595
4602 public void addAssetTag(long pk,
4603 com.liferay.portlet.asset.model.AssetTag assetTag)
4604 throws SystemException {
4605 try {
4606 addAssetTag.add(pk, assetTag.getPrimaryKey());
4607 }
4608 catch (Exception e) {
4609 throw processException(e);
4610 }
4611 finally {
4612 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4613 }
4614 }
4615
4616
4623 public void addAssetTags(long pk, long[] assetTagPKs)
4624 throws SystemException {
4625 try {
4626 for (long assetTagPK : assetTagPKs) {
4627 addAssetTag.add(pk, assetTagPK);
4628 }
4629 }
4630 catch (Exception e) {
4631 throw processException(e);
4632 }
4633 finally {
4634 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4635 }
4636 }
4637
4638
4645 public void addAssetTags(long pk,
4646 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
4647 throws SystemException {
4648 try {
4649 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4650 addAssetTag.add(pk, assetTag.getPrimaryKey());
4651 }
4652 }
4653 catch (Exception e) {
4654 throw processException(e);
4655 }
4656 finally {
4657 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4658 }
4659 }
4660
4661
4667 public void clearAssetTags(long pk) throws SystemException {
4668 try {
4669 clearAssetTags.clear(pk);
4670 }
4671 catch (Exception e) {
4672 throw processException(e);
4673 }
4674 finally {
4675 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4676 }
4677 }
4678
4679
4686 public void removeAssetTag(long pk, long assetTagPK)
4687 throws SystemException {
4688 try {
4689 removeAssetTag.remove(pk, assetTagPK);
4690 }
4691 catch (Exception e) {
4692 throw processException(e);
4693 }
4694 finally {
4695 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4696 }
4697 }
4698
4699
4706 public void removeAssetTag(long pk,
4707 com.liferay.portlet.asset.model.AssetTag assetTag)
4708 throws SystemException {
4709 try {
4710 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
4711 }
4712 catch (Exception e) {
4713 throw processException(e);
4714 }
4715 finally {
4716 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4717 }
4718 }
4719
4720
4727 public void removeAssetTags(long pk, long[] assetTagPKs)
4728 throws SystemException {
4729 try {
4730 for (long assetTagPK : assetTagPKs) {
4731 removeAssetTag.remove(pk, assetTagPK);
4732 }
4733 }
4734 catch (Exception e) {
4735 throw processException(e);
4736 }
4737 finally {
4738 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4739 }
4740 }
4741
4742
4749 public void removeAssetTags(long pk,
4750 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
4751 throws SystemException {
4752 try {
4753 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4754 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
4755 }
4756 }
4757 catch (Exception e) {
4758 throw processException(e);
4759 }
4760 finally {
4761 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4762 }
4763 }
4764
4765
4772 public void setAssetTags(long pk, long[] assetTagPKs)
4773 throws SystemException {
4774 try {
4775 Set<Long> assetTagPKSet = SetUtil.fromArray(assetTagPKs);
4776
4777 List<com.liferay.portlet.asset.model.AssetTag> assetTags = getAssetTags(pk);
4778
4779 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4780 if (!assetTagPKSet.remove(assetTag.getPrimaryKey())) {
4781 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
4782 }
4783 }
4784
4785 for (Long assetTagPK : assetTagPKSet) {
4786 addAssetTag.add(pk, assetTagPK);
4787 }
4788 }
4789 catch (Exception e) {
4790 throw processException(e);
4791 }
4792 finally {
4793 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4794 }
4795 }
4796
4797
4804 public void setAssetTags(long pk,
4805 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
4806 throws SystemException {
4807 try {
4808 long[] assetTagPKs = new long[assetTags.size()];
4809
4810 for (int i = 0; i < assetTags.size(); i++) {
4811 com.liferay.portlet.asset.model.AssetTag assetTag = assetTags.get(i);
4812
4813 assetTagPKs[i] = assetTag.getPrimaryKey();
4814 }
4815
4816 setAssetTags(pk, assetTagPKs);
4817 }
4818 catch (Exception e) {
4819 throw processException(e);
4820 }
4821 finally {
4822 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4823 }
4824 }
4825
4826
4829 public void afterPropertiesSet() {
4830 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4831 com.liferay.portal.util.PropsUtil.get(
4832 "value.object.listener.com.liferay.portlet.asset.model.AssetEntry")));
4833
4834 if (listenerClassNames.length > 0) {
4835 try {
4836 List<ModelListener<AssetEntry>> listenersList = new ArrayList<ModelListener<AssetEntry>>();
4837
4838 for (String listenerClassName : listenerClassNames) {
4839 listenersList.add((ModelListener<AssetEntry>)InstanceFactory.newInstance(
4840 listenerClassName));
4841 }
4842
4843 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4844 }
4845 catch (Exception e) {
4846 _log.error(e);
4847 }
4848 }
4849
4850 containsAssetCategory = new ContainsAssetCategory();
4851
4852 addAssetCategory = new AddAssetCategory();
4853 clearAssetCategories = new ClearAssetCategories();
4854 removeAssetCategory = new RemoveAssetCategory();
4855
4856 containsAssetTag = new ContainsAssetTag();
4857
4858 addAssetTag = new AddAssetTag();
4859 clearAssetTags = new ClearAssetTags();
4860 removeAssetTag = new RemoveAssetTag();
4861 }
4862
4863 public void destroy() {
4864 EntityCacheUtil.removeCache(AssetEntryImpl.class.getName());
4865 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4866 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4867 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4868 }
4869
4870 @BeanReference(type = AssetCategoryPersistence.class)
4871 protected AssetCategoryPersistence assetCategoryPersistence;
4872 protected ContainsAssetCategory containsAssetCategory;
4873 protected AddAssetCategory addAssetCategory;
4874 protected ClearAssetCategories clearAssetCategories;
4875 protected RemoveAssetCategory removeAssetCategory;
4876 @BeanReference(type = AssetTagPersistence.class)
4877 protected AssetTagPersistence assetTagPersistence;
4878 protected ContainsAssetTag containsAssetTag;
4879 protected AddAssetTag addAssetTag;
4880 protected ClearAssetTags clearAssetTags;
4881 protected RemoveAssetTag removeAssetTag;
4882
4883 protected class ContainsAssetCategory {
4884 protected ContainsAssetCategory() {
4885 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4886 _SQL_CONTAINSASSETCATEGORY,
4887 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4888 RowMapper.COUNT);
4889 }
4890
4891 protected boolean contains(long entryId, long categoryId) {
4892 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4893 new Long(entryId), new Long(categoryId)
4894 });
4895
4896 if (results.size() > 0) {
4897 Integer count = results.get(0);
4898
4899 if (count.intValue() > 0) {
4900 return true;
4901 }
4902 }
4903
4904 return false;
4905 }
4906
4907 private MappingSqlQuery<Integer> _mappingSqlQuery;
4908 }
4909
4910 protected class AddAssetCategory {
4911 protected AddAssetCategory() {
4912 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4913 "INSERT INTO AssetEntries_AssetCategories (entryId, categoryId) VALUES (?, ?)",
4914 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4915 }
4916
4917 protected void add(long entryId, long categoryId)
4918 throws SystemException {
4919 if (!containsAssetCategory.contains(entryId, categoryId)) {
4920 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4921 assetCategoryPersistence.getListeners();
4922
4923 for (ModelListener<AssetEntry> listener : listeners) {
4924 listener.onBeforeAddAssociation(entryId,
4925 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4926 categoryId);
4927 }
4928
4929 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4930 listener.onBeforeAddAssociation(categoryId,
4931 AssetEntry.class.getName(), entryId);
4932 }
4933
4934 _sqlUpdate.update(new Object[] {
4935 new Long(entryId), new Long(categoryId)
4936 });
4937
4938 for (ModelListener<AssetEntry> listener : listeners) {
4939 listener.onAfterAddAssociation(entryId,
4940 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4941 categoryId);
4942 }
4943
4944 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4945 listener.onAfterAddAssociation(categoryId,
4946 AssetEntry.class.getName(), entryId);
4947 }
4948 }
4949 }
4950
4951 private SqlUpdate _sqlUpdate;
4952 }
4953
4954 protected class ClearAssetCategories {
4955 protected ClearAssetCategories() {
4956 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4957 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ?",
4958 new int[] { java.sql.Types.BIGINT });
4959 }
4960
4961 protected void clear(long entryId) throws SystemException {
4962 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4963 assetCategoryPersistence.getListeners();
4964
4965 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = null;
4966
4967 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
4968 assetCategories = getAssetCategories(entryId);
4969
4970 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4971 for (ModelListener<AssetEntry> listener : listeners) {
4972 listener.onBeforeRemoveAssociation(entryId,
4973 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4974 assetCategory.getPrimaryKey());
4975 }
4976
4977 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4978 listener.onBeforeRemoveAssociation(assetCategory.getPrimaryKey(),
4979 AssetEntry.class.getName(), entryId);
4980 }
4981 }
4982 }
4983
4984 _sqlUpdate.update(new Object[] { new Long(entryId) });
4985
4986 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
4987 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4988 for (ModelListener<AssetEntry> listener : listeners) {
4989 listener.onAfterRemoveAssociation(entryId,
4990 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4991 assetCategory.getPrimaryKey());
4992 }
4993
4994 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4995 listener.onAfterRemoveAssociation(assetCategory.getPrimaryKey(),
4996 AssetEntry.class.getName(), entryId);
4997 }
4998 }
4999 }
5000 }
5001
5002 private SqlUpdate _sqlUpdate;
5003 }
5004
5005 protected class RemoveAssetCategory {
5006 protected RemoveAssetCategory() {
5007 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5008 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?",
5009 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5010 }
5011
5012 protected void remove(long entryId, long categoryId)
5013 throws SystemException {
5014 if (containsAssetCategory.contains(entryId, categoryId)) {
5015 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
5016 assetCategoryPersistence.getListeners();
5017
5018 for (ModelListener<AssetEntry> listener : listeners) {
5019 listener.onBeforeRemoveAssociation(entryId,
5020 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
5021 categoryId);
5022 }
5023
5024 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
5025 listener.onBeforeRemoveAssociation(categoryId,
5026 AssetEntry.class.getName(), entryId);
5027 }
5028
5029 _sqlUpdate.update(new Object[] {
5030 new Long(entryId), new Long(categoryId)
5031 });
5032
5033 for (ModelListener<AssetEntry> listener : listeners) {
5034 listener.onAfterRemoveAssociation(entryId,
5035 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
5036 categoryId);
5037 }
5038
5039 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
5040 listener.onAfterRemoveAssociation(categoryId,
5041 AssetEntry.class.getName(), entryId);
5042 }
5043 }
5044 }
5045
5046 private SqlUpdate _sqlUpdate;
5047 }
5048
5049 protected class ContainsAssetTag {
5050 protected ContainsAssetTag() {
5051 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5052 _SQL_CONTAINSASSETTAG,
5053 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
5054 RowMapper.COUNT);
5055 }
5056
5057 protected boolean contains(long entryId, long tagId) {
5058 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5059 new Long(entryId), new Long(tagId)
5060 });
5061
5062 if (results.size() > 0) {
5063 Integer count = results.get(0);
5064
5065 if (count.intValue() > 0) {
5066 return true;
5067 }
5068 }
5069
5070 return false;
5071 }
5072
5073 private MappingSqlQuery<Integer> _mappingSqlQuery;
5074 }
5075
5076 protected class AddAssetTag {
5077 protected AddAssetTag() {
5078 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5079 "INSERT INTO AssetEntries_AssetTags (entryId, tagId) VALUES (?, ?)",
5080 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5081 }
5082
5083 protected void add(long entryId, long tagId) throws SystemException {
5084 if (!containsAssetTag.contains(entryId, tagId)) {
5085 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
5086 assetTagPersistence.getListeners();
5087
5088 for (ModelListener<AssetEntry> listener : listeners) {
5089 listener.onBeforeAddAssociation(entryId,
5090 com.liferay.portlet.asset.model.AssetTag.class.getName(),
5091 tagId);
5092 }
5093
5094 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
5095 listener.onBeforeAddAssociation(tagId,
5096 AssetEntry.class.getName(), entryId);
5097 }
5098
5099 _sqlUpdate.update(new Object[] {
5100 new Long(entryId), new Long(tagId)
5101 });
5102
5103 for (ModelListener<AssetEntry> listener : listeners) {
5104 listener.onAfterAddAssociation(entryId,
5105 com.liferay.portlet.asset.model.AssetTag.class.getName(),
5106 tagId);
5107 }
5108
5109 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
5110 listener.onAfterAddAssociation(tagId,
5111 AssetEntry.class.getName(), entryId);
5112 }
5113 }
5114 }
5115
5116 private SqlUpdate _sqlUpdate;
5117 }
5118
5119 protected class ClearAssetTags {
5120 protected ClearAssetTags() {
5121 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5122 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ?",
5123 new int[] { java.sql.Types.BIGINT });
5124 }
5125
5126 protected void clear(long entryId) throws SystemException {
5127 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
5128 assetTagPersistence.getListeners();
5129
5130 List<com.liferay.portlet.asset.model.AssetTag> assetTags = null;
5131
5132 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
5133 assetTags = getAssetTags(entryId);
5134
5135 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
5136 for (ModelListener<AssetEntry> listener : listeners) {
5137 listener.onBeforeRemoveAssociation(entryId,
5138 com.liferay.portlet.asset.model.AssetTag.class.getName(),
5139 assetTag.getPrimaryKey());
5140 }
5141
5142 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
5143 listener.onBeforeRemoveAssociation(assetTag.getPrimaryKey(),
5144 AssetEntry.class.getName(), entryId);
5145 }
5146 }
5147 }
5148
5149 _sqlUpdate.update(new Object[] { new Long(entryId) });
5150
5151 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
5152 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
5153 for (ModelListener<AssetEntry> listener : listeners) {
5154 listener.onAfterRemoveAssociation(entryId,
5155 com.liferay.portlet.asset.model.AssetTag.class.getName(),
5156 assetTag.getPrimaryKey());
5157 }
5158
5159 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
5160 listener.onAfterRemoveAssociation(assetTag.getPrimaryKey(),
5161 AssetEntry.class.getName(), entryId);
5162 }
5163 }
5164 }
5165 }
5166
5167 private SqlUpdate _sqlUpdate;
5168 }
5169
5170 protected class RemoveAssetTag {
5171 protected RemoveAssetTag() {
5172 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5173 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?",
5174 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5175 }
5176
5177 protected void remove(long entryId, long tagId)
5178 throws SystemException {
5179 if (containsAssetTag.contains(entryId, tagId)) {
5180 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
5181 assetTagPersistence.getListeners();
5182
5183 for (ModelListener<AssetEntry> listener : listeners) {
5184 listener.onBeforeRemoveAssociation(entryId,
5185 com.liferay.portlet.asset.model.AssetTag.class.getName(),
5186 tagId);
5187 }
5188
5189 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
5190 listener.onBeforeRemoveAssociation(tagId,
5191 AssetEntry.class.getName(), entryId);
5192 }
5193
5194 _sqlUpdate.update(new Object[] {
5195 new Long(entryId), new Long(tagId)
5196 });
5197
5198 for (ModelListener<AssetEntry> listener : listeners) {
5199 listener.onAfterRemoveAssociation(entryId,
5200 com.liferay.portlet.asset.model.AssetTag.class.getName(),
5201 tagId);
5202 }
5203
5204 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
5205 listener.onAfterRemoveAssociation(tagId,
5206 AssetEntry.class.getName(), entryId);
5207 }
5208 }
5209 }
5210
5211 private SqlUpdate _sqlUpdate;
5212 }
5213
5214 private static final String _SQL_SELECT_ASSETENTRY = "SELECT assetEntry FROM AssetEntry assetEntry";
5215 private static final String _SQL_SELECT_ASSETENTRY_WHERE = "SELECT assetEntry FROM AssetEntry assetEntry WHERE ";
5216 private static final String _SQL_COUNT_ASSETENTRY = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry";
5217 private static final String _SQL_COUNT_ASSETENTRY_WHERE = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry WHERE ";
5218 private static final String _SQL_GETASSETCATEGORIES = "SELECT {AssetCategory.*} FROM AssetCategory INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.categoryId = AssetCategory.categoryId) WHERE (AssetEntries_AssetCategories.entryId = ?)";
5219 private static final String _SQL_GETASSETCATEGORIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ?";
5220 private static final String _SQL_CONTAINSASSETCATEGORY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?";
5221 private static final String _SQL_GETASSETTAGS = "SELECT {AssetTag.*} FROM AssetTag INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.tagId = AssetTag.tagId) WHERE (AssetEntries_AssetTags.entryId = ?)";
5222 private static final String _SQL_GETASSETTAGSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ?";
5223 private static final String _SQL_CONTAINSASSETTAG = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?";
5224 private static final String _ORDER_BY_ENTITY_ALIAS = "assetEntry.";
5225 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetEntry exists with the primary key ";
5226 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetEntry exists with the key {";
5227 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5228 private static Log _log = LogFactoryUtil.getLog(AssetEntryPersistenceImpl.class);
5229 private static AssetEntry _nullAssetEntry = new AssetEntryImpl() {
5230 @Override
5231 public Object clone() {
5232 return this;
5233 }
5234
5235 @Override
5236 public CacheModel<AssetEntry> toCacheModel() {
5237 return _nullAssetEntryCacheModel;
5238 }
5239 };
5240
5241 private static CacheModel<AssetEntry> _nullAssetEntryCacheModel = new CacheModel<AssetEntry>() {
5242 public AssetEntry toEntityModel() {
5243 return _nullAssetEntry;
5244 }
5245 };
5246 }