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