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