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.orm.EntityCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderPath;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.QueryPos;
26 import com.liferay.portal.kernel.dao.orm.QueryUtil;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.log.Log;
29 import com.liferay.portal.kernel.log.LogFactoryUtil;
30 import com.liferay.portal.kernel.util.GetterUtil;
31 import com.liferay.portal.kernel.util.OrderByComparator;
32 import com.liferay.portal.kernel.util.StringBundler;
33 import com.liferay.portal.kernel.util.StringPool;
34 import com.liferay.portal.kernel.util.StringUtil;
35 import com.liferay.portal.kernel.util.Validator;
36 import com.liferay.portal.model.ModelListener;
37 import com.liferay.portal.service.persistence.BatchSessionUtil;
38 import com.liferay.portal.service.persistence.ResourcePersistence;
39 import com.liferay.portal.service.persistence.UserPersistence;
40 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41
42 import com.liferay.portlet.tags.NoSuchPropertyException;
43 import com.liferay.portlet.tags.model.TagsProperty;
44 import com.liferay.portlet.tags.model.impl.TagsPropertyImpl;
45 import com.liferay.portlet.tags.model.impl.TagsPropertyModelImpl;
46
47 import java.io.Serializable;
48
49 import java.util.ArrayList;
50 import java.util.Collections;
51 import java.util.List;
52
53
66 public class TagsPropertyPersistenceImpl extends BasePersistenceImpl<TagsProperty>
67 implements TagsPropertyPersistence {
68 public static final String FINDER_CLASS_NAME_ENTITY = TagsPropertyImpl.class.getName();
69 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
70 ".List";
71 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
72 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
73 "findByCompanyId", new String[] { Long.class.getName() });
74 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
75 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
76 "findByCompanyId",
77 new String[] {
78 Long.class.getName(),
79
80 "java.lang.Integer", "java.lang.Integer",
81 "com.liferay.portal.kernel.util.OrderByComparator"
82 });
83 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
84 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
85 "countByCompanyId", new String[] { Long.class.getName() });
86 public static final FinderPath FINDER_PATH_FIND_BY_ENTRYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
87 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
88 "findByEntryId", new String[] { Long.class.getName() });
89 public static final FinderPath FINDER_PATH_FIND_BY_OBC_ENTRYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
90 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
91 "findByEntryId",
92 new String[] {
93 Long.class.getName(),
94
95 "java.lang.Integer", "java.lang.Integer",
96 "com.liferay.portal.kernel.util.OrderByComparator"
97 });
98 public static final FinderPath FINDER_PATH_COUNT_BY_ENTRYID = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
99 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100 "countByEntryId", new String[] { Long.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_BY_C_K = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
102 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103 "findByC_K",
104 new String[] { Long.class.getName(), String.class.getName() });
105 public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_K = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
106 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
107 "findByC_K",
108 new String[] {
109 Long.class.getName(), String.class.getName(),
110
111 "java.lang.Integer", "java.lang.Integer",
112 "com.liferay.portal.kernel.util.OrderByComparator"
113 });
114 public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
115 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
116 "countByC_K",
117 new String[] { Long.class.getName(), String.class.getName() });
118 public static final FinderPath FINDER_PATH_FETCH_BY_E_K = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
119 TagsPropertyModelImpl.FINDER_CACHE_ENABLED,
120 FINDER_CLASS_NAME_ENTITY, "fetchByE_K",
121 new String[] { Long.class.getName(), String.class.getName() });
122 public static final FinderPath FINDER_PATH_COUNT_BY_E_K = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
123 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
124 "countByE_K",
125 new String[] { Long.class.getName(), String.class.getName() });
126 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
127 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
128 "findAll", new String[0]);
129 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
130 TagsPropertyModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
131 "countAll", new String[0]);
132
133 public void cacheResult(TagsProperty tagsProperty) {
134 EntityCacheUtil.putResult(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
135 TagsPropertyImpl.class, tagsProperty.getPrimaryKey(), tagsProperty);
136
137 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_K,
138 new Object[] {
139 new Long(tagsProperty.getEntryId()),
140
141 tagsProperty.getKey()
142 }, tagsProperty);
143 }
144
145 public void cacheResult(List<TagsProperty> tagsProperties) {
146 for (TagsProperty tagsProperty : tagsProperties) {
147 if (EntityCacheUtil.getResult(
148 TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
149 TagsPropertyImpl.class, tagsProperty.getPrimaryKey(),
150 this) == null) {
151 cacheResult(tagsProperty);
152 }
153 }
154 }
155
156 public void clearCache() {
157 CacheRegistry.clear(TagsPropertyImpl.class.getName());
158 EntityCacheUtil.clearCache(TagsPropertyImpl.class.getName());
159 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
160 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
161 }
162
163 public TagsProperty create(long propertyId) {
164 TagsProperty tagsProperty = new TagsPropertyImpl();
165
166 tagsProperty.setNew(true);
167 tagsProperty.setPrimaryKey(propertyId);
168
169 return tagsProperty;
170 }
171
172 public TagsProperty remove(Serializable primaryKey)
173 throws NoSuchModelException, SystemException {
174 return remove(((Long)primaryKey).longValue());
175 }
176
177 public TagsProperty remove(long propertyId)
178 throws NoSuchPropertyException, SystemException {
179 Session session = null;
180
181 try {
182 session = openSession();
183
184 TagsProperty tagsProperty = (TagsProperty)session.get(TagsPropertyImpl.class,
185 new Long(propertyId));
186
187 if (tagsProperty == null) {
188 if (_log.isWarnEnabled()) {
189 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + propertyId);
190 }
191
192 throw new NoSuchPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
193 propertyId);
194 }
195
196 return remove(tagsProperty);
197 }
198 catch (NoSuchPropertyException nsee) {
199 throw nsee;
200 }
201 catch (Exception e) {
202 throw processException(e);
203 }
204 finally {
205 closeSession(session);
206 }
207 }
208
209 public TagsProperty remove(TagsProperty tagsProperty)
210 throws SystemException {
211 for (ModelListener<TagsProperty> listener : listeners) {
212 listener.onBeforeRemove(tagsProperty);
213 }
214
215 tagsProperty = removeImpl(tagsProperty);
216
217 for (ModelListener<TagsProperty> listener : listeners) {
218 listener.onAfterRemove(tagsProperty);
219 }
220
221 return tagsProperty;
222 }
223
224 protected TagsProperty removeImpl(TagsProperty tagsProperty)
225 throws SystemException {
226 tagsProperty = toUnwrappedModel(tagsProperty);
227
228 Session session = null;
229
230 try {
231 session = openSession();
232
233 if (tagsProperty.isCachedModel() || BatchSessionUtil.isEnabled()) {
234 Object staleObject = session.get(TagsPropertyImpl.class,
235 tagsProperty.getPrimaryKeyObj());
236
237 if (staleObject != null) {
238 session.evict(staleObject);
239 }
240 }
241
242 session.delete(tagsProperty);
243
244 session.flush();
245 }
246 catch (Exception e) {
247 throw processException(e);
248 }
249 finally {
250 closeSession(session);
251 }
252
253 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
254
255 TagsPropertyModelImpl tagsPropertyModelImpl = (TagsPropertyModelImpl)tagsProperty;
256
257 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_E_K,
258 new Object[] {
259 new Long(tagsPropertyModelImpl.getOriginalEntryId()),
260
261 tagsPropertyModelImpl.getOriginalKey()
262 });
263
264 EntityCacheUtil.removeResult(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
265 TagsPropertyImpl.class, tagsProperty.getPrimaryKey());
266
267 return tagsProperty;
268 }
269
270
273 public TagsProperty update(TagsProperty tagsProperty)
274 throws SystemException {
275 if (_log.isWarnEnabled()) {
276 _log.warn(
277 "Using the deprecated update(TagsProperty tagsProperty) method. Use update(TagsProperty tagsProperty, boolean merge) instead.");
278 }
279
280 return update(tagsProperty, false);
281 }
282
283 public TagsProperty updateImpl(
284 com.liferay.portlet.tags.model.TagsProperty tagsProperty, boolean merge)
285 throws SystemException {
286 tagsProperty = toUnwrappedModel(tagsProperty);
287
288 boolean isNew = tagsProperty.isNew();
289
290 TagsPropertyModelImpl tagsPropertyModelImpl = (TagsPropertyModelImpl)tagsProperty;
291
292 Session session = null;
293
294 try {
295 session = openSession();
296
297 BatchSessionUtil.update(session, tagsProperty, merge);
298
299 tagsProperty.setNew(false);
300 }
301 catch (Exception e) {
302 throw processException(e);
303 }
304 finally {
305 closeSession(session);
306 }
307
308 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
309
310 EntityCacheUtil.putResult(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
311 TagsPropertyImpl.class, tagsProperty.getPrimaryKey(), tagsProperty);
312
313 if (!isNew &&
314 ((tagsProperty.getEntryId() != tagsPropertyModelImpl.getOriginalEntryId()) ||
315 !Validator.equals(tagsProperty.getKey(),
316 tagsPropertyModelImpl.getOriginalKey()))) {
317 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_E_K,
318 new Object[] {
319 new Long(tagsPropertyModelImpl.getOriginalEntryId()),
320
321 tagsPropertyModelImpl.getOriginalKey()
322 });
323 }
324
325 if (isNew ||
326 ((tagsProperty.getEntryId() != tagsPropertyModelImpl.getOriginalEntryId()) ||
327 !Validator.equals(tagsProperty.getKey(),
328 tagsPropertyModelImpl.getOriginalKey()))) {
329 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_K,
330 new Object[] {
331 new Long(tagsProperty.getEntryId()),
332
333 tagsProperty.getKey()
334 }, tagsProperty);
335 }
336
337 return tagsProperty;
338 }
339
340 protected TagsProperty toUnwrappedModel(TagsProperty tagsProperty) {
341 if (tagsProperty instanceof TagsPropertyImpl) {
342 return tagsProperty;
343 }
344
345 TagsPropertyImpl tagsPropertyImpl = new TagsPropertyImpl();
346
347 tagsPropertyImpl.setNew(tagsProperty.isNew());
348 tagsPropertyImpl.setPrimaryKey(tagsProperty.getPrimaryKey());
349
350 tagsPropertyImpl.setPropertyId(tagsProperty.getPropertyId());
351 tagsPropertyImpl.setCompanyId(tagsProperty.getCompanyId());
352 tagsPropertyImpl.setUserId(tagsProperty.getUserId());
353 tagsPropertyImpl.setUserName(tagsProperty.getUserName());
354 tagsPropertyImpl.setCreateDate(tagsProperty.getCreateDate());
355 tagsPropertyImpl.setModifiedDate(tagsProperty.getModifiedDate());
356 tagsPropertyImpl.setEntryId(tagsProperty.getEntryId());
357 tagsPropertyImpl.setKey(tagsProperty.getKey());
358 tagsPropertyImpl.setValue(tagsProperty.getValue());
359
360 return tagsPropertyImpl;
361 }
362
363 public TagsProperty findByPrimaryKey(Serializable primaryKey)
364 throws NoSuchModelException, SystemException {
365 return findByPrimaryKey(((Long)primaryKey).longValue());
366 }
367
368 public TagsProperty findByPrimaryKey(long propertyId)
369 throws NoSuchPropertyException, SystemException {
370 TagsProperty tagsProperty = fetchByPrimaryKey(propertyId);
371
372 if (tagsProperty == null) {
373 if (_log.isWarnEnabled()) {
374 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + propertyId);
375 }
376
377 throw new NoSuchPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
378 propertyId);
379 }
380
381 return tagsProperty;
382 }
383
384 public TagsProperty fetchByPrimaryKey(Serializable primaryKey)
385 throws SystemException {
386 return fetchByPrimaryKey(((Long)primaryKey).longValue());
387 }
388
389 public TagsProperty fetchByPrimaryKey(long propertyId)
390 throws SystemException {
391 TagsProperty tagsProperty = (TagsProperty)EntityCacheUtil.getResult(TagsPropertyModelImpl.ENTITY_CACHE_ENABLED,
392 TagsPropertyImpl.class, propertyId, this);
393
394 if (tagsProperty == null) {
395 Session session = null;
396
397 try {
398 session = openSession();
399
400 tagsProperty = (TagsProperty)session.get(TagsPropertyImpl.class,
401 new Long(propertyId));
402 }
403 catch (Exception e) {
404 throw processException(e);
405 }
406 finally {
407 if (tagsProperty != null) {
408 cacheResult(tagsProperty);
409 }
410
411 closeSession(session);
412 }
413 }
414
415 return tagsProperty;
416 }
417
418 public List<TagsProperty> findByCompanyId(long companyId)
419 throws SystemException {
420 Object[] finderArgs = new Object[] { new Long(companyId) };
421
422 List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
423 finderArgs, this);
424
425 if (list == null) {
426 Session session = null;
427
428 try {
429 session = openSession();
430
431 StringBundler query = new StringBundler(3);
432
433 query.append(_SQL_SELECT_TAGSPROPERTY_WHERE);
434
435 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
436
437 query.append(TagsPropertyModelImpl.ORDER_BY_JPQL);
438
439 String sql = query.toString();
440
441 Query q = session.createQuery(sql);
442
443 QueryPos qPos = QueryPos.getInstance(q);
444
445 qPos.add(companyId);
446
447 list = q.list();
448 }
449 catch (Exception e) {
450 throw processException(e);
451 }
452 finally {
453 if (list == null) {
454 list = new ArrayList<TagsProperty>();
455 }
456
457 cacheResult(list);
458
459 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
460 finderArgs, list);
461
462 closeSession(session);
463 }
464 }
465
466 return list;
467 }
468
469 public List<TagsProperty> findByCompanyId(long companyId, int start, int end)
470 throws SystemException {
471 return findByCompanyId(companyId, start, end, null);
472 }
473
474 public List<TagsProperty> findByCompanyId(long companyId, int start,
475 int end, OrderByComparator orderByComparator) throws SystemException {
476 Object[] finderArgs = new Object[] {
477 new Long(companyId),
478
479 String.valueOf(start), String.valueOf(end),
480 String.valueOf(orderByComparator)
481 };
482
483 List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
484 finderArgs, this);
485
486 if (list == null) {
487 Session session = null;
488
489 try {
490 session = openSession();
491
492 StringBundler query = null;
493
494 if (orderByComparator != null) {
495 query = new StringBundler(3 +
496 (orderByComparator.getOrderByFields().length * 3));
497 }
498 else {
499 query = new StringBundler(3);
500 }
501
502 query.append(_SQL_SELECT_TAGSPROPERTY_WHERE);
503
504 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
505
506 if (orderByComparator != null) {
507 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
508 orderByComparator);
509 }
510
511 else {
512 query.append(TagsPropertyModelImpl.ORDER_BY_JPQL);
513 }
514
515 String sql = query.toString();
516
517 Query q = session.createQuery(sql);
518
519 QueryPos qPos = QueryPos.getInstance(q);
520
521 qPos.add(companyId);
522
523 list = (List<TagsProperty>)QueryUtil.list(q, getDialect(),
524 start, end);
525 }
526 catch (Exception e) {
527 throw processException(e);
528 }
529 finally {
530 if (list == null) {
531 list = new ArrayList<TagsProperty>();
532 }
533
534 cacheResult(list);
535
536 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
537 finderArgs, list);
538
539 closeSession(session);
540 }
541 }
542
543 return list;
544 }
545
546 public TagsProperty findByCompanyId_First(long companyId,
547 OrderByComparator orderByComparator)
548 throws NoSuchPropertyException, SystemException {
549 List<TagsProperty> list = findByCompanyId(companyId, 0, 1,
550 orderByComparator);
551
552 if (list.isEmpty()) {
553 StringBundler msg = new StringBundler(4);
554
555 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
556
557 msg.append("companyId=");
558 msg.append(companyId);
559
560 msg.append(StringPool.CLOSE_CURLY_BRACE);
561
562 throw new NoSuchPropertyException(msg.toString());
563 }
564 else {
565 return list.get(0);
566 }
567 }
568
569 public TagsProperty findByCompanyId_Last(long companyId,
570 OrderByComparator orderByComparator)
571 throws NoSuchPropertyException, SystemException {
572 int count = countByCompanyId(companyId);
573
574 List<TagsProperty> list = findByCompanyId(companyId, count - 1, count,
575 orderByComparator);
576
577 if (list.isEmpty()) {
578 StringBundler msg = new StringBundler(4);
579
580 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
581
582 msg.append("companyId=");
583 msg.append(companyId);
584
585 msg.append(StringPool.CLOSE_CURLY_BRACE);
586
587 throw new NoSuchPropertyException(msg.toString());
588 }
589 else {
590 return list.get(0);
591 }
592 }
593
594 public TagsProperty[] findByCompanyId_PrevAndNext(long propertyId,
595 long companyId, OrderByComparator orderByComparator)
596 throws NoSuchPropertyException, SystemException {
597 TagsProperty tagsProperty = findByPrimaryKey(propertyId);
598
599 int count = countByCompanyId(companyId);
600
601 Session session = null;
602
603 try {
604 session = openSession();
605
606 StringBundler query = null;
607
608 if (orderByComparator != null) {
609 query = new StringBundler(3 +
610 (orderByComparator.getOrderByFields().length * 3));
611 }
612 else {
613 query = new StringBundler(3);
614 }
615
616 query.append(_SQL_SELECT_TAGSPROPERTY_WHERE);
617
618 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
619
620 if (orderByComparator != null) {
621 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
622 orderByComparator);
623 }
624
625 else {
626 query.append(TagsPropertyModelImpl.ORDER_BY_JPQL);
627 }
628
629 String sql = query.toString();
630
631 Query q = session.createQuery(sql);
632
633 QueryPos qPos = QueryPos.getInstance(q);
634
635 qPos.add(companyId);
636
637 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
638 orderByComparator, tagsProperty);
639
640 TagsProperty[] array = new TagsPropertyImpl[3];
641
642 array[0] = (TagsProperty)objArray[0];
643 array[1] = (TagsProperty)objArray[1];
644 array[2] = (TagsProperty)objArray[2];
645
646 return array;
647 }
648 catch (Exception e) {
649 throw processException(e);
650 }
651 finally {
652 closeSession(session);
653 }
654 }
655
656 public List<TagsProperty> findByEntryId(long entryId)
657 throws SystemException {
658 Object[] finderArgs = new Object[] { new Long(entryId) };
659
660 List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ENTRYID,
661 finderArgs, this);
662
663 if (list == null) {
664 Session session = null;
665
666 try {
667 session = openSession();
668
669 StringBundler query = new StringBundler(3);
670
671 query.append(_SQL_SELECT_TAGSPROPERTY_WHERE);
672
673 query.append(_FINDER_COLUMN_ENTRYID_ENTRYID_2);
674
675 query.append(TagsPropertyModelImpl.ORDER_BY_JPQL);
676
677 String sql = query.toString();
678
679 Query q = session.createQuery(sql);
680
681 QueryPos qPos = QueryPos.getInstance(q);
682
683 qPos.add(entryId);
684
685 list = q.list();
686 }
687 catch (Exception e) {
688 throw processException(e);
689 }
690 finally {
691 if (list == null) {
692 list = new ArrayList<TagsProperty>();
693 }
694
695 cacheResult(list);
696
697 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ENTRYID,
698 finderArgs, list);
699
700 closeSession(session);
701 }
702 }
703
704 return list;
705 }
706
707 public List<TagsProperty> findByEntryId(long entryId, int start, int end)
708 throws SystemException {
709 return findByEntryId(entryId, start, end, null);
710 }
711
712 public List<TagsProperty> findByEntryId(long entryId, int start, int end,
713 OrderByComparator orderByComparator) throws SystemException {
714 Object[] finderArgs = new Object[] {
715 new Long(entryId),
716
717 String.valueOf(start), String.valueOf(end),
718 String.valueOf(orderByComparator)
719 };
720
721 List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ENTRYID,
722 finderArgs, this);
723
724 if (list == null) {
725 Session session = null;
726
727 try {
728 session = openSession();
729
730 StringBundler query = null;
731
732 if (orderByComparator != null) {
733 query = new StringBundler(3 +
734 (orderByComparator.getOrderByFields().length * 3));
735 }
736 else {
737 query = new StringBundler(3);
738 }
739
740 query.append(_SQL_SELECT_TAGSPROPERTY_WHERE);
741
742 query.append(_FINDER_COLUMN_ENTRYID_ENTRYID_2);
743
744 if (orderByComparator != null) {
745 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
746 orderByComparator);
747 }
748
749 else {
750 query.append(TagsPropertyModelImpl.ORDER_BY_JPQL);
751 }
752
753 String sql = query.toString();
754
755 Query q = session.createQuery(sql);
756
757 QueryPos qPos = QueryPos.getInstance(q);
758
759 qPos.add(entryId);
760
761 list = (List<TagsProperty>)QueryUtil.list(q, getDialect(),
762 start, end);
763 }
764 catch (Exception e) {
765 throw processException(e);
766 }
767 finally {
768 if (list == null) {
769 list = new ArrayList<TagsProperty>();
770 }
771
772 cacheResult(list);
773
774 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ENTRYID,
775 finderArgs, list);
776
777 closeSession(session);
778 }
779 }
780
781 return list;
782 }
783
784 public TagsProperty findByEntryId_First(long entryId,
785 OrderByComparator orderByComparator)
786 throws NoSuchPropertyException, SystemException {
787 List<TagsProperty> list = findByEntryId(entryId, 0, 1, orderByComparator);
788
789 if (list.isEmpty()) {
790 StringBundler msg = new StringBundler(4);
791
792 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
793
794 msg.append("entryId=");
795 msg.append(entryId);
796
797 msg.append(StringPool.CLOSE_CURLY_BRACE);
798
799 throw new NoSuchPropertyException(msg.toString());
800 }
801 else {
802 return list.get(0);
803 }
804 }
805
806 public TagsProperty findByEntryId_Last(long entryId,
807 OrderByComparator orderByComparator)
808 throws NoSuchPropertyException, SystemException {
809 int count = countByEntryId(entryId);
810
811 List<TagsProperty> list = findByEntryId(entryId, count - 1, count,
812 orderByComparator);
813
814 if (list.isEmpty()) {
815 StringBundler msg = new StringBundler(4);
816
817 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
818
819 msg.append("entryId=");
820 msg.append(entryId);
821
822 msg.append(StringPool.CLOSE_CURLY_BRACE);
823
824 throw new NoSuchPropertyException(msg.toString());
825 }
826 else {
827 return list.get(0);
828 }
829 }
830
831 public TagsProperty[] findByEntryId_PrevAndNext(long propertyId,
832 long entryId, OrderByComparator orderByComparator)
833 throws NoSuchPropertyException, SystemException {
834 TagsProperty tagsProperty = findByPrimaryKey(propertyId);
835
836 int count = countByEntryId(entryId);
837
838 Session session = null;
839
840 try {
841 session = openSession();
842
843 StringBundler query = null;
844
845 if (orderByComparator != null) {
846 query = new StringBundler(3 +
847 (orderByComparator.getOrderByFields().length * 3));
848 }
849 else {
850 query = new StringBundler(3);
851 }
852
853 query.append(_SQL_SELECT_TAGSPROPERTY_WHERE);
854
855 query.append(_FINDER_COLUMN_ENTRYID_ENTRYID_2);
856
857 if (orderByComparator != null) {
858 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
859 orderByComparator);
860 }
861
862 else {
863 query.append(TagsPropertyModelImpl.ORDER_BY_JPQL);
864 }
865
866 String sql = query.toString();
867
868 Query q = session.createQuery(sql);
869
870 QueryPos qPos = QueryPos.getInstance(q);
871
872 qPos.add(entryId);
873
874 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
875 orderByComparator, tagsProperty);
876
877 TagsProperty[] array = new TagsPropertyImpl[3];
878
879 array[0] = (TagsProperty)objArray[0];
880 array[1] = (TagsProperty)objArray[1];
881 array[2] = (TagsProperty)objArray[2];
882
883 return array;
884 }
885 catch (Exception e) {
886 throw processException(e);
887 }
888 finally {
889 closeSession(session);
890 }
891 }
892
893 public List<TagsProperty> findByC_K(long companyId, String key)
894 throws SystemException {
895 Object[] finderArgs = new Object[] { new Long(companyId), key };
896
897 List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_K,
898 finderArgs, this);
899
900 if (list == null) {
901 Session session = null;
902
903 try {
904 session = openSession();
905
906 StringBundler query = new StringBundler(4);
907
908 query.append(_SQL_SELECT_TAGSPROPERTY_WHERE);
909
910 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
911
912 if (key == null) {
913 query.append(_FINDER_COLUMN_C_K_KEY_1);
914 }
915 else {
916 if (key.equals(StringPool.BLANK)) {
917 query.append(_FINDER_COLUMN_C_K_KEY_3);
918 }
919 else {
920 query.append(_FINDER_COLUMN_C_K_KEY_2);
921 }
922 }
923
924 query.append(TagsPropertyModelImpl.ORDER_BY_JPQL);
925
926 String sql = query.toString();
927
928 Query q = session.createQuery(sql);
929
930 QueryPos qPos = QueryPos.getInstance(q);
931
932 qPos.add(companyId);
933
934 if (key != null) {
935 qPos.add(key);
936 }
937
938 list = q.list();
939 }
940 catch (Exception e) {
941 throw processException(e);
942 }
943 finally {
944 if (list == null) {
945 list = new ArrayList<TagsProperty>();
946 }
947
948 cacheResult(list);
949
950 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_K, finderArgs,
951 list);
952
953 closeSession(session);
954 }
955 }
956
957 return list;
958 }
959
960 public List<TagsProperty> findByC_K(long companyId, String key, int start,
961 int end) throws SystemException {
962 return findByC_K(companyId, key, start, end, null);
963 }
964
965 public List<TagsProperty> findByC_K(long companyId, String key, int start,
966 int end, OrderByComparator orderByComparator) throws SystemException {
967 Object[] finderArgs = new Object[] {
968 new Long(companyId),
969
970 key,
971
972 String.valueOf(start), String.valueOf(end),
973 String.valueOf(orderByComparator)
974 };
975
976 List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_K,
977 finderArgs, this);
978
979 if (list == null) {
980 Session session = null;
981
982 try {
983 session = openSession();
984
985 StringBundler query = null;
986
987 if (orderByComparator != null) {
988 query = new StringBundler(4 +
989 (orderByComparator.getOrderByFields().length * 3));
990 }
991 else {
992 query = new StringBundler(4);
993 }
994
995 query.append(_SQL_SELECT_TAGSPROPERTY_WHERE);
996
997 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
998
999 if (key == null) {
1000 query.append(_FINDER_COLUMN_C_K_KEY_1);
1001 }
1002 else {
1003 if (key.equals(StringPool.BLANK)) {
1004 query.append(_FINDER_COLUMN_C_K_KEY_3);
1005 }
1006 else {
1007 query.append(_FINDER_COLUMN_C_K_KEY_2);
1008 }
1009 }
1010
1011 if (orderByComparator != null) {
1012 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1013 orderByComparator);
1014 }
1015
1016 else {
1017 query.append(TagsPropertyModelImpl.ORDER_BY_JPQL);
1018 }
1019
1020 String sql = query.toString();
1021
1022 Query q = session.createQuery(sql);
1023
1024 QueryPos qPos = QueryPos.getInstance(q);
1025
1026 qPos.add(companyId);
1027
1028 if (key != null) {
1029 qPos.add(key);
1030 }
1031
1032 list = (List<TagsProperty>)QueryUtil.list(q, getDialect(),
1033 start, end);
1034 }
1035 catch (Exception e) {
1036 throw processException(e);
1037 }
1038 finally {
1039 if (list == null) {
1040 list = new ArrayList<TagsProperty>();
1041 }
1042
1043 cacheResult(list);
1044
1045 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_K,
1046 finderArgs, list);
1047
1048 closeSession(session);
1049 }
1050 }
1051
1052 return list;
1053 }
1054
1055 public TagsProperty findByC_K_First(long companyId, String key,
1056 OrderByComparator orderByComparator)
1057 throws NoSuchPropertyException, SystemException {
1058 List<TagsProperty> list = findByC_K(companyId, key, 0, 1,
1059 orderByComparator);
1060
1061 if (list.isEmpty()) {
1062 StringBundler msg = new StringBundler(6);
1063
1064 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1065
1066 msg.append("companyId=");
1067 msg.append(companyId);
1068
1069 msg.append(", key=");
1070 msg.append(key);
1071
1072 msg.append(StringPool.CLOSE_CURLY_BRACE);
1073
1074 throw new NoSuchPropertyException(msg.toString());
1075 }
1076 else {
1077 return list.get(0);
1078 }
1079 }
1080
1081 public TagsProperty findByC_K_Last(long companyId, String key,
1082 OrderByComparator orderByComparator)
1083 throws NoSuchPropertyException, SystemException {
1084 int count = countByC_K(companyId, key);
1085
1086 List<TagsProperty> list = findByC_K(companyId, key, count - 1, count,
1087 orderByComparator);
1088
1089 if (list.isEmpty()) {
1090 StringBundler msg = new StringBundler(6);
1091
1092 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1093
1094 msg.append("companyId=");
1095 msg.append(companyId);
1096
1097 msg.append(", key=");
1098 msg.append(key);
1099
1100 msg.append(StringPool.CLOSE_CURLY_BRACE);
1101
1102 throw new NoSuchPropertyException(msg.toString());
1103 }
1104 else {
1105 return list.get(0);
1106 }
1107 }
1108
1109 public TagsProperty[] findByC_K_PrevAndNext(long propertyId,
1110 long companyId, String key, OrderByComparator orderByComparator)
1111 throws NoSuchPropertyException, SystemException {
1112 TagsProperty tagsProperty = findByPrimaryKey(propertyId);
1113
1114 int count = countByC_K(companyId, key);
1115
1116 Session session = null;
1117
1118 try {
1119 session = openSession();
1120
1121 StringBundler query = null;
1122
1123 if (orderByComparator != null) {
1124 query = new StringBundler(4 +
1125 (orderByComparator.getOrderByFields().length * 3));
1126 }
1127 else {
1128 query = new StringBundler(4);
1129 }
1130
1131 query.append(_SQL_SELECT_TAGSPROPERTY_WHERE);
1132
1133 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1134
1135 if (key == null) {
1136 query.append(_FINDER_COLUMN_C_K_KEY_1);
1137 }
1138 else {
1139 if (key.equals(StringPool.BLANK)) {
1140 query.append(_FINDER_COLUMN_C_K_KEY_3);
1141 }
1142 else {
1143 query.append(_FINDER_COLUMN_C_K_KEY_2);
1144 }
1145 }
1146
1147 if (orderByComparator != null) {
1148 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1149 orderByComparator);
1150 }
1151
1152 else {
1153 query.append(TagsPropertyModelImpl.ORDER_BY_JPQL);
1154 }
1155
1156 String sql = query.toString();
1157
1158 Query q = session.createQuery(sql);
1159
1160 QueryPos qPos = QueryPos.getInstance(q);
1161
1162 qPos.add(companyId);
1163
1164 if (key != null) {
1165 qPos.add(key);
1166 }
1167
1168 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1169 orderByComparator, tagsProperty);
1170
1171 TagsProperty[] array = new TagsPropertyImpl[3];
1172
1173 array[0] = (TagsProperty)objArray[0];
1174 array[1] = (TagsProperty)objArray[1];
1175 array[2] = (TagsProperty)objArray[2];
1176
1177 return array;
1178 }
1179 catch (Exception e) {
1180 throw processException(e);
1181 }
1182 finally {
1183 closeSession(session);
1184 }
1185 }
1186
1187 public TagsProperty findByE_K(long entryId, String key)
1188 throws NoSuchPropertyException, SystemException {
1189 TagsProperty tagsProperty = fetchByE_K(entryId, key);
1190
1191 if (tagsProperty == null) {
1192 StringBundler msg = new StringBundler(6);
1193
1194 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1195
1196 msg.append("entryId=");
1197 msg.append(entryId);
1198
1199 msg.append(", key=");
1200 msg.append(key);
1201
1202 msg.append(StringPool.CLOSE_CURLY_BRACE);
1203
1204 if (_log.isWarnEnabled()) {
1205 _log.warn(msg.toString());
1206 }
1207
1208 throw new NoSuchPropertyException(msg.toString());
1209 }
1210
1211 return tagsProperty;
1212 }
1213
1214 public TagsProperty fetchByE_K(long entryId, String key)
1215 throws SystemException {
1216 return fetchByE_K(entryId, key, true);
1217 }
1218
1219 public TagsProperty fetchByE_K(long entryId, String key,
1220 boolean retrieveFromCache) throws SystemException {
1221 Object[] finderArgs = new Object[] { new Long(entryId), key };
1222
1223 Object result = null;
1224
1225 if (retrieveFromCache) {
1226 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_E_K,
1227 finderArgs, this);
1228 }
1229
1230 if (result == null) {
1231 Session session = null;
1232
1233 try {
1234 session = openSession();
1235
1236 StringBundler query = new StringBundler(4);
1237
1238 query.append(_SQL_SELECT_TAGSPROPERTY_WHERE);
1239
1240 query.append(_FINDER_COLUMN_E_K_ENTRYID_2);
1241
1242 if (key == null) {
1243 query.append(_FINDER_COLUMN_E_K_KEY_1);
1244 }
1245 else {
1246 if (key.equals(StringPool.BLANK)) {
1247 query.append(_FINDER_COLUMN_E_K_KEY_3);
1248 }
1249 else {
1250 query.append(_FINDER_COLUMN_E_K_KEY_2);
1251 }
1252 }
1253
1254 query.append(TagsPropertyModelImpl.ORDER_BY_JPQL);
1255
1256 String sql = query.toString();
1257
1258 Query q = session.createQuery(sql);
1259
1260 QueryPos qPos = QueryPos.getInstance(q);
1261
1262 qPos.add(entryId);
1263
1264 if (key != null) {
1265 qPos.add(key);
1266 }
1267
1268 List<TagsProperty> list = q.list();
1269
1270 result = list;
1271
1272 TagsProperty tagsProperty = null;
1273
1274 if (list.isEmpty()) {
1275 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_K,
1276 finderArgs, list);
1277 }
1278 else {
1279 tagsProperty = list.get(0);
1280
1281 cacheResult(tagsProperty);
1282
1283 if ((tagsProperty.getEntryId() != entryId) ||
1284 (tagsProperty.getKey() == null) ||
1285 !tagsProperty.getKey().equals(key)) {
1286 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_K,
1287 finderArgs, tagsProperty);
1288 }
1289 }
1290
1291 return tagsProperty;
1292 }
1293 catch (Exception e) {
1294 throw processException(e);
1295 }
1296 finally {
1297 if (result == null) {
1298 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_K,
1299 finderArgs, new ArrayList<TagsProperty>());
1300 }
1301
1302 closeSession(session);
1303 }
1304 }
1305 else {
1306 if (result instanceof List<?>) {
1307 return null;
1308 }
1309 else {
1310 return (TagsProperty)result;
1311 }
1312 }
1313 }
1314
1315 public List<TagsProperty> findAll() throws SystemException {
1316 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1317 }
1318
1319 public List<TagsProperty> findAll(int start, int end)
1320 throws SystemException {
1321 return findAll(start, end, null);
1322 }
1323
1324 public List<TagsProperty> findAll(int start, int end,
1325 OrderByComparator orderByComparator) throws SystemException {
1326 Object[] finderArgs = new Object[] {
1327 String.valueOf(start), String.valueOf(end),
1328 String.valueOf(orderByComparator)
1329 };
1330
1331 List<TagsProperty> list = (List<TagsProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1332 finderArgs, this);
1333
1334 if (list == null) {
1335 Session session = null;
1336
1337 try {
1338 session = openSession();
1339
1340 StringBundler query = null;
1341 String sql = null;
1342
1343 if (orderByComparator != null) {
1344 query = new StringBundler(2 +
1345 (orderByComparator.getOrderByFields().length * 3));
1346
1347 query.append(_SQL_SELECT_TAGSPROPERTY);
1348
1349 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1350 orderByComparator);
1351
1352 sql = query.toString();
1353 }
1354
1355 else {
1356 sql = _SQL_SELECT_TAGSPROPERTY.concat(TagsPropertyModelImpl.ORDER_BY_JPQL);
1357 }
1358
1359 Query q = session.createQuery(sql);
1360
1361 if (orderByComparator == null) {
1362 list = (List<TagsProperty>)QueryUtil.list(q, getDialect(),
1363 start, end, false);
1364
1365 Collections.sort(list);
1366 }
1367 else {
1368 list = (List<TagsProperty>)QueryUtil.list(q, getDialect(),
1369 start, end);
1370 }
1371 }
1372 catch (Exception e) {
1373 throw processException(e);
1374 }
1375 finally {
1376 if (list == null) {
1377 list = new ArrayList<TagsProperty>();
1378 }
1379
1380 cacheResult(list);
1381
1382 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1383
1384 closeSession(session);
1385 }
1386 }
1387
1388 return list;
1389 }
1390
1391 public void removeByCompanyId(long companyId) throws SystemException {
1392 for (TagsProperty tagsProperty : findByCompanyId(companyId)) {
1393 remove(tagsProperty);
1394 }
1395 }
1396
1397 public void removeByEntryId(long entryId) throws SystemException {
1398 for (TagsProperty tagsProperty : findByEntryId(entryId)) {
1399 remove(tagsProperty);
1400 }
1401 }
1402
1403 public void removeByC_K(long companyId, String key)
1404 throws SystemException {
1405 for (TagsProperty tagsProperty : findByC_K(companyId, key)) {
1406 remove(tagsProperty);
1407 }
1408 }
1409
1410 public void removeByE_K(long entryId, String key)
1411 throws NoSuchPropertyException, SystemException {
1412 TagsProperty tagsProperty = findByE_K(entryId, key);
1413
1414 remove(tagsProperty);
1415 }
1416
1417 public void removeAll() throws SystemException {
1418 for (TagsProperty tagsProperty : findAll()) {
1419 remove(tagsProperty);
1420 }
1421 }
1422
1423 public int countByCompanyId(long companyId) throws SystemException {
1424 Object[] finderArgs = new Object[] { new Long(companyId) };
1425
1426 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1427 finderArgs, this);
1428
1429 if (count == null) {
1430 Session session = null;
1431
1432 try {
1433 session = openSession();
1434
1435 StringBundler query = new StringBundler(2);
1436
1437 query.append(_SQL_COUNT_TAGSPROPERTY_WHERE);
1438
1439 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1440
1441 String sql = query.toString();
1442
1443 Query q = session.createQuery(sql);
1444
1445 QueryPos qPos = QueryPos.getInstance(q);
1446
1447 qPos.add(companyId);
1448
1449 count = (Long)q.uniqueResult();
1450 }
1451 catch (Exception e) {
1452 throw processException(e);
1453 }
1454 finally {
1455 if (count == null) {
1456 count = Long.valueOf(0);
1457 }
1458
1459 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1460 finderArgs, count);
1461
1462 closeSession(session);
1463 }
1464 }
1465
1466 return count.intValue();
1467 }
1468
1469 public int countByEntryId(long entryId) throws SystemException {
1470 Object[] finderArgs = new Object[] { new Long(entryId) };
1471
1472 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ENTRYID,
1473 finderArgs, this);
1474
1475 if (count == null) {
1476 Session session = null;
1477
1478 try {
1479 session = openSession();
1480
1481 StringBundler query = new StringBundler(2);
1482
1483 query.append(_SQL_COUNT_TAGSPROPERTY_WHERE);
1484
1485 query.append(_FINDER_COLUMN_ENTRYID_ENTRYID_2);
1486
1487 String sql = query.toString();
1488
1489 Query q = session.createQuery(sql);
1490
1491 QueryPos qPos = QueryPos.getInstance(q);
1492
1493 qPos.add(entryId);
1494
1495 count = (Long)q.uniqueResult();
1496 }
1497 catch (Exception e) {
1498 throw processException(e);
1499 }
1500 finally {
1501 if (count == null) {
1502 count = Long.valueOf(0);
1503 }
1504
1505 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ENTRYID,
1506 finderArgs, count);
1507
1508 closeSession(session);
1509 }
1510 }
1511
1512 return count.intValue();
1513 }
1514
1515 public int countByC_K(long companyId, String key) throws SystemException {
1516 Object[] finderArgs = new Object[] { new Long(companyId), key };
1517
1518 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_K,
1519 finderArgs, this);
1520
1521 if (count == null) {
1522 Session session = null;
1523
1524 try {
1525 session = openSession();
1526
1527 StringBundler query = new StringBundler(3);
1528
1529 query.append(_SQL_COUNT_TAGSPROPERTY_WHERE);
1530
1531 query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1532
1533 if (key == null) {
1534 query.append(_FINDER_COLUMN_C_K_KEY_1);
1535 }
1536 else {
1537 if (key.equals(StringPool.BLANK)) {
1538 query.append(_FINDER_COLUMN_C_K_KEY_3);
1539 }
1540 else {
1541 query.append(_FINDER_COLUMN_C_K_KEY_2);
1542 }
1543 }
1544
1545 String sql = query.toString();
1546
1547 Query q = session.createQuery(sql);
1548
1549 QueryPos qPos = QueryPos.getInstance(q);
1550
1551 qPos.add(companyId);
1552
1553 if (key != null) {
1554 qPos.add(key);
1555 }
1556
1557 count = (Long)q.uniqueResult();
1558 }
1559 catch (Exception e) {
1560 throw processException(e);
1561 }
1562 finally {
1563 if (count == null) {
1564 count = Long.valueOf(0);
1565 }
1566
1567 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, finderArgs,
1568 count);
1569
1570 closeSession(session);
1571 }
1572 }
1573
1574 return count.intValue();
1575 }
1576
1577 public int countByE_K(long entryId, String key) throws SystemException {
1578 Object[] finderArgs = new Object[] { new Long(entryId), key };
1579
1580 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_E_K,
1581 finderArgs, this);
1582
1583 if (count == null) {
1584 Session session = null;
1585
1586 try {
1587 session = openSession();
1588
1589 StringBundler query = new StringBundler(3);
1590
1591 query.append(_SQL_COUNT_TAGSPROPERTY_WHERE);
1592
1593 query.append(_FINDER_COLUMN_E_K_ENTRYID_2);
1594
1595 if (key == null) {
1596 query.append(_FINDER_COLUMN_E_K_KEY_1);
1597 }
1598 else {
1599 if (key.equals(StringPool.BLANK)) {
1600 query.append(_FINDER_COLUMN_E_K_KEY_3);
1601 }
1602 else {
1603 query.append(_FINDER_COLUMN_E_K_KEY_2);
1604 }
1605 }
1606
1607 String sql = query.toString();
1608
1609 Query q = session.createQuery(sql);
1610
1611 QueryPos qPos = QueryPos.getInstance(q);
1612
1613 qPos.add(entryId);
1614
1615 if (key != null) {
1616 qPos.add(key);
1617 }
1618
1619 count = (Long)q.uniqueResult();
1620 }
1621 catch (Exception e) {
1622 throw processException(e);
1623 }
1624 finally {
1625 if (count == null) {
1626 count = Long.valueOf(0);
1627 }
1628
1629 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_E_K, finderArgs,
1630 count);
1631
1632 closeSession(session);
1633 }
1634 }
1635
1636 return count.intValue();
1637 }
1638
1639 public int countAll() throws SystemException {
1640 Object[] finderArgs = new Object[0];
1641
1642 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1643 finderArgs, this);
1644
1645 if (count == null) {
1646 Session session = null;
1647
1648 try {
1649 session = openSession();
1650
1651 Query q = session.createQuery(_SQL_COUNT_TAGSPROPERTY);
1652
1653 count = (Long)q.uniqueResult();
1654 }
1655 catch (Exception e) {
1656 throw processException(e);
1657 }
1658 finally {
1659 if (count == null) {
1660 count = Long.valueOf(0);
1661 }
1662
1663 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1664 count);
1665
1666 closeSession(session);
1667 }
1668 }
1669
1670 return count.intValue();
1671 }
1672
1673 public void afterPropertiesSet() {
1674 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1675 com.liferay.portal.util.PropsUtil.get(
1676 "value.object.listener.com.liferay.portlet.tags.model.TagsProperty")));
1677
1678 if (listenerClassNames.length > 0) {
1679 try {
1680 List<ModelListener<TagsProperty>> listenersList = new ArrayList<ModelListener<TagsProperty>>();
1681
1682 for (String listenerClassName : listenerClassNames) {
1683 listenersList.add((ModelListener<TagsProperty>)Class.forName(
1684 listenerClassName).newInstance());
1685 }
1686
1687 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1688 }
1689 catch (Exception e) {
1690 _log.error(e);
1691 }
1692 }
1693 }
1694
1695 @BeanReference(type = TagsAssetPersistence.class)
1696 protected TagsAssetPersistence tagsAssetPersistence;
1697 @BeanReference(type = TagsEntryPersistence.class)
1698 protected TagsEntryPersistence tagsEntryPersistence;
1699 @BeanReference(type = TagsPropertyPersistence.class)
1700 protected TagsPropertyPersistence tagsPropertyPersistence;
1701 @BeanReference(type = TagsSourcePersistence.class)
1702 protected TagsSourcePersistence tagsSourcePersistence;
1703 @BeanReference(type = TagsVocabularyPersistence.class)
1704 protected TagsVocabularyPersistence tagsVocabularyPersistence;
1705 @BeanReference(type = ResourcePersistence.class)
1706 protected ResourcePersistence resourcePersistence;
1707 @BeanReference(type = UserPersistence.class)
1708 protected UserPersistence userPersistence;
1709 private static final String _SQL_SELECT_TAGSPROPERTY = "SELECT tagsProperty FROM TagsProperty tagsProperty";
1710 private static final String _SQL_SELECT_TAGSPROPERTY_WHERE = "SELECT tagsProperty FROM TagsProperty tagsProperty WHERE ";
1711 private static final String _SQL_COUNT_TAGSPROPERTY = "SELECT COUNT(tagsProperty) FROM TagsProperty tagsProperty";
1712 private static final String _SQL_COUNT_TAGSPROPERTY_WHERE = "SELECT COUNT(tagsProperty) FROM TagsProperty tagsProperty WHERE ";
1713 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "tagsProperty.companyId = ?";
1714 private static final String _FINDER_COLUMN_ENTRYID_ENTRYID_2 = "tagsProperty.entryId = ?";
1715 private static final String _FINDER_COLUMN_C_K_COMPANYID_2 = "tagsProperty.companyId = ? AND ";
1716 private static final String _FINDER_COLUMN_C_K_KEY_1 = "tagsProperty.key IS NULL";
1717 private static final String _FINDER_COLUMN_C_K_KEY_2 = "tagsProperty.key = ?";
1718 private static final String _FINDER_COLUMN_C_K_KEY_3 = "(tagsProperty.key IS NULL OR tagsProperty.key = ?)";
1719 private static final String _FINDER_COLUMN_E_K_ENTRYID_2 = "tagsProperty.entryId = ? AND ";
1720 private static final String _FINDER_COLUMN_E_K_KEY_1 = "tagsProperty.key IS NULL";
1721 private static final String _FINDER_COLUMN_E_K_KEY_2 = "tagsProperty.key = ?";
1722 private static final String _FINDER_COLUMN_E_K_KEY_3 = "(tagsProperty.key IS NULL OR tagsProperty.key = ?)";
1723 private static final String _ORDER_BY_ENTITY_ALIAS = "tagsProperty.";
1724 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No TagsProperty exists with the primary key ";
1725 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No TagsProperty exists with the key {";
1726 private static Log _log = LogFactoryUtil.getLog(TagsPropertyPersistenceImpl.class);
1727}