001
014
015 package com.liferay.portlet.announcements.service.persistence;
016
017 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderPath;
021 import com.liferay.portal.kernel.dao.orm.Query;
022 import com.liferay.portal.kernel.dao.orm.QueryPos;
023 import com.liferay.portal.kernel.dao.orm.QueryUtil;
024 import com.liferay.portal.kernel.dao.orm.SQLQuery;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.GetterUtil;
030 import com.liferay.portal.kernel.util.InstanceFactory;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.StringUtil;
035 import com.liferay.portal.kernel.util.UnmodifiableList;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import com.liferay.portlet.announcements.NoSuchEntryException;
044 import com.liferay.portlet.announcements.model.AnnouncementsEntry;
045 import com.liferay.portlet.announcements.model.impl.AnnouncementsEntryImpl;
046 import com.liferay.portlet.announcements.model.impl.AnnouncementsEntryModelImpl;
047
048 import java.io.Serializable;
049
050 import java.util.ArrayList;
051 import java.util.Collections;
052 import java.util.List;
053
054
066 public class AnnouncementsEntryPersistenceImpl extends BasePersistenceImpl<AnnouncementsEntry>
067 implements AnnouncementsEntryPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = AnnouncementsEntryImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
079 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
080 AnnouncementsEntryImpl.class,
081 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
082 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
083 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
084 AnnouncementsEntryImpl.class,
085 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
086 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
087 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
089 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
090 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
091 AnnouncementsEntryImpl.class,
092 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
093 new String[] {
094 String.class.getName(),
095
096 Integer.class.getName(), Integer.class.getName(),
097 OrderByComparator.class.getName()
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
100 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
101 AnnouncementsEntryImpl.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
103 new String[] { String.class.getName() },
104 AnnouncementsEntryModelImpl.UUID_COLUMN_BITMASK |
105 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
106 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
107 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
108 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
109 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
110 new String[] { String.class.getName() });
111
112
119 public List<AnnouncementsEntry> findByUuid(String uuid)
120 throws SystemException {
121 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
122 }
123
124
137 public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end)
138 throws SystemException {
139 return findByUuid(uuid, start, end, null);
140 }
141
142
156 public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end,
157 OrderByComparator orderByComparator) throws SystemException {
158 boolean pagination = true;
159 FinderPath finderPath = null;
160 Object[] finderArgs = null;
161
162 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
163 (orderByComparator == null)) {
164 pagination = false;
165 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
166 finderArgs = new Object[] { uuid };
167 }
168 else {
169 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
170 finderArgs = new Object[] { uuid, start, end, orderByComparator };
171 }
172
173 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
174 finderArgs, this);
175
176 if ((list != null) && !list.isEmpty()) {
177 for (AnnouncementsEntry announcementsEntry : list) {
178 if (!Validator.equals(uuid, announcementsEntry.getUuid())) {
179 list = null;
180
181 break;
182 }
183 }
184 }
185
186 if (list == null) {
187 StringBundler query = null;
188
189 if (orderByComparator != null) {
190 query = new StringBundler(3 +
191 (orderByComparator.getOrderByFields().length * 3));
192 }
193 else {
194 query = new StringBundler(3);
195 }
196
197 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
198
199 boolean bindUuid = false;
200
201 if (uuid == null) {
202 query.append(_FINDER_COLUMN_UUID_UUID_1);
203 }
204 else if (uuid.equals(StringPool.BLANK)) {
205 query.append(_FINDER_COLUMN_UUID_UUID_3);
206 }
207 else {
208 bindUuid = true;
209
210 query.append(_FINDER_COLUMN_UUID_UUID_2);
211 }
212
213 if (orderByComparator != null) {
214 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
215 orderByComparator);
216 }
217 else
218 if (pagination) {
219 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
220 }
221
222 String sql = query.toString();
223
224 Session session = null;
225
226 try {
227 session = openSession();
228
229 Query q = session.createQuery(sql);
230
231 QueryPos qPos = QueryPos.getInstance(q);
232
233 if (bindUuid) {
234 qPos.add(uuid);
235 }
236
237 if (!pagination) {
238 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
239 getDialect(), start, end, false);
240
241 Collections.sort(list);
242
243 list = new UnmodifiableList<AnnouncementsEntry>(list);
244 }
245 else {
246 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
247 getDialect(), start, end);
248 }
249
250 cacheResult(list);
251
252 FinderCacheUtil.putResult(finderPath, finderArgs, list);
253 }
254 catch (Exception e) {
255 FinderCacheUtil.removeResult(finderPath, finderArgs);
256
257 throw processException(e);
258 }
259 finally {
260 closeSession(session);
261 }
262 }
263
264 return list;
265 }
266
267
276 public AnnouncementsEntry findByUuid_First(String uuid,
277 OrderByComparator orderByComparator)
278 throws NoSuchEntryException, SystemException {
279 AnnouncementsEntry announcementsEntry = fetchByUuid_First(uuid,
280 orderByComparator);
281
282 if (announcementsEntry != null) {
283 return announcementsEntry;
284 }
285
286 StringBundler msg = new StringBundler(4);
287
288 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
289
290 msg.append("uuid=");
291 msg.append(uuid);
292
293 msg.append(StringPool.CLOSE_CURLY_BRACE);
294
295 throw new NoSuchEntryException(msg.toString());
296 }
297
298
306 public AnnouncementsEntry fetchByUuid_First(String uuid,
307 OrderByComparator orderByComparator) throws SystemException {
308 List<AnnouncementsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
309
310 if (!list.isEmpty()) {
311 return list.get(0);
312 }
313
314 return null;
315 }
316
317
326 public AnnouncementsEntry findByUuid_Last(String uuid,
327 OrderByComparator orderByComparator)
328 throws NoSuchEntryException, SystemException {
329 AnnouncementsEntry announcementsEntry = fetchByUuid_Last(uuid,
330 orderByComparator);
331
332 if (announcementsEntry != null) {
333 return announcementsEntry;
334 }
335
336 StringBundler msg = new StringBundler(4);
337
338 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
339
340 msg.append("uuid=");
341 msg.append(uuid);
342
343 msg.append(StringPool.CLOSE_CURLY_BRACE);
344
345 throw new NoSuchEntryException(msg.toString());
346 }
347
348
356 public AnnouncementsEntry fetchByUuid_Last(String uuid,
357 OrderByComparator orderByComparator) throws SystemException {
358 int count = countByUuid(uuid);
359
360 List<AnnouncementsEntry> list = findByUuid(uuid, count - 1, count,
361 orderByComparator);
362
363 if (!list.isEmpty()) {
364 return list.get(0);
365 }
366
367 return null;
368 }
369
370
380 public AnnouncementsEntry[] findByUuid_PrevAndNext(long entryId,
381 String uuid, OrderByComparator orderByComparator)
382 throws NoSuchEntryException, SystemException {
383 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
384
385 Session session = null;
386
387 try {
388 session = openSession();
389
390 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
391
392 array[0] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
393 orderByComparator, true);
394
395 array[1] = announcementsEntry;
396
397 array[2] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
398 orderByComparator, false);
399
400 return array;
401 }
402 catch (Exception e) {
403 throw processException(e);
404 }
405 finally {
406 closeSession(session);
407 }
408 }
409
410 protected AnnouncementsEntry getByUuid_PrevAndNext(Session session,
411 AnnouncementsEntry announcementsEntry, String uuid,
412 OrderByComparator orderByComparator, boolean previous) {
413 StringBundler query = null;
414
415 if (orderByComparator != null) {
416 query = new StringBundler(6 +
417 (orderByComparator.getOrderByFields().length * 6));
418 }
419 else {
420 query = new StringBundler(3);
421 }
422
423 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
424
425 boolean bindUuid = false;
426
427 if (uuid == null) {
428 query.append(_FINDER_COLUMN_UUID_UUID_1);
429 }
430 else if (uuid.equals(StringPool.BLANK)) {
431 query.append(_FINDER_COLUMN_UUID_UUID_3);
432 }
433 else {
434 bindUuid = true;
435
436 query.append(_FINDER_COLUMN_UUID_UUID_2);
437 }
438
439 if (orderByComparator != null) {
440 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
441
442 if (orderByConditionFields.length > 0) {
443 query.append(WHERE_AND);
444 }
445
446 for (int i = 0; i < orderByConditionFields.length; i++) {
447 query.append(_ORDER_BY_ENTITY_ALIAS);
448 query.append(orderByConditionFields[i]);
449
450 if ((i + 1) < orderByConditionFields.length) {
451 if (orderByComparator.isAscending() ^ previous) {
452 query.append(WHERE_GREATER_THAN_HAS_NEXT);
453 }
454 else {
455 query.append(WHERE_LESSER_THAN_HAS_NEXT);
456 }
457 }
458 else {
459 if (orderByComparator.isAscending() ^ previous) {
460 query.append(WHERE_GREATER_THAN);
461 }
462 else {
463 query.append(WHERE_LESSER_THAN);
464 }
465 }
466 }
467
468 query.append(ORDER_BY_CLAUSE);
469
470 String[] orderByFields = orderByComparator.getOrderByFields();
471
472 for (int i = 0; i < orderByFields.length; i++) {
473 query.append(_ORDER_BY_ENTITY_ALIAS);
474 query.append(orderByFields[i]);
475
476 if ((i + 1) < orderByFields.length) {
477 if (orderByComparator.isAscending() ^ previous) {
478 query.append(ORDER_BY_ASC_HAS_NEXT);
479 }
480 else {
481 query.append(ORDER_BY_DESC_HAS_NEXT);
482 }
483 }
484 else {
485 if (orderByComparator.isAscending() ^ previous) {
486 query.append(ORDER_BY_ASC);
487 }
488 else {
489 query.append(ORDER_BY_DESC);
490 }
491 }
492 }
493 }
494 else {
495 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
496 }
497
498 String sql = query.toString();
499
500 Query q = session.createQuery(sql);
501
502 q.setFirstResult(0);
503 q.setMaxResults(2);
504
505 QueryPos qPos = QueryPos.getInstance(q);
506
507 if (bindUuid) {
508 qPos.add(uuid);
509 }
510
511 if (orderByComparator != null) {
512 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
513
514 for (Object value : values) {
515 qPos.add(value);
516 }
517 }
518
519 List<AnnouncementsEntry> list = q.list();
520
521 if (list.size() == 2) {
522 return list.get(1);
523 }
524 else {
525 return null;
526 }
527 }
528
529
536 public List<AnnouncementsEntry> filterFindByUuid(String uuid)
537 throws SystemException {
538 return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
539 }
540
541
554 public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
555 int end) throws SystemException {
556 return filterFindByUuid(uuid, start, end, null);
557 }
558
559
573 public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
574 int end, OrderByComparator orderByComparator) throws SystemException {
575 if (!InlineSQLHelperUtil.isEnabled()) {
576 return findByUuid(uuid, start, end, orderByComparator);
577 }
578
579 StringBundler query = null;
580
581 if (orderByComparator != null) {
582 query = new StringBundler(3 +
583 (orderByComparator.getOrderByFields().length * 3));
584 }
585 else {
586 query = new StringBundler(3);
587 }
588
589 if (getDB().isSupportsInlineDistinct()) {
590 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
591 }
592 else {
593 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
594 }
595
596 boolean bindUuid = false;
597
598 if (uuid == null) {
599 query.append(_FINDER_COLUMN_UUID_UUID_1);
600 }
601 else if (uuid.equals(StringPool.BLANK)) {
602 query.append(_FINDER_COLUMN_UUID_UUID_3);
603 }
604 else {
605 bindUuid = true;
606
607 query.append(_FINDER_COLUMN_UUID_UUID_2);
608 }
609
610 if (!getDB().isSupportsInlineDistinct()) {
611 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
612 }
613
614 if (orderByComparator != null) {
615 if (getDB().isSupportsInlineDistinct()) {
616 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
617 orderByComparator);
618 }
619 else {
620 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
621 orderByComparator);
622 }
623 }
624 else {
625 if (getDB().isSupportsInlineDistinct()) {
626 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
627 }
628 else {
629 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
630 }
631 }
632
633 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
634 AnnouncementsEntry.class.getName(),
635 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
636
637 Session session = null;
638
639 try {
640 session = openSession();
641
642 SQLQuery q = session.createSQLQuery(sql);
643
644 if (getDB().isSupportsInlineDistinct()) {
645 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
646 }
647 else {
648 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
649 }
650
651 QueryPos qPos = QueryPos.getInstance(q);
652
653 if (bindUuid) {
654 qPos.add(uuid);
655 }
656
657 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
658 start, end);
659 }
660 catch (Exception e) {
661 throw processException(e);
662 }
663 finally {
664 closeSession(session);
665 }
666 }
667
668
678 public AnnouncementsEntry[] filterFindByUuid_PrevAndNext(long entryId,
679 String uuid, OrderByComparator orderByComparator)
680 throws NoSuchEntryException, SystemException {
681 if (!InlineSQLHelperUtil.isEnabled()) {
682 return findByUuid_PrevAndNext(entryId, uuid, orderByComparator);
683 }
684
685 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
686
687 Session session = null;
688
689 try {
690 session = openSession();
691
692 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
693
694 array[0] = filterGetByUuid_PrevAndNext(session, announcementsEntry,
695 uuid, orderByComparator, true);
696
697 array[1] = announcementsEntry;
698
699 array[2] = filterGetByUuid_PrevAndNext(session, announcementsEntry,
700 uuid, orderByComparator, false);
701
702 return array;
703 }
704 catch (Exception e) {
705 throw processException(e);
706 }
707 finally {
708 closeSession(session);
709 }
710 }
711
712 protected AnnouncementsEntry filterGetByUuid_PrevAndNext(Session session,
713 AnnouncementsEntry announcementsEntry, String uuid,
714 OrderByComparator orderByComparator, boolean previous) {
715 StringBundler query = null;
716
717 if (orderByComparator != null) {
718 query = new StringBundler(6 +
719 (orderByComparator.getOrderByFields().length * 6));
720 }
721 else {
722 query = new StringBundler(3);
723 }
724
725 if (getDB().isSupportsInlineDistinct()) {
726 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
727 }
728 else {
729 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
730 }
731
732 boolean bindUuid = false;
733
734 if (uuid == null) {
735 query.append(_FINDER_COLUMN_UUID_UUID_1);
736 }
737 else if (uuid.equals(StringPool.BLANK)) {
738 query.append(_FINDER_COLUMN_UUID_UUID_3);
739 }
740 else {
741 bindUuid = true;
742
743 query.append(_FINDER_COLUMN_UUID_UUID_2);
744 }
745
746 if (!getDB().isSupportsInlineDistinct()) {
747 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
748 }
749
750 if (orderByComparator != null) {
751 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
752
753 if (orderByConditionFields.length > 0) {
754 query.append(WHERE_AND);
755 }
756
757 for (int i = 0; i < orderByConditionFields.length; i++) {
758 if (getDB().isSupportsInlineDistinct()) {
759 query.append(_ORDER_BY_ENTITY_ALIAS);
760 }
761 else {
762 query.append(_ORDER_BY_ENTITY_TABLE);
763 }
764
765 query.append(orderByConditionFields[i]);
766
767 if ((i + 1) < orderByConditionFields.length) {
768 if (orderByComparator.isAscending() ^ previous) {
769 query.append(WHERE_GREATER_THAN_HAS_NEXT);
770 }
771 else {
772 query.append(WHERE_LESSER_THAN_HAS_NEXT);
773 }
774 }
775 else {
776 if (orderByComparator.isAscending() ^ previous) {
777 query.append(WHERE_GREATER_THAN);
778 }
779 else {
780 query.append(WHERE_LESSER_THAN);
781 }
782 }
783 }
784
785 query.append(ORDER_BY_CLAUSE);
786
787 String[] orderByFields = orderByComparator.getOrderByFields();
788
789 for (int i = 0; i < orderByFields.length; i++) {
790 if (getDB().isSupportsInlineDistinct()) {
791 query.append(_ORDER_BY_ENTITY_ALIAS);
792 }
793 else {
794 query.append(_ORDER_BY_ENTITY_TABLE);
795 }
796
797 query.append(orderByFields[i]);
798
799 if ((i + 1) < orderByFields.length) {
800 if (orderByComparator.isAscending() ^ previous) {
801 query.append(ORDER_BY_ASC_HAS_NEXT);
802 }
803 else {
804 query.append(ORDER_BY_DESC_HAS_NEXT);
805 }
806 }
807 else {
808 if (orderByComparator.isAscending() ^ previous) {
809 query.append(ORDER_BY_ASC);
810 }
811 else {
812 query.append(ORDER_BY_DESC);
813 }
814 }
815 }
816 }
817 else {
818 if (getDB().isSupportsInlineDistinct()) {
819 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
820 }
821 else {
822 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
823 }
824 }
825
826 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
827 AnnouncementsEntry.class.getName(),
828 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
829
830 SQLQuery q = session.createSQLQuery(sql);
831
832 q.setFirstResult(0);
833 q.setMaxResults(2);
834
835 if (getDB().isSupportsInlineDistinct()) {
836 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
837 }
838 else {
839 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
840 }
841
842 QueryPos qPos = QueryPos.getInstance(q);
843
844 if (bindUuid) {
845 qPos.add(uuid);
846 }
847
848 if (orderByComparator != null) {
849 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
850
851 for (Object value : values) {
852 qPos.add(value);
853 }
854 }
855
856 List<AnnouncementsEntry> list = q.list();
857
858 if (list.size() == 2) {
859 return list.get(1);
860 }
861 else {
862 return null;
863 }
864 }
865
866
872 public void removeByUuid(String uuid) throws SystemException {
873 for (AnnouncementsEntry announcementsEntry : findByUuid(uuid,
874 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
875 remove(announcementsEntry);
876 }
877 }
878
879
886 public int countByUuid(String uuid) throws SystemException {
887 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
888
889 Object[] finderArgs = new Object[] { uuid };
890
891 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
892 this);
893
894 if (count == null) {
895 StringBundler query = new StringBundler(2);
896
897 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
898
899 boolean bindUuid = false;
900
901 if (uuid == null) {
902 query.append(_FINDER_COLUMN_UUID_UUID_1);
903 }
904 else if (uuid.equals(StringPool.BLANK)) {
905 query.append(_FINDER_COLUMN_UUID_UUID_3);
906 }
907 else {
908 bindUuid = true;
909
910 query.append(_FINDER_COLUMN_UUID_UUID_2);
911 }
912
913 String sql = query.toString();
914
915 Session session = null;
916
917 try {
918 session = openSession();
919
920 Query q = session.createQuery(sql);
921
922 QueryPos qPos = QueryPos.getInstance(q);
923
924 if (bindUuid) {
925 qPos.add(uuid);
926 }
927
928 count = (Long)q.uniqueResult();
929
930 FinderCacheUtil.putResult(finderPath, finderArgs, count);
931 }
932 catch (Exception e) {
933 FinderCacheUtil.removeResult(finderPath, finderArgs);
934
935 throw processException(e);
936 }
937 finally {
938 closeSession(session);
939 }
940 }
941
942 return count.intValue();
943 }
944
945
952 public int filterCountByUuid(String uuid) throws SystemException {
953 if (!InlineSQLHelperUtil.isEnabled()) {
954 return countByUuid(uuid);
955 }
956
957 StringBundler query = new StringBundler(2);
958
959 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
960
961 boolean bindUuid = false;
962
963 if (uuid == null) {
964 query.append(_FINDER_COLUMN_UUID_UUID_1);
965 }
966 else if (uuid.equals(StringPool.BLANK)) {
967 query.append(_FINDER_COLUMN_UUID_UUID_3);
968 }
969 else {
970 bindUuid = true;
971
972 query.append(_FINDER_COLUMN_UUID_UUID_2);
973 }
974
975 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
976 AnnouncementsEntry.class.getName(),
977 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
978
979 Session session = null;
980
981 try {
982 session = openSession();
983
984 SQLQuery q = session.createSQLQuery(sql);
985
986 q.addScalar(COUNT_COLUMN_NAME,
987 com.liferay.portal.kernel.dao.orm.Type.LONG);
988
989 QueryPos qPos = QueryPos.getInstance(q);
990
991 if (bindUuid) {
992 qPos.add(uuid);
993 }
994
995 Long count = (Long)q.uniqueResult();
996
997 return count.intValue();
998 }
999 catch (Exception e) {
1000 throw processException(e);
1001 }
1002 finally {
1003 closeSession(session);
1004 }
1005 }
1006
1007 private static final String _FINDER_COLUMN_UUID_UUID_1 = "announcementsEntry.uuid IS NULL";
1008 private static final String _FINDER_COLUMN_UUID_UUID_2 = "announcementsEntry.uuid = ?";
1009 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(announcementsEntry.uuid IS NULL OR announcementsEntry.uuid = '')";
1010 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
1011 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
1012 AnnouncementsEntryImpl.class,
1013 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
1014 new String[] {
1015 String.class.getName(), Long.class.getName(),
1016
1017 Integer.class.getName(), Integer.class.getName(),
1018 OrderByComparator.class.getName()
1019 });
1020 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1021 new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
1022 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
1023 AnnouncementsEntryImpl.class,
1024 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1025 new String[] { String.class.getName(), Long.class.getName() },
1026 AnnouncementsEntryModelImpl.UUID_COLUMN_BITMASK |
1027 AnnouncementsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
1028 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
1029 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
1030 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
1031 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1032 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1033 new String[] { String.class.getName(), Long.class.getName() });
1034
1035
1043 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId)
1044 throws SystemException {
1045 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1046 QueryUtil.ALL_POS, null);
1047 }
1048
1049
1063 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId,
1064 int start, int end) throws SystemException {
1065 return findByUuid_C(uuid, companyId, start, end, null);
1066 }
1067
1068
1083 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId,
1084 int start, int end, OrderByComparator orderByComparator)
1085 throws SystemException {
1086 boolean pagination = true;
1087 FinderPath finderPath = null;
1088 Object[] finderArgs = null;
1089
1090 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1091 (orderByComparator == null)) {
1092 pagination = false;
1093 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1094 finderArgs = new Object[] { uuid, companyId };
1095 }
1096 else {
1097 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1098 finderArgs = new Object[] {
1099 uuid, companyId,
1100
1101 start, end, orderByComparator
1102 };
1103 }
1104
1105 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
1106 finderArgs, this);
1107
1108 if ((list != null) && !list.isEmpty()) {
1109 for (AnnouncementsEntry announcementsEntry : list) {
1110 if (!Validator.equals(uuid, announcementsEntry.getUuid()) ||
1111 (companyId != announcementsEntry.getCompanyId())) {
1112 list = null;
1113
1114 break;
1115 }
1116 }
1117 }
1118
1119 if (list == null) {
1120 StringBundler query = null;
1121
1122 if (orderByComparator != null) {
1123 query = new StringBundler(4 +
1124 (orderByComparator.getOrderByFields().length * 3));
1125 }
1126 else {
1127 query = new StringBundler(4);
1128 }
1129
1130 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1131
1132 boolean bindUuid = false;
1133
1134 if (uuid == null) {
1135 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1136 }
1137 else if (uuid.equals(StringPool.BLANK)) {
1138 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1139 }
1140 else {
1141 bindUuid = true;
1142
1143 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1144 }
1145
1146 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1147
1148 if (orderByComparator != null) {
1149 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1150 orderByComparator);
1151 }
1152 else
1153 if (pagination) {
1154 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1155 }
1156
1157 String sql = query.toString();
1158
1159 Session session = null;
1160
1161 try {
1162 session = openSession();
1163
1164 Query q = session.createQuery(sql);
1165
1166 QueryPos qPos = QueryPos.getInstance(q);
1167
1168 if (bindUuid) {
1169 qPos.add(uuid);
1170 }
1171
1172 qPos.add(companyId);
1173
1174 if (!pagination) {
1175 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
1176 getDialect(), start, end, false);
1177
1178 Collections.sort(list);
1179
1180 list = new UnmodifiableList<AnnouncementsEntry>(list);
1181 }
1182 else {
1183 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
1184 getDialect(), start, end);
1185 }
1186
1187 cacheResult(list);
1188
1189 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1190 }
1191 catch (Exception e) {
1192 FinderCacheUtil.removeResult(finderPath, finderArgs);
1193
1194 throw processException(e);
1195 }
1196 finally {
1197 closeSession(session);
1198 }
1199 }
1200
1201 return list;
1202 }
1203
1204
1214 public AnnouncementsEntry findByUuid_C_First(String uuid, long companyId,
1215 OrderByComparator orderByComparator)
1216 throws NoSuchEntryException, SystemException {
1217 AnnouncementsEntry announcementsEntry = fetchByUuid_C_First(uuid,
1218 companyId, orderByComparator);
1219
1220 if (announcementsEntry != null) {
1221 return announcementsEntry;
1222 }
1223
1224 StringBundler msg = new StringBundler(6);
1225
1226 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1227
1228 msg.append("uuid=");
1229 msg.append(uuid);
1230
1231 msg.append(", companyId=");
1232 msg.append(companyId);
1233
1234 msg.append(StringPool.CLOSE_CURLY_BRACE);
1235
1236 throw new NoSuchEntryException(msg.toString());
1237 }
1238
1239
1248 public AnnouncementsEntry fetchByUuid_C_First(String uuid, long companyId,
1249 OrderByComparator orderByComparator) throws SystemException {
1250 List<AnnouncementsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1251 orderByComparator);
1252
1253 if (!list.isEmpty()) {
1254 return list.get(0);
1255 }
1256
1257 return null;
1258 }
1259
1260
1270 public AnnouncementsEntry findByUuid_C_Last(String uuid, long companyId,
1271 OrderByComparator orderByComparator)
1272 throws NoSuchEntryException, SystemException {
1273 AnnouncementsEntry announcementsEntry = fetchByUuid_C_Last(uuid,
1274 companyId, orderByComparator);
1275
1276 if (announcementsEntry != null) {
1277 return announcementsEntry;
1278 }
1279
1280 StringBundler msg = new StringBundler(6);
1281
1282 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1283
1284 msg.append("uuid=");
1285 msg.append(uuid);
1286
1287 msg.append(", companyId=");
1288 msg.append(companyId);
1289
1290 msg.append(StringPool.CLOSE_CURLY_BRACE);
1291
1292 throw new NoSuchEntryException(msg.toString());
1293 }
1294
1295
1304 public AnnouncementsEntry fetchByUuid_C_Last(String uuid, long companyId,
1305 OrderByComparator orderByComparator) throws SystemException {
1306 int count = countByUuid_C(uuid, companyId);
1307
1308 List<AnnouncementsEntry> list = findByUuid_C(uuid, companyId,
1309 count - 1, count, orderByComparator);
1310
1311 if (!list.isEmpty()) {
1312 return list.get(0);
1313 }
1314
1315 return null;
1316 }
1317
1318
1329 public AnnouncementsEntry[] findByUuid_C_PrevAndNext(long entryId,
1330 String uuid, long companyId, OrderByComparator orderByComparator)
1331 throws NoSuchEntryException, SystemException {
1332 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1333
1334 Session session = null;
1335
1336 try {
1337 session = openSession();
1338
1339 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1340
1341 array[0] = getByUuid_C_PrevAndNext(session, announcementsEntry,
1342 uuid, companyId, orderByComparator, true);
1343
1344 array[1] = announcementsEntry;
1345
1346 array[2] = getByUuid_C_PrevAndNext(session, announcementsEntry,
1347 uuid, companyId, orderByComparator, false);
1348
1349 return array;
1350 }
1351 catch (Exception e) {
1352 throw processException(e);
1353 }
1354 finally {
1355 closeSession(session);
1356 }
1357 }
1358
1359 protected AnnouncementsEntry getByUuid_C_PrevAndNext(Session session,
1360 AnnouncementsEntry announcementsEntry, String uuid, long companyId,
1361 OrderByComparator orderByComparator, boolean previous) {
1362 StringBundler query = null;
1363
1364 if (orderByComparator != null) {
1365 query = new StringBundler(6 +
1366 (orderByComparator.getOrderByFields().length * 6));
1367 }
1368 else {
1369 query = new StringBundler(3);
1370 }
1371
1372 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1373
1374 boolean bindUuid = false;
1375
1376 if (uuid == null) {
1377 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1378 }
1379 else if (uuid.equals(StringPool.BLANK)) {
1380 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1381 }
1382 else {
1383 bindUuid = true;
1384
1385 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1386 }
1387
1388 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1389
1390 if (orderByComparator != null) {
1391 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1392
1393 if (orderByConditionFields.length > 0) {
1394 query.append(WHERE_AND);
1395 }
1396
1397 for (int i = 0; i < orderByConditionFields.length; i++) {
1398 query.append(_ORDER_BY_ENTITY_ALIAS);
1399 query.append(orderByConditionFields[i]);
1400
1401 if ((i + 1) < orderByConditionFields.length) {
1402 if (orderByComparator.isAscending() ^ previous) {
1403 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1404 }
1405 else {
1406 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1407 }
1408 }
1409 else {
1410 if (orderByComparator.isAscending() ^ previous) {
1411 query.append(WHERE_GREATER_THAN);
1412 }
1413 else {
1414 query.append(WHERE_LESSER_THAN);
1415 }
1416 }
1417 }
1418
1419 query.append(ORDER_BY_CLAUSE);
1420
1421 String[] orderByFields = orderByComparator.getOrderByFields();
1422
1423 for (int i = 0; i < orderByFields.length; i++) {
1424 query.append(_ORDER_BY_ENTITY_ALIAS);
1425 query.append(orderByFields[i]);
1426
1427 if ((i + 1) < orderByFields.length) {
1428 if (orderByComparator.isAscending() ^ previous) {
1429 query.append(ORDER_BY_ASC_HAS_NEXT);
1430 }
1431 else {
1432 query.append(ORDER_BY_DESC_HAS_NEXT);
1433 }
1434 }
1435 else {
1436 if (orderByComparator.isAscending() ^ previous) {
1437 query.append(ORDER_BY_ASC);
1438 }
1439 else {
1440 query.append(ORDER_BY_DESC);
1441 }
1442 }
1443 }
1444 }
1445 else {
1446 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1447 }
1448
1449 String sql = query.toString();
1450
1451 Query q = session.createQuery(sql);
1452
1453 q.setFirstResult(0);
1454 q.setMaxResults(2);
1455
1456 QueryPos qPos = QueryPos.getInstance(q);
1457
1458 if (bindUuid) {
1459 qPos.add(uuid);
1460 }
1461
1462 qPos.add(companyId);
1463
1464 if (orderByComparator != null) {
1465 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1466
1467 for (Object value : values) {
1468 qPos.add(value);
1469 }
1470 }
1471
1472 List<AnnouncementsEntry> list = q.list();
1473
1474 if (list.size() == 2) {
1475 return list.get(1);
1476 }
1477 else {
1478 return null;
1479 }
1480 }
1481
1482
1490 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1491 long companyId) throws SystemException {
1492 return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1493 QueryUtil.ALL_POS, null);
1494 }
1495
1496
1510 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1511 long companyId, int start, int end) throws SystemException {
1512 return filterFindByUuid_C(uuid, companyId, start, end, null);
1513 }
1514
1515
1530 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1531 long companyId, int start, int end, OrderByComparator orderByComparator)
1532 throws SystemException {
1533 if (!InlineSQLHelperUtil.isEnabled()) {
1534 return findByUuid_C(uuid, companyId, start, end, orderByComparator);
1535 }
1536
1537 StringBundler query = null;
1538
1539 if (orderByComparator != null) {
1540 query = new StringBundler(4 +
1541 (orderByComparator.getOrderByFields().length * 3));
1542 }
1543 else {
1544 query = new StringBundler(4);
1545 }
1546
1547 if (getDB().isSupportsInlineDistinct()) {
1548 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1549 }
1550 else {
1551 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1552 }
1553
1554 boolean bindUuid = false;
1555
1556 if (uuid == null) {
1557 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1558 }
1559 else if (uuid.equals(StringPool.BLANK)) {
1560 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1561 }
1562 else {
1563 bindUuid = true;
1564
1565 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1566 }
1567
1568 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1569
1570 if (!getDB().isSupportsInlineDistinct()) {
1571 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1572 }
1573
1574 if (orderByComparator != null) {
1575 if (getDB().isSupportsInlineDistinct()) {
1576 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1577 orderByComparator);
1578 }
1579 else {
1580 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1581 orderByComparator);
1582 }
1583 }
1584 else {
1585 if (getDB().isSupportsInlineDistinct()) {
1586 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1587 }
1588 else {
1589 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1590 }
1591 }
1592
1593 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1594 AnnouncementsEntry.class.getName(),
1595 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1596
1597 Session session = null;
1598
1599 try {
1600 session = openSession();
1601
1602 SQLQuery q = session.createSQLQuery(sql);
1603
1604 if (getDB().isSupportsInlineDistinct()) {
1605 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1606 }
1607 else {
1608 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1609 }
1610
1611 QueryPos qPos = QueryPos.getInstance(q);
1612
1613 if (bindUuid) {
1614 qPos.add(uuid);
1615 }
1616
1617 qPos.add(companyId);
1618
1619 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
1620 start, end);
1621 }
1622 catch (Exception e) {
1623 throw processException(e);
1624 }
1625 finally {
1626 closeSession(session);
1627 }
1628 }
1629
1630
1641 public AnnouncementsEntry[] filterFindByUuid_C_PrevAndNext(long entryId,
1642 String uuid, long companyId, OrderByComparator orderByComparator)
1643 throws NoSuchEntryException, SystemException {
1644 if (!InlineSQLHelperUtil.isEnabled()) {
1645 return findByUuid_C_PrevAndNext(entryId, uuid, companyId,
1646 orderByComparator);
1647 }
1648
1649 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1650
1651 Session session = null;
1652
1653 try {
1654 session = openSession();
1655
1656 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1657
1658 array[0] = filterGetByUuid_C_PrevAndNext(session,
1659 announcementsEntry, uuid, companyId, orderByComparator, true);
1660
1661 array[1] = announcementsEntry;
1662
1663 array[2] = filterGetByUuid_C_PrevAndNext(session,
1664 announcementsEntry, uuid, companyId, orderByComparator,
1665 false);
1666
1667 return array;
1668 }
1669 catch (Exception e) {
1670 throw processException(e);
1671 }
1672 finally {
1673 closeSession(session);
1674 }
1675 }
1676
1677 protected AnnouncementsEntry filterGetByUuid_C_PrevAndNext(
1678 Session session, AnnouncementsEntry announcementsEntry, String uuid,
1679 long companyId, OrderByComparator orderByComparator, boolean previous) {
1680 StringBundler query = null;
1681
1682 if (orderByComparator != null) {
1683 query = new StringBundler(6 +
1684 (orderByComparator.getOrderByFields().length * 6));
1685 }
1686 else {
1687 query = new StringBundler(3);
1688 }
1689
1690 if (getDB().isSupportsInlineDistinct()) {
1691 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1692 }
1693 else {
1694 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1695 }
1696
1697 boolean bindUuid = false;
1698
1699 if (uuid == null) {
1700 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1701 }
1702 else if (uuid.equals(StringPool.BLANK)) {
1703 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1704 }
1705 else {
1706 bindUuid = true;
1707
1708 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1709 }
1710
1711 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1712
1713 if (!getDB().isSupportsInlineDistinct()) {
1714 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1715 }
1716
1717 if (orderByComparator != null) {
1718 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1719
1720 if (orderByConditionFields.length > 0) {
1721 query.append(WHERE_AND);
1722 }
1723
1724 for (int i = 0; i < orderByConditionFields.length; i++) {
1725 if (getDB().isSupportsInlineDistinct()) {
1726 query.append(_ORDER_BY_ENTITY_ALIAS);
1727 }
1728 else {
1729 query.append(_ORDER_BY_ENTITY_TABLE);
1730 }
1731
1732 query.append(orderByConditionFields[i]);
1733
1734 if ((i + 1) < orderByConditionFields.length) {
1735 if (orderByComparator.isAscending() ^ previous) {
1736 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1737 }
1738 else {
1739 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1740 }
1741 }
1742 else {
1743 if (orderByComparator.isAscending() ^ previous) {
1744 query.append(WHERE_GREATER_THAN);
1745 }
1746 else {
1747 query.append(WHERE_LESSER_THAN);
1748 }
1749 }
1750 }
1751
1752 query.append(ORDER_BY_CLAUSE);
1753
1754 String[] orderByFields = orderByComparator.getOrderByFields();
1755
1756 for (int i = 0; i < orderByFields.length; i++) {
1757 if (getDB().isSupportsInlineDistinct()) {
1758 query.append(_ORDER_BY_ENTITY_ALIAS);
1759 }
1760 else {
1761 query.append(_ORDER_BY_ENTITY_TABLE);
1762 }
1763
1764 query.append(orderByFields[i]);
1765
1766 if ((i + 1) < orderByFields.length) {
1767 if (orderByComparator.isAscending() ^ previous) {
1768 query.append(ORDER_BY_ASC_HAS_NEXT);
1769 }
1770 else {
1771 query.append(ORDER_BY_DESC_HAS_NEXT);
1772 }
1773 }
1774 else {
1775 if (orderByComparator.isAscending() ^ previous) {
1776 query.append(ORDER_BY_ASC);
1777 }
1778 else {
1779 query.append(ORDER_BY_DESC);
1780 }
1781 }
1782 }
1783 }
1784 else {
1785 if (getDB().isSupportsInlineDistinct()) {
1786 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1787 }
1788 else {
1789 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1790 }
1791 }
1792
1793 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1794 AnnouncementsEntry.class.getName(),
1795 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1796
1797 SQLQuery q = session.createSQLQuery(sql);
1798
1799 q.setFirstResult(0);
1800 q.setMaxResults(2);
1801
1802 if (getDB().isSupportsInlineDistinct()) {
1803 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1804 }
1805 else {
1806 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1807 }
1808
1809 QueryPos qPos = QueryPos.getInstance(q);
1810
1811 if (bindUuid) {
1812 qPos.add(uuid);
1813 }
1814
1815 qPos.add(companyId);
1816
1817 if (orderByComparator != null) {
1818 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1819
1820 for (Object value : values) {
1821 qPos.add(value);
1822 }
1823 }
1824
1825 List<AnnouncementsEntry> list = q.list();
1826
1827 if (list.size() == 2) {
1828 return list.get(1);
1829 }
1830 else {
1831 return null;
1832 }
1833 }
1834
1835
1842 public void removeByUuid_C(String uuid, long companyId)
1843 throws SystemException {
1844 for (AnnouncementsEntry announcementsEntry : findByUuid_C(uuid,
1845 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1846 remove(announcementsEntry);
1847 }
1848 }
1849
1850
1858 public int countByUuid_C(String uuid, long companyId)
1859 throws SystemException {
1860 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1861
1862 Object[] finderArgs = new Object[] { uuid, companyId };
1863
1864 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1865 this);
1866
1867 if (count == null) {
1868 StringBundler query = new StringBundler(3);
1869
1870 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
1871
1872 boolean bindUuid = false;
1873
1874 if (uuid == null) {
1875 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1876 }
1877 else if (uuid.equals(StringPool.BLANK)) {
1878 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1879 }
1880 else {
1881 bindUuid = true;
1882
1883 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1884 }
1885
1886 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1887
1888 String sql = query.toString();
1889
1890 Session session = null;
1891
1892 try {
1893 session = openSession();
1894
1895 Query q = session.createQuery(sql);
1896
1897 QueryPos qPos = QueryPos.getInstance(q);
1898
1899 if (bindUuid) {
1900 qPos.add(uuid);
1901 }
1902
1903 qPos.add(companyId);
1904
1905 count = (Long)q.uniqueResult();
1906
1907 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1908 }
1909 catch (Exception e) {
1910 FinderCacheUtil.removeResult(finderPath, finderArgs);
1911
1912 throw processException(e);
1913 }
1914 finally {
1915 closeSession(session);
1916 }
1917 }
1918
1919 return count.intValue();
1920 }
1921
1922
1930 public int filterCountByUuid_C(String uuid, long companyId)
1931 throws SystemException {
1932 if (!InlineSQLHelperUtil.isEnabled()) {
1933 return countByUuid_C(uuid, companyId);
1934 }
1935
1936 StringBundler query = new StringBundler(3);
1937
1938 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
1939
1940 boolean bindUuid = false;
1941
1942 if (uuid == null) {
1943 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1944 }
1945 else if (uuid.equals(StringPool.BLANK)) {
1946 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1947 }
1948 else {
1949 bindUuid = true;
1950
1951 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1952 }
1953
1954 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1955
1956 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1957 AnnouncementsEntry.class.getName(),
1958 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1959
1960 Session session = null;
1961
1962 try {
1963 session = openSession();
1964
1965 SQLQuery q = session.createSQLQuery(sql);
1966
1967 q.addScalar(COUNT_COLUMN_NAME,
1968 com.liferay.portal.kernel.dao.orm.Type.LONG);
1969
1970 QueryPos qPos = QueryPos.getInstance(q);
1971
1972 if (bindUuid) {
1973 qPos.add(uuid);
1974 }
1975
1976 qPos.add(companyId);
1977
1978 Long count = (Long)q.uniqueResult();
1979
1980 return count.intValue();
1981 }
1982 catch (Exception e) {
1983 throw processException(e);
1984 }
1985 finally {
1986 closeSession(session);
1987 }
1988 }
1989
1990 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "announcementsEntry.uuid IS NULL AND ";
1991 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "announcementsEntry.uuid = ? AND ";
1992 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(announcementsEntry.uuid IS NULL OR announcementsEntry.uuid = '') AND ";
1993 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "announcementsEntry.companyId = ?";
1994 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
1995 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
1996 AnnouncementsEntryImpl.class,
1997 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
1998 new String[] {
1999 Long.class.getName(),
2000
2001 Integer.class.getName(), Integer.class.getName(),
2002 OrderByComparator.class.getName()
2003 });
2004 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
2005 new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2006 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2007 AnnouncementsEntryImpl.class,
2008 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
2009 new String[] { Long.class.getName() },
2010 AnnouncementsEntryModelImpl.USERID_COLUMN_BITMASK |
2011 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
2012 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
2013 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2014 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2015 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
2016 new String[] { Long.class.getName() });
2017
2018
2025 public List<AnnouncementsEntry> findByUserId(long userId)
2026 throws SystemException {
2027 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2028 }
2029
2030
2043 public List<AnnouncementsEntry> findByUserId(long userId, int start, int end)
2044 throws SystemException {
2045 return findByUserId(userId, start, end, null);
2046 }
2047
2048
2062 public List<AnnouncementsEntry> findByUserId(long userId, int start,
2063 int end, OrderByComparator orderByComparator) throws SystemException {
2064 boolean pagination = true;
2065 FinderPath finderPath = null;
2066 Object[] finderArgs = null;
2067
2068 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2069 (orderByComparator == null)) {
2070 pagination = false;
2071 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
2072 finderArgs = new Object[] { userId };
2073 }
2074 else {
2075 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
2076 finderArgs = new Object[] { userId, start, end, orderByComparator };
2077 }
2078
2079 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
2080 finderArgs, this);
2081
2082 if ((list != null) && !list.isEmpty()) {
2083 for (AnnouncementsEntry announcementsEntry : list) {
2084 if ((userId != announcementsEntry.getUserId())) {
2085 list = null;
2086
2087 break;
2088 }
2089 }
2090 }
2091
2092 if (list == null) {
2093 StringBundler query = null;
2094
2095 if (orderByComparator != null) {
2096 query = new StringBundler(3 +
2097 (orderByComparator.getOrderByFields().length * 3));
2098 }
2099 else {
2100 query = new StringBundler(3);
2101 }
2102
2103 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2104
2105 query.append(_FINDER_COLUMN_USERID_USERID_2);
2106
2107 if (orderByComparator != null) {
2108 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2109 orderByComparator);
2110 }
2111 else
2112 if (pagination) {
2113 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2114 }
2115
2116 String sql = query.toString();
2117
2118 Session session = null;
2119
2120 try {
2121 session = openSession();
2122
2123 Query q = session.createQuery(sql);
2124
2125 QueryPos qPos = QueryPos.getInstance(q);
2126
2127 qPos.add(userId);
2128
2129 if (!pagination) {
2130 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2131 getDialect(), start, end, false);
2132
2133 Collections.sort(list);
2134
2135 list = new UnmodifiableList<AnnouncementsEntry>(list);
2136 }
2137 else {
2138 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2139 getDialect(), start, end);
2140 }
2141
2142 cacheResult(list);
2143
2144 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2145 }
2146 catch (Exception e) {
2147 FinderCacheUtil.removeResult(finderPath, finderArgs);
2148
2149 throw processException(e);
2150 }
2151 finally {
2152 closeSession(session);
2153 }
2154 }
2155
2156 return list;
2157 }
2158
2159
2168 public AnnouncementsEntry findByUserId_First(long userId,
2169 OrderByComparator orderByComparator)
2170 throws NoSuchEntryException, SystemException {
2171 AnnouncementsEntry announcementsEntry = fetchByUserId_First(userId,
2172 orderByComparator);
2173
2174 if (announcementsEntry != null) {
2175 return announcementsEntry;
2176 }
2177
2178 StringBundler msg = new StringBundler(4);
2179
2180 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2181
2182 msg.append("userId=");
2183 msg.append(userId);
2184
2185 msg.append(StringPool.CLOSE_CURLY_BRACE);
2186
2187 throw new NoSuchEntryException(msg.toString());
2188 }
2189
2190
2198 public AnnouncementsEntry fetchByUserId_First(long userId,
2199 OrderByComparator orderByComparator) throws SystemException {
2200 List<AnnouncementsEntry> list = findByUserId(userId, 0, 1,
2201 orderByComparator);
2202
2203 if (!list.isEmpty()) {
2204 return list.get(0);
2205 }
2206
2207 return null;
2208 }
2209
2210
2219 public AnnouncementsEntry findByUserId_Last(long userId,
2220 OrderByComparator orderByComparator)
2221 throws NoSuchEntryException, SystemException {
2222 AnnouncementsEntry announcementsEntry = fetchByUserId_Last(userId,
2223 orderByComparator);
2224
2225 if (announcementsEntry != null) {
2226 return announcementsEntry;
2227 }
2228
2229 StringBundler msg = new StringBundler(4);
2230
2231 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2232
2233 msg.append("userId=");
2234 msg.append(userId);
2235
2236 msg.append(StringPool.CLOSE_CURLY_BRACE);
2237
2238 throw new NoSuchEntryException(msg.toString());
2239 }
2240
2241
2249 public AnnouncementsEntry fetchByUserId_Last(long userId,
2250 OrderByComparator orderByComparator) throws SystemException {
2251 int count = countByUserId(userId);
2252
2253 List<AnnouncementsEntry> list = findByUserId(userId, count - 1, count,
2254 orderByComparator);
2255
2256 if (!list.isEmpty()) {
2257 return list.get(0);
2258 }
2259
2260 return null;
2261 }
2262
2263
2273 public AnnouncementsEntry[] findByUserId_PrevAndNext(long entryId,
2274 long userId, OrderByComparator orderByComparator)
2275 throws NoSuchEntryException, SystemException {
2276 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2277
2278 Session session = null;
2279
2280 try {
2281 session = openSession();
2282
2283 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2284
2285 array[0] = getByUserId_PrevAndNext(session, announcementsEntry,
2286 userId, orderByComparator, true);
2287
2288 array[1] = announcementsEntry;
2289
2290 array[2] = getByUserId_PrevAndNext(session, announcementsEntry,
2291 userId, orderByComparator, false);
2292
2293 return array;
2294 }
2295 catch (Exception e) {
2296 throw processException(e);
2297 }
2298 finally {
2299 closeSession(session);
2300 }
2301 }
2302
2303 protected AnnouncementsEntry getByUserId_PrevAndNext(Session session,
2304 AnnouncementsEntry announcementsEntry, long userId,
2305 OrderByComparator orderByComparator, boolean previous) {
2306 StringBundler query = null;
2307
2308 if (orderByComparator != null) {
2309 query = new StringBundler(6 +
2310 (orderByComparator.getOrderByFields().length * 6));
2311 }
2312 else {
2313 query = new StringBundler(3);
2314 }
2315
2316 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2317
2318 query.append(_FINDER_COLUMN_USERID_USERID_2);
2319
2320 if (orderByComparator != null) {
2321 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2322
2323 if (orderByConditionFields.length > 0) {
2324 query.append(WHERE_AND);
2325 }
2326
2327 for (int i = 0; i < orderByConditionFields.length; i++) {
2328 query.append(_ORDER_BY_ENTITY_ALIAS);
2329 query.append(orderByConditionFields[i]);
2330
2331 if ((i + 1) < orderByConditionFields.length) {
2332 if (orderByComparator.isAscending() ^ previous) {
2333 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2334 }
2335 else {
2336 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2337 }
2338 }
2339 else {
2340 if (orderByComparator.isAscending() ^ previous) {
2341 query.append(WHERE_GREATER_THAN);
2342 }
2343 else {
2344 query.append(WHERE_LESSER_THAN);
2345 }
2346 }
2347 }
2348
2349 query.append(ORDER_BY_CLAUSE);
2350
2351 String[] orderByFields = orderByComparator.getOrderByFields();
2352
2353 for (int i = 0; i < orderByFields.length; i++) {
2354 query.append(_ORDER_BY_ENTITY_ALIAS);
2355 query.append(orderByFields[i]);
2356
2357 if ((i + 1) < orderByFields.length) {
2358 if (orderByComparator.isAscending() ^ previous) {
2359 query.append(ORDER_BY_ASC_HAS_NEXT);
2360 }
2361 else {
2362 query.append(ORDER_BY_DESC_HAS_NEXT);
2363 }
2364 }
2365 else {
2366 if (orderByComparator.isAscending() ^ previous) {
2367 query.append(ORDER_BY_ASC);
2368 }
2369 else {
2370 query.append(ORDER_BY_DESC);
2371 }
2372 }
2373 }
2374 }
2375 else {
2376 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2377 }
2378
2379 String sql = query.toString();
2380
2381 Query q = session.createQuery(sql);
2382
2383 q.setFirstResult(0);
2384 q.setMaxResults(2);
2385
2386 QueryPos qPos = QueryPos.getInstance(q);
2387
2388 qPos.add(userId);
2389
2390 if (orderByComparator != null) {
2391 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2392
2393 for (Object value : values) {
2394 qPos.add(value);
2395 }
2396 }
2397
2398 List<AnnouncementsEntry> list = q.list();
2399
2400 if (list.size() == 2) {
2401 return list.get(1);
2402 }
2403 else {
2404 return null;
2405 }
2406 }
2407
2408
2415 public List<AnnouncementsEntry> filterFindByUserId(long userId)
2416 throws SystemException {
2417 return filterFindByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2418 null);
2419 }
2420
2421
2434 public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
2435 int end) throws SystemException {
2436 return filterFindByUserId(userId, start, end, null);
2437 }
2438
2439
2453 public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
2454 int end, OrderByComparator orderByComparator) throws SystemException {
2455 if (!InlineSQLHelperUtil.isEnabled()) {
2456 return findByUserId(userId, start, end, orderByComparator);
2457 }
2458
2459 StringBundler query = null;
2460
2461 if (orderByComparator != null) {
2462 query = new StringBundler(3 +
2463 (orderByComparator.getOrderByFields().length * 3));
2464 }
2465 else {
2466 query = new StringBundler(3);
2467 }
2468
2469 if (getDB().isSupportsInlineDistinct()) {
2470 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2471 }
2472 else {
2473 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2474 }
2475
2476 query.append(_FINDER_COLUMN_USERID_USERID_2);
2477
2478 if (!getDB().isSupportsInlineDistinct()) {
2479 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2480 }
2481
2482 if (orderByComparator != null) {
2483 if (getDB().isSupportsInlineDistinct()) {
2484 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2485 orderByComparator);
2486 }
2487 else {
2488 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2489 orderByComparator);
2490 }
2491 }
2492 else {
2493 if (getDB().isSupportsInlineDistinct()) {
2494 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2495 }
2496 else {
2497 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2498 }
2499 }
2500
2501 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2502 AnnouncementsEntry.class.getName(),
2503 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2504
2505 Session session = null;
2506
2507 try {
2508 session = openSession();
2509
2510 SQLQuery q = session.createSQLQuery(sql);
2511
2512 if (getDB().isSupportsInlineDistinct()) {
2513 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2514 }
2515 else {
2516 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2517 }
2518
2519 QueryPos qPos = QueryPos.getInstance(q);
2520
2521 qPos.add(userId);
2522
2523 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
2524 start, end);
2525 }
2526 catch (Exception e) {
2527 throw processException(e);
2528 }
2529 finally {
2530 closeSession(session);
2531 }
2532 }
2533
2534
2544 public AnnouncementsEntry[] filterFindByUserId_PrevAndNext(long entryId,
2545 long userId, OrderByComparator orderByComparator)
2546 throws NoSuchEntryException, SystemException {
2547 if (!InlineSQLHelperUtil.isEnabled()) {
2548 return findByUserId_PrevAndNext(entryId, userId, orderByComparator);
2549 }
2550
2551 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2552
2553 Session session = null;
2554
2555 try {
2556 session = openSession();
2557
2558 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2559
2560 array[0] = filterGetByUserId_PrevAndNext(session,
2561 announcementsEntry, userId, orderByComparator, true);
2562
2563 array[1] = announcementsEntry;
2564
2565 array[2] = filterGetByUserId_PrevAndNext(session,
2566 announcementsEntry, userId, orderByComparator, false);
2567
2568 return array;
2569 }
2570 catch (Exception e) {
2571 throw processException(e);
2572 }
2573 finally {
2574 closeSession(session);
2575 }
2576 }
2577
2578 protected AnnouncementsEntry filterGetByUserId_PrevAndNext(
2579 Session session, AnnouncementsEntry announcementsEntry, long userId,
2580 OrderByComparator orderByComparator, boolean previous) {
2581 StringBundler query = null;
2582
2583 if (orderByComparator != null) {
2584 query = new StringBundler(6 +
2585 (orderByComparator.getOrderByFields().length * 6));
2586 }
2587 else {
2588 query = new StringBundler(3);
2589 }
2590
2591 if (getDB().isSupportsInlineDistinct()) {
2592 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2593 }
2594 else {
2595 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2596 }
2597
2598 query.append(_FINDER_COLUMN_USERID_USERID_2);
2599
2600 if (!getDB().isSupportsInlineDistinct()) {
2601 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2602 }
2603
2604 if (orderByComparator != null) {
2605 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2606
2607 if (orderByConditionFields.length > 0) {
2608 query.append(WHERE_AND);
2609 }
2610
2611 for (int i = 0; i < orderByConditionFields.length; i++) {
2612 if (getDB().isSupportsInlineDistinct()) {
2613 query.append(_ORDER_BY_ENTITY_ALIAS);
2614 }
2615 else {
2616 query.append(_ORDER_BY_ENTITY_TABLE);
2617 }
2618
2619 query.append(orderByConditionFields[i]);
2620
2621 if ((i + 1) < orderByConditionFields.length) {
2622 if (orderByComparator.isAscending() ^ previous) {
2623 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2624 }
2625 else {
2626 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2627 }
2628 }
2629 else {
2630 if (orderByComparator.isAscending() ^ previous) {
2631 query.append(WHERE_GREATER_THAN);
2632 }
2633 else {
2634 query.append(WHERE_LESSER_THAN);
2635 }
2636 }
2637 }
2638
2639 query.append(ORDER_BY_CLAUSE);
2640
2641 String[] orderByFields = orderByComparator.getOrderByFields();
2642
2643 for (int i = 0; i < orderByFields.length; i++) {
2644 if (getDB().isSupportsInlineDistinct()) {
2645 query.append(_ORDER_BY_ENTITY_ALIAS);
2646 }
2647 else {
2648 query.append(_ORDER_BY_ENTITY_TABLE);
2649 }
2650
2651 query.append(orderByFields[i]);
2652
2653 if ((i + 1) < orderByFields.length) {
2654 if (orderByComparator.isAscending() ^ previous) {
2655 query.append(ORDER_BY_ASC_HAS_NEXT);
2656 }
2657 else {
2658 query.append(ORDER_BY_DESC_HAS_NEXT);
2659 }
2660 }
2661 else {
2662 if (orderByComparator.isAscending() ^ previous) {
2663 query.append(ORDER_BY_ASC);
2664 }
2665 else {
2666 query.append(ORDER_BY_DESC);
2667 }
2668 }
2669 }
2670 }
2671 else {
2672 if (getDB().isSupportsInlineDistinct()) {
2673 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2674 }
2675 else {
2676 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2677 }
2678 }
2679
2680 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2681 AnnouncementsEntry.class.getName(),
2682 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2683
2684 SQLQuery q = session.createSQLQuery(sql);
2685
2686 q.setFirstResult(0);
2687 q.setMaxResults(2);
2688
2689 if (getDB().isSupportsInlineDistinct()) {
2690 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2691 }
2692 else {
2693 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2694 }
2695
2696 QueryPos qPos = QueryPos.getInstance(q);
2697
2698 qPos.add(userId);
2699
2700 if (orderByComparator != null) {
2701 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2702
2703 for (Object value : values) {
2704 qPos.add(value);
2705 }
2706 }
2707
2708 List<AnnouncementsEntry> list = q.list();
2709
2710 if (list.size() == 2) {
2711 return list.get(1);
2712 }
2713 else {
2714 return null;
2715 }
2716 }
2717
2718
2724 public void removeByUserId(long userId) throws SystemException {
2725 for (AnnouncementsEntry announcementsEntry : findByUserId(userId,
2726 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2727 remove(announcementsEntry);
2728 }
2729 }
2730
2731
2738 public int countByUserId(long userId) throws SystemException {
2739 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
2740
2741 Object[] finderArgs = new Object[] { userId };
2742
2743 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2744 this);
2745
2746 if (count == null) {
2747 StringBundler query = new StringBundler(2);
2748
2749 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2750
2751 query.append(_FINDER_COLUMN_USERID_USERID_2);
2752
2753 String sql = query.toString();
2754
2755 Session session = null;
2756
2757 try {
2758 session = openSession();
2759
2760 Query q = session.createQuery(sql);
2761
2762 QueryPos qPos = QueryPos.getInstance(q);
2763
2764 qPos.add(userId);
2765
2766 count = (Long)q.uniqueResult();
2767
2768 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2769 }
2770 catch (Exception e) {
2771 FinderCacheUtil.removeResult(finderPath, finderArgs);
2772
2773 throw processException(e);
2774 }
2775 finally {
2776 closeSession(session);
2777 }
2778 }
2779
2780 return count.intValue();
2781 }
2782
2783
2790 public int filterCountByUserId(long userId) throws SystemException {
2791 if (!InlineSQLHelperUtil.isEnabled()) {
2792 return countByUserId(userId);
2793 }
2794
2795 StringBundler query = new StringBundler(2);
2796
2797 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2798
2799 query.append(_FINDER_COLUMN_USERID_USERID_2);
2800
2801 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2802 AnnouncementsEntry.class.getName(),
2803 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2804
2805 Session session = null;
2806
2807 try {
2808 session = openSession();
2809
2810 SQLQuery q = session.createSQLQuery(sql);
2811
2812 q.addScalar(COUNT_COLUMN_NAME,
2813 com.liferay.portal.kernel.dao.orm.Type.LONG);
2814
2815 QueryPos qPos = QueryPos.getInstance(q);
2816
2817 qPos.add(userId);
2818
2819 Long count = (Long)q.uniqueResult();
2820
2821 return count.intValue();
2822 }
2823 catch (Exception e) {
2824 throw processException(e);
2825 }
2826 finally {
2827 closeSession(session);
2828 }
2829 }
2830
2831 private static final String _FINDER_COLUMN_USERID_USERID_2 = "announcementsEntry.userId = ?";
2832 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2833 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2834 AnnouncementsEntryImpl.class,
2835 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
2836 new String[] {
2837 Long.class.getName(), Long.class.getName(),
2838
2839 Integer.class.getName(), Integer.class.getName(),
2840 OrderByComparator.class.getName()
2841 });
2842 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2843 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2844 AnnouncementsEntryImpl.class,
2845 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
2846 new String[] { Long.class.getName(), Long.class.getName() },
2847 AnnouncementsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2848 AnnouncementsEntryModelImpl.CLASSPK_COLUMN_BITMASK |
2849 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
2850 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
2851 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2852 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2853 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
2854 new String[] { Long.class.getName(), Long.class.getName() });
2855
2856
2864 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK)
2865 throws SystemException {
2866 return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
2867 QueryUtil.ALL_POS, null);
2868 }
2869
2870
2884 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
2885 int start, int end) throws SystemException {
2886 return findByC_C(classNameId, classPK, start, end, null);
2887 }
2888
2889
2904 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
2905 int start, int end, OrderByComparator orderByComparator)
2906 throws SystemException {
2907 boolean pagination = true;
2908 FinderPath finderPath = null;
2909 Object[] finderArgs = null;
2910
2911 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2912 (orderByComparator == null)) {
2913 pagination = false;
2914 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
2915 finderArgs = new Object[] { classNameId, classPK };
2916 }
2917 else {
2918 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
2919 finderArgs = new Object[] {
2920 classNameId, classPK,
2921
2922 start, end, orderByComparator
2923 };
2924 }
2925
2926 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
2927 finderArgs, this);
2928
2929 if ((list != null) && !list.isEmpty()) {
2930 for (AnnouncementsEntry announcementsEntry : list) {
2931 if ((classNameId != announcementsEntry.getClassNameId()) ||
2932 (classPK != announcementsEntry.getClassPK())) {
2933 list = null;
2934
2935 break;
2936 }
2937 }
2938 }
2939
2940 if (list == null) {
2941 StringBundler query = null;
2942
2943 if (orderByComparator != null) {
2944 query = new StringBundler(4 +
2945 (orderByComparator.getOrderByFields().length * 3));
2946 }
2947 else {
2948 query = new StringBundler(4);
2949 }
2950
2951 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2952
2953 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2954
2955 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2956
2957 if (orderByComparator != null) {
2958 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2959 orderByComparator);
2960 }
2961 else
2962 if (pagination) {
2963 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2964 }
2965
2966 String sql = query.toString();
2967
2968 Session session = null;
2969
2970 try {
2971 session = openSession();
2972
2973 Query q = session.createQuery(sql);
2974
2975 QueryPos qPos = QueryPos.getInstance(q);
2976
2977 qPos.add(classNameId);
2978
2979 qPos.add(classPK);
2980
2981 if (!pagination) {
2982 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2983 getDialect(), start, end, false);
2984
2985 Collections.sort(list);
2986
2987 list = new UnmodifiableList<AnnouncementsEntry>(list);
2988 }
2989 else {
2990 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2991 getDialect(), start, end);
2992 }
2993
2994 cacheResult(list);
2995
2996 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2997 }
2998 catch (Exception e) {
2999 FinderCacheUtil.removeResult(finderPath, finderArgs);
3000
3001 throw processException(e);
3002 }
3003 finally {
3004 closeSession(session);
3005 }
3006 }
3007
3008 return list;
3009 }
3010
3011
3021 public AnnouncementsEntry findByC_C_First(long classNameId, long classPK,
3022 OrderByComparator orderByComparator)
3023 throws NoSuchEntryException, SystemException {
3024 AnnouncementsEntry announcementsEntry = fetchByC_C_First(classNameId,
3025 classPK, orderByComparator);
3026
3027 if (announcementsEntry != null) {
3028 return announcementsEntry;
3029 }
3030
3031 StringBundler msg = new StringBundler(6);
3032
3033 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3034
3035 msg.append("classNameId=");
3036 msg.append(classNameId);
3037
3038 msg.append(", classPK=");
3039 msg.append(classPK);
3040
3041 msg.append(StringPool.CLOSE_CURLY_BRACE);
3042
3043 throw new NoSuchEntryException(msg.toString());
3044 }
3045
3046
3055 public AnnouncementsEntry fetchByC_C_First(long classNameId, long classPK,
3056 OrderByComparator orderByComparator) throws SystemException {
3057 List<AnnouncementsEntry> list = findByC_C(classNameId, classPK, 0, 1,
3058 orderByComparator);
3059
3060 if (!list.isEmpty()) {
3061 return list.get(0);
3062 }
3063
3064 return null;
3065 }
3066
3067
3077 public AnnouncementsEntry findByC_C_Last(long classNameId, long classPK,
3078 OrderByComparator orderByComparator)
3079 throws NoSuchEntryException, SystemException {
3080 AnnouncementsEntry announcementsEntry = fetchByC_C_Last(classNameId,
3081 classPK, orderByComparator);
3082
3083 if (announcementsEntry != null) {
3084 return announcementsEntry;
3085 }
3086
3087 StringBundler msg = new StringBundler(6);
3088
3089 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3090
3091 msg.append("classNameId=");
3092 msg.append(classNameId);
3093
3094 msg.append(", classPK=");
3095 msg.append(classPK);
3096
3097 msg.append(StringPool.CLOSE_CURLY_BRACE);
3098
3099 throw new NoSuchEntryException(msg.toString());
3100 }
3101
3102
3111 public AnnouncementsEntry fetchByC_C_Last(long classNameId, long classPK,
3112 OrderByComparator orderByComparator) throws SystemException {
3113 int count = countByC_C(classNameId, classPK);
3114
3115 List<AnnouncementsEntry> list = findByC_C(classNameId, classPK,
3116 count - 1, count, orderByComparator);
3117
3118 if (!list.isEmpty()) {
3119 return list.get(0);
3120 }
3121
3122 return null;
3123 }
3124
3125
3136 public AnnouncementsEntry[] findByC_C_PrevAndNext(long entryId,
3137 long classNameId, long classPK, OrderByComparator orderByComparator)
3138 throws NoSuchEntryException, SystemException {
3139 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
3140
3141 Session session = null;
3142
3143 try {
3144 session = openSession();
3145
3146 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
3147
3148 array[0] = getByC_C_PrevAndNext(session, announcementsEntry,
3149 classNameId, classPK, orderByComparator, true);
3150
3151 array[1] = announcementsEntry;
3152
3153 array[2] = getByC_C_PrevAndNext(session, announcementsEntry,
3154 classNameId, classPK, orderByComparator, false);
3155
3156 return array;
3157 }
3158 catch (Exception e) {
3159 throw processException(e);
3160 }
3161 finally {
3162 closeSession(session);
3163 }
3164 }
3165
3166 protected AnnouncementsEntry getByC_C_PrevAndNext(Session session,
3167 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
3168 OrderByComparator orderByComparator, boolean previous) {
3169 StringBundler query = null;
3170
3171 if (orderByComparator != null) {
3172 query = new StringBundler(6 +
3173 (orderByComparator.getOrderByFields().length * 6));
3174 }
3175 else {
3176 query = new StringBundler(3);
3177 }
3178
3179 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3180
3181 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3182
3183 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3184
3185 if (orderByComparator != null) {
3186 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3187
3188 if (orderByConditionFields.length > 0) {
3189 query.append(WHERE_AND);
3190 }
3191
3192 for (int i = 0; i < orderByConditionFields.length; i++) {
3193 query.append(_ORDER_BY_ENTITY_ALIAS);
3194 query.append(orderByConditionFields[i]);
3195
3196 if ((i + 1) < orderByConditionFields.length) {
3197 if (orderByComparator.isAscending() ^ previous) {
3198 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3199 }
3200 else {
3201 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3202 }
3203 }
3204 else {
3205 if (orderByComparator.isAscending() ^ previous) {
3206 query.append(WHERE_GREATER_THAN);
3207 }
3208 else {
3209 query.append(WHERE_LESSER_THAN);
3210 }
3211 }
3212 }
3213
3214 query.append(ORDER_BY_CLAUSE);
3215
3216 String[] orderByFields = orderByComparator.getOrderByFields();
3217
3218 for (int i = 0; i < orderByFields.length; i++) {
3219 query.append(_ORDER_BY_ENTITY_ALIAS);
3220 query.append(orderByFields[i]);
3221
3222 if ((i + 1) < orderByFields.length) {
3223 if (orderByComparator.isAscending() ^ previous) {
3224 query.append(ORDER_BY_ASC_HAS_NEXT);
3225 }
3226 else {
3227 query.append(ORDER_BY_DESC_HAS_NEXT);
3228 }
3229 }
3230 else {
3231 if (orderByComparator.isAscending() ^ previous) {
3232 query.append(ORDER_BY_ASC);
3233 }
3234 else {
3235 query.append(ORDER_BY_DESC);
3236 }
3237 }
3238 }
3239 }
3240 else {
3241 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3242 }
3243
3244 String sql = query.toString();
3245
3246 Query q = session.createQuery(sql);
3247
3248 q.setFirstResult(0);
3249 q.setMaxResults(2);
3250
3251 QueryPos qPos = QueryPos.getInstance(q);
3252
3253 qPos.add(classNameId);
3254
3255 qPos.add(classPK);
3256
3257 if (orderByComparator != null) {
3258 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
3259
3260 for (Object value : values) {
3261 qPos.add(value);
3262 }
3263 }
3264
3265 List<AnnouncementsEntry> list = q.list();
3266
3267 if (list.size() == 2) {
3268 return list.get(1);
3269 }
3270 else {
3271 return null;
3272 }
3273 }
3274
3275
3283 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3284 long classPK) throws SystemException {
3285 return filterFindByC_C(classNameId, classPK, QueryUtil.ALL_POS,
3286 QueryUtil.ALL_POS, null);
3287 }
3288
3289
3303 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3304 long classPK, int start, int end) throws SystemException {
3305 return filterFindByC_C(classNameId, classPK, start, end, null);
3306 }
3307
3308
3323 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3324 long classPK, int start, int end, OrderByComparator orderByComparator)
3325 throws SystemException {
3326 if (!InlineSQLHelperUtil.isEnabled()) {
3327 return findByC_C(classNameId, classPK, start, end, orderByComparator);
3328 }
3329
3330 StringBundler query = null;
3331
3332 if (orderByComparator != null) {
3333 query = new StringBundler(4 +
3334 (orderByComparator.getOrderByFields().length * 3));
3335 }
3336 else {
3337 query = new StringBundler(4);
3338 }
3339
3340 if (getDB().isSupportsInlineDistinct()) {
3341 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3342 }
3343 else {
3344 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3345 }
3346
3347 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3348
3349 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3350
3351 if (!getDB().isSupportsInlineDistinct()) {
3352 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3353 }
3354
3355 if (orderByComparator != null) {
3356 if (getDB().isSupportsInlineDistinct()) {
3357 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3358 orderByComparator);
3359 }
3360 else {
3361 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3362 orderByComparator);
3363 }
3364 }
3365 else {
3366 if (getDB().isSupportsInlineDistinct()) {
3367 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3368 }
3369 else {
3370 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
3371 }
3372 }
3373
3374 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3375 AnnouncementsEntry.class.getName(),
3376 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3377
3378 Session session = null;
3379
3380 try {
3381 session = openSession();
3382
3383 SQLQuery q = session.createSQLQuery(sql);
3384
3385 if (getDB().isSupportsInlineDistinct()) {
3386 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
3387 }
3388 else {
3389 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
3390 }
3391
3392 QueryPos qPos = QueryPos.getInstance(q);
3393
3394 qPos.add(classNameId);
3395
3396 qPos.add(classPK);
3397
3398 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
3399 start, end);
3400 }
3401 catch (Exception e) {
3402 throw processException(e);
3403 }
3404 finally {
3405 closeSession(session);
3406 }
3407 }
3408
3409
3420 public AnnouncementsEntry[] filterFindByC_C_PrevAndNext(long entryId,
3421 long classNameId, long classPK, OrderByComparator orderByComparator)
3422 throws NoSuchEntryException, SystemException {
3423 if (!InlineSQLHelperUtil.isEnabled()) {
3424 return findByC_C_PrevAndNext(entryId, classNameId, classPK,
3425 orderByComparator);
3426 }
3427
3428 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
3429
3430 Session session = null;
3431
3432 try {
3433 session = openSession();
3434
3435 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
3436
3437 array[0] = filterGetByC_C_PrevAndNext(session, announcementsEntry,
3438 classNameId, classPK, orderByComparator, true);
3439
3440 array[1] = announcementsEntry;
3441
3442 array[2] = filterGetByC_C_PrevAndNext(session, announcementsEntry,
3443 classNameId, classPK, orderByComparator, false);
3444
3445 return array;
3446 }
3447 catch (Exception e) {
3448 throw processException(e);
3449 }
3450 finally {
3451 closeSession(session);
3452 }
3453 }
3454
3455 protected AnnouncementsEntry filterGetByC_C_PrevAndNext(Session session,
3456 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
3457 OrderByComparator orderByComparator, boolean previous) {
3458 StringBundler query = null;
3459
3460 if (orderByComparator != null) {
3461 query = new StringBundler(6 +
3462 (orderByComparator.getOrderByFields().length * 6));
3463 }
3464 else {
3465 query = new StringBundler(3);
3466 }
3467
3468 if (getDB().isSupportsInlineDistinct()) {
3469 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3470 }
3471 else {
3472 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3473 }
3474
3475 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3476
3477 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3478
3479 if (!getDB().isSupportsInlineDistinct()) {
3480 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3481 }
3482
3483 if (orderByComparator != null) {
3484 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3485
3486 if (orderByConditionFields.length > 0) {
3487 query.append(WHERE_AND);
3488 }
3489
3490 for (int i = 0; i < orderByConditionFields.length; i++) {
3491 if (getDB().isSupportsInlineDistinct()) {
3492 query.append(_ORDER_BY_ENTITY_ALIAS);
3493 }
3494 else {
3495 query.append(_ORDER_BY_ENTITY_TABLE);
3496 }
3497
3498 query.append(orderByConditionFields[i]);
3499
3500 if ((i + 1) < orderByConditionFields.length) {
3501 if (orderByComparator.isAscending() ^ previous) {
3502 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3503 }
3504 else {
3505 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3506 }
3507 }
3508 else {
3509 if (orderByComparator.isAscending() ^ previous) {
3510 query.append(WHERE_GREATER_THAN);
3511 }
3512 else {
3513 query.append(WHERE_LESSER_THAN);
3514 }
3515 }
3516 }
3517
3518 query.append(ORDER_BY_CLAUSE);
3519
3520 String[] orderByFields = orderByComparator.getOrderByFields();
3521
3522 for (int i = 0; i < orderByFields.length; i++) {
3523 if (getDB().isSupportsInlineDistinct()) {
3524 query.append(_ORDER_BY_ENTITY_ALIAS);
3525 }
3526 else {
3527 query.append(_ORDER_BY_ENTITY_TABLE);
3528 }
3529
3530 query.append(orderByFields[i]);
3531
3532 if ((i + 1) < orderByFields.length) {
3533 if (orderByComparator.isAscending() ^ previous) {
3534 query.append(ORDER_BY_ASC_HAS_NEXT);
3535 }
3536 else {
3537 query.append(ORDER_BY_DESC_HAS_NEXT);
3538 }
3539 }
3540 else {
3541 if (orderByComparator.isAscending() ^ previous) {
3542 query.append(ORDER_BY_ASC);
3543 }
3544 else {
3545 query.append(ORDER_BY_DESC);
3546 }
3547 }
3548 }
3549 }
3550 else {
3551 if (getDB().isSupportsInlineDistinct()) {
3552 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3553 }
3554 else {
3555 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
3556 }
3557 }
3558
3559 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3560 AnnouncementsEntry.class.getName(),
3561 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3562
3563 SQLQuery q = session.createSQLQuery(sql);
3564
3565 q.setFirstResult(0);
3566 q.setMaxResults(2);
3567
3568 if (getDB().isSupportsInlineDistinct()) {
3569 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
3570 }
3571 else {
3572 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
3573 }
3574
3575 QueryPos qPos = QueryPos.getInstance(q);
3576
3577 qPos.add(classNameId);
3578
3579 qPos.add(classPK);
3580
3581 if (orderByComparator != null) {
3582 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
3583
3584 for (Object value : values) {
3585 qPos.add(value);
3586 }
3587 }
3588
3589 List<AnnouncementsEntry> list = q.list();
3590
3591 if (list.size() == 2) {
3592 return list.get(1);
3593 }
3594 else {
3595 return null;
3596 }
3597 }
3598
3599
3606 public void removeByC_C(long classNameId, long classPK)
3607 throws SystemException {
3608 for (AnnouncementsEntry announcementsEntry : findByC_C(classNameId,
3609 classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3610 remove(announcementsEntry);
3611 }
3612 }
3613
3614
3622 public int countByC_C(long classNameId, long classPK)
3623 throws SystemException {
3624 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
3625
3626 Object[] finderArgs = new Object[] { classNameId, classPK };
3627
3628 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3629 this);
3630
3631 if (count == null) {
3632 StringBundler query = new StringBundler(3);
3633
3634 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3635
3636 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3637
3638 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3639
3640 String sql = query.toString();
3641
3642 Session session = null;
3643
3644 try {
3645 session = openSession();
3646
3647 Query q = session.createQuery(sql);
3648
3649 QueryPos qPos = QueryPos.getInstance(q);
3650
3651 qPos.add(classNameId);
3652
3653 qPos.add(classPK);
3654
3655 count = (Long)q.uniqueResult();
3656
3657 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3658 }
3659 catch (Exception e) {
3660 FinderCacheUtil.removeResult(finderPath, finderArgs);
3661
3662 throw processException(e);
3663 }
3664 finally {
3665 closeSession(session);
3666 }
3667 }
3668
3669 return count.intValue();
3670 }
3671
3672
3680 public int filterCountByC_C(long classNameId, long classPK)
3681 throws SystemException {
3682 if (!InlineSQLHelperUtil.isEnabled()) {
3683 return countByC_C(classNameId, classPK);
3684 }
3685
3686 StringBundler query = new StringBundler(3);
3687
3688 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3689
3690 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3691
3692 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3693
3694 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3695 AnnouncementsEntry.class.getName(),
3696 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3697
3698 Session session = null;
3699
3700 try {
3701 session = openSession();
3702
3703 SQLQuery q = session.createSQLQuery(sql);
3704
3705 q.addScalar(COUNT_COLUMN_NAME,
3706 com.liferay.portal.kernel.dao.orm.Type.LONG);
3707
3708 QueryPos qPos = QueryPos.getInstance(q);
3709
3710 qPos.add(classNameId);
3711
3712 qPos.add(classPK);
3713
3714 Long count = (Long)q.uniqueResult();
3715
3716 return count.intValue();
3717 }
3718 catch (Exception e) {
3719 throw processException(e);
3720 }
3721 finally {
3722 closeSession(session);
3723 }
3724 }
3725
3726 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
3727 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "announcementsEntry.classPK = ?";
3728 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
3729 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
3730 AnnouncementsEntryImpl.class,
3731 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_A",
3732 new String[] {
3733 Long.class.getName(), Long.class.getName(),
3734 Boolean.class.getName(),
3735
3736 Integer.class.getName(), Integer.class.getName(),
3737 OrderByComparator.class.getName()
3738 });
3739 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
3740 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
3741 AnnouncementsEntryImpl.class,
3742 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_A",
3743 new String[] {
3744 Long.class.getName(), Long.class.getName(),
3745 Boolean.class.getName()
3746 },
3747 AnnouncementsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
3748 AnnouncementsEntryModelImpl.CLASSPK_COLUMN_BITMASK |
3749 AnnouncementsEntryModelImpl.ALERT_COLUMN_BITMASK |
3750 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
3751 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
3752 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
3753 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3754 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_A",
3755 new String[] {
3756 Long.class.getName(), Long.class.getName(),
3757 Boolean.class.getName()
3758 });
3759
3760
3769 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3770 boolean alert) throws SystemException {
3771 return findByC_C_A(classNameId, classPK, alert, QueryUtil.ALL_POS,
3772 QueryUtil.ALL_POS, null);
3773 }
3774
3775
3790 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3791 boolean alert, int start, int end) throws SystemException {
3792 return findByC_C_A(classNameId, classPK, alert, start, end, null);
3793 }
3794
3795
3811 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3812 boolean alert, int start, int end, OrderByComparator orderByComparator)
3813 throws SystemException {
3814 boolean pagination = true;
3815 FinderPath finderPath = null;
3816 Object[] finderArgs = null;
3817
3818 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3819 (orderByComparator == null)) {
3820 pagination = false;
3821 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A;
3822 finderArgs = new Object[] { classNameId, classPK, alert };
3823 }
3824 else {
3825 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_A;
3826 finderArgs = new Object[] {
3827 classNameId, classPK, alert,
3828
3829 start, end, orderByComparator
3830 };
3831 }
3832
3833 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
3834 finderArgs, this);
3835
3836 if ((list != null) && !list.isEmpty()) {
3837 for (AnnouncementsEntry announcementsEntry : list) {
3838 if ((classNameId != announcementsEntry.getClassNameId()) ||
3839 (classPK != announcementsEntry.getClassPK()) ||
3840 (alert != announcementsEntry.getAlert())) {
3841 list = null;
3842
3843 break;
3844 }
3845 }
3846 }
3847
3848 if (list == null) {
3849 StringBundler query = null;
3850
3851 if (orderByComparator != null) {
3852 query = new StringBundler(5 +
3853 (orderByComparator.getOrderByFields().length * 3));
3854 }
3855 else {
3856 query = new StringBundler(5);
3857 }
3858
3859 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3860
3861 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
3862
3863 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
3864
3865 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
3866
3867 if (orderByComparator != null) {
3868 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3869 orderByComparator);
3870 }
3871 else
3872 if (pagination) {
3873 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3874 }
3875
3876 String sql = query.toString();
3877
3878 Session session = null;
3879
3880 try {
3881 session = openSession();
3882
3883 Query q = session.createQuery(sql);
3884
3885 QueryPos qPos = QueryPos.getInstance(q);
3886
3887 qPos.add(classNameId);
3888
3889 qPos.add(classPK);
3890
3891 qPos.add(alert);
3892
3893 if (!pagination) {
3894 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3895 getDialect(), start, end, false);
3896
3897 Collections.sort(list);
3898
3899 list = new UnmodifiableList<AnnouncementsEntry>(list);
3900 }
3901 else {
3902 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3903 getDialect(), start, end);
3904 }
3905
3906 cacheResult(list);
3907
3908 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3909 }
3910 catch (Exception e) {
3911 FinderCacheUtil.removeResult(finderPath, finderArgs);
3912
3913 throw processException(e);
3914 }
3915 finally {
3916 closeSession(session);
3917 }
3918 }
3919
3920 return list;
3921 }
3922
3923
3934 public AnnouncementsEntry findByC_C_A_First(long classNameId, long classPK,
3935 boolean alert, OrderByComparator orderByComparator)
3936 throws NoSuchEntryException, SystemException {
3937 AnnouncementsEntry announcementsEntry = fetchByC_C_A_First(classNameId,
3938 classPK, alert, orderByComparator);
3939
3940 if (announcementsEntry != null) {
3941 return announcementsEntry;
3942 }
3943
3944 StringBundler msg = new StringBundler(8);
3945
3946 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3947
3948 msg.append("classNameId=");
3949 msg.append(classNameId);
3950
3951 msg.append(", classPK=");
3952 msg.append(classPK);
3953
3954 msg.append(", alert=");
3955 msg.append(alert);
3956
3957 msg.append(StringPool.CLOSE_CURLY_BRACE);
3958
3959 throw new NoSuchEntryException(msg.toString());
3960 }
3961
3962
3972 public AnnouncementsEntry fetchByC_C_A_First(long classNameId,
3973 long classPK, boolean alert, OrderByComparator orderByComparator)
3974 throws SystemException {
3975 List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
3976 alert, 0, 1, orderByComparator);
3977
3978 if (!list.isEmpty()) {
3979 return list.get(0);
3980 }
3981
3982 return null;
3983 }
3984
3985
3996 public AnnouncementsEntry findByC_C_A_Last(long classNameId, long classPK,
3997 boolean alert, OrderByComparator orderByComparator)
3998 throws NoSuchEntryException, SystemException {
3999 AnnouncementsEntry announcementsEntry = fetchByC_C_A_Last(classNameId,
4000 classPK, alert, orderByComparator);
4001
4002 if (announcementsEntry != null) {
4003 return announcementsEntry;
4004 }
4005
4006 StringBundler msg = new StringBundler(8);
4007
4008 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4009
4010 msg.append("classNameId=");
4011 msg.append(classNameId);
4012
4013 msg.append(", classPK=");
4014 msg.append(classPK);
4015
4016 msg.append(", alert=");
4017 msg.append(alert);
4018
4019 msg.append(StringPool.CLOSE_CURLY_BRACE);
4020
4021 throw new NoSuchEntryException(msg.toString());
4022 }
4023
4024
4034 public AnnouncementsEntry fetchByC_C_A_Last(long classNameId, long classPK,
4035 boolean alert, OrderByComparator orderByComparator)
4036 throws SystemException {
4037 int count = countByC_C_A(classNameId, classPK, alert);
4038
4039 List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
4040 alert, count - 1, count, orderByComparator);
4041
4042 if (!list.isEmpty()) {
4043 return list.get(0);
4044 }
4045
4046 return null;
4047 }
4048
4049
4061 public AnnouncementsEntry[] findByC_C_A_PrevAndNext(long entryId,
4062 long classNameId, long classPK, boolean alert,
4063 OrderByComparator orderByComparator)
4064 throws NoSuchEntryException, SystemException {
4065 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
4066
4067 Session session = null;
4068
4069 try {
4070 session = openSession();
4071
4072 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
4073
4074 array[0] = getByC_C_A_PrevAndNext(session, announcementsEntry,
4075 classNameId, classPK, alert, orderByComparator, true);
4076
4077 array[1] = announcementsEntry;
4078
4079 array[2] = getByC_C_A_PrevAndNext(session, announcementsEntry,
4080 classNameId, classPK, alert, orderByComparator, false);
4081
4082 return array;
4083 }
4084 catch (Exception e) {
4085 throw processException(e);
4086 }
4087 finally {
4088 closeSession(session);
4089 }
4090 }
4091
4092 protected AnnouncementsEntry getByC_C_A_PrevAndNext(Session session,
4093 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
4094 boolean alert, OrderByComparator orderByComparator, boolean previous) {
4095 StringBundler query = null;
4096
4097 if (orderByComparator != null) {
4098 query = new StringBundler(6 +
4099 (orderByComparator.getOrderByFields().length * 6));
4100 }
4101 else {
4102 query = new StringBundler(3);
4103 }
4104
4105 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4106
4107 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4108
4109 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4110
4111 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4112
4113 if (orderByComparator != null) {
4114 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4115
4116 if (orderByConditionFields.length > 0) {
4117 query.append(WHERE_AND);
4118 }
4119
4120 for (int i = 0; i < orderByConditionFields.length; i++) {
4121 query.append(_ORDER_BY_ENTITY_ALIAS);
4122 query.append(orderByConditionFields[i]);
4123
4124 if ((i + 1) < orderByConditionFields.length) {
4125 if (orderByComparator.isAscending() ^ previous) {
4126 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4127 }
4128 else {
4129 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4130 }
4131 }
4132 else {
4133 if (orderByComparator.isAscending() ^ previous) {
4134 query.append(WHERE_GREATER_THAN);
4135 }
4136 else {
4137 query.append(WHERE_LESSER_THAN);
4138 }
4139 }
4140 }
4141
4142 query.append(ORDER_BY_CLAUSE);
4143
4144 String[] orderByFields = orderByComparator.getOrderByFields();
4145
4146 for (int i = 0; i < orderByFields.length; i++) {
4147 query.append(_ORDER_BY_ENTITY_ALIAS);
4148 query.append(orderByFields[i]);
4149
4150 if ((i + 1) < orderByFields.length) {
4151 if (orderByComparator.isAscending() ^ previous) {
4152 query.append(ORDER_BY_ASC_HAS_NEXT);
4153 }
4154 else {
4155 query.append(ORDER_BY_DESC_HAS_NEXT);
4156 }
4157 }
4158 else {
4159 if (orderByComparator.isAscending() ^ previous) {
4160 query.append(ORDER_BY_ASC);
4161 }
4162 else {
4163 query.append(ORDER_BY_DESC);
4164 }
4165 }
4166 }
4167 }
4168 else {
4169 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4170 }
4171
4172 String sql = query.toString();
4173
4174 Query q = session.createQuery(sql);
4175
4176 q.setFirstResult(0);
4177 q.setMaxResults(2);
4178
4179 QueryPos qPos = QueryPos.getInstance(q);
4180
4181 qPos.add(classNameId);
4182
4183 qPos.add(classPK);
4184
4185 qPos.add(alert);
4186
4187 if (orderByComparator != null) {
4188 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
4189
4190 for (Object value : values) {
4191 qPos.add(value);
4192 }
4193 }
4194
4195 List<AnnouncementsEntry> list = q.list();
4196
4197 if (list.size() == 2) {
4198 return list.get(1);
4199 }
4200 else {
4201 return null;
4202 }
4203 }
4204
4205
4214 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4215 long classPK, boolean alert) throws SystemException {
4216 return filterFindByC_C_A(classNameId, classPK, alert,
4217 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4218 }
4219
4220
4235 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4236 long classPK, boolean alert, int start, int end)
4237 throws SystemException {
4238 return filterFindByC_C_A(classNameId, classPK, alert, start, end, null);
4239 }
4240
4241
4257 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4258 long classPK, boolean alert, int start, int end,
4259 OrderByComparator orderByComparator) throws SystemException {
4260 if (!InlineSQLHelperUtil.isEnabled()) {
4261 return findByC_C_A(classNameId, classPK, alert, start, end,
4262 orderByComparator);
4263 }
4264
4265 StringBundler query = null;
4266
4267 if (orderByComparator != null) {
4268 query = new StringBundler(5 +
4269 (orderByComparator.getOrderByFields().length * 3));
4270 }
4271 else {
4272 query = new StringBundler(5);
4273 }
4274
4275 if (getDB().isSupportsInlineDistinct()) {
4276 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4277 }
4278 else {
4279 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4280 }
4281
4282 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4283
4284 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4285
4286 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4287
4288 if (!getDB().isSupportsInlineDistinct()) {
4289 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4290 }
4291
4292 if (orderByComparator != null) {
4293 if (getDB().isSupportsInlineDistinct()) {
4294 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4295 orderByComparator);
4296 }
4297 else {
4298 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4299 orderByComparator);
4300 }
4301 }
4302 else {
4303 if (getDB().isSupportsInlineDistinct()) {
4304 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4305 }
4306 else {
4307 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
4308 }
4309 }
4310
4311 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4312 AnnouncementsEntry.class.getName(),
4313 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4314
4315 Session session = null;
4316
4317 try {
4318 session = openSession();
4319
4320 SQLQuery q = session.createSQLQuery(sql);
4321
4322 if (getDB().isSupportsInlineDistinct()) {
4323 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
4324 }
4325 else {
4326 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
4327 }
4328
4329 QueryPos qPos = QueryPos.getInstance(q);
4330
4331 qPos.add(classNameId);
4332
4333 qPos.add(classPK);
4334
4335 qPos.add(alert);
4336
4337 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
4338 start, end);
4339 }
4340 catch (Exception e) {
4341 throw processException(e);
4342 }
4343 finally {
4344 closeSession(session);
4345 }
4346 }
4347
4348
4360 public AnnouncementsEntry[] filterFindByC_C_A_PrevAndNext(long entryId,
4361 long classNameId, long classPK, boolean alert,
4362 OrderByComparator orderByComparator)
4363 throws NoSuchEntryException, SystemException {
4364 if (!InlineSQLHelperUtil.isEnabled()) {
4365 return findByC_C_A_PrevAndNext(entryId, classNameId, classPK,
4366 alert, orderByComparator);
4367 }
4368
4369 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
4370
4371 Session session = null;
4372
4373 try {
4374 session = openSession();
4375
4376 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
4377
4378 array[0] = filterGetByC_C_A_PrevAndNext(session,
4379 announcementsEntry, classNameId, classPK, alert,
4380 orderByComparator, true);
4381
4382 array[1] = announcementsEntry;
4383
4384 array[2] = filterGetByC_C_A_PrevAndNext(session,
4385 announcementsEntry, classNameId, classPK, alert,
4386 orderByComparator, false);
4387
4388 return array;
4389 }
4390 catch (Exception e) {
4391 throw processException(e);
4392 }
4393 finally {
4394 closeSession(session);
4395 }
4396 }
4397
4398 protected AnnouncementsEntry filterGetByC_C_A_PrevAndNext(Session session,
4399 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
4400 boolean alert, OrderByComparator orderByComparator, boolean previous) {
4401 StringBundler query = null;
4402
4403 if (orderByComparator != null) {
4404 query = new StringBundler(6 +
4405 (orderByComparator.getOrderByFields().length * 6));
4406 }
4407 else {
4408 query = new StringBundler(3);
4409 }
4410
4411 if (getDB().isSupportsInlineDistinct()) {
4412 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4413 }
4414 else {
4415 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4416 }
4417
4418 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4419
4420 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4421
4422 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4423
4424 if (!getDB().isSupportsInlineDistinct()) {
4425 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4426 }
4427
4428 if (orderByComparator != null) {
4429 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4430
4431 if (orderByConditionFields.length > 0) {
4432 query.append(WHERE_AND);
4433 }
4434
4435 for (int i = 0; i < orderByConditionFields.length; i++) {
4436 if (getDB().isSupportsInlineDistinct()) {
4437 query.append(_ORDER_BY_ENTITY_ALIAS);
4438 }
4439 else {
4440 query.append(_ORDER_BY_ENTITY_TABLE);
4441 }
4442
4443 query.append(orderByConditionFields[i]);
4444
4445 if ((i + 1) < orderByConditionFields.length) {
4446 if (orderByComparator.isAscending() ^ previous) {
4447 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4448 }
4449 else {
4450 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4451 }
4452 }
4453 else {
4454 if (orderByComparator.isAscending() ^ previous) {
4455 query.append(WHERE_GREATER_THAN);
4456 }
4457 else {
4458 query.append(WHERE_LESSER_THAN);
4459 }
4460 }
4461 }
4462
4463 query.append(ORDER_BY_CLAUSE);
4464
4465 String[] orderByFields = orderByComparator.getOrderByFields();
4466
4467 for (int i = 0; i < orderByFields.length; i++) {
4468 if (getDB().isSupportsInlineDistinct()) {
4469 query.append(_ORDER_BY_ENTITY_ALIAS);
4470 }
4471 else {
4472 query.append(_ORDER_BY_ENTITY_TABLE);
4473 }
4474
4475 query.append(orderByFields[i]);
4476
4477 if ((i + 1) < orderByFields.length) {
4478 if (orderByComparator.isAscending() ^ previous) {
4479 query.append(ORDER_BY_ASC_HAS_NEXT);
4480 }
4481 else {
4482 query.append(ORDER_BY_DESC_HAS_NEXT);
4483 }
4484 }
4485 else {
4486 if (orderByComparator.isAscending() ^ previous) {
4487 query.append(ORDER_BY_ASC);
4488 }
4489 else {
4490 query.append(ORDER_BY_DESC);
4491 }
4492 }
4493 }
4494 }
4495 else {
4496 if (getDB().isSupportsInlineDistinct()) {
4497 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4498 }
4499 else {
4500 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
4501 }
4502 }
4503
4504 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4505 AnnouncementsEntry.class.getName(),
4506 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4507
4508 SQLQuery q = session.createSQLQuery(sql);
4509
4510 q.setFirstResult(0);
4511 q.setMaxResults(2);
4512
4513 if (getDB().isSupportsInlineDistinct()) {
4514 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
4515 }
4516 else {
4517 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
4518 }
4519
4520 QueryPos qPos = QueryPos.getInstance(q);
4521
4522 qPos.add(classNameId);
4523
4524 qPos.add(classPK);
4525
4526 qPos.add(alert);
4527
4528 if (orderByComparator != null) {
4529 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
4530
4531 for (Object value : values) {
4532 qPos.add(value);
4533 }
4534 }
4535
4536 List<AnnouncementsEntry> list = q.list();
4537
4538 if (list.size() == 2) {
4539 return list.get(1);
4540 }
4541 else {
4542 return null;
4543 }
4544 }
4545
4546
4554 public void removeByC_C_A(long classNameId, long classPK, boolean alert)
4555 throws SystemException {
4556 for (AnnouncementsEntry announcementsEntry : findByC_C_A(classNameId,
4557 classPK, alert, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4558 remove(announcementsEntry);
4559 }
4560 }
4561
4562
4571 public int countByC_C_A(long classNameId, long classPK, boolean alert)
4572 throws SystemException {
4573 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_A;
4574
4575 Object[] finderArgs = new Object[] { classNameId, classPK, alert };
4576
4577 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4578 this);
4579
4580 if (count == null) {
4581 StringBundler query = new StringBundler(4);
4582
4583 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4584
4585 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4586
4587 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4588
4589 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4590
4591 String sql = query.toString();
4592
4593 Session session = null;
4594
4595 try {
4596 session = openSession();
4597
4598 Query q = session.createQuery(sql);
4599
4600 QueryPos qPos = QueryPos.getInstance(q);
4601
4602 qPos.add(classNameId);
4603
4604 qPos.add(classPK);
4605
4606 qPos.add(alert);
4607
4608 count = (Long)q.uniqueResult();
4609
4610 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4611 }
4612 catch (Exception e) {
4613 FinderCacheUtil.removeResult(finderPath, finderArgs);
4614
4615 throw processException(e);
4616 }
4617 finally {
4618 closeSession(session);
4619 }
4620 }
4621
4622 return count.intValue();
4623 }
4624
4625
4634 public int filterCountByC_C_A(long classNameId, long classPK, boolean alert)
4635 throws SystemException {
4636 if (!InlineSQLHelperUtil.isEnabled()) {
4637 return countByC_C_A(classNameId, classPK, alert);
4638 }
4639
4640 StringBundler query = new StringBundler(4);
4641
4642 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4643
4644 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4645
4646 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4647
4648 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4649
4650 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4651 AnnouncementsEntry.class.getName(),
4652 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4653
4654 Session session = null;
4655
4656 try {
4657 session = openSession();
4658
4659 SQLQuery q = session.createSQLQuery(sql);
4660
4661 q.addScalar(COUNT_COLUMN_NAME,
4662 com.liferay.portal.kernel.dao.orm.Type.LONG);
4663
4664 QueryPos qPos = QueryPos.getInstance(q);
4665
4666 qPos.add(classNameId);
4667
4668 qPos.add(classPK);
4669
4670 qPos.add(alert);
4671
4672 Long count = (Long)q.uniqueResult();
4673
4674 return count.intValue();
4675 }
4676 catch (Exception e) {
4677 throw processException(e);
4678 }
4679 finally {
4680 closeSession(session);
4681 }
4682 }
4683
4684 private static final String _FINDER_COLUMN_C_C_A_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
4685 private static final String _FINDER_COLUMN_C_C_A_CLASSPK_2 = "announcementsEntry.classPK = ? AND ";
4686 private static final String _FINDER_COLUMN_C_C_A_ALERT_2 = "announcementsEntry.alert = ?";
4687
4688
4693 public void cacheResult(AnnouncementsEntry announcementsEntry) {
4694 EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4695 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
4696 announcementsEntry);
4697
4698 announcementsEntry.resetOriginalValues();
4699 }
4700
4701
4706 public void cacheResult(List<AnnouncementsEntry> announcementsEntries) {
4707 for (AnnouncementsEntry announcementsEntry : announcementsEntries) {
4708 if (EntityCacheUtil.getResult(
4709 AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4710 AnnouncementsEntryImpl.class,
4711 announcementsEntry.getPrimaryKey()) == null) {
4712 cacheResult(announcementsEntry);
4713 }
4714 else {
4715 announcementsEntry.resetOriginalValues();
4716 }
4717 }
4718 }
4719
4720
4727 @Override
4728 public void clearCache() {
4729 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
4730 CacheRegistryUtil.clear(AnnouncementsEntryImpl.class.getName());
4731 }
4732
4733 EntityCacheUtil.clearCache(AnnouncementsEntryImpl.class.getName());
4734
4735 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4736 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4737 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4738 }
4739
4740
4747 @Override
4748 public void clearCache(AnnouncementsEntry announcementsEntry) {
4749 EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4750 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
4751
4752 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4753 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4754 }
4755
4756 @Override
4757 public void clearCache(List<AnnouncementsEntry> announcementsEntries) {
4758 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4759 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4760
4761 for (AnnouncementsEntry announcementsEntry : announcementsEntries) {
4762 EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4763 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
4764 }
4765 }
4766
4767
4773 public AnnouncementsEntry create(long entryId) {
4774 AnnouncementsEntry announcementsEntry = new AnnouncementsEntryImpl();
4775
4776 announcementsEntry.setNew(true);
4777 announcementsEntry.setPrimaryKey(entryId);
4778
4779 String uuid = PortalUUIDUtil.generate();
4780
4781 announcementsEntry.setUuid(uuid);
4782
4783 return announcementsEntry;
4784 }
4785
4786
4794 public AnnouncementsEntry remove(long entryId)
4795 throws NoSuchEntryException, SystemException {
4796 return remove((Serializable)entryId);
4797 }
4798
4799
4807 @Override
4808 public AnnouncementsEntry remove(Serializable primaryKey)
4809 throws NoSuchEntryException, SystemException {
4810 Session session = null;
4811
4812 try {
4813 session = openSession();
4814
4815 AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
4816 primaryKey);
4817
4818 if (announcementsEntry == null) {
4819 if (_log.isWarnEnabled()) {
4820 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4821 }
4822
4823 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4824 primaryKey);
4825 }
4826
4827 return remove(announcementsEntry);
4828 }
4829 catch (NoSuchEntryException nsee) {
4830 throw nsee;
4831 }
4832 catch (Exception e) {
4833 throw processException(e);
4834 }
4835 finally {
4836 closeSession(session);
4837 }
4838 }
4839
4840 @Override
4841 protected AnnouncementsEntry removeImpl(
4842 AnnouncementsEntry announcementsEntry) throws SystemException {
4843 announcementsEntry = toUnwrappedModel(announcementsEntry);
4844
4845 Session session = null;
4846
4847 try {
4848 session = openSession();
4849
4850 if (!session.contains(announcementsEntry)) {
4851 announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
4852 announcementsEntry.getPrimaryKeyObj());
4853 }
4854
4855 if (announcementsEntry != null) {
4856 session.delete(announcementsEntry);
4857 }
4858 }
4859 catch (Exception e) {
4860 throw processException(e);
4861 }
4862 finally {
4863 closeSession(session);
4864 }
4865
4866 if (announcementsEntry != null) {
4867 clearCache(announcementsEntry);
4868 }
4869
4870 return announcementsEntry;
4871 }
4872
4873 @Override
4874 public AnnouncementsEntry updateImpl(
4875 com.liferay.portlet.announcements.model.AnnouncementsEntry announcementsEntry)
4876 throws SystemException {
4877 announcementsEntry = toUnwrappedModel(announcementsEntry);
4878
4879 boolean isNew = announcementsEntry.isNew();
4880
4881 AnnouncementsEntryModelImpl announcementsEntryModelImpl = (AnnouncementsEntryModelImpl)announcementsEntry;
4882
4883 if (Validator.isNull(announcementsEntry.getUuid())) {
4884 String uuid = PortalUUIDUtil.generate();
4885
4886 announcementsEntry.setUuid(uuid);
4887 }
4888
4889 Session session = null;
4890
4891 try {
4892 session = openSession();
4893
4894 if (announcementsEntry.isNew()) {
4895 session.save(announcementsEntry);
4896
4897 announcementsEntry.setNew(false);
4898 }
4899 else {
4900 session.merge(announcementsEntry);
4901 }
4902 }
4903 catch (Exception e) {
4904 throw processException(e);
4905 }
4906 finally {
4907 closeSession(session);
4908 }
4909
4910 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4911
4912 if (isNew || !AnnouncementsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
4913 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4914 }
4915
4916 else {
4917 if ((announcementsEntryModelImpl.getColumnBitmask() &
4918 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
4919 Object[] args = new Object[] {
4920 announcementsEntryModelImpl.getOriginalUuid()
4921 };
4922
4923 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4924 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4925 args);
4926
4927 args = new Object[] { announcementsEntryModelImpl.getUuid() };
4928
4929 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4930 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4931 args);
4932 }
4933
4934 if ((announcementsEntryModelImpl.getColumnBitmask() &
4935 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
4936 Object[] args = new Object[] {
4937 announcementsEntryModelImpl.getOriginalUuid(),
4938 announcementsEntryModelImpl.getOriginalCompanyId()
4939 };
4940
4941 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4942 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4943 args);
4944
4945 args = new Object[] {
4946 announcementsEntryModelImpl.getUuid(),
4947 announcementsEntryModelImpl.getCompanyId()
4948 };
4949
4950 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4951 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4952 args);
4953 }
4954
4955 if ((announcementsEntryModelImpl.getColumnBitmask() &
4956 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
4957 Object[] args = new Object[] {
4958 announcementsEntryModelImpl.getOriginalUserId()
4959 };
4960
4961 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
4962 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
4963 args);
4964
4965 args = new Object[] { announcementsEntryModelImpl.getUserId() };
4966
4967 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
4968 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
4969 args);
4970 }
4971
4972 if ((announcementsEntryModelImpl.getColumnBitmask() &
4973 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
4974 Object[] args = new Object[] {
4975 announcementsEntryModelImpl.getOriginalClassNameId(),
4976 announcementsEntryModelImpl.getOriginalClassPK()
4977 };
4978
4979 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
4980 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
4981 args);
4982
4983 args = new Object[] {
4984 announcementsEntryModelImpl.getClassNameId(),
4985 announcementsEntryModelImpl.getClassPK()
4986 };
4987
4988 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
4989 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
4990 args);
4991 }
4992
4993 if ((announcementsEntryModelImpl.getColumnBitmask() &
4994 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A.getColumnBitmask()) != 0) {
4995 Object[] args = new Object[] {
4996 announcementsEntryModelImpl.getOriginalClassNameId(),
4997 announcementsEntryModelImpl.getOriginalClassPK(),
4998 announcementsEntryModelImpl.getOriginalAlert()
4999 };
5000
5001 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_A, args);
5002 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A,
5003 args);
5004
5005 args = new Object[] {
5006 announcementsEntryModelImpl.getClassNameId(),
5007 announcementsEntryModelImpl.getClassPK(),
5008 announcementsEntryModelImpl.getAlert()
5009 };
5010
5011 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_A, args);
5012 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A,
5013 args);
5014 }
5015 }
5016
5017 EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5018 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
5019 announcementsEntry);
5020
5021 return announcementsEntry;
5022 }
5023
5024 protected AnnouncementsEntry toUnwrappedModel(
5025 AnnouncementsEntry announcementsEntry) {
5026 if (announcementsEntry instanceof AnnouncementsEntryImpl) {
5027 return announcementsEntry;
5028 }
5029
5030 AnnouncementsEntryImpl announcementsEntryImpl = new AnnouncementsEntryImpl();
5031
5032 announcementsEntryImpl.setNew(announcementsEntry.isNew());
5033 announcementsEntryImpl.setPrimaryKey(announcementsEntry.getPrimaryKey());
5034
5035 announcementsEntryImpl.setUuid(announcementsEntry.getUuid());
5036 announcementsEntryImpl.setEntryId(announcementsEntry.getEntryId());
5037 announcementsEntryImpl.setCompanyId(announcementsEntry.getCompanyId());
5038 announcementsEntryImpl.setUserId(announcementsEntry.getUserId());
5039 announcementsEntryImpl.setUserName(announcementsEntry.getUserName());
5040 announcementsEntryImpl.setCreateDate(announcementsEntry.getCreateDate());
5041 announcementsEntryImpl.setModifiedDate(announcementsEntry.getModifiedDate());
5042 announcementsEntryImpl.setClassNameId(announcementsEntry.getClassNameId());
5043 announcementsEntryImpl.setClassPK(announcementsEntry.getClassPK());
5044 announcementsEntryImpl.setTitle(announcementsEntry.getTitle());
5045 announcementsEntryImpl.setContent(announcementsEntry.getContent());
5046 announcementsEntryImpl.setUrl(announcementsEntry.getUrl());
5047 announcementsEntryImpl.setType(announcementsEntry.getType());
5048 announcementsEntryImpl.setDisplayDate(announcementsEntry.getDisplayDate());
5049 announcementsEntryImpl.setExpirationDate(announcementsEntry.getExpirationDate());
5050 announcementsEntryImpl.setPriority(announcementsEntry.getPriority());
5051 announcementsEntryImpl.setAlert(announcementsEntry.isAlert());
5052
5053 return announcementsEntryImpl;
5054 }
5055
5056
5064 @Override
5065 public AnnouncementsEntry findByPrimaryKey(Serializable primaryKey)
5066 throws NoSuchEntryException, SystemException {
5067 AnnouncementsEntry announcementsEntry = fetchByPrimaryKey(primaryKey);
5068
5069 if (announcementsEntry == null) {
5070 if (_log.isWarnEnabled()) {
5071 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5072 }
5073
5074 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5075 primaryKey);
5076 }
5077
5078 return announcementsEntry;
5079 }
5080
5081
5089 public AnnouncementsEntry findByPrimaryKey(long entryId)
5090 throws NoSuchEntryException, SystemException {
5091 return findByPrimaryKey((Serializable)entryId);
5092 }
5093
5094
5101 @Override
5102 public AnnouncementsEntry fetchByPrimaryKey(Serializable primaryKey)
5103 throws SystemException {
5104 AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)EntityCacheUtil.getResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5105 AnnouncementsEntryImpl.class, primaryKey);
5106
5107 if (announcementsEntry == _nullAnnouncementsEntry) {
5108 return null;
5109 }
5110
5111 if (announcementsEntry == null) {
5112 Session session = null;
5113
5114 try {
5115 session = openSession();
5116
5117 announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
5118 primaryKey);
5119
5120 if (announcementsEntry != null) {
5121 cacheResult(announcementsEntry);
5122 }
5123 else {
5124 EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5125 AnnouncementsEntryImpl.class, primaryKey,
5126 _nullAnnouncementsEntry);
5127 }
5128 }
5129 catch (Exception e) {
5130 EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5131 AnnouncementsEntryImpl.class, primaryKey);
5132
5133 throw processException(e);
5134 }
5135 finally {
5136 closeSession(session);
5137 }
5138 }
5139
5140 return announcementsEntry;
5141 }
5142
5143
5150 public AnnouncementsEntry fetchByPrimaryKey(long entryId)
5151 throws SystemException {
5152 return fetchByPrimaryKey((Serializable)entryId);
5153 }
5154
5155
5161 public List<AnnouncementsEntry> findAll() throws SystemException {
5162 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5163 }
5164
5165
5177 public List<AnnouncementsEntry> findAll(int start, int end)
5178 throws SystemException {
5179 return findAll(start, end, null);
5180 }
5181
5182
5195 public List<AnnouncementsEntry> findAll(int start, int end,
5196 OrderByComparator orderByComparator) throws SystemException {
5197 boolean pagination = true;
5198 FinderPath finderPath = null;
5199 Object[] finderArgs = null;
5200
5201 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5202 (orderByComparator == null)) {
5203 pagination = false;
5204 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5205 finderArgs = FINDER_ARGS_EMPTY;
5206 }
5207 else {
5208 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5209 finderArgs = new Object[] { start, end, orderByComparator };
5210 }
5211
5212 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
5213 finderArgs, this);
5214
5215 if (list == null) {
5216 StringBundler query = null;
5217 String sql = null;
5218
5219 if (orderByComparator != null) {
5220 query = new StringBundler(2 +
5221 (orderByComparator.getOrderByFields().length * 3));
5222
5223 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY);
5224
5225 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5226 orderByComparator);
5227
5228 sql = query.toString();
5229 }
5230 else {
5231 sql = _SQL_SELECT_ANNOUNCEMENTSENTRY;
5232
5233 if (pagination) {
5234 sql = sql.concat(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
5235 }
5236 }
5237
5238 Session session = null;
5239
5240 try {
5241 session = openSession();
5242
5243 Query q = session.createQuery(sql);
5244
5245 if (!pagination) {
5246 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
5247 getDialect(), start, end, false);
5248
5249 Collections.sort(list);
5250
5251 list = new UnmodifiableList<AnnouncementsEntry>(list);
5252 }
5253 else {
5254 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
5255 getDialect(), start, end);
5256 }
5257
5258 cacheResult(list);
5259
5260 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5261 }
5262 catch (Exception e) {
5263 FinderCacheUtil.removeResult(finderPath, finderArgs);
5264
5265 throw processException(e);
5266 }
5267 finally {
5268 closeSession(session);
5269 }
5270 }
5271
5272 return list;
5273 }
5274
5275
5280 public void removeAll() throws SystemException {
5281 for (AnnouncementsEntry announcementsEntry : findAll()) {
5282 remove(announcementsEntry);
5283 }
5284 }
5285
5286
5292 public int countAll() throws SystemException {
5293 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5294 FINDER_ARGS_EMPTY, this);
5295
5296 if (count == null) {
5297 Session session = null;
5298
5299 try {
5300 session = openSession();
5301
5302 Query q = session.createQuery(_SQL_COUNT_ANNOUNCEMENTSENTRY);
5303
5304 count = (Long)q.uniqueResult();
5305
5306 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5307 FINDER_ARGS_EMPTY, count);
5308 }
5309 catch (Exception e) {
5310 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5311 FINDER_ARGS_EMPTY);
5312
5313 throw processException(e);
5314 }
5315 finally {
5316 closeSession(session);
5317 }
5318 }
5319
5320 return count.intValue();
5321 }
5322
5323
5326 public void afterPropertiesSet() {
5327 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5328 com.liferay.portal.util.PropsUtil.get(
5329 "value.object.listener.com.liferay.portlet.announcements.model.AnnouncementsEntry")));
5330
5331 if (listenerClassNames.length > 0) {
5332 try {
5333 List<ModelListener<AnnouncementsEntry>> listenersList = new ArrayList<ModelListener<AnnouncementsEntry>>();
5334
5335 for (String listenerClassName : listenerClassNames) {
5336 listenersList.add((ModelListener<AnnouncementsEntry>)InstanceFactory.newInstance(
5337 listenerClassName));
5338 }
5339
5340 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5341 }
5342 catch (Exception e) {
5343 _log.error(e);
5344 }
5345 }
5346 }
5347
5348 public void destroy() {
5349 EntityCacheUtil.removeCache(AnnouncementsEntryImpl.class.getName());
5350 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5351 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5352 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5353 }
5354
5355 private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry";
5356 private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry WHERE ";
5357 private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry";
5358 private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry WHERE ";
5359 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "announcementsEntry.entryId";
5360 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT DISTINCT {announcementsEntry.*} FROM AnnouncementsEntry announcementsEntry WHERE ";
5361 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
5362 "SELECT {AnnouncementsEntry.*} FROM (SELECT DISTINCT announcementsEntry.entryId FROM AnnouncementsEntry announcementsEntry WHERE ";
5363 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
5364 ") TEMP_TABLE INNER JOIN AnnouncementsEntry ON TEMP_TABLE.entryId = AnnouncementsEntry.entryId";
5365 private static final String _FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(DISTINCT announcementsEntry.entryId) AS COUNT_VALUE FROM AnnouncementsEntry announcementsEntry WHERE ";
5366 private static final String _FILTER_ENTITY_ALIAS = "announcementsEntry";
5367 private static final String _FILTER_ENTITY_TABLE = "AnnouncementsEntry";
5368 private static final String _ORDER_BY_ENTITY_ALIAS = "announcementsEntry.";
5369 private static final String _ORDER_BY_ENTITY_TABLE = "AnnouncementsEntry.";
5370 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AnnouncementsEntry exists with the primary key ";
5371 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AnnouncementsEntry exists with the key {";
5372 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5373 private static Log _log = LogFactoryUtil.getLog(AnnouncementsEntryPersistenceImpl.class);
5374 private static AnnouncementsEntry _nullAnnouncementsEntry = new AnnouncementsEntryImpl() {
5375 @Override
5376 public Object clone() {
5377 return this;
5378 }
5379
5380 @Override
5381 public CacheModel<AnnouncementsEntry> toCacheModel() {
5382 return _nullAnnouncementsEntryCacheModel;
5383 }
5384 };
5385
5386 private static CacheModel<AnnouncementsEntry> _nullAnnouncementsEntryCacheModel =
5387 new CacheModel<AnnouncementsEntry>() {
5388 public AnnouncementsEntry toEntityModel() {
5389 return _nullAnnouncementsEntry;
5390 }
5391 };
5392 }