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