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