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