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