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