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