1
14
15 package com.liferay.portlet.tags.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
22 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
23 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
24 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
25 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
26 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
27 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
28 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
29 import com.liferay.portal.kernel.dao.orm.FinderPath;
30 import com.liferay.portal.kernel.dao.orm.Query;
31 import com.liferay.portal.kernel.dao.orm.QueryPos;
32 import com.liferay.portal.kernel.dao.orm.QueryUtil;
33 import com.liferay.portal.kernel.dao.orm.SQLQuery;
34 import com.liferay.portal.kernel.dao.orm.Session;
35 import com.liferay.portal.kernel.dao.orm.Type;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.SetUtil;
41 import com.liferay.portal.kernel.util.StringBundler;
42 import com.liferay.portal.kernel.util.StringPool;
43 import com.liferay.portal.kernel.util.StringUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.service.persistence.BatchSessionUtil;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.tags.NoSuchAssetException;
49 import com.liferay.portlet.tags.model.TagsAsset;
50 import com.liferay.portlet.tags.model.impl.TagsAssetImpl;
51 import com.liferay.portlet.tags.model.impl.TagsAssetModelImpl;
52
53 import java.io.Serializable;
54
55 import java.sql.Types;
56
57 import java.util.ArrayList;
58 import java.util.Collections;
59 import java.util.List;
60 import java.util.Set;
61
62
75 public class TagsAssetPersistenceImpl extends BasePersistenceImpl<TagsAsset>
76 implements TagsAssetPersistence {
77 public static final String FINDER_CLASS_NAME_ENTITY = TagsAssetImpl.class.getName();
78 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
79 ".List";
80 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
81 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
82 "findByCompanyId", new String[] { Long.class.getName() });
83 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
84 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
85 "findByCompanyId",
86 new String[] {
87 Long.class.getName(),
88
89 "java.lang.Integer", "java.lang.Integer",
90 "com.liferay.portal.kernel.util.OrderByComparator"
91 });
92 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
93 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
94 "countByCompanyId", new String[] { Long.class.getName() });
95 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
96 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
97 "fetchByC_C",
98 new String[] { Long.class.getName(), Long.class.getName() });
99 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
100 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101 "countByC_C",
102 new String[] { Long.class.getName(), Long.class.getName() });
103 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
104 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105 "findAll", new String[0]);
106 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
107 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108 "countAll", new String[0]);
109
110 public void cacheResult(TagsAsset tagsAsset) {
111 EntityCacheUtil.putResult(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
112 TagsAssetImpl.class, tagsAsset.getPrimaryKey(), tagsAsset);
113
114 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
115 new Object[] {
116 new Long(tagsAsset.getClassNameId()),
117 new Long(tagsAsset.getClassPK())
118 }, tagsAsset);
119 }
120
121 public void cacheResult(List<TagsAsset> tagsAssets) {
122 for (TagsAsset tagsAsset : tagsAssets) {
123 if (EntityCacheUtil.getResult(
124 TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
125 TagsAssetImpl.class, tagsAsset.getPrimaryKey(), this) == null) {
126 cacheResult(tagsAsset);
127 }
128 }
129 }
130
131 public void clearCache() {
132 CacheRegistry.clear(TagsAssetImpl.class.getName());
133 EntityCacheUtil.clearCache(TagsAssetImpl.class.getName());
134 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
135 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
136 }
137
138 public TagsAsset create(long assetId) {
139 TagsAsset tagsAsset = new TagsAssetImpl();
140
141 tagsAsset.setNew(true);
142 tagsAsset.setPrimaryKey(assetId);
143
144 return tagsAsset;
145 }
146
147 public TagsAsset remove(Serializable primaryKey)
148 throws NoSuchModelException, SystemException {
149 return remove(((Long)primaryKey).longValue());
150 }
151
152 public TagsAsset remove(long assetId)
153 throws NoSuchAssetException, SystemException {
154 Session session = null;
155
156 try {
157 session = openSession();
158
159 TagsAsset tagsAsset = (TagsAsset)session.get(TagsAssetImpl.class,
160 new Long(assetId));
161
162 if (tagsAsset == null) {
163 if (_log.isWarnEnabled()) {
164 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + assetId);
165 }
166
167 throw new NoSuchAssetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
168 assetId);
169 }
170
171 return remove(tagsAsset);
172 }
173 catch (NoSuchAssetException nsee) {
174 throw nsee;
175 }
176 catch (Exception e) {
177 throw processException(e);
178 }
179 finally {
180 closeSession(session);
181 }
182 }
183
184 public TagsAsset remove(TagsAsset tagsAsset) throws SystemException {
185 for (ModelListener<TagsAsset> listener : listeners) {
186 listener.onBeforeRemove(tagsAsset);
187 }
188
189 tagsAsset = removeImpl(tagsAsset);
190
191 for (ModelListener<TagsAsset> listener : listeners) {
192 listener.onAfterRemove(tagsAsset);
193 }
194
195 return tagsAsset;
196 }
197
198 protected TagsAsset removeImpl(TagsAsset tagsAsset)
199 throws SystemException {
200 tagsAsset = toUnwrappedModel(tagsAsset);
201
202 try {
203 clearTagsEntries.clear(tagsAsset.getPrimaryKey());
204 }
205 catch (Exception e) {
206 throw processException(e);
207 }
208 finally {
209 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
210 }
211
212 Session session = null;
213
214 try {
215 session = openSession();
216
217 if (tagsAsset.isCachedModel() || BatchSessionUtil.isEnabled()) {
218 Object staleObject = session.get(TagsAssetImpl.class,
219 tagsAsset.getPrimaryKeyObj());
220
221 if (staleObject != null) {
222 session.evict(staleObject);
223 }
224 }
225
226 session.delete(tagsAsset);
227
228 session.flush();
229 }
230 catch (Exception e) {
231 throw processException(e);
232 }
233 finally {
234 closeSession(session);
235 }
236
237 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
238
239 TagsAssetModelImpl tagsAssetModelImpl = (TagsAssetModelImpl)tagsAsset;
240
241 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
242 new Object[] {
243 new Long(tagsAssetModelImpl.getOriginalClassNameId()),
244 new Long(tagsAssetModelImpl.getOriginalClassPK())
245 });
246
247 EntityCacheUtil.removeResult(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
248 TagsAssetImpl.class, tagsAsset.getPrimaryKey());
249
250 return tagsAsset;
251 }
252
253
256 public TagsAsset update(TagsAsset tagsAsset) throws SystemException {
257 if (_log.isWarnEnabled()) {
258 _log.warn(
259 "Using the deprecated update(TagsAsset tagsAsset) method. Use update(TagsAsset tagsAsset, boolean merge) instead.");
260 }
261
262 return update(tagsAsset, false);
263 }
264
265 public TagsAsset updateImpl(
266 com.liferay.portlet.tags.model.TagsAsset tagsAsset, boolean merge)
267 throws SystemException {
268 tagsAsset = toUnwrappedModel(tagsAsset);
269
270 boolean isNew = tagsAsset.isNew();
271
272 TagsAssetModelImpl tagsAssetModelImpl = (TagsAssetModelImpl)tagsAsset;
273
274 Session session = null;
275
276 try {
277 session = openSession();
278
279 BatchSessionUtil.update(session, tagsAsset, merge);
280
281 tagsAsset.setNew(false);
282 }
283 catch (Exception e) {
284 throw processException(e);
285 }
286 finally {
287 closeSession(session);
288 }
289
290 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
291
292 EntityCacheUtil.putResult(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
293 TagsAssetImpl.class, tagsAsset.getPrimaryKey(), tagsAsset);
294
295 if (!isNew &&
296 ((tagsAsset.getClassNameId() != tagsAssetModelImpl.getOriginalClassNameId()) ||
297 (tagsAsset.getClassPK() != tagsAssetModelImpl.getOriginalClassPK()))) {
298 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
299 new Object[] {
300 new Long(tagsAssetModelImpl.getOriginalClassNameId()),
301 new Long(tagsAssetModelImpl.getOriginalClassPK())
302 });
303 }
304
305 if (isNew ||
306 ((tagsAsset.getClassNameId() != tagsAssetModelImpl.getOriginalClassNameId()) ||
307 (tagsAsset.getClassPK() != tagsAssetModelImpl.getOriginalClassPK()))) {
308 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
309 new Object[] {
310 new Long(tagsAsset.getClassNameId()),
311 new Long(tagsAsset.getClassPK())
312 }, tagsAsset);
313 }
314
315 return tagsAsset;
316 }
317
318 protected TagsAsset toUnwrappedModel(TagsAsset tagsAsset) {
319 if (tagsAsset instanceof TagsAssetImpl) {
320 return tagsAsset;
321 }
322
323 TagsAssetImpl tagsAssetImpl = new TagsAssetImpl();
324
325 tagsAssetImpl.setNew(tagsAsset.isNew());
326 tagsAssetImpl.setPrimaryKey(tagsAsset.getPrimaryKey());
327
328 tagsAssetImpl.setAssetId(tagsAsset.getAssetId());
329 tagsAssetImpl.setGroupId(tagsAsset.getGroupId());
330 tagsAssetImpl.setCompanyId(tagsAsset.getCompanyId());
331 tagsAssetImpl.setUserId(tagsAsset.getUserId());
332 tagsAssetImpl.setUserName(tagsAsset.getUserName());
333 tagsAssetImpl.setCreateDate(tagsAsset.getCreateDate());
334 tagsAssetImpl.setModifiedDate(tagsAsset.getModifiedDate());
335 tagsAssetImpl.setClassNameId(tagsAsset.getClassNameId());
336 tagsAssetImpl.setClassPK(tagsAsset.getClassPK());
337 tagsAssetImpl.setStartDate(tagsAsset.getStartDate());
338 tagsAssetImpl.setEndDate(tagsAsset.getEndDate());
339 tagsAssetImpl.setPublishDate(tagsAsset.getPublishDate());
340 tagsAssetImpl.setExpirationDate(tagsAsset.getExpirationDate());
341 tagsAssetImpl.setMimeType(tagsAsset.getMimeType());
342 tagsAssetImpl.setTitle(tagsAsset.getTitle());
343 tagsAssetImpl.setDescription(tagsAsset.getDescription());
344 tagsAssetImpl.setSummary(tagsAsset.getSummary());
345 tagsAssetImpl.setUrl(tagsAsset.getUrl());
346 tagsAssetImpl.setHeight(tagsAsset.getHeight());
347 tagsAssetImpl.setWidth(tagsAsset.getWidth());
348 tagsAssetImpl.setPriority(tagsAsset.getPriority());
349 tagsAssetImpl.setViewCount(tagsAsset.getViewCount());
350
351 return tagsAssetImpl;
352 }
353
354 public TagsAsset findByPrimaryKey(Serializable primaryKey)
355 throws NoSuchModelException, SystemException {
356 return findByPrimaryKey(((Long)primaryKey).longValue());
357 }
358
359 public TagsAsset findByPrimaryKey(long assetId)
360 throws NoSuchAssetException, SystemException {
361 TagsAsset tagsAsset = fetchByPrimaryKey(assetId);
362
363 if (tagsAsset == null) {
364 if (_log.isWarnEnabled()) {
365 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + assetId);
366 }
367
368 throw new NoSuchAssetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
369 assetId);
370 }
371
372 return tagsAsset;
373 }
374
375 public TagsAsset fetchByPrimaryKey(Serializable primaryKey)
376 throws SystemException {
377 return fetchByPrimaryKey(((Long)primaryKey).longValue());
378 }
379
380 public TagsAsset fetchByPrimaryKey(long assetId) throws SystemException {
381 TagsAsset tagsAsset = (TagsAsset)EntityCacheUtil.getResult(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
382 TagsAssetImpl.class, assetId, this);
383
384 if (tagsAsset == null) {
385 Session session = null;
386
387 try {
388 session = openSession();
389
390 tagsAsset = (TagsAsset)session.get(TagsAssetImpl.class,
391 new Long(assetId));
392 }
393 catch (Exception e) {
394 throw processException(e);
395 }
396 finally {
397 if (tagsAsset != null) {
398 cacheResult(tagsAsset);
399 }
400
401 closeSession(session);
402 }
403 }
404
405 return tagsAsset;
406 }
407
408 public List<TagsAsset> findByCompanyId(long companyId)
409 throws SystemException {
410 Object[] finderArgs = new Object[] { new Long(companyId) };
411
412 List<TagsAsset> list = (List<TagsAsset>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
413 finderArgs, this);
414
415 if (list == null) {
416 Session session = null;
417
418 try {
419 session = openSession();
420
421 StringBundler query = new StringBundler(2);
422
423 query.append(_SQL_SELECT_TAGSASSET_WHERE);
424
425 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
426
427 String sql = query.toString();
428
429 Query q = session.createQuery(sql);
430
431 QueryPos qPos = QueryPos.getInstance(q);
432
433 qPos.add(companyId);
434
435 list = q.list();
436 }
437 catch (Exception e) {
438 throw processException(e);
439 }
440 finally {
441 if (list == null) {
442 list = new ArrayList<TagsAsset>();
443 }
444
445 cacheResult(list);
446
447 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
448 finderArgs, list);
449
450 closeSession(session);
451 }
452 }
453
454 return list;
455 }
456
457 public List<TagsAsset> findByCompanyId(long companyId, int start, int end)
458 throws SystemException {
459 return findByCompanyId(companyId, start, end, null);
460 }
461
462 public List<TagsAsset> findByCompanyId(long companyId, int start, int end,
463 OrderByComparator obc) throws SystemException {
464 Object[] finderArgs = new Object[] {
465 new Long(companyId),
466
467 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
468 };
469
470 List<TagsAsset> list = (List<TagsAsset>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
471 finderArgs, this);
472
473 if (list == null) {
474 Session session = null;
475
476 try {
477 session = openSession();
478
479 StringBundler query = null;
480
481 if (obc != null) {
482 query = new StringBundler(3 +
483 (obc.getOrderByFields().length * 3));
484 }
485 else {
486 query = new StringBundler(2);
487 }
488
489 query.append(_SQL_SELECT_TAGSASSET_WHERE);
490
491 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
492
493 if (obc != null) {
494 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
495 }
496
497 String sql = query.toString();
498
499 Query q = session.createQuery(sql);
500
501 QueryPos qPos = QueryPos.getInstance(q);
502
503 qPos.add(companyId);
504
505 list = (List<TagsAsset>)QueryUtil.list(q, getDialect(), start,
506 end);
507 }
508 catch (Exception e) {
509 throw processException(e);
510 }
511 finally {
512 if (list == null) {
513 list = new ArrayList<TagsAsset>();
514 }
515
516 cacheResult(list);
517
518 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
519 finderArgs, list);
520
521 closeSession(session);
522 }
523 }
524
525 return list;
526 }
527
528 public TagsAsset findByCompanyId_First(long companyId, OrderByComparator obc)
529 throws NoSuchAssetException, SystemException {
530 List<TagsAsset> list = findByCompanyId(companyId, 0, 1, obc);
531
532 if (list.isEmpty()) {
533 StringBundler msg = new StringBundler(4);
534
535 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
536
537 msg.append("companyId=");
538 msg.append(companyId);
539
540 msg.append(StringPool.CLOSE_CURLY_BRACE);
541
542 throw new NoSuchAssetException(msg.toString());
543 }
544 else {
545 return list.get(0);
546 }
547 }
548
549 public TagsAsset findByCompanyId_Last(long companyId, OrderByComparator obc)
550 throws NoSuchAssetException, SystemException {
551 int count = countByCompanyId(companyId);
552
553 List<TagsAsset> list = findByCompanyId(companyId, count - 1, count, obc);
554
555 if (list.isEmpty()) {
556 StringBundler msg = new StringBundler(4);
557
558 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
559
560 msg.append("companyId=");
561 msg.append(companyId);
562
563 msg.append(StringPool.CLOSE_CURLY_BRACE);
564
565 throw new NoSuchAssetException(msg.toString());
566 }
567 else {
568 return list.get(0);
569 }
570 }
571
572 public TagsAsset[] findByCompanyId_PrevAndNext(long assetId,
573 long companyId, OrderByComparator obc)
574 throws NoSuchAssetException, SystemException {
575 TagsAsset tagsAsset = findByPrimaryKey(assetId);
576
577 int count = countByCompanyId(companyId);
578
579 Session session = null;
580
581 try {
582 session = openSession();
583
584 StringBundler query = null;
585
586 if (obc != null) {
587 query = new StringBundler(3 +
588 (obc.getOrderByFields().length * 3));
589 }
590 else {
591 query = new StringBundler(2);
592 }
593
594 query.append(_SQL_SELECT_TAGSASSET_WHERE);
595
596 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
597
598 if (obc != null) {
599 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
600 }
601
602 String sql = query.toString();
603
604 Query q = session.createQuery(sql);
605
606 QueryPos qPos = QueryPos.getInstance(q);
607
608 qPos.add(companyId);
609
610 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
611 tagsAsset);
612
613 TagsAsset[] array = new TagsAssetImpl[3];
614
615 array[0] = (TagsAsset)objArray[0];
616 array[1] = (TagsAsset)objArray[1];
617 array[2] = (TagsAsset)objArray[2];
618
619 return array;
620 }
621 catch (Exception e) {
622 throw processException(e);
623 }
624 finally {
625 closeSession(session);
626 }
627 }
628
629 public TagsAsset findByC_C(long classNameId, long classPK)
630 throws NoSuchAssetException, SystemException {
631 TagsAsset tagsAsset = fetchByC_C(classNameId, classPK);
632
633 if (tagsAsset == null) {
634 StringBundler msg = new StringBundler(6);
635
636 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
637
638 msg.append("classNameId=");
639 msg.append(classNameId);
640
641 msg.append(", classPK=");
642 msg.append(classPK);
643
644 msg.append(StringPool.CLOSE_CURLY_BRACE);
645
646 if (_log.isWarnEnabled()) {
647 _log.warn(msg.toString());
648 }
649
650 throw new NoSuchAssetException(msg.toString());
651 }
652
653 return tagsAsset;
654 }
655
656 public TagsAsset fetchByC_C(long classNameId, long classPK)
657 throws SystemException {
658 return fetchByC_C(classNameId, classPK, true);
659 }
660
661 public TagsAsset fetchByC_C(long classNameId, long classPK,
662 boolean retrieveFromCache) throws SystemException {
663 Object[] finderArgs = new Object[] {
664 new Long(classNameId), new Long(classPK)
665 };
666
667 Object result = null;
668
669 if (retrieveFromCache) {
670 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
671 finderArgs, this);
672 }
673
674 if (result == null) {
675 Session session = null;
676
677 try {
678 session = openSession();
679
680 StringBundler query = new StringBundler(3);
681
682 query.append(_SQL_SELECT_TAGSASSET_WHERE);
683
684 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
685
686 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
687
688 String sql = query.toString();
689
690 Query q = session.createQuery(sql);
691
692 QueryPos qPos = QueryPos.getInstance(q);
693
694 qPos.add(classNameId);
695
696 qPos.add(classPK);
697
698 List<TagsAsset> list = q.list();
699
700 result = list;
701
702 TagsAsset tagsAsset = null;
703
704 if (list.isEmpty()) {
705 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
706 finderArgs, list);
707 }
708 else {
709 tagsAsset = list.get(0);
710
711 cacheResult(tagsAsset);
712
713 if ((tagsAsset.getClassNameId() != classNameId) ||
714 (tagsAsset.getClassPK() != classPK)) {
715 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
716 finderArgs, tagsAsset);
717 }
718 }
719
720 return tagsAsset;
721 }
722 catch (Exception e) {
723 throw processException(e);
724 }
725 finally {
726 if (result == null) {
727 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
728 finderArgs, new ArrayList<TagsAsset>());
729 }
730
731 closeSession(session);
732 }
733 }
734 else {
735 if (result instanceof List<?>) {
736 return null;
737 }
738 else {
739 return (TagsAsset)result;
740 }
741 }
742 }
743
744 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
745 throws SystemException {
746 Session session = null;
747
748 try {
749 session = openSession();
750
751 dynamicQuery.compile(session);
752
753 return dynamicQuery.list();
754 }
755 catch (Exception e) {
756 throw processException(e);
757 }
758 finally {
759 closeSession(session);
760 }
761 }
762
763 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
764 int start, int end) throws SystemException {
765 Session session = null;
766
767 try {
768 session = openSession();
769
770 dynamicQuery.setLimit(start, end);
771
772 dynamicQuery.compile(session);
773
774 return dynamicQuery.list();
775 }
776 catch (Exception e) {
777 throw processException(e);
778 }
779 finally {
780 closeSession(session);
781 }
782 }
783
784 public List<TagsAsset> findAll() throws SystemException {
785 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
786 }
787
788 public List<TagsAsset> findAll(int start, int end)
789 throws SystemException {
790 return findAll(start, end, null);
791 }
792
793 public List<TagsAsset> findAll(int start, int end, OrderByComparator obc)
794 throws SystemException {
795 Object[] finderArgs = new Object[] {
796 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
797 };
798
799 List<TagsAsset> list = (List<TagsAsset>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
800 finderArgs, this);
801
802 if (list == null) {
803 Session session = null;
804
805 try {
806 session = openSession();
807
808 StringBundler query = null;
809 String sql = null;
810
811 if (obc != null) {
812 query = new StringBundler(2 +
813 (obc.getOrderByFields().length * 3));
814
815 query.append(_SQL_SELECT_TAGSASSET);
816
817 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
818
819 sql = query.toString();
820 }
821
822 sql = _SQL_SELECT_TAGSASSET;
823
824 Query q = session.createQuery(sql);
825
826 if (obc == null) {
827 list = (List<TagsAsset>)QueryUtil.list(q, getDialect(),
828 start, end, false);
829
830 Collections.sort(list);
831 }
832 else {
833 list = (List<TagsAsset>)QueryUtil.list(q, getDialect(),
834 start, end);
835 }
836 }
837 catch (Exception e) {
838 throw processException(e);
839 }
840 finally {
841 if (list == null) {
842 list = new ArrayList<TagsAsset>();
843 }
844
845 cacheResult(list);
846
847 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
848
849 closeSession(session);
850 }
851 }
852
853 return list;
854 }
855
856 public void removeByCompanyId(long companyId) throws SystemException {
857 for (TagsAsset tagsAsset : findByCompanyId(companyId)) {
858 remove(tagsAsset);
859 }
860 }
861
862 public void removeByC_C(long classNameId, long classPK)
863 throws NoSuchAssetException, SystemException {
864 TagsAsset tagsAsset = findByC_C(classNameId, classPK);
865
866 remove(tagsAsset);
867 }
868
869 public void removeAll() throws SystemException {
870 for (TagsAsset tagsAsset : findAll()) {
871 remove(tagsAsset);
872 }
873 }
874
875 public int countByCompanyId(long companyId) throws SystemException {
876 Object[] finderArgs = new Object[] { new Long(companyId) };
877
878 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
879 finderArgs, this);
880
881 if (count == null) {
882 Session session = null;
883
884 try {
885 session = openSession();
886
887 StringBundler query = new StringBundler(2);
888
889 query.append(_SQL_COUNT_TAGSASSET_WHERE);
890
891 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
892
893 String sql = query.toString();
894
895 Query q = session.createQuery(sql);
896
897 QueryPos qPos = QueryPos.getInstance(q);
898
899 qPos.add(companyId);
900
901 count = (Long)q.uniqueResult();
902 }
903 catch (Exception e) {
904 throw processException(e);
905 }
906 finally {
907 if (count == null) {
908 count = Long.valueOf(0);
909 }
910
911 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
912 finderArgs, count);
913
914 closeSession(session);
915 }
916 }
917
918 return count.intValue();
919 }
920
921 public int countByC_C(long classNameId, long classPK)
922 throws SystemException {
923 Object[] finderArgs = new Object[] {
924 new Long(classNameId), new Long(classPK)
925 };
926
927 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
928 finderArgs, this);
929
930 if (count == null) {
931 Session session = null;
932
933 try {
934 session = openSession();
935
936 StringBundler query = new StringBundler(3);
937
938 query.append(_SQL_COUNT_TAGSASSET_WHERE);
939
940 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
941
942 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
943
944 String sql = query.toString();
945
946 Query q = session.createQuery(sql);
947
948 QueryPos qPos = QueryPos.getInstance(q);
949
950 qPos.add(classNameId);
951
952 qPos.add(classPK);
953
954 count = (Long)q.uniqueResult();
955 }
956 catch (Exception e) {
957 throw processException(e);
958 }
959 finally {
960 if (count == null) {
961 count = Long.valueOf(0);
962 }
963
964 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
965 count);
966
967 closeSession(session);
968 }
969 }
970
971 return count.intValue();
972 }
973
974 public int countAll() throws SystemException {
975 Object[] finderArgs = new Object[0];
976
977 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
978 finderArgs, this);
979
980 if (count == null) {
981 Session session = null;
982
983 try {
984 session = openSession();
985
986 Query q = session.createQuery(_SQL_COUNT_TAGSASSET);
987
988 count = (Long)q.uniqueResult();
989 }
990 catch (Exception e) {
991 throw processException(e);
992 }
993 finally {
994 if (count == null) {
995 count = Long.valueOf(0);
996 }
997
998 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
999 count);
1000
1001 closeSession(session);
1002 }
1003 }
1004
1005 return count.intValue();
1006 }
1007
1008 public List<com.liferay.portlet.tags.model.TagsEntry> getTagsEntries(
1009 long pk) throws SystemException {
1010 return getTagsEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1011 }
1012
1013 public List<com.liferay.portlet.tags.model.TagsEntry> getTagsEntries(
1014 long pk, int start, int end) throws SystemException {
1015 return getTagsEntries(pk, start, end, null);
1016 }
1017
1018 public static final FinderPath FINDER_PATH_GET_TAGSENTRIES = new FinderPath(com.liferay.portlet.tags.model.impl.TagsEntryModelImpl.ENTITY_CACHE_ENABLED,
1019 TagsAssetModelImpl.FINDER_CACHE_ENABLED_TAGSASSETS_TAGSENTRIES,
1020 TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME,
1021 "getTagsEntries",
1022 new String[] {
1023 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1024 "com.liferay.portal.kernel.util.OrderByComparator"
1025 });
1026
1027 public List<com.liferay.portlet.tags.model.TagsEntry> getTagsEntries(
1028 long pk, int start, int end, OrderByComparator obc)
1029 throws SystemException {
1030 Object[] finderArgs = new Object[] {
1031 new Long(pk), String.valueOf(start), String.valueOf(end),
1032 String.valueOf(obc)
1033 };
1034
1035 List<com.liferay.portlet.tags.model.TagsEntry> list = (List<com.liferay.portlet.tags.model.TagsEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_TAGSENTRIES,
1036 finderArgs, this);
1037
1038 if (list == null) {
1039 Session session = null;
1040
1041 try {
1042 session = openSession();
1043
1044 String sql = null;
1045
1046 if (obc != null) {
1047 sql = _SQL_GETTAGSENTRIES.concat(ORDER_BY_CLAUSE)
1048 .concat(obc.getOrderBy());
1049 }
1050
1051 else {
1052 sql = _SQL_GETTAGSENTRIES.concat(com.liferay.portlet.tags.model.impl.TagsEntryModelImpl.ORDER_BY_SQL);
1053 }
1054
1055 SQLQuery q = session.createSQLQuery(sql);
1056
1057 q.addEntity("TagsEntry",
1058 com.liferay.portlet.tags.model.impl.TagsEntryImpl.class);
1059
1060 QueryPos qPos = QueryPos.getInstance(q);
1061
1062 qPos.add(pk);
1063
1064 list = (List<com.liferay.portlet.tags.model.TagsEntry>)QueryUtil.list(q,
1065 getDialect(), start, end);
1066 }
1067 catch (Exception e) {
1068 throw processException(e);
1069 }
1070 finally {
1071 if (list == null) {
1072 list = new ArrayList<com.liferay.portlet.tags.model.TagsEntry>();
1073 }
1074
1075 tagsEntryPersistence.cacheResult(list);
1076
1077 FinderCacheUtil.putResult(FINDER_PATH_GET_TAGSENTRIES,
1078 finderArgs, list);
1079
1080 closeSession(session);
1081 }
1082 }
1083
1084 return list;
1085 }
1086
1087 public static final FinderPath FINDER_PATH_GET_TAGSENTRIES_SIZE = new FinderPath(com.liferay.portlet.tags.model.impl.TagsEntryModelImpl.ENTITY_CACHE_ENABLED,
1088 TagsAssetModelImpl.FINDER_CACHE_ENABLED_TAGSASSETS_TAGSENTRIES,
1089 TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME,
1090 "getTagsEntriesSize", new String[] { Long.class.getName() });
1091
1092 public int getTagsEntriesSize(long pk) throws SystemException {
1093 Object[] finderArgs = new Object[] { new Long(pk) };
1094
1095 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_TAGSENTRIES_SIZE,
1096 finderArgs, this);
1097
1098 if (count == null) {
1099 Session session = null;
1100
1101 try {
1102 session = openSession();
1103
1104 SQLQuery q = session.createSQLQuery(_SQL_GETTAGSENTRIESSIZE);
1105
1106 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1107
1108 QueryPos qPos = QueryPos.getInstance(q);
1109
1110 qPos.add(pk);
1111
1112 count = (Long)q.uniqueResult();
1113 }
1114 catch (Exception e) {
1115 throw processException(e);
1116 }
1117 finally {
1118 if (count == null) {
1119 count = Long.valueOf(0);
1120 }
1121
1122 FinderCacheUtil.putResult(FINDER_PATH_GET_TAGSENTRIES_SIZE,
1123 finderArgs, count);
1124
1125 closeSession(session);
1126 }
1127 }
1128
1129 return count.intValue();
1130 }
1131
1132 public static final FinderPath FINDER_PATH_CONTAINS_TAGSENTRY = new FinderPath(com.liferay.portlet.tags.model.impl.TagsEntryModelImpl.ENTITY_CACHE_ENABLED,
1133 TagsAssetModelImpl.FINDER_CACHE_ENABLED_TAGSASSETS_TAGSENTRIES,
1134 TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME,
1135 "containsTagsEntry",
1136 new String[] { Long.class.getName(), Long.class.getName() });
1137
1138 public boolean containsTagsEntry(long pk, long tagsEntryPK)
1139 throws SystemException {
1140 Object[] finderArgs = new Object[] { new Long(pk), new Long(tagsEntryPK) };
1141
1142 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_TAGSENTRY,
1143 finderArgs, this);
1144
1145 if (value == null) {
1146 try {
1147 value = Boolean.valueOf(containsTagsEntry.contains(pk,
1148 tagsEntryPK));
1149 }
1150 catch (Exception e) {
1151 throw processException(e);
1152 }
1153 finally {
1154 if (value == null) {
1155 value = Boolean.FALSE;
1156 }
1157
1158 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_TAGSENTRY,
1159 finderArgs, value);
1160 }
1161 }
1162
1163 return value.booleanValue();
1164 }
1165
1166 public boolean containsTagsEntries(long pk) throws SystemException {
1167 if (getTagsEntriesSize(pk) > 0) {
1168 return true;
1169 }
1170 else {
1171 return false;
1172 }
1173 }
1174
1175 public void addTagsEntry(long pk, long tagsEntryPK)
1176 throws SystemException {
1177 try {
1178 addTagsEntry.add(pk, tagsEntryPK);
1179 }
1180 catch (Exception e) {
1181 throw processException(e);
1182 }
1183 finally {
1184 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1185 }
1186 }
1187
1188 public void addTagsEntry(long pk,
1189 com.liferay.portlet.tags.model.TagsEntry tagsEntry)
1190 throws SystemException {
1191 try {
1192 addTagsEntry.add(pk, tagsEntry.getPrimaryKey());
1193 }
1194 catch (Exception e) {
1195 throw processException(e);
1196 }
1197 finally {
1198 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1199 }
1200 }
1201
1202 public void addTagsEntries(long pk, long[] tagsEntryPKs)
1203 throws SystemException {
1204 try {
1205 for (long tagsEntryPK : tagsEntryPKs) {
1206 addTagsEntry.add(pk, tagsEntryPK);
1207 }
1208 }
1209 catch (Exception e) {
1210 throw processException(e);
1211 }
1212 finally {
1213 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1214 }
1215 }
1216
1217 public void addTagsEntries(long pk,
1218 List<com.liferay.portlet.tags.model.TagsEntry> tagsEntries)
1219 throws SystemException {
1220 try {
1221 for (com.liferay.portlet.tags.model.TagsEntry tagsEntry : tagsEntries) {
1222 addTagsEntry.add(pk, tagsEntry.getPrimaryKey());
1223 }
1224 }
1225 catch (Exception e) {
1226 throw processException(e);
1227 }
1228 finally {
1229 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1230 }
1231 }
1232
1233 public void clearTagsEntries(long pk) throws SystemException {
1234 try {
1235 clearTagsEntries.clear(pk);
1236 }
1237 catch (Exception e) {
1238 throw processException(e);
1239 }
1240 finally {
1241 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1242 }
1243 }
1244
1245 public void removeTagsEntry(long pk, long tagsEntryPK)
1246 throws SystemException {
1247 try {
1248 removeTagsEntry.remove(pk, tagsEntryPK);
1249 }
1250 catch (Exception e) {
1251 throw processException(e);
1252 }
1253 finally {
1254 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1255 }
1256 }
1257
1258 public void removeTagsEntry(long pk,
1259 com.liferay.portlet.tags.model.TagsEntry tagsEntry)
1260 throws SystemException {
1261 try {
1262 removeTagsEntry.remove(pk, tagsEntry.getPrimaryKey());
1263 }
1264 catch (Exception e) {
1265 throw processException(e);
1266 }
1267 finally {
1268 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1269 }
1270 }
1271
1272 public void removeTagsEntries(long pk, long[] tagsEntryPKs)
1273 throws SystemException {
1274 try {
1275 for (long tagsEntryPK : tagsEntryPKs) {
1276 removeTagsEntry.remove(pk, tagsEntryPK);
1277 }
1278 }
1279 catch (Exception e) {
1280 throw processException(e);
1281 }
1282 finally {
1283 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1284 }
1285 }
1286
1287 public void removeTagsEntries(long pk,
1288 List<com.liferay.portlet.tags.model.TagsEntry> tagsEntries)
1289 throws SystemException {
1290 try {
1291 for (com.liferay.portlet.tags.model.TagsEntry tagsEntry : tagsEntries) {
1292 removeTagsEntry.remove(pk, tagsEntry.getPrimaryKey());
1293 }
1294 }
1295 catch (Exception e) {
1296 throw processException(e);
1297 }
1298 finally {
1299 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1300 }
1301 }
1302
1303 public void setTagsEntries(long pk, long[] tagsEntryPKs)
1304 throws SystemException {
1305 try {
1306 Set<Long> tagsEntryPKSet = SetUtil.fromArray(tagsEntryPKs);
1307
1308 List<com.liferay.portlet.tags.model.TagsEntry> tagsEntries = getTagsEntries(pk);
1309
1310 for (com.liferay.portlet.tags.model.TagsEntry tagsEntry : tagsEntries) {
1311 if (!tagsEntryPKSet.contains(tagsEntry.getPrimaryKey())) {
1312 removeTagsEntry.remove(pk, tagsEntry.getPrimaryKey());
1313 }
1314 else {
1315 tagsEntryPKSet.remove(tagsEntry.getPrimaryKey());
1316 }
1317 }
1318
1319 for (Long tagsEntryPK : tagsEntryPKSet) {
1320 addTagsEntry.add(pk, tagsEntryPK);
1321 }
1322 }
1323 catch (Exception e) {
1324 throw processException(e);
1325 }
1326 finally {
1327 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1328 }
1329 }
1330
1331 public void setTagsEntries(long pk,
1332 List<com.liferay.portlet.tags.model.TagsEntry> tagsEntries)
1333 throws SystemException {
1334 try {
1335 long[] tagsEntryPKs = new long[tagsEntries.size()];
1336
1337 for (int i = 0; i < tagsEntries.size(); i++) {
1338 com.liferay.portlet.tags.model.TagsEntry tagsEntry = tagsEntries.get(i);
1339
1340 tagsEntryPKs[i] = tagsEntry.getPrimaryKey();
1341 }
1342
1343 setTagsEntries(pk, tagsEntryPKs);
1344 }
1345 catch (Exception e) {
1346 throw processException(e);
1347 }
1348 finally {
1349 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1350 }
1351 }
1352
1353 public void afterPropertiesSet() {
1354 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1355 com.liferay.portal.util.PropsUtil.get(
1356 "value.object.listener.com.liferay.portlet.tags.model.TagsAsset")));
1357
1358 if (listenerClassNames.length > 0) {
1359 try {
1360 List<ModelListener<TagsAsset>> listenersList = new ArrayList<ModelListener<TagsAsset>>();
1361
1362 for (String listenerClassName : listenerClassNames) {
1363 listenersList.add((ModelListener<TagsAsset>)Class.forName(
1364 listenerClassName).newInstance());
1365 }
1366
1367 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1368 }
1369 catch (Exception e) {
1370 _log.error(e);
1371 }
1372 }
1373
1374 containsTagsEntry = new ContainsTagsEntry(this);
1375
1376 addTagsEntry = new AddTagsEntry(this);
1377 clearTagsEntries = new ClearTagsEntries(this);
1378 removeTagsEntry = new RemoveTagsEntry(this);
1379 }
1380
1381 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence")
1382 protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
1383 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsEntryPersistence")
1384 protected com.liferay.portlet.tags.service.persistence.TagsEntryPersistence tagsEntryPersistence;
1385 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsPropertyPersistence")
1386 protected com.liferay.portlet.tags.service.persistence.TagsPropertyPersistence tagsPropertyPersistence;
1387 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsSourcePersistence")
1388 protected com.liferay.portlet.tags.service.persistence.TagsSourcePersistence tagsSourcePersistence;
1389 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
1390 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1391 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
1392 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1393 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
1394 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1395 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
1396 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1397 @BeanReference(name = "com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence")
1398 protected com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence blogsEntryPersistence;
1399 @BeanReference(name = "com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistence")
1400 protected com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistence bookmarksEntryPersistence;
1401 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence")
1402 protected com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence dlFileEntryPersistence;
1403 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticlePersistence")
1404 protected com.liferay.portlet.journal.service.persistence.JournalArticlePersistence journalArticlePersistence;
1405 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence")
1406 protected com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence journalArticleResourcePersistence;
1407 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence")
1408 protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
1409 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPagePersistence")
1410 protected com.liferay.portlet.wiki.service.persistence.WikiPagePersistence wikiPagePersistence;
1411 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence")
1412 protected com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence wikiPageResourcePersistence;
1413 protected ContainsTagsEntry containsTagsEntry;
1414 protected AddTagsEntry addTagsEntry;
1415 protected ClearTagsEntries clearTagsEntries;
1416 protected RemoveTagsEntry removeTagsEntry;
1417
1418 protected class ContainsTagsEntry {
1419 protected ContainsTagsEntry(TagsAssetPersistenceImpl persistenceImpl) {
1420 super();
1421
1422 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1423 _SQL_CONTAINSTAGSENTRY,
1424 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
1425 }
1426
1427 protected boolean contains(long assetId, long entryId) {
1428 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1429 new Long(assetId), new Long(entryId)
1430 });
1431
1432 if (results.size() > 0) {
1433 Integer count = results.get(0);
1434
1435 if (count.intValue() > 0) {
1436 return true;
1437 }
1438 }
1439
1440 return false;
1441 }
1442
1443 private MappingSqlQuery _mappingSqlQuery;
1444 }
1445
1446 protected class AddTagsEntry {
1447 protected AddTagsEntry(TagsAssetPersistenceImpl persistenceImpl) {
1448 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1449 "INSERT INTO TagsAssets_TagsEntries (assetId, entryId) VALUES (?, ?)",
1450 new int[] { Types.BIGINT, Types.BIGINT });
1451 _persistenceImpl = persistenceImpl;
1452 }
1453
1454 protected void add(long assetId, long entryId) {
1455 if (!_persistenceImpl.containsTagsEntry.contains(assetId, entryId)) {
1456 _sqlUpdate.update(new Object[] {
1457 new Long(assetId), new Long(entryId)
1458 });
1459 }
1460 }
1461
1462 private SqlUpdate _sqlUpdate;
1463 private TagsAssetPersistenceImpl _persistenceImpl;
1464 }
1465
1466 protected class ClearTagsEntries {
1467 protected ClearTagsEntries(TagsAssetPersistenceImpl persistenceImpl) {
1468 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1469 "DELETE FROM TagsAssets_TagsEntries WHERE assetId = ?",
1470 new int[] { Types.BIGINT });
1471 }
1472
1473 protected void clear(long assetId) {
1474 _sqlUpdate.update(new Object[] { new Long(assetId) });
1475 }
1476
1477 private SqlUpdate _sqlUpdate;
1478 }
1479
1480 protected class RemoveTagsEntry {
1481 protected RemoveTagsEntry(TagsAssetPersistenceImpl persistenceImpl) {
1482 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1483 "DELETE FROM TagsAssets_TagsEntries WHERE assetId = ? AND entryId = ?",
1484 new int[] { Types.BIGINT, Types.BIGINT });
1485 }
1486
1487 protected void remove(long assetId, long entryId) {
1488 _sqlUpdate.update(new Object[] { new Long(assetId), new Long(
1489 entryId) });
1490 }
1491
1492 private SqlUpdate _sqlUpdate;
1493 }
1494
1495 private static final String _SQL_SELECT_TAGSASSET = "SELECT tagsAsset FROM TagsAsset tagsAsset";
1496 private static final String _SQL_SELECT_TAGSASSET_WHERE = "SELECT tagsAsset FROM TagsAsset tagsAsset WHERE ";
1497 private static final String _SQL_COUNT_TAGSASSET = "SELECT COUNT(tagsAsset) FROM TagsAsset tagsAsset";
1498 private static final String _SQL_COUNT_TAGSASSET_WHERE = "SELECT COUNT(tagsAsset) FROM TagsAsset tagsAsset WHERE ";
1499 private static final String _SQL_GETTAGSENTRIES = "SELECT {TagsEntry.*} FROM TagsEntry INNER JOIN TagsAssets_TagsEntries ON (TagsAssets_TagsEntries.entryId = TagsEntry.entryId) WHERE (TagsAssets_TagsEntries.assetId = ?)";
1500 private static final String _SQL_GETTAGSENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM TagsAssets_TagsEntries WHERE assetId = ?";
1501 private static final String _SQL_CONTAINSTAGSENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM TagsAssets_TagsEntries WHERE assetId = ? AND entryId = ?";
1502 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "tagsAsset.companyId = ?";
1503 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "tagsAsset.classNameId = ? AND ";
1504 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "tagsAsset.classPK = ?";
1505 private static final String _ORDER_BY_ENTITY_ALIAS = "tagsAsset.";
1506 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No TagsAsset exists with the primary key ";
1507 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No TagsAsset exists with the key {";
1508 private static Log _log = LogFactoryUtil.getLog(TagsAssetPersistenceImpl.class);
1509}