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