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