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.GetterUtil;
036 import com.liferay.portal.kernel.util.InstanceFactory;
037 import com.liferay.portal.kernel.util.OrderByComparator;
038 import com.liferay.portal.kernel.util.SetUtil;
039 import com.liferay.portal.kernel.util.StringBundler;
040 import com.liferay.portal.kernel.util.StringPool;
041 import com.liferay.portal.kernel.util.StringUtil;
042 import com.liferay.portal.kernel.util.UnmodifiableList;
043 import com.liferay.portal.kernel.util.Validator;
044 import com.liferay.portal.model.CacheModel;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
047 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048
049 import com.liferay.portlet.asset.NoSuchTagException;
050 import com.liferay.portlet.asset.model.AssetTag;
051 import com.liferay.portlet.asset.model.impl.AssetTagImpl;
052 import com.liferay.portlet.asset.model.impl.AssetTagModelImpl;
053
054 import java.io.Serializable;
055
056 import java.util.ArrayList;
057 import java.util.Collections;
058 import java.util.List;
059 import java.util.Set;
060
061
073 public class AssetTagPersistenceImpl extends BasePersistenceImpl<AssetTag>
074 implements AssetTagPersistence {
075
080 public static final String FINDER_CLASS_NAME_ENTITY = AssetTagImpl.class.getName();
081 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List1";
083 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List2";
085 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
086 AssetTagModelImpl.FINDER_CACHE_ENABLED, AssetTagImpl.class,
087 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
088 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
089 AssetTagModelImpl.FINDER_CACHE_ENABLED, AssetTagImpl.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
092 AssetTagModelImpl.FINDER_CACHE_ENABLED, Long.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
095 AssetTagModelImpl.FINDER_CACHE_ENABLED, AssetTagImpl.class,
096 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
097 new String[] {
098 Long.class.getName(),
099
100 Integer.class.getName(), Integer.class.getName(),
101 OrderByComparator.class.getName()
102 });
103 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
104 new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
105 AssetTagModelImpl.FINDER_CACHE_ENABLED, AssetTagImpl.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
107 new String[] { Long.class.getName() },
108 AssetTagModelImpl.GROUPID_COLUMN_BITMASK |
109 AssetTagModelImpl.NAME_COLUMN_BITMASK);
110 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
111 AssetTagModelImpl.FINDER_CACHE_ENABLED, Long.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
113 new String[] { Long.class.getName() });
114
115
122 public List<AssetTag> findByGroupId(long groupId) throws SystemException {
123 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
124 }
125
126
139 public List<AssetTag> findByGroupId(long groupId, int start, int end)
140 throws SystemException {
141 return findByGroupId(groupId, start, end, null);
142 }
143
144
158 public List<AssetTag> findByGroupId(long groupId, int start, int end,
159 OrderByComparator orderByComparator) throws SystemException {
160 boolean pagination = true;
161 FinderPath finderPath = null;
162 Object[] finderArgs = null;
163
164 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
165 (orderByComparator == null)) {
166 pagination = false;
167 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
168 finderArgs = new Object[] { groupId };
169 }
170 else {
171 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
172 finderArgs = new Object[] { groupId, start, end, orderByComparator };
173 }
174
175 List<AssetTag> list = (List<AssetTag>)FinderCacheUtil.getResult(finderPath,
176 finderArgs, this);
177
178 if ((list != null) && !list.isEmpty()) {
179 for (AssetTag assetTag : list) {
180 if ((groupId != assetTag.getGroupId())) {
181 list = null;
182
183 break;
184 }
185 }
186 }
187
188 if (list == null) {
189 StringBundler query = null;
190
191 if (orderByComparator != null) {
192 query = new StringBundler(3 +
193 (orderByComparator.getOrderByFields().length * 3));
194 }
195 else {
196 query = new StringBundler(3);
197 }
198
199 query.append(_SQL_SELECT_ASSETTAG_WHERE);
200
201 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
202
203 if (orderByComparator != null) {
204 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
205 orderByComparator);
206 }
207 else
208 if (pagination) {
209 query.append(AssetTagModelImpl.ORDER_BY_JPQL);
210 }
211
212 String sql = query.toString();
213
214 Session session = null;
215
216 try {
217 session = openSession();
218
219 Query q = session.createQuery(sql);
220
221 QueryPos qPos = QueryPos.getInstance(q);
222
223 qPos.add(groupId);
224
225 if (!pagination) {
226 list = (List<AssetTag>)QueryUtil.list(q, getDialect(),
227 start, end, false);
228
229 Collections.sort(list);
230
231 list = new UnmodifiableList<AssetTag>(list);
232 }
233 else {
234 list = (List<AssetTag>)QueryUtil.list(q, getDialect(),
235 start, end);
236 }
237
238 cacheResult(list);
239
240 FinderCacheUtil.putResult(finderPath, finderArgs, list);
241 }
242 catch (Exception e) {
243 FinderCacheUtil.removeResult(finderPath, finderArgs);
244
245 throw processException(e);
246 }
247 finally {
248 closeSession(session);
249 }
250 }
251
252 return list;
253 }
254
255
264 public AssetTag findByGroupId_First(long groupId,
265 OrderByComparator orderByComparator)
266 throws NoSuchTagException, SystemException {
267 AssetTag assetTag = fetchByGroupId_First(groupId, orderByComparator);
268
269 if (assetTag != null) {
270 return assetTag;
271 }
272
273 StringBundler msg = new StringBundler(4);
274
275 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
276
277 msg.append("groupId=");
278 msg.append(groupId);
279
280 msg.append(StringPool.CLOSE_CURLY_BRACE);
281
282 throw new NoSuchTagException(msg.toString());
283 }
284
285
293 public AssetTag fetchByGroupId_First(long groupId,
294 OrderByComparator orderByComparator) throws SystemException {
295 List<AssetTag> list = findByGroupId(groupId, 0, 1, orderByComparator);
296
297 if (!list.isEmpty()) {
298 return list.get(0);
299 }
300
301 return null;
302 }
303
304
313 public AssetTag findByGroupId_Last(long groupId,
314 OrderByComparator orderByComparator)
315 throws NoSuchTagException, SystemException {
316 AssetTag assetTag = fetchByGroupId_Last(groupId, orderByComparator);
317
318 if (assetTag != null) {
319 return assetTag;
320 }
321
322 StringBundler msg = new StringBundler(4);
323
324 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
325
326 msg.append("groupId=");
327 msg.append(groupId);
328
329 msg.append(StringPool.CLOSE_CURLY_BRACE);
330
331 throw new NoSuchTagException(msg.toString());
332 }
333
334
342 public AssetTag fetchByGroupId_Last(long groupId,
343 OrderByComparator orderByComparator) throws SystemException {
344 int count = countByGroupId(groupId);
345
346 List<AssetTag> list = findByGroupId(groupId, count - 1, count,
347 orderByComparator);
348
349 if (!list.isEmpty()) {
350 return list.get(0);
351 }
352
353 return null;
354 }
355
356
366 public AssetTag[] findByGroupId_PrevAndNext(long tagId, long groupId,
367 OrderByComparator orderByComparator)
368 throws NoSuchTagException, SystemException {
369 AssetTag assetTag = findByPrimaryKey(tagId);
370
371 Session session = null;
372
373 try {
374 session = openSession();
375
376 AssetTag[] array = new AssetTagImpl[3];
377
378 array[0] = getByGroupId_PrevAndNext(session, assetTag, groupId,
379 orderByComparator, true);
380
381 array[1] = assetTag;
382
383 array[2] = getByGroupId_PrevAndNext(session, assetTag, groupId,
384 orderByComparator, false);
385
386 return array;
387 }
388 catch (Exception e) {
389 throw processException(e);
390 }
391 finally {
392 closeSession(session);
393 }
394 }
395
396 protected AssetTag getByGroupId_PrevAndNext(Session session,
397 AssetTag assetTag, long groupId, OrderByComparator orderByComparator,
398 boolean previous) {
399 StringBundler query = null;
400
401 if (orderByComparator != null) {
402 query = new StringBundler(6 +
403 (orderByComparator.getOrderByFields().length * 6));
404 }
405 else {
406 query = new StringBundler(3);
407 }
408
409 query.append(_SQL_SELECT_ASSETTAG_WHERE);
410
411 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
412
413 if (orderByComparator != null) {
414 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
415
416 if (orderByConditionFields.length > 0) {
417 query.append(WHERE_AND);
418 }
419
420 for (int i = 0; i < orderByConditionFields.length; i++) {
421 query.append(_ORDER_BY_ENTITY_ALIAS);
422 query.append(orderByConditionFields[i]);
423
424 if ((i + 1) < orderByConditionFields.length) {
425 if (orderByComparator.isAscending() ^ previous) {
426 query.append(WHERE_GREATER_THAN_HAS_NEXT);
427 }
428 else {
429 query.append(WHERE_LESSER_THAN_HAS_NEXT);
430 }
431 }
432 else {
433 if (orderByComparator.isAscending() ^ previous) {
434 query.append(WHERE_GREATER_THAN);
435 }
436 else {
437 query.append(WHERE_LESSER_THAN);
438 }
439 }
440 }
441
442 query.append(ORDER_BY_CLAUSE);
443
444 String[] orderByFields = orderByComparator.getOrderByFields();
445
446 for (int i = 0; i < orderByFields.length; i++) {
447 query.append(_ORDER_BY_ENTITY_ALIAS);
448 query.append(orderByFields[i]);
449
450 if ((i + 1) < orderByFields.length) {
451 if (orderByComparator.isAscending() ^ previous) {
452 query.append(ORDER_BY_ASC_HAS_NEXT);
453 }
454 else {
455 query.append(ORDER_BY_DESC_HAS_NEXT);
456 }
457 }
458 else {
459 if (orderByComparator.isAscending() ^ previous) {
460 query.append(ORDER_BY_ASC);
461 }
462 else {
463 query.append(ORDER_BY_DESC);
464 }
465 }
466 }
467 }
468 else {
469 query.append(AssetTagModelImpl.ORDER_BY_JPQL);
470 }
471
472 String sql = query.toString();
473
474 Query q = session.createQuery(sql);
475
476 q.setFirstResult(0);
477 q.setMaxResults(2);
478
479 QueryPos qPos = QueryPos.getInstance(q);
480
481 qPos.add(groupId);
482
483 if (orderByComparator != null) {
484 Object[] values = orderByComparator.getOrderByConditionValues(assetTag);
485
486 for (Object value : values) {
487 qPos.add(value);
488 }
489 }
490
491 List<AssetTag> list = q.list();
492
493 if (list.size() == 2) {
494 return list.get(1);
495 }
496 else {
497 return null;
498 }
499 }
500
501
508 public List<AssetTag> filterFindByGroupId(long groupId)
509 throws SystemException {
510 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
511 QueryUtil.ALL_POS, null);
512 }
513
514
527 public List<AssetTag> filterFindByGroupId(long groupId, int start, int end)
528 throws SystemException {
529 return filterFindByGroupId(groupId, start, end, null);
530 }
531
532
546 public List<AssetTag> filterFindByGroupId(long groupId, int start, int end,
547 OrderByComparator orderByComparator) throws SystemException {
548 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
549 return findByGroupId(groupId, start, end, orderByComparator);
550 }
551
552 StringBundler query = null;
553
554 if (orderByComparator != null) {
555 query = new StringBundler(3 +
556 (orderByComparator.getOrderByFields().length * 3));
557 }
558 else {
559 query = new StringBundler(3);
560 }
561
562 if (getDB().isSupportsInlineDistinct()) {
563 query.append(_FILTER_SQL_SELECT_ASSETTAG_WHERE);
564 }
565 else {
566 query.append(_FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_1);
567 }
568
569 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
570
571 if (!getDB().isSupportsInlineDistinct()) {
572 query.append(_FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_2);
573 }
574
575 if (orderByComparator != null) {
576 if (getDB().isSupportsInlineDistinct()) {
577 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
578 orderByComparator, true);
579 }
580 else {
581 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
582 orderByComparator, true);
583 }
584 }
585 else {
586 if (getDB().isSupportsInlineDistinct()) {
587 query.append(AssetTagModelImpl.ORDER_BY_JPQL);
588 }
589 else {
590 query.append(AssetTagModelImpl.ORDER_BY_SQL);
591 }
592 }
593
594 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
595 AssetTag.class.getName(),
596 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
597
598 Session session = null;
599
600 try {
601 session = openSession();
602
603 SQLQuery q = session.createSQLQuery(sql);
604
605 if (getDB().isSupportsInlineDistinct()) {
606 q.addEntity(_FILTER_ENTITY_ALIAS, AssetTagImpl.class);
607 }
608 else {
609 q.addEntity(_FILTER_ENTITY_TABLE, AssetTagImpl.class);
610 }
611
612 QueryPos qPos = QueryPos.getInstance(q);
613
614 qPos.add(groupId);
615
616 return (List<AssetTag>)QueryUtil.list(q, getDialect(), start, end);
617 }
618 catch (Exception e) {
619 throw processException(e);
620 }
621 finally {
622 closeSession(session);
623 }
624 }
625
626
636 public AssetTag[] filterFindByGroupId_PrevAndNext(long tagId, long groupId,
637 OrderByComparator orderByComparator)
638 throws NoSuchTagException, SystemException {
639 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
640 return findByGroupId_PrevAndNext(tagId, groupId, orderByComparator);
641 }
642
643 AssetTag assetTag = findByPrimaryKey(tagId);
644
645 Session session = null;
646
647 try {
648 session = openSession();
649
650 AssetTag[] array = new AssetTagImpl[3];
651
652 array[0] = filterGetByGroupId_PrevAndNext(session, assetTag,
653 groupId, orderByComparator, true);
654
655 array[1] = assetTag;
656
657 array[2] = filterGetByGroupId_PrevAndNext(session, assetTag,
658 groupId, orderByComparator, false);
659
660 return array;
661 }
662 catch (Exception e) {
663 throw processException(e);
664 }
665 finally {
666 closeSession(session);
667 }
668 }
669
670 protected AssetTag filterGetByGroupId_PrevAndNext(Session session,
671 AssetTag assetTag, long groupId, OrderByComparator orderByComparator,
672 boolean previous) {
673 StringBundler query = null;
674
675 if (orderByComparator != null) {
676 query = new StringBundler(6 +
677 (orderByComparator.getOrderByFields().length * 6));
678 }
679 else {
680 query = new StringBundler(3);
681 }
682
683 if (getDB().isSupportsInlineDistinct()) {
684 query.append(_FILTER_SQL_SELECT_ASSETTAG_WHERE);
685 }
686 else {
687 query.append(_FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_1);
688 }
689
690 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
691
692 if (!getDB().isSupportsInlineDistinct()) {
693 query.append(_FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_2);
694 }
695
696 if (orderByComparator != null) {
697 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
698
699 if (orderByConditionFields.length > 0) {
700 query.append(WHERE_AND);
701 }
702
703 for (int i = 0; i < orderByConditionFields.length; i++) {
704 if (getDB().isSupportsInlineDistinct()) {
705 query.append(_ORDER_BY_ENTITY_ALIAS);
706 }
707 else {
708 query.append(_ORDER_BY_ENTITY_TABLE);
709 }
710
711 query.append(orderByConditionFields[i]);
712
713 if ((i + 1) < orderByConditionFields.length) {
714 if (orderByComparator.isAscending() ^ previous) {
715 query.append(WHERE_GREATER_THAN_HAS_NEXT);
716 }
717 else {
718 query.append(WHERE_LESSER_THAN_HAS_NEXT);
719 }
720 }
721 else {
722 if (orderByComparator.isAscending() ^ previous) {
723 query.append(WHERE_GREATER_THAN);
724 }
725 else {
726 query.append(WHERE_LESSER_THAN);
727 }
728 }
729 }
730
731 query.append(ORDER_BY_CLAUSE);
732
733 String[] orderByFields = orderByComparator.getOrderByFields();
734
735 for (int i = 0; i < orderByFields.length; i++) {
736 if (getDB().isSupportsInlineDistinct()) {
737 query.append(_ORDER_BY_ENTITY_ALIAS);
738 }
739 else {
740 query.append(_ORDER_BY_ENTITY_TABLE);
741 }
742
743 query.append(orderByFields[i]);
744
745 if ((i + 1) < orderByFields.length) {
746 if (orderByComparator.isAscending() ^ previous) {
747 query.append(ORDER_BY_ASC_HAS_NEXT);
748 }
749 else {
750 query.append(ORDER_BY_DESC_HAS_NEXT);
751 }
752 }
753 else {
754 if (orderByComparator.isAscending() ^ previous) {
755 query.append(ORDER_BY_ASC);
756 }
757 else {
758 query.append(ORDER_BY_DESC);
759 }
760 }
761 }
762 }
763 else {
764 if (getDB().isSupportsInlineDistinct()) {
765 query.append(AssetTagModelImpl.ORDER_BY_JPQL);
766 }
767 else {
768 query.append(AssetTagModelImpl.ORDER_BY_SQL);
769 }
770 }
771
772 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
773 AssetTag.class.getName(),
774 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
775
776 SQLQuery q = session.createSQLQuery(sql);
777
778 q.setFirstResult(0);
779 q.setMaxResults(2);
780
781 if (getDB().isSupportsInlineDistinct()) {
782 q.addEntity(_FILTER_ENTITY_ALIAS, AssetTagImpl.class);
783 }
784 else {
785 q.addEntity(_FILTER_ENTITY_TABLE, AssetTagImpl.class);
786 }
787
788 QueryPos qPos = QueryPos.getInstance(q);
789
790 qPos.add(groupId);
791
792 if (orderByComparator != null) {
793 Object[] values = orderByComparator.getOrderByConditionValues(assetTag);
794
795 for (Object value : values) {
796 qPos.add(value);
797 }
798 }
799
800 List<AssetTag> list = q.list();
801
802 if (list.size() == 2) {
803 return list.get(1);
804 }
805 else {
806 return null;
807 }
808 }
809
810
816 public void removeByGroupId(long groupId) throws SystemException {
817 for (AssetTag assetTag : findByGroupId(groupId, QueryUtil.ALL_POS,
818 QueryUtil.ALL_POS, null)) {
819 remove(assetTag);
820 }
821 }
822
823
830 public int countByGroupId(long groupId) throws SystemException {
831 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
832
833 Object[] finderArgs = new Object[] { groupId };
834
835 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
836 this);
837
838 if (count == null) {
839 StringBundler query = new StringBundler(2);
840
841 query.append(_SQL_COUNT_ASSETTAG_WHERE);
842
843 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
844
845 String sql = query.toString();
846
847 Session session = null;
848
849 try {
850 session = openSession();
851
852 Query q = session.createQuery(sql);
853
854 QueryPos qPos = QueryPos.getInstance(q);
855
856 qPos.add(groupId);
857
858 count = (Long)q.uniqueResult();
859
860 FinderCacheUtil.putResult(finderPath, finderArgs, count);
861 }
862 catch (Exception e) {
863 FinderCacheUtil.removeResult(finderPath, finderArgs);
864
865 throw processException(e);
866 }
867 finally {
868 closeSession(session);
869 }
870 }
871
872 return count.intValue();
873 }
874
875
882 public int filterCountByGroupId(long groupId) throws SystemException {
883 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
884 return countByGroupId(groupId);
885 }
886
887 StringBundler query = new StringBundler(2);
888
889 query.append(_FILTER_SQL_COUNT_ASSETTAG_WHERE);
890
891 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
892
893 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
894 AssetTag.class.getName(),
895 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
896
897 Session session = null;
898
899 try {
900 session = openSession();
901
902 SQLQuery q = session.createSQLQuery(sql);
903
904 q.addScalar(COUNT_COLUMN_NAME,
905 com.liferay.portal.kernel.dao.orm.Type.LONG);
906
907 QueryPos qPos = QueryPos.getInstance(q);
908
909 qPos.add(groupId);
910
911 Long count = (Long)q.uniqueResult();
912
913 return count.intValue();
914 }
915 catch (Exception e) {
916 throw processException(e);
917 }
918 finally {
919 closeSession(session);
920 }
921 }
922
923 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetTag.groupId = ?";
924 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
925 AssetTagModelImpl.FINDER_CACHE_ENABLED, AssetTagImpl.class,
926 FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
927 new String[] { Long.class.getName(), String.class.getName() },
928 AssetTagModelImpl.GROUPID_COLUMN_BITMASK |
929 AssetTagModelImpl.NAME_COLUMN_BITMASK);
930 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
931 AssetTagModelImpl.FINDER_CACHE_ENABLED, Long.class,
932 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
933 new String[] { Long.class.getName(), String.class.getName() });
934
935
944 public AssetTag findByG_N(long groupId, String name)
945 throws NoSuchTagException, SystemException {
946 AssetTag assetTag = fetchByG_N(groupId, name);
947
948 if (assetTag == null) {
949 StringBundler msg = new StringBundler(6);
950
951 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
952
953 msg.append("groupId=");
954 msg.append(groupId);
955
956 msg.append(", name=");
957 msg.append(name);
958
959 msg.append(StringPool.CLOSE_CURLY_BRACE);
960
961 if (_log.isWarnEnabled()) {
962 _log.warn(msg.toString());
963 }
964
965 throw new NoSuchTagException(msg.toString());
966 }
967
968 return assetTag;
969 }
970
971
979 public AssetTag fetchByG_N(long groupId, String name)
980 throws SystemException {
981 return fetchByG_N(groupId, name, true);
982 }
983
984
993 public AssetTag fetchByG_N(long groupId, String name,
994 boolean retrieveFromCache) throws SystemException {
995 Object[] finderArgs = new Object[] { groupId, name };
996
997 Object result = null;
998
999 if (retrieveFromCache) {
1000 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
1001 finderArgs, this);
1002 }
1003
1004 if (result instanceof AssetTag) {
1005 AssetTag assetTag = (AssetTag)result;
1006
1007 if ((groupId != assetTag.getGroupId()) ||
1008 !Validator.equals(name, assetTag.getName())) {
1009 result = null;
1010 }
1011 }
1012
1013 if (result == null) {
1014 StringBundler query = new StringBundler(4);
1015
1016 query.append(_SQL_SELECT_ASSETTAG_WHERE);
1017
1018 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1019
1020 boolean bindName = false;
1021
1022 if (name == null) {
1023 query.append(_FINDER_COLUMN_G_N_NAME_1);
1024 }
1025 else if (name.equals(StringPool.BLANK)) {
1026 query.append(_FINDER_COLUMN_G_N_NAME_3);
1027 }
1028 else {
1029 bindName = true;
1030
1031 query.append(_FINDER_COLUMN_G_N_NAME_2);
1032 }
1033
1034 String sql = query.toString();
1035
1036 Session session = null;
1037
1038 try {
1039 session = openSession();
1040
1041 Query q = session.createQuery(sql);
1042
1043 QueryPos qPos = QueryPos.getInstance(q);
1044
1045 qPos.add(groupId);
1046
1047 if (bindName) {
1048 qPos.add(name);
1049 }
1050
1051 List<AssetTag> list = q.list();
1052
1053 if (list.isEmpty()) {
1054 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1055 finderArgs, list);
1056 }
1057 else {
1058 if ((list.size() > 1) && _log.isWarnEnabled()) {
1059 _log.warn(
1060 "AssetTagPersistenceImpl.fetchByG_N(long, String, boolean) with parameters (" +
1061 StringUtil.merge(finderArgs) +
1062 ") 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.");
1063 }
1064
1065 AssetTag assetTag = list.get(0);
1066
1067 result = assetTag;
1068
1069 cacheResult(assetTag);
1070
1071 if ((assetTag.getGroupId() != groupId) ||
1072 (assetTag.getName() == null) ||
1073 !assetTag.getName().equals(name)) {
1074 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1075 finderArgs, assetTag);
1076 }
1077 }
1078 }
1079 catch (Exception e) {
1080 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
1081 finderArgs);
1082
1083 throw processException(e);
1084 }
1085 finally {
1086 closeSession(session);
1087 }
1088 }
1089
1090 if (result instanceof List<?>) {
1091 return null;
1092 }
1093 else {
1094 return (AssetTag)result;
1095 }
1096 }
1097
1098
1106 public AssetTag removeByG_N(long groupId, String name)
1107 throws NoSuchTagException, SystemException {
1108 AssetTag assetTag = findByG_N(groupId, name);
1109
1110 return remove(assetTag);
1111 }
1112
1113
1121 public int countByG_N(long groupId, String name) throws SystemException {
1122 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N;
1123
1124 Object[] finderArgs = new Object[] { groupId, name };
1125
1126 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1127 this);
1128
1129 if (count == null) {
1130 StringBundler query = new StringBundler(3);
1131
1132 query.append(_SQL_COUNT_ASSETTAG_WHERE);
1133
1134 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1135
1136 boolean bindName = false;
1137
1138 if (name == null) {
1139 query.append(_FINDER_COLUMN_G_N_NAME_1);
1140 }
1141 else if (name.equals(StringPool.BLANK)) {
1142 query.append(_FINDER_COLUMN_G_N_NAME_3);
1143 }
1144 else {
1145 bindName = true;
1146
1147 query.append(_FINDER_COLUMN_G_N_NAME_2);
1148 }
1149
1150 String sql = query.toString();
1151
1152 Session session = null;
1153
1154 try {
1155 session = openSession();
1156
1157 Query q = session.createQuery(sql);
1158
1159 QueryPos qPos = QueryPos.getInstance(q);
1160
1161 qPos.add(groupId);
1162
1163 if (bindName) {
1164 qPos.add(name);
1165 }
1166
1167 count = (Long)q.uniqueResult();
1168
1169 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1170 }
1171 catch (Exception e) {
1172 FinderCacheUtil.removeResult(finderPath, finderArgs);
1173
1174 throw processException(e);
1175 }
1176 finally {
1177 closeSession(session);
1178 }
1179 }
1180
1181 return count.intValue();
1182 }
1183
1184 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetTag.groupId = ? AND ";
1185 private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetTag.name IS NULL";
1186 private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetTag.name = ?";
1187 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetTag.name IS NULL OR assetTag.name = '')";
1188
1189
1194 public void cacheResult(AssetTag assetTag) {
1195 EntityCacheUtil.putResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1196 AssetTagImpl.class, assetTag.getPrimaryKey(), assetTag);
1197
1198 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1199 new Object[] { assetTag.getGroupId(), assetTag.getName() }, assetTag);
1200
1201 assetTag.resetOriginalValues();
1202 }
1203
1204
1209 public void cacheResult(List<AssetTag> assetTags) {
1210 for (AssetTag assetTag : assetTags) {
1211 if (EntityCacheUtil.getResult(
1212 AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1213 AssetTagImpl.class, assetTag.getPrimaryKey()) == null) {
1214 cacheResult(assetTag);
1215 }
1216 else {
1217 assetTag.resetOriginalValues();
1218 }
1219 }
1220 }
1221
1222
1229 @Override
1230 public void clearCache() {
1231 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1232 CacheRegistryUtil.clear(AssetTagImpl.class.getName());
1233 }
1234
1235 EntityCacheUtil.clearCache(AssetTagImpl.class.getName());
1236
1237 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1238 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1239 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1240 }
1241
1242
1249 @Override
1250 public void clearCache(AssetTag assetTag) {
1251 EntityCacheUtil.removeResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1252 AssetTagImpl.class, assetTag.getPrimaryKey());
1253
1254 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1255 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1256
1257 clearUniqueFindersCache(assetTag);
1258 }
1259
1260 @Override
1261 public void clearCache(List<AssetTag> assetTags) {
1262 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1263 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1264
1265 for (AssetTag assetTag : assetTags) {
1266 EntityCacheUtil.removeResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1267 AssetTagImpl.class, assetTag.getPrimaryKey());
1268
1269 clearUniqueFindersCache(assetTag);
1270 }
1271 }
1272
1273 protected void cacheUniqueFindersCache(AssetTag assetTag) {
1274 if (assetTag.isNew()) {
1275 Object[] args = new Object[] {
1276 assetTag.getGroupId(), assetTag.getName()
1277 };
1278
1279 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
1280 Long.valueOf(1));
1281 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args, assetTag);
1282 }
1283 else {
1284 AssetTagModelImpl assetTagModelImpl = (AssetTagModelImpl)assetTag;
1285
1286 if ((assetTagModelImpl.getColumnBitmask() &
1287 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
1288 Object[] args = new Object[] {
1289 assetTag.getGroupId(), assetTag.getName()
1290 };
1291
1292 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
1293 Long.valueOf(1));
1294 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
1295 assetTag);
1296 }
1297 }
1298 }
1299
1300 protected void clearUniqueFindersCache(AssetTag assetTag) {
1301 AssetTagModelImpl assetTagModelImpl = (AssetTagModelImpl)assetTag;
1302
1303 Object[] args = new Object[] { assetTag.getGroupId(), assetTag.getName() };
1304
1305 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
1306 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
1307
1308 if ((assetTagModelImpl.getColumnBitmask() &
1309 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
1310 args = new Object[] {
1311 assetTagModelImpl.getOriginalGroupId(),
1312 assetTagModelImpl.getOriginalName()
1313 };
1314
1315 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
1316 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
1317 }
1318 }
1319
1320
1326 public AssetTag create(long tagId) {
1327 AssetTag assetTag = new AssetTagImpl();
1328
1329 assetTag.setNew(true);
1330 assetTag.setPrimaryKey(tagId);
1331
1332 return assetTag;
1333 }
1334
1335
1343 public AssetTag remove(long tagId)
1344 throws NoSuchTagException, SystemException {
1345 return remove((Serializable)tagId);
1346 }
1347
1348
1356 @Override
1357 public AssetTag remove(Serializable primaryKey)
1358 throws NoSuchTagException, SystemException {
1359 Session session = null;
1360
1361 try {
1362 session = openSession();
1363
1364 AssetTag assetTag = (AssetTag)session.get(AssetTagImpl.class,
1365 primaryKey);
1366
1367 if (assetTag == null) {
1368 if (_log.isWarnEnabled()) {
1369 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1370 }
1371
1372 throw new NoSuchTagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1373 primaryKey);
1374 }
1375
1376 return remove(assetTag);
1377 }
1378 catch (NoSuchTagException nsee) {
1379 throw nsee;
1380 }
1381 catch (Exception e) {
1382 throw processException(e);
1383 }
1384 finally {
1385 closeSession(session);
1386 }
1387 }
1388
1389 @Override
1390 protected AssetTag removeImpl(AssetTag assetTag) throws SystemException {
1391 assetTag = toUnwrappedModel(assetTag);
1392
1393 try {
1394 clearAssetEntries.clear(assetTag.getPrimaryKey());
1395 }
1396 catch (Exception e) {
1397 throw processException(e);
1398 }
1399 finally {
1400 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1401 }
1402
1403 Session session = null;
1404
1405 try {
1406 session = openSession();
1407
1408 if (!session.contains(assetTag)) {
1409 assetTag = (AssetTag)session.get(AssetTagImpl.class,
1410 assetTag.getPrimaryKeyObj());
1411 }
1412
1413 if (assetTag != null) {
1414 session.delete(assetTag);
1415 }
1416 }
1417 catch (Exception e) {
1418 throw processException(e);
1419 }
1420 finally {
1421 closeSession(session);
1422 }
1423
1424 if (assetTag != null) {
1425 clearCache(assetTag);
1426 }
1427
1428 return assetTag;
1429 }
1430
1431 @Override
1432 public AssetTag updateImpl(
1433 com.liferay.portlet.asset.model.AssetTag assetTag)
1434 throws SystemException {
1435 assetTag = toUnwrappedModel(assetTag);
1436
1437 boolean isNew = assetTag.isNew();
1438
1439 AssetTagModelImpl assetTagModelImpl = (AssetTagModelImpl)assetTag;
1440
1441 Session session = null;
1442
1443 try {
1444 session = openSession();
1445
1446 if (assetTag.isNew()) {
1447 session.save(assetTag);
1448
1449 assetTag.setNew(false);
1450 }
1451 else {
1452 session.merge(assetTag);
1453 }
1454 }
1455 catch (Exception e) {
1456 throw processException(e);
1457 }
1458 finally {
1459 closeSession(session);
1460 }
1461
1462 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1463
1464 if (isNew || !AssetTagModelImpl.COLUMN_BITMASK_ENABLED) {
1465 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1466 }
1467
1468 else {
1469 if ((assetTagModelImpl.getColumnBitmask() &
1470 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
1471 Object[] args = new Object[] {
1472 assetTagModelImpl.getOriginalGroupId()
1473 };
1474
1475 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
1476 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
1477 args);
1478
1479 args = new Object[] { assetTagModelImpl.getGroupId() };
1480
1481 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
1482 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
1483 args);
1484 }
1485 }
1486
1487 EntityCacheUtil.putResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1488 AssetTagImpl.class, assetTag.getPrimaryKey(), assetTag);
1489
1490 clearUniqueFindersCache(assetTag);
1491 cacheUniqueFindersCache(assetTag);
1492
1493 return assetTag;
1494 }
1495
1496 protected AssetTag toUnwrappedModel(AssetTag assetTag) {
1497 if (assetTag instanceof AssetTagImpl) {
1498 return assetTag;
1499 }
1500
1501 AssetTagImpl assetTagImpl = new AssetTagImpl();
1502
1503 assetTagImpl.setNew(assetTag.isNew());
1504 assetTagImpl.setPrimaryKey(assetTag.getPrimaryKey());
1505
1506 assetTagImpl.setTagId(assetTag.getTagId());
1507 assetTagImpl.setGroupId(assetTag.getGroupId());
1508 assetTagImpl.setCompanyId(assetTag.getCompanyId());
1509 assetTagImpl.setUserId(assetTag.getUserId());
1510 assetTagImpl.setUserName(assetTag.getUserName());
1511 assetTagImpl.setCreateDate(assetTag.getCreateDate());
1512 assetTagImpl.setModifiedDate(assetTag.getModifiedDate());
1513 assetTagImpl.setName(assetTag.getName());
1514 assetTagImpl.setAssetCount(assetTag.getAssetCount());
1515
1516 return assetTagImpl;
1517 }
1518
1519
1527 @Override
1528 public AssetTag findByPrimaryKey(Serializable primaryKey)
1529 throws NoSuchTagException, SystemException {
1530 AssetTag assetTag = fetchByPrimaryKey(primaryKey);
1531
1532 if (assetTag == null) {
1533 if (_log.isWarnEnabled()) {
1534 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1535 }
1536
1537 throw new NoSuchTagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1538 primaryKey);
1539 }
1540
1541 return assetTag;
1542 }
1543
1544
1552 public AssetTag findByPrimaryKey(long tagId)
1553 throws NoSuchTagException, SystemException {
1554 return findByPrimaryKey((Serializable)tagId);
1555 }
1556
1557
1564 @Override
1565 public AssetTag fetchByPrimaryKey(Serializable primaryKey)
1566 throws SystemException {
1567 AssetTag assetTag = (AssetTag)EntityCacheUtil.getResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1568 AssetTagImpl.class, primaryKey);
1569
1570 if (assetTag == _nullAssetTag) {
1571 return null;
1572 }
1573
1574 if (assetTag == null) {
1575 Session session = null;
1576
1577 try {
1578 session = openSession();
1579
1580 assetTag = (AssetTag)session.get(AssetTagImpl.class, primaryKey);
1581
1582 if (assetTag != null) {
1583 cacheResult(assetTag);
1584 }
1585 else {
1586 EntityCacheUtil.putResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1587 AssetTagImpl.class, primaryKey, _nullAssetTag);
1588 }
1589 }
1590 catch (Exception e) {
1591 EntityCacheUtil.removeResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1592 AssetTagImpl.class, primaryKey);
1593
1594 throw processException(e);
1595 }
1596 finally {
1597 closeSession(session);
1598 }
1599 }
1600
1601 return assetTag;
1602 }
1603
1604
1611 public AssetTag fetchByPrimaryKey(long tagId) throws SystemException {
1612 return fetchByPrimaryKey((Serializable)tagId);
1613 }
1614
1615
1621 public List<AssetTag> findAll() throws SystemException {
1622 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1623 }
1624
1625
1637 public List<AssetTag> findAll(int start, int end) throws SystemException {
1638 return findAll(start, end, null);
1639 }
1640
1641
1654 public List<AssetTag> findAll(int start, int end,
1655 OrderByComparator orderByComparator) throws SystemException {
1656 boolean pagination = true;
1657 FinderPath finderPath = null;
1658 Object[] finderArgs = null;
1659
1660 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1661 (orderByComparator == null)) {
1662 pagination = false;
1663 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1664 finderArgs = FINDER_ARGS_EMPTY;
1665 }
1666 else {
1667 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1668 finderArgs = new Object[] { start, end, orderByComparator };
1669 }
1670
1671 List<AssetTag> list = (List<AssetTag>)FinderCacheUtil.getResult(finderPath,
1672 finderArgs, this);
1673
1674 if (list == null) {
1675 StringBundler query = null;
1676 String sql = null;
1677
1678 if (orderByComparator != null) {
1679 query = new StringBundler(2 +
1680 (orderByComparator.getOrderByFields().length * 3));
1681
1682 query.append(_SQL_SELECT_ASSETTAG);
1683
1684 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1685 orderByComparator);
1686
1687 sql = query.toString();
1688 }
1689 else {
1690 sql = _SQL_SELECT_ASSETTAG;
1691
1692 if (pagination) {
1693 sql = sql.concat(AssetTagModelImpl.ORDER_BY_JPQL);
1694 }
1695 }
1696
1697 Session session = null;
1698
1699 try {
1700 session = openSession();
1701
1702 Query q = session.createQuery(sql);
1703
1704 if (!pagination) {
1705 list = (List<AssetTag>)QueryUtil.list(q, getDialect(),
1706 start, end, false);
1707
1708 Collections.sort(list);
1709
1710 list = new UnmodifiableList<AssetTag>(list);
1711 }
1712 else {
1713 list = (List<AssetTag>)QueryUtil.list(q, getDialect(),
1714 start, end);
1715 }
1716
1717 cacheResult(list);
1718
1719 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1720 }
1721 catch (Exception e) {
1722 FinderCacheUtil.removeResult(finderPath, finderArgs);
1723
1724 throw processException(e);
1725 }
1726 finally {
1727 closeSession(session);
1728 }
1729 }
1730
1731 return list;
1732 }
1733
1734
1739 public void removeAll() throws SystemException {
1740 for (AssetTag assetTag : findAll()) {
1741 remove(assetTag);
1742 }
1743 }
1744
1745
1751 public int countAll() throws SystemException {
1752 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1753 FINDER_ARGS_EMPTY, this);
1754
1755 if (count == null) {
1756 Session session = null;
1757
1758 try {
1759 session = openSession();
1760
1761 Query q = session.createQuery(_SQL_COUNT_ASSETTAG);
1762
1763 count = (Long)q.uniqueResult();
1764
1765 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1766 FINDER_ARGS_EMPTY, count);
1767 }
1768 catch (Exception e) {
1769 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1770 FINDER_ARGS_EMPTY);
1771
1772 throw processException(e);
1773 }
1774 finally {
1775 closeSession(session);
1776 }
1777 }
1778
1779 return count.intValue();
1780 }
1781
1782
1789 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
1790 long pk) throws SystemException {
1791 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1792 }
1793
1794
1807 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
1808 long pk, int start, int end) throws SystemException {
1809 return getAssetEntries(pk, start, end, null);
1810 }
1811
1812 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1813 AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1814 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class,
1815 AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1816 "getAssetEntries",
1817 new String[] {
1818 Long.class.getName(), Integer.class.getName(),
1819 Integer.class.getName(), OrderByComparator.class.getName()
1820 });
1821
1822 static {
1823 FINDER_PATH_GET_ASSETENTRIES.setCacheKeyGeneratorCacheName(null);
1824 }
1825
1826
1840 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
1841 long pk, int start, int end, OrderByComparator orderByComparator)
1842 throws SystemException {
1843 boolean pagination = true;
1844 Object[] finderArgs = null;
1845
1846 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1847 (orderByComparator == null)) {
1848 pagination = false;
1849 finderArgs = new Object[] { pk };
1850 }
1851 else {
1852 finderArgs = new Object[] { pk, start, end, orderByComparator };
1853 }
1854
1855 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
1856 finderArgs, this);
1857
1858 if (list == null) {
1859 Session session = null;
1860
1861 try {
1862 session = openSession();
1863
1864 String sql = null;
1865
1866 if (orderByComparator != null) {
1867 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
1868 .concat(orderByComparator.getOrderBy());
1869 }
1870 else {
1871 sql = _SQL_GETASSETENTRIES;
1872
1873 if (pagination) {
1874 sql = sql.concat(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ORDER_BY_SQL);
1875 }
1876 }
1877
1878 SQLQuery q = session.createSQLQuery(sql);
1879
1880 q.addEntity("AssetEntry",
1881 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
1882
1883 QueryPos qPos = QueryPos.getInstance(q);
1884
1885 qPos.add(pk);
1886
1887 if (!pagination) {
1888 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
1889 getDialect(), start, end, false);
1890
1891 Collections.sort(list);
1892
1893 list = new UnmodifiableList<com.liferay.portlet.asset.model.AssetEntry>(list);
1894 }
1895 else {
1896 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
1897 getDialect(), start, end);
1898 }
1899
1900 assetEntryPersistence.cacheResult(list);
1901
1902 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
1903 finderArgs, list);
1904 }
1905 catch (Exception e) {
1906 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
1907 finderArgs);
1908
1909 throw processException(e);
1910 }
1911 finally {
1912 closeSession(session);
1913 }
1914 }
1915
1916 return list;
1917 }
1918
1919 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1920 AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1921 Long.class,
1922 AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1923 "getAssetEntriesSize", new String[] { Long.class.getName() });
1924
1925 static {
1926 FINDER_PATH_GET_ASSETENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
1927 }
1928
1929
1936 public int getAssetEntriesSize(long pk) throws SystemException {
1937 Object[] finderArgs = new Object[] { pk };
1938
1939 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
1940 finderArgs, this);
1941
1942 if (count == null) {
1943 Session session = null;
1944
1945 try {
1946 session = openSession();
1947
1948 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
1949
1950 q.addScalar(COUNT_COLUMN_NAME,
1951 com.liferay.portal.kernel.dao.orm.Type.LONG);
1952
1953 QueryPos qPos = QueryPos.getInstance(q);
1954
1955 qPos.add(pk);
1956
1957 count = (Long)q.uniqueResult();
1958
1959 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
1960 finderArgs, count);
1961 }
1962 catch (Exception e) {
1963 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
1964 finderArgs);
1965
1966 throw processException(e);
1967 }
1968 finally {
1969 closeSession(session);
1970 }
1971 }
1972
1973 return count.intValue();
1974 }
1975
1976 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1977 AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1978 Boolean.class,
1979 AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1980 "containsAssetEntry",
1981 new String[] { Long.class.getName(), Long.class.getName() });
1982
1983
1991 public boolean containsAssetEntry(long pk, long assetEntryPK)
1992 throws SystemException {
1993 Object[] finderArgs = new Object[] { pk, assetEntryPK };
1994
1995 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
1996 finderArgs, this);
1997
1998 if (value == null) {
1999 try {
2000 value = Boolean.valueOf(containsAssetEntry.contains(pk,
2001 assetEntryPK));
2002
2003 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
2004 finderArgs, value);
2005 }
2006 catch (Exception e) {
2007 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_ASSETENTRY,
2008 finderArgs);
2009
2010 throw processException(e);
2011 }
2012 }
2013
2014 return value.booleanValue();
2015 }
2016
2017
2024 public boolean containsAssetEntries(long pk) throws SystemException {
2025 if (getAssetEntriesSize(pk) > 0) {
2026 return true;
2027 }
2028 else {
2029 return false;
2030 }
2031 }
2032
2033
2040 public void addAssetEntry(long pk, long assetEntryPK)
2041 throws SystemException {
2042 try {
2043 addAssetEntry.add(pk, assetEntryPK);
2044 }
2045 catch (Exception e) {
2046 throw processException(e);
2047 }
2048 finally {
2049 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2050 }
2051 }
2052
2053
2060 public void addAssetEntry(long pk,
2061 com.liferay.portlet.asset.model.AssetEntry assetEntry)
2062 throws SystemException {
2063 try {
2064 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
2065 }
2066 catch (Exception e) {
2067 throw processException(e);
2068 }
2069 finally {
2070 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2071 }
2072 }
2073
2074
2081 public void addAssetEntries(long pk, long[] assetEntryPKs)
2082 throws SystemException {
2083 try {
2084 for (long assetEntryPK : assetEntryPKs) {
2085 addAssetEntry.add(pk, assetEntryPK);
2086 }
2087 }
2088 catch (Exception e) {
2089 throw processException(e);
2090 }
2091 finally {
2092 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2093 }
2094 }
2095
2096
2103 public void addAssetEntries(long pk,
2104 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
2105 throws SystemException {
2106 try {
2107 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
2108 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
2109 }
2110 }
2111 catch (Exception e) {
2112 throw processException(e);
2113 }
2114 finally {
2115 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2116 }
2117 }
2118
2119
2125 public void clearAssetEntries(long pk) throws SystemException {
2126 try {
2127 clearAssetEntries.clear(pk);
2128 }
2129 catch (Exception e) {
2130 throw processException(e);
2131 }
2132 finally {
2133 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2134 }
2135 }
2136
2137
2144 public void removeAssetEntry(long pk, long assetEntryPK)
2145 throws SystemException {
2146 try {
2147 removeAssetEntry.remove(pk, assetEntryPK);
2148 }
2149 catch (Exception e) {
2150 throw processException(e);
2151 }
2152 finally {
2153 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2154 }
2155 }
2156
2157
2164 public void removeAssetEntry(long pk,
2165 com.liferay.portlet.asset.model.AssetEntry assetEntry)
2166 throws SystemException {
2167 try {
2168 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
2169 }
2170 catch (Exception e) {
2171 throw processException(e);
2172 }
2173 finally {
2174 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2175 }
2176 }
2177
2178
2185 public void removeAssetEntries(long pk, long[] assetEntryPKs)
2186 throws SystemException {
2187 try {
2188 for (long assetEntryPK : assetEntryPKs) {
2189 removeAssetEntry.remove(pk, assetEntryPK);
2190 }
2191 }
2192 catch (Exception e) {
2193 throw processException(e);
2194 }
2195 finally {
2196 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2197 }
2198 }
2199
2200
2207 public void removeAssetEntries(long pk,
2208 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
2209 throws SystemException {
2210 try {
2211 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
2212 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
2213 }
2214 }
2215 catch (Exception e) {
2216 throw processException(e);
2217 }
2218 finally {
2219 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2220 }
2221 }
2222
2223
2230 public void setAssetEntries(long pk, long[] assetEntryPKs)
2231 throws SystemException {
2232 try {
2233 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
2234
2235 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
2236
2237 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
2238 if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
2239 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
2240 }
2241 }
2242
2243 for (Long assetEntryPK : assetEntryPKSet) {
2244 addAssetEntry.add(pk, assetEntryPK);
2245 }
2246 }
2247 catch (Exception e) {
2248 throw processException(e);
2249 }
2250 finally {
2251 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2252 }
2253 }
2254
2255
2262 public void setAssetEntries(long pk,
2263 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
2264 throws SystemException {
2265 try {
2266 long[] assetEntryPKs = new long[assetEntries.size()];
2267
2268 for (int i = 0; i < assetEntries.size(); i++) {
2269 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
2270
2271 assetEntryPKs[i] = assetEntry.getPrimaryKey();
2272 }
2273
2274 setAssetEntries(pk, assetEntryPKs);
2275 }
2276 catch (Exception e) {
2277 throw processException(e);
2278 }
2279 finally {
2280 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2281 }
2282 }
2283
2284
2287 public void afterPropertiesSet() {
2288 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2289 com.liferay.portal.util.PropsUtil.get(
2290 "value.object.listener.com.liferay.portlet.asset.model.AssetTag")));
2291
2292 if (listenerClassNames.length > 0) {
2293 try {
2294 List<ModelListener<AssetTag>> listenersList = new ArrayList<ModelListener<AssetTag>>();
2295
2296 for (String listenerClassName : listenerClassNames) {
2297 listenersList.add((ModelListener<AssetTag>)InstanceFactory.newInstance(
2298 getClassLoader(), listenerClassName));
2299 }
2300
2301 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2302 }
2303 catch (Exception e) {
2304 _log.error(e);
2305 }
2306 }
2307
2308 containsAssetEntry = new ContainsAssetEntry();
2309
2310 addAssetEntry = new AddAssetEntry();
2311 clearAssetEntries = new ClearAssetEntries();
2312 removeAssetEntry = new RemoveAssetEntry();
2313 }
2314
2315 public void destroy() {
2316 EntityCacheUtil.removeCache(AssetTagImpl.class.getName());
2317 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2318 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2319 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2320 }
2321
2322 @BeanReference(type = AssetEntryPersistence.class)
2323 protected AssetEntryPersistence assetEntryPersistence;
2324 protected ContainsAssetEntry containsAssetEntry;
2325 protected AddAssetEntry addAssetEntry;
2326 protected ClearAssetEntries clearAssetEntries;
2327 protected RemoveAssetEntry removeAssetEntry;
2328
2329 protected class ContainsAssetEntry {
2330 protected ContainsAssetEntry() {
2331 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2332 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE tagId = ? AND entryId = ?",
2333 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2334 RowMapper.COUNT);
2335 }
2336
2337 protected boolean contains(long tagId, long entryId) {
2338 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2339 new Long(tagId), new Long(entryId)
2340 });
2341
2342 if (results.size() > 0) {
2343 Integer count = results.get(0);
2344
2345 if (count.intValue() > 0) {
2346 return true;
2347 }
2348 }
2349
2350 return false;
2351 }
2352
2353 private MappingSqlQuery<Integer> _mappingSqlQuery;
2354 }
2355
2356 protected class AddAssetEntry {
2357 protected AddAssetEntry() {
2358 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2359 "INSERT INTO AssetEntries_AssetTags (tagId, entryId) VALUES (?, ?)",
2360 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2361 }
2362
2363 protected void add(long tagId, long entryId) throws SystemException {
2364 if (!containsAssetEntry.contains(tagId, entryId)) {
2365 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
2366 assetEntryPersistence.getListeners();
2367
2368 for (ModelListener<AssetTag> listener : listeners) {
2369 listener.onBeforeAddAssociation(tagId,
2370 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2371 entryId);
2372 }
2373
2374 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2375 listener.onBeforeAddAssociation(entryId,
2376 AssetTag.class.getName(), tagId);
2377 }
2378
2379 _sqlUpdate.update(new Object[] {
2380 new Long(tagId), new Long(entryId)
2381 });
2382
2383 for (ModelListener<AssetTag> listener : listeners) {
2384 listener.onAfterAddAssociation(tagId,
2385 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2386 entryId);
2387 }
2388
2389 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2390 listener.onAfterAddAssociation(entryId,
2391 AssetTag.class.getName(), tagId);
2392 }
2393 }
2394 }
2395
2396 private SqlUpdate _sqlUpdate;
2397 }
2398
2399 protected class ClearAssetEntries {
2400 protected ClearAssetEntries() {
2401 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2402 "DELETE FROM AssetEntries_AssetTags WHERE tagId = ?",
2403 new int[] { java.sql.Types.BIGINT });
2404 }
2405
2406 protected void clear(long tagId) throws SystemException {
2407 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
2408 assetEntryPersistence.getListeners();
2409
2410 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
2411
2412 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
2413 assetEntries = getAssetEntries(tagId);
2414
2415 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
2416 for (ModelListener<AssetTag> listener : listeners) {
2417 listener.onBeforeRemoveAssociation(tagId,
2418 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2419 assetEntry.getPrimaryKey());
2420 }
2421
2422 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2423 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
2424 AssetTag.class.getName(), tagId);
2425 }
2426 }
2427 }
2428
2429 _sqlUpdate.update(new Object[] { new Long(tagId) });
2430
2431 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
2432 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
2433 for (ModelListener<AssetTag> listener : listeners) {
2434 listener.onAfterRemoveAssociation(tagId,
2435 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2436 assetEntry.getPrimaryKey());
2437 }
2438
2439 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2440 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
2441 AssetTag.class.getName(), tagId);
2442 }
2443 }
2444 }
2445 }
2446
2447 private SqlUpdate _sqlUpdate;
2448 }
2449
2450 protected class RemoveAssetEntry {
2451 protected RemoveAssetEntry() {
2452 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2453 "DELETE FROM AssetEntries_AssetTags WHERE tagId = ? AND entryId = ?",
2454 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2455 }
2456
2457 protected void remove(long tagId, long entryId)
2458 throws SystemException {
2459 if (containsAssetEntry.contains(tagId, entryId)) {
2460 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
2461 assetEntryPersistence.getListeners();
2462
2463 for (ModelListener<AssetTag> listener : listeners) {
2464 listener.onBeforeRemoveAssociation(tagId,
2465 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2466 entryId);
2467 }
2468
2469 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2470 listener.onBeforeRemoveAssociation(entryId,
2471 AssetTag.class.getName(), tagId);
2472 }
2473
2474 _sqlUpdate.update(new Object[] {
2475 new Long(tagId), new Long(entryId)
2476 });
2477
2478 for (ModelListener<AssetTag> listener : listeners) {
2479 listener.onAfterRemoveAssociation(tagId,
2480 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2481 entryId);
2482 }
2483
2484 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2485 listener.onAfterRemoveAssociation(entryId,
2486 AssetTag.class.getName(), tagId);
2487 }
2488 }
2489 }
2490
2491 private SqlUpdate _sqlUpdate;
2492 }
2493
2494 private static final String _SQL_SELECT_ASSETTAG = "SELECT assetTag FROM AssetTag assetTag";
2495 private static final String _SQL_SELECT_ASSETTAG_WHERE = "SELECT assetTag FROM AssetTag assetTag WHERE ";
2496 private static final String _SQL_COUNT_ASSETTAG = "SELECT COUNT(assetTag) FROM AssetTag assetTag";
2497 private static final String _SQL_COUNT_ASSETTAG_WHERE = "SELECT COUNT(assetTag) FROM AssetTag assetTag WHERE ";
2498 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetTags.tagId = ?)";
2499 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE tagId = ?";
2500 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetTag.tagId";
2501 private static final String _FILTER_SQL_SELECT_ASSETTAG_WHERE = "SELECT DISTINCT {assetTag.*} FROM AssetTag assetTag WHERE ";
2502 private static final String _FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_1 =
2503 "SELECT {AssetTag.*} FROM (SELECT DISTINCT assetTag.tagId FROM AssetTag assetTag WHERE ";
2504 private static final String _FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_2 =
2505 ") TEMP_TABLE INNER JOIN AssetTag ON TEMP_TABLE.tagId = AssetTag.tagId";
2506 private static final String _FILTER_SQL_COUNT_ASSETTAG_WHERE = "SELECT COUNT(DISTINCT assetTag.tagId) AS COUNT_VALUE FROM AssetTag assetTag WHERE ";
2507 private static final String _FILTER_ENTITY_ALIAS = "assetTag";
2508 private static final String _FILTER_ENTITY_TABLE = "AssetTag";
2509 private static final String _ORDER_BY_ENTITY_ALIAS = "assetTag.";
2510 private static final String _ORDER_BY_ENTITY_TABLE = "AssetTag.";
2511 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetTag exists with the primary key ";
2512 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetTag exists with the key {";
2513 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2514 private static Log _log = LogFactoryUtil.getLog(AssetTagPersistenceImpl.class);
2515 private static AssetTag _nullAssetTag = new AssetTagImpl() {
2516 @Override
2517 public Object clone() {
2518 return this;
2519 }
2520
2521 @Override
2522 public CacheModel<AssetTag> toCacheModel() {
2523 return _nullAssetTagCacheModel;
2524 }
2525 };
2526
2527 private static CacheModel<AssetTag> _nullAssetTagCacheModel = new CacheModel<AssetTag>() {
2528 public AssetTag toEntityModel() {
2529 return _nullAssetTag;
2530 }
2531 };
2532 }