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