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 @Override
122 public List<AnnouncementsEntry> findByUuid(String uuid)
123 throws SystemException {
124 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
125 }
126
127
140 @Override
141 public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end)
142 throws SystemException {
143 return findByUuid(uuid, start, end, null);
144 }
145
146
160 @Override
161 public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end,
162 OrderByComparator orderByComparator) throws SystemException {
163 boolean pagination = true;
164 FinderPath finderPath = null;
165 Object[] finderArgs = null;
166
167 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
168 (orderByComparator == null)) {
169 pagination = false;
170 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
171 finderArgs = new Object[] { uuid };
172 }
173 else {
174 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
175 finderArgs = new Object[] { uuid, start, end, orderByComparator };
176 }
177
178 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
179 finderArgs, this);
180
181 if ((list != null) && !list.isEmpty()) {
182 for (AnnouncementsEntry announcementsEntry : list) {
183 if (!Validator.equals(uuid, announcementsEntry.getUuid())) {
184 list = null;
185
186 break;
187 }
188 }
189 }
190
191 if (list == null) {
192 StringBundler query = null;
193
194 if (orderByComparator != null) {
195 query = new StringBundler(3 +
196 (orderByComparator.getOrderByFields().length * 3));
197 }
198 else {
199 query = new StringBundler(3);
200 }
201
202 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
203
204 boolean bindUuid = false;
205
206 if (uuid == null) {
207 query.append(_FINDER_COLUMN_UUID_UUID_1);
208 }
209 else if (uuid.equals(StringPool.BLANK)) {
210 query.append(_FINDER_COLUMN_UUID_UUID_3);
211 }
212 else {
213 bindUuid = true;
214
215 query.append(_FINDER_COLUMN_UUID_UUID_2);
216 }
217
218 if (orderByComparator != null) {
219 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
220 orderByComparator);
221 }
222 else
223 if (pagination) {
224 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
225 }
226
227 String sql = query.toString();
228
229 Session session = null;
230
231 try {
232 session = openSession();
233
234 Query q = session.createQuery(sql);
235
236 QueryPos qPos = QueryPos.getInstance(q);
237
238 if (bindUuid) {
239 qPos.add(uuid);
240 }
241
242 if (!pagination) {
243 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
244 getDialect(), start, end, false);
245
246 Collections.sort(list);
247
248 list = new UnmodifiableList<AnnouncementsEntry>(list);
249 }
250 else {
251 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
252 getDialect(), start, end);
253 }
254
255 cacheResult(list);
256
257 FinderCacheUtil.putResult(finderPath, finderArgs, list);
258 }
259 catch (Exception e) {
260 FinderCacheUtil.removeResult(finderPath, finderArgs);
261
262 throw processException(e);
263 }
264 finally {
265 closeSession(session);
266 }
267 }
268
269 return list;
270 }
271
272
281 @Override
282 public AnnouncementsEntry findByUuid_First(String uuid,
283 OrderByComparator orderByComparator)
284 throws NoSuchEntryException, SystemException {
285 AnnouncementsEntry announcementsEntry = fetchByUuid_First(uuid,
286 orderByComparator);
287
288 if (announcementsEntry != null) {
289 return announcementsEntry;
290 }
291
292 StringBundler msg = new StringBundler(4);
293
294 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
295
296 msg.append("uuid=");
297 msg.append(uuid);
298
299 msg.append(StringPool.CLOSE_CURLY_BRACE);
300
301 throw new NoSuchEntryException(msg.toString());
302 }
303
304
312 @Override
313 public AnnouncementsEntry fetchByUuid_First(String uuid,
314 OrderByComparator orderByComparator) throws SystemException {
315 List<AnnouncementsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
316
317 if (!list.isEmpty()) {
318 return list.get(0);
319 }
320
321 return null;
322 }
323
324
333 @Override
334 public AnnouncementsEntry findByUuid_Last(String uuid,
335 OrderByComparator orderByComparator)
336 throws NoSuchEntryException, SystemException {
337 AnnouncementsEntry announcementsEntry = fetchByUuid_Last(uuid,
338 orderByComparator);
339
340 if (announcementsEntry != null) {
341 return announcementsEntry;
342 }
343
344 StringBundler msg = new StringBundler(4);
345
346 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
347
348 msg.append("uuid=");
349 msg.append(uuid);
350
351 msg.append(StringPool.CLOSE_CURLY_BRACE);
352
353 throw new NoSuchEntryException(msg.toString());
354 }
355
356
364 @Override
365 public AnnouncementsEntry fetchByUuid_Last(String uuid,
366 OrderByComparator orderByComparator) throws SystemException {
367 int count = countByUuid(uuid);
368
369 if (count == 0) {
370 return null;
371 }
372
373 List<AnnouncementsEntry> list = findByUuid(uuid, count - 1, count,
374 orderByComparator);
375
376 if (!list.isEmpty()) {
377 return list.get(0);
378 }
379
380 return null;
381 }
382
383
393 @Override
394 public AnnouncementsEntry[] findByUuid_PrevAndNext(long entryId,
395 String uuid, OrderByComparator orderByComparator)
396 throws NoSuchEntryException, SystemException {
397 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
398
399 Session session = null;
400
401 try {
402 session = openSession();
403
404 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
405
406 array[0] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
407 orderByComparator, true);
408
409 array[1] = announcementsEntry;
410
411 array[2] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
412 orderByComparator, false);
413
414 return array;
415 }
416 catch (Exception e) {
417 throw processException(e);
418 }
419 finally {
420 closeSession(session);
421 }
422 }
423
424 protected AnnouncementsEntry getByUuid_PrevAndNext(Session session,
425 AnnouncementsEntry announcementsEntry, String uuid,
426 OrderByComparator orderByComparator, boolean previous) {
427 StringBundler query = null;
428
429 if (orderByComparator != null) {
430 query = new StringBundler(6 +
431 (orderByComparator.getOrderByFields().length * 6));
432 }
433 else {
434 query = new StringBundler(3);
435 }
436
437 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
438
439 boolean bindUuid = false;
440
441 if (uuid == null) {
442 query.append(_FINDER_COLUMN_UUID_UUID_1);
443 }
444 else if (uuid.equals(StringPool.BLANK)) {
445 query.append(_FINDER_COLUMN_UUID_UUID_3);
446 }
447 else {
448 bindUuid = true;
449
450 query.append(_FINDER_COLUMN_UUID_UUID_2);
451 }
452
453 if (orderByComparator != null) {
454 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
455
456 if (orderByConditionFields.length > 0) {
457 query.append(WHERE_AND);
458 }
459
460 for (int i = 0; i < orderByConditionFields.length; i++) {
461 query.append(_ORDER_BY_ENTITY_ALIAS);
462 query.append(orderByConditionFields[i]);
463
464 if ((i + 1) < orderByConditionFields.length) {
465 if (orderByComparator.isAscending() ^ previous) {
466 query.append(WHERE_GREATER_THAN_HAS_NEXT);
467 }
468 else {
469 query.append(WHERE_LESSER_THAN_HAS_NEXT);
470 }
471 }
472 else {
473 if (orderByComparator.isAscending() ^ previous) {
474 query.append(WHERE_GREATER_THAN);
475 }
476 else {
477 query.append(WHERE_LESSER_THAN);
478 }
479 }
480 }
481
482 query.append(ORDER_BY_CLAUSE);
483
484 String[] orderByFields = orderByComparator.getOrderByFields();
485
486 for (int i = 0; i < orderByFields.length; i++) {
487 query.append(_ORDER_BY_ENTITY_ALIAS);
488 query.append(orderByFields[i]);
489
490 if ((i + 1) < orderByFields.length) {
491 if (orderByComparator.isAscending() ^ previous) {
492 query.append(ORDER_BY_ASC_HAS_NEXT);
493 }
494 else {
495 query.append(ORDER_BY_DESC_HAS_NEXT);
496 }
497 }
498 else {
499 if (orderByComparator.isAscending() ^ previous) {
500 query.append(ORDER_BY_ASC);
501 }
502 else {
503 query.append(ORDER_BY_DESC);
504 }
505 }
506 }
507 }
508 else {
509 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
510 }
511
512 String sql = query.toString();
513
514 Query q = session.createQuery(sql);
515
516 q.setFirstResult(0);
517 q.setMaxResults(2);
518
519 QueryPos qPos = QueryPos.getInstance(q);
520
521 if (bindUuid) {
522 qPos.add(uuid);
523 }
524
525 if (orderByComparator != null) {
526 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
527
528 for (Object value : values) {
529 qPos.add(value);
530 }
531 }
532
533 List<AnnouncementsEntry> list = q.list();
534
535 if (list.size() == 2) {
536 return list.get(1);
537 }
538 else {
539 return null;
540 }
541 }
542
543
550 @Override
551 public List<AnnouncementsEntry> filterFindByUuid(String uuid)
552 throws SystemException {
553 return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
554 }
555
556
569 @Override
570 public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
571 int end) throws SystemException {
572 return filterFindByUuid(uuid, start, end, null);
573 }
574
575
589 @Override
590 public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
591 int end, OrderByComparator orderByComparator) throws SystemException {
592 if (!InlineSQLHelperUtil.isEnabled()) {
593 return findByUuid(uuid, start, end, orderByComparator);
594 }
595
596 StringBundler query = null;
597
598 if (orderByComparator != null) {
599 query = new StringBundler(3 +
600 (orderByComparator.getOrderByFields().length * 3));
601 }
602 else {
603 query = new StringBundler(3);
604 }
605
606 if (getDB().isSupportsInlineDistinct()) {
607 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
608 }
609 else {
610 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
611 }
612
613 boolean bindUuid = false;
614
615 if (uuid == null) {
616 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
617 }
618 else if (uuid.equals(StringPool.BLANK)) {
619 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
620 }
621 else {
622 bindUuid = true;
623
624 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
625 }
626
627 if (!getDB().isSupportsInlineDistinct()) {
628 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
629 }
630
631 if (orderByComparator != null) {
632 if (getDB().isSupportsInlineDistinct()) {
633 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
634 orderByComparator, true);
635 }
636 else {
637 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
638 orderByComparator, true);
639 }
640 }
641 else {
642 if (getDB().isSupportsInlineDistinct()) {
643 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
644 }
645 else {
646 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
647 }
648 }
649
650 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
651 AnnouncementsEntry.class.getName(),
652 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
653
654 Session session = null;
655
656 try {
657 session = openSession();
658
659 SQLQuery q = session.createSQLQuery(sql);
660
661 if (getDB().isSupportsInlineDistinct()) {
662 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
663 }
664 else {
665 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
666 }
667
668 QueryPos qPos = QueryPos.getInstance(q);
669
670 if (bindUuid) {
671 qPos.add(uuid);
672 }
673
674 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
675 start, end);
676 }
677 catch (Exception e) {
678 throw processException(e);
679 }
680 finally {
681 closeSession(session);
682 }
683 }
684
685
695 @Override
696 public AnnouncementsEntry[] filterFindByUuid_PrevAndNext(long entryId,
697 String uuid, OrderByComparator orderByComparator)
698 throws NoSuchEntryException, SystemException {
699 if (!InlineSQLHelperUtil.isEnabled()) {
700 return findByUuid_PrevAndNext(entryId, uuid, orderByComparator);
701 }
702
703 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
704
705 Session session = null;
706
707 try {
708 session = openSession();
709
710 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
711
712 array[0] = filterGetByUuid_PrevAndNext(session, announcementsEntry,
713 uuid, orderByComparator, true);
714
715 array[1] = announcementsEntry;
716
717 array[2] = filterGetByUuid_PrevAndNext(session, announcementsEntry,
718 uuid, orderByComparator, false);
719
720 return array;
721 }
722 catch (Exception e) {
723 throw processException(e);
724 }
725 finally {
726 closeSession(session);
727 }
728 }
729
730 protected AnnouncementsEntry filterGetByUuid_PrevAndNext(Session session,
731 AnnouncementsEntry announcementsEntry, String uuid,
732 OrderByComparator orderByComparator, boolean previous) {
733 StringBundler query = null;
734
735 if (orderByComparator != null) {
736 query = new StringBundler(6 +
737 (orderByComparator.getOrderByFields().length * 6));
738 }
739 else {
740 query = new StringBundler(3);
741 }
742
743 if (getDB().isSupportsInlineDistinct()) {
744 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
745 }
746 else {
747 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
748 }
749
750 boolean bindUuid = false;
751
752 if (uuid == null) {
753 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
754 }
755 else if (uuid.equals(StringPool.BLANK)) {
756 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
757 }
758 else {
759 bindUuid = true;
760
761 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
762 }
763
764 if (!getDB().isSupportsInlineDistinct()) {
765 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
766 }
767
768 if (orderByComparator != null) {
769 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
770
771 if (orderByConditionFields.length > 0) {
772 query.append(WHERE_AND);
773 }
774
775 for (int i = 0; i < orderByConditionFields.length; i++) {
776 if (getDB().isSupportsInlineDistinct()) {
777 query.append(_ORDER_BY_ENTITY_ALIAS);
778 }
779 else {
780 query.append(_ORDER_BY_ENTITY_TABLE);
781 }
782
783 query.append(orderByConditionFields[i]);
784
785 if ((i + 1) < orderByConditionFields.length) {
786 if (orderByComparator.isAscending() ^ previous) {
787 query.append(WHERE_GREATER_THAN_HAS_NEXT);
788 }
789 else {
790 query.append(WHERE_LESSER_THAN_HAS_NEXT);
791 }
792 }
793 else {
794 if (orderByComparator.isAscending() ^ previous) {
795 query.append(WHERE_GREATER_THAN);
796 }
797 else {
798 query.append(WHERE_LESSER_THAN);
799 }
800 }
801 }
802
803 query.append(ORDER_BY_CLAUSE);
804
805 String[] orderByFields = orderByComparator.getOrderByFields();
806
807 for (int i = 0; i < orderByFields.length; i++) {
808 if (getDB().isSupportsInlineDistinct()) {
809 query.append(_ORDER_BY_ENTITY_ALIAS);
810 }
811 else {
812 query.append(_ORDER_BY_ENTITY_TABLE);
813 }
814
815 query.append(orderByFields[i]);
816
817 if ((i + 1) < orderByFields.length) {
818 if (orderByComparator.isAscending() ^ previous) {
819 query.append(ORDER_BY_ASC_HAS_NEXT);
820 }
821 else {
822 query.append(ORDER_BY_DESC_HAS_NEXT);
823 }
824 }
825 else {
826 if (orderByComparator.isAscending() ^ previous) {
827 query.append(ORDER_BY_ASC);
828 }
829 else {
830 query.append(ORDER_BY_DESC);
831 }
832 }
833 }
834 }
835 else {
836 if (getDB().isSupportsInlineDistinct()) {
837 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
838 }
839 else {
840 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
841 }
842 }
843
844 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
845 AnnouncementsEntry.class.getName(),
846 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
847
848 SQLQuery q = session.createSQLQuery(sql);
849
850 q.setFirstResult(0);
851 q.setMaxResults(2);
852
853 if (getDB().isSupportsInlineDistinct()) {
854 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
855 }
856 else {
857 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
858 }
859
860 QueryPos qPos = QueryPos.getInstance(q);
861
862 if (bindUuid) {
863 qPos.add(uuid);
864 }
865
866 if (orderByComparator != null) {
867 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
868
869 for (Object value : values) {
870 qPos.add(value);
871 }
872 }
873
874 List<AnnouncementsEntry> list = q.list();
875
876 if (list.size() == 2) {
877 return list.get(1);
878 }
879 else {
880 return null;
881 }
882 }
883
884
890 @Override
891 public void removeByUuid(String uuid) throws SystemException {
892 for (AnnouncementsEntry announcementsEntry : findByUuid(uuid,
893 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
894 remove(announcementsEntry);
895 }
896 }
897
898
905 @Override
906 public int countByUuid(String uuid) throws SystemException {
907 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
908
909 Object[] finderArgs = new Object[] { uuid };
910
911 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
912 this);
913
914 if (count == null) {
915 StringBundler query = new StringBundler(2);
916
917 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
918
919 boolean bindUuid = false;
920
921 if (uuid == null) {
922 query.append(_FINDER_COLUMN_UUID_UUID_1);
923 }
924 else if (uuid.equals(StringPool.BLANK)) {
925 query.append(_FINDER_COLUMN_UUID_UUID_3);
926 }
927 else {
928 bindUuid = true;
929
930 query.append(_FINDER_COLUMN_UUID_UUID_2);
931 }
932
933 String sql = query.toString();
934
935 Session session = null;
936
937 try {
938 session = openSession();
939
940 Query q = session.createQuery(sql);
941
942 QueryPos qPos = QueryPos.getInstance(q);
943
944 if (bindUuid) {
945 qPos.add(uuid);
946 }
947
948 count = (Long)q.uniqueResult();
949
950 FinderCacheUtil.putResult(finderPath, finderArgs, count);
951 }
952 catch (Exception e) {
953 FinderCacheUtil.removeResult(finderPath, finderArgs);
954
955 throw processException(e);
956 }
957 finally {
958 closeSession(session);
959 }
960 }
961
962 return count.intValue();
963 }
964
965
972 @Override
973 public int filterCountByUuid(String uuid) throws SystemException {
974 if (!InlineSQLHelperUtil.isEnabled()) {
975 return countByUuid(uuid);
976 }
977
978 StringBundler query = new StringBundler(2);
979
980 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
981
982 boolean bindUuid = false;
983
984 if (uuid == null) {
985 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
986 }
987 else if (uuid.equals(StringPool.BLANK)) {
988 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
989 }
990 else {
991 bindUuid = true;
992
993 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
994 }
995
996 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
997 AnnouncementsEntry.class.getName(),
998 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
999
1000 Session session = null;
1001
1002 try {
1003 session = openSession();
1004
1005 SQLQuery q = session.createSQLQuery(sql);
1006
1007 q.addScalar(COUNT_COLUMN_NAME,
1008 com.liferay.portal.kernel.dao.orm.Type.LONG);
1009
1010 QueryPos qPos = QueryPos.getInstance(q);
1011
1012 if (bindUuid) {
1013 qPos.add(uuid);
1014 }
1015
1016 Long count = (Long)q.uniqueResult();
1017
1018 return count.intValue();
1019 }
1020 catch (Exception e) {
1021 throw processException(e);
1022 }
1023 finally {
1024 closeSession(session);
1025 }
1026 }
1027
1028 private static final String _FINDER_COLUMN_UUID_UUID_1 = "announcementsEntry.uuid IS NULL";
1029 private static final String _FINDER_COLUMN_UUID_UUID_2 = "announcementsEntry.uuid = ?";
1030 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(announcementsEntry.uuid IS NULL OR announcementsEntry.uuid = '')";
1031 private static final String _FINDER_COLUMN_UUID_UUID_1_SQL = "announcementsEntry.uuid_ IS NULL";
1032 private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "announcementsEntry.uuid_ = ?";
1033 private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(announcementsEntry.uuid_ IS NULL OR announcementsEntry.uuid_ = '')";
1034 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
1035 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
1036 AnnouncementsEntryImpl.class,
1037 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
1038 new String[] {
1039 String.class.getName(), Long.class.getName(),
1040
1041 Integer.class.getName(), Integer.class.getName(),
1042 OrderByComparator.class.getName()
1043 });
1044 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1045 new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
1046 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
1047 AnnouncementsEntryImpl.class,
1048 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1049 new String[] { String.class.getName(), Long.class.getName() },
1050 AnnouncementsEntryModelImpl.UUID_COLUMN_BITMASK |
1051 AnnouncementsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
1052 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
1053 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
1054 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
1055 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1056 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1057 new String[] { String.class.getName(), Long.class.getName() });
1058
1059
1067 @Override
1068 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId)
1069 throws SystemException {
1070 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1071 QueryUtil.ALL_POS, null);
1072 }
1073
1074
1088 @Override
1089 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId,
1090 int start, int end) throws SystemException {
1091 return findByUuid_C(uuid, companyId, start, end, null);
1092 }
1093
1094
1109 @Override
1110 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId,
1111 int start, int end, OrderByComparator orderByComparator)
1112 throws SystemException {
1113 boolean pagination = true;
1114 FinderPath finderPath = null;
1115 Object[] finderArgs = null;
1116
1117 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1118 (orderByComparator == null)) {
1119 pagination = false;
1120 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1121 finderArgs = new Object[] { uuid, companyId };
1122 }
1123 else {
1124 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1125 finderArgs = new Object[] {
1126 uuid, companyId,
1127
1128 start, end, orderByComparator
1129 };
1130 }
1131
1132 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
1133 finderArgs, this);
1134
1135 if ((list != null) && !list.isEmpty()) {
1136 for (AnnouncementsEntry announcementsEntry : list) {
1137 if (!Validator.equals(uuid, announcementsEntry.getUuid()) ||
1138 (companyId != announcementsEntry.getCompanyId())) {
1139 list = null;
1140
1141 break;
1142 }
1143 }
1144 }
1145
1146 if (list == null) {
1147 StringBundler query = null;
1148
1149 if (orderByComparator != null) {
1150 query = new StringBundler(4 +
1151 (orderByComparator.getOrderByFields().length * 3));
1152 }
1153 else {
1154 query = new StringBundler(4);
1155 }
1156
1157 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1158
1159 boolean bindUuid = false;
1160
1161 if (uuid == null) {
1162 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1163 }
1164 else if (uuid.equals(StringPool.BLANK)) {
1165 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1166 }
1167 else {
1168 bindUuid = true;
1169
1170 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1171 }
1172
1173 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1174
1175 if (orderByComparator != null) {
1176 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1177 orderByComparator);
1178 }
1179 else
1180 if (pagination) {
1181 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1182 }
1183
1184 String sql = query.toString();
1185
1186 Session session = null;
1187
1188 try {
1189 session = openSession();
1190
1191 Query q = session.createQuery(sql);
1192
1193 QueryPos qPos = QueryPos.getInstance(q);
1194
1195 if (bindUuid) {
1196 qPos.add(uuid);
1197 }
1198
1199 qPos.add(companyId);
1200
1201 if (!pagination) {
1202 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
1203 getDialect(), start, end, false);
1204
1205 Collections.sort(list);
1206
1207 list = new UnmodifiableList<AnnouncementsEntry>(list);
1208 }
1209 else {
1210 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
1211 getDialect(), start, end);
1212 }
1213
1214 cacheResult(list);
1215
1216 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1217 }
1218 catch (Exception e) {
1219 FinderCacheUtil.removeResult(finderPath, finderArgs);
1220
1221 throw processException(e);
1222 }
1223 finally {
1224 closeSession(session);
1225 }
1226 }
1227
1228 return list;
1229 }
1230
1231
1241 @Override
1242 public AnnouncementsEntry findByUuid_C_First(String uuid, long companyId,
1243 OrderByComparator orderByComparator)
1244 throws NoSuchEntryException, SystemException {
1245 AnnouncementsEntry announcementsEntry = fetchByUuid_C_First(uuid,
1246 companyId, orderByComparator);
1247
1248 if (announcementsEntry != null) {
1249 return announcementsEntry;
1250 }
1251
1252 StringBundler msg = new StringBundler(6);
1253
1254 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1255
1256 msg.append("uuid=");
1257 msg.append(uuid);
1258
1259 msg.append(", companyId=");
1260 msg.append(companyId);
1261
1262 msg.append(StringPool.CLOSE_CURLY_BRACE);
1263
1264 throw new NoSuchEntryException(msg.toString());
1265 }
1266
1267
1276 @Override
1277 public AnnouncementsEntry fetchByUuid_C_First(String uuid, long companyId,
1278 OrderByComparator orderByComparator) throws SystemException {
1279 List<AnnouncementsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1280 orderByComparator);
1281
1282 if (!list.isEmpty()) {
1283 return list.get(0);
1284 }
1285
1286 return null;
1287 }
1288
1289
1299 @Override
1300 public AnnouncementsEntry findByUuid_C_Last(String uuid, long companyId,
1301 OrderByComparator orderByComparator)
1302 throws NoSuchEntryException, SystemException {
1303 AnnouncementsEntry announcementsEntry = fetchByUuid_C_Last(uuid,
1304 companyId, orderByComparator);
1305
1306 if (announcementsEntry != null) {
1307 return announcementsEntry;
1308 }
1309
1310 StringBundler msg = new StringBundler(6);
1311
1312 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1313
1314 msg.append("uuid=");
1315 msg.append(uuid);
1316
1317 msg.append(", companyId=");
1318 msg.append(companyId);
1319
1320 msg.append(StringPool.CLOSE_CURLY_BRACE);
1321
1322 throw new NoSuchEntryException(msg.toString());
1323 }
1324
1325
1334 @Override
1335 public AnnouncementsEntry fetchByUuid_C_Last(String uuid, long companyId,
1336 OrderByComparator orderByComparator) throws SystemException {
1337 int count = countByUuid_C(uuid, companyId);
1338
1339 if (count == 0) {
1340 return null;
1341 }
1342
1343 List<AnnouncementsEntry> list = findByUuid_C(uuid, companyId,
1344 count - 1, count, orderByComparator);
1345
1346 if (!list.isEmpty()) {
1347 return list.get(0);
1348 }
1349
1350 return null;
1351 }
1352
1353
1364 @Override
1365 public AnnouncementsEntry[] findByUuid_C_PrevAndNext(long entryId,
1366 String uuid, long companyId, OrderByComparator orderByComparator)
1367 throws NoSuchEntryException, SystemException {
1368 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1369
1370 Session session = null;
1371
1372 try {
1373 session = openSession();
1374
1375 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1376
1377 array[0] = getByUuid_C_PrevAndNext(session, announcementsEntry,
1378 uuid, companyId, orderByComparator, true);
1379
1380 array[1] = announcementsEntry;
1381
1382 array[2] = getByUuid_C_PrevAndNext(session, announcementsEntry,
1383 uuid, companyId, orderByComparator, false);
1384
1385 return array;
1386 }
1387 catch (Exception e) {
1388 throw processException(e);
1389 }
1390 finally {
1391 closeSession(session);
1392 }
1393 }
1394
1395 protected AnnouncementsEntry getByUuid_C_PrevAndNext(Session session,
1396 AnnouncementsEntry announcementsEntry, String uuid, long companyId,
1397 OrderByComparator orderByComparator, boolean previous) {
1398 StringBundler query = null;
1399
1400 if (orderByComparator != null) {
1401 query = new StringBundler(6 +
1402 (orderByComparator.getOrderByFields().length * 6));
1403 }
1404 else {
1405 query = new StringBundler(3);
1406 }
1407
1408 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1409
1410 boolean bindUuid = false;
1411
1412 if (uuid == null) {
1413 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1414 }
1415 else if (uuid.equals(StringPool.BLANK)) {
1416 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1417 }
1418 else {
1419 bindUuid = true;
1420
1421 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1422 }
1423
1424 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1425
1426 if (orderByComparator != null) {
1427 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1428
1429 if (orderByConditionFields.length > 0) {
1430 query.append(WHERE_AND);
1431 }
1432
1433 for (int i = 0; i < orderByConditionFields.length; i++) {
1434 query.append(_ORDER_BY_ENTITY_ALIAS);
1435 query.append(orderByConditionFields[i]);
1436
1437 if ((i + 1) < orderByConditionFields.length) {
1438 if (orderByComparator.isAscending() ^ previous) {
1439 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1440 }
1441 else {
1442 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1443 }
1444 }
1445 else {
1446 if (orderByComparator.isAscending() ^ previous) {
1447 query.append(WHERE_GREATER_THAN);
1448 }
1449 else {
1450 query.append(WHERE_LESSER_THAN);
1451 }
1452 }
1453 }
1454
1455 query.append(ORDER_BY_CLAUSE);
1456
1457 String[] orderByFields = orderByComparator.getOrderByFields();
1458
1459 for (int i = 0; i < orderByFields.length; i++) {
1460 query.append(_ORDER_BY_ENTITY_ALIAS);
1461 query.append(orderByFields[i]);
1462
1463 if ((i + 1) < orderByFields.length) {
1464 if (orderByComparator.isAscending() ^ previous) {
1465 query.append(ORDER_BY_ASC_HAS_NEXT);
1466 }
1467 else {
1468 query.append(ORDER_BY_DESC_HAS_NEXT);
1469 }
1470 }
1471 else {
1472 if (orderByComparator.isAscending() ^ previous) {
1473 query.append(ORDER_BY_ASC);
1474 }
1475 else {
1476 query.append(ORDER_BY_DESC);
1477 }
1478 }
1479 }
1480 }
1481 else {
1482 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1483 }
1484
1485 String sql = query.toString();
1486
1487 Query q = session.createQuery(sql);
1488
1489 q.setFirstResult(0);
1490 q.setMaxResults(2);
1491
1492 QueryPos qPos = QueryPos.getInstance(q);
1493
1494 if (bindUuid) {
1495 qPos.add(uuid);
1496 }
1497
1498 qPos.add(companyId);
1499
1500 if (orderByComparator != null) {
1501 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1502
1503 for (Object value : values) {
1504 qPos.add(value);
1505 }
1506 }
1507
1508 List<AnnouncementsEntry> list = q.list();
1509
1510 if (list.size() == 2) {
1511 return list.get(1);
1512 }
1513 else {
1514 return null;
1515 }
1516 }
1517
1518
1526 @Override
1527 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1528 long companyId) throws SystemException {
1529 return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1530 QueryUtil.ALL_POS, null);
1531 }
1532
1533
1547 @Override
1548 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1549 long companyId, int start, int end) throws SystemException {
1550 return filterFindByUuid_C(uuid, companyId, start, end, null);
1551 }
1552
1553
1568 @Override
1569 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1570 long companyId, int start, int end, OrderByComparator orderByComparator)
1571 throws SystemException {
1572 if (!InlineSQLHelperUtil.isEnabled()) {
1573 return findByUuid_C(uuid, companyId, start, end, orderByComparator);
1574 }
1575
1576 StringBundler query = null;
1577
1578 if (orderByComparator != null) {
1579 query = new StringBundler(4 +
1580 (orderByComparator.getOrderByFields().length * 3));
1581 }
1582 else {
1583 query = new StringBundler(4);
1584 }
1585
1586 if (getDB().isSupportsInlineDistinct()) {
1587 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1588 }
1589 else {
1590 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1591 }
1592
1593 boolean bindUuid = false;
1594
1595 if (uuid == null) {
1596 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1597 }
1598 else if (uuid.equals(StringPool.BLANK)) {
1599 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1600 }
1601 else {
1602 bindUuid = true;
1603
1604 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1605 }
1606
1607 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1608
1609 if (!getDB().isSupportsInlineDistinct()) {
1610 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1611 }
1612
1613 if (orderByComparator != null) {
1614 if (getDB().isSupportsInlineDistinct()) {
1615 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1616 orderByComparator, true);
1617 }
1618 else {
1619 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1620 orderByComparator, true);
1621 }
1622 }
1623 else {
1624 if (getDB().isSupportsInlineDistinct()) {
1625 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1626 }
1627 else {
1628 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1629 }
1630 }
1631
1632 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1633 AnnouncementsEntry.class.getName(),
1634 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1635
1636 Session session = null;
1637
1638 try {
1639 session = openSession();
1640
1641 SQLQuery q = session.createSQLQuery(sql);
1642
1643 if (getDB().isSupportsInlineDistinct()) {
1644 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1645 }
1646 else {
1647 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1648 }
1649
1650 QueryPos qPos = QueryPos.getInstance(q);
1651
1652 if (bindUuid) {
1653 qPos.add(uuid);
1654 }
1655
1656 qPos.add(companyId);
1657
1658 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
1659 start, end);
1660 }
1661 catch (Exception e) {
1662 throw processException(e);
1663 }
1664 finally {
1665 closeSession(session);
1666 }
1667 }
1668
1669
1680 @Override
1681 public AnnouncementsEntry[] filterFindByUuid_C_PrevAndNext(long entryId,
1682 String uuid, long companyId, OrderByComparator orderByComparator)
1683 throws NoSuchEntryException, SystemException {
1684 if (!InlineSQLHelperUtil.isEnabled()) {
1685 return findByUuid_C_PrevAndNext(entryId, uuid, companyId,
1686 orderByComparator);
1687 }
1688
1689 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1690
1691 Session session = null;
1692
1693 try {
1694 session = openSession();
1695
1696 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1697
1698 array[0] = filterGetByUuid_C_PrevAndNext(session,
1699 announcementsEntry, uuid, companyId, orderByComparator, true);
1700
1701 array[1] = announcementsEntry;
1702
1703 array[2] = filterGetByUuid_C_PrevAndNext(session,
1704 announcementsEntry, uuid, companyId, orderByComparator,
1705 false);
1706
1707 return array;
1708 }
1709 catch (Exception e) {
1710 throw processException(e);
1711 }
1712 finally {
1713 closeSession(session);
1714 }
1715 }
1716
1717 protected AnnouncementsEntry filterGetByUuid_C_PrevAndNext(
1718 Session session, AnnouncementsEntry announcementsEntry, String uuid,
1719 long companyId, OrderByComparator orderByComparator, boolean previous) {
1720 StringBundler query = null;
1721
1722 if (orderByComparator != null) {
1723 query = new StringBundler(6 +
1724 (orderByComparator.getOrderByFields().length * 6));
1725 }
1726 else {
1727 query = new StringBundler(3);
1728 }
1729
1730 if (getDB().isSupportsInlineDistinct()) {
1731 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1732 }
1733 else {
1734 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1735 }
1736
1737 boolean bindUuid = false;
1738
1739 if (uuid == null) {
1740 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1741 }
1742 else if (uuid.equals(StringPool.BLANK)) {
1743 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1744 }
1745 else {
1746 bindUuid = true;
1747
1748 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1749 }
1750
1751 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1752
1753 if (!getDB().isSupportsInlineDistinct()) {
1754 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1755 }
1756
1757 if (orderByComparator != null) {
1758 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1759
1760 if (orderByConditionFields.length > 0) {
1761 query.append(WHERE_AND);
1762 }
1763
1764 for (int i = 0; i < orderByConditionFields.length; i++) {
1765 if (getDB().isSupportsInlineDistinct()) {
1766 query.append(_ORDER_BY_ENTITY_ALIAS);
1767 }
1768 else {
1769 query.append(_ORDER_BY_ENTITY_TABLE);
1770 }
1771
1772 query.append(orderByConditionFields[i]);
1773
1774 if ((i + 1) < orderByConditionFields.length) {
1775 if (orderByComparator.isAscending() ^ previous) {
1776 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1777 }
1778 else {
1779 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1780 }
1781 }
1782 else {
1783 if (orderByComparator.isAscending() ^ previous) {
1784 query.append(WHERE_GREATER_THAN);
1785 }
1786 else {
1787 query.append(WHERE_LESSER_THAN);
1788 }
1789 }
1790 }
1791
1792 query.append(ORDER_BY_CLAUSE);
1793
1794 String[] orderByFields = orderByComparator.getOrderByFields();
1795
1796 for (int i = 0; i < orderByFields.length; i++) {
1797 if (getDB().isSupportsInlineDistinct()) {
1798 query.append(_ORDER_BY_ENTITY_ALIAS);
1799 }
1800 else {
1801 query.append(_ORDER_BY_ENTITY_TABLE);
1802 }
1803
1804 query.append(orderByFields[i]);
1805
1806 if ((i + 1) < orderByFields.length) {
1807 if (orderByComparator.isAscending() ^ previous) {
1808 query.append(ORDER_BY_ASC_HAS_NEXT);
1809 }
1810 else {
1811 query.append(ORDER_BY_DESC_HAS_NEXT);
1812 }
1813 }
1814 else {
1815 if (orderByComparator.isAscending() ^ previous) {
1816 query.append(ORDER_BY_ASC);
1817 }
1818 else {
1819 query.append(ORDER_BY_DESC);
1820 }
1821 }
1822 }
1823 }
1824 else {
1825 if (getDB().isSupportsInlineDistinct()) {
1826 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1827 }
1828 else {
1829 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1830 }
1831 }
1832
1833 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1834 AnnouncementsEntry.class.getName(),
1835 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1836
1837 SQLQuery q = session.createSQLQuery(sql);
1838
1839 q.setFirstResult(0);
1840 q.setMaxResults(2);
1841
1842 if (getDB().isSupportsInlineDistinct()) {
1843 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1844 }
1845 else {
1846 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1847 }
1848
1849 QueryPos qPos = QueryPos.getInstance(q);
1850
1851 if (bindUuid) {
1852 qPos.add(uuid);
1853 }
1854
1855 qPos.add(companyId);
1856
1857 if (orderByComparator != null) {
1858 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1859
1860 for (Object value : values) {
1861 qPos.add(value);
1862 }
1863 }
1864
1865 List<AnnouncementsEntry> list = q.list();
1866
1867 if (list.size() == 2) {
1868 return list.get(1);
1869 }
1870 else {
1871 return null;
1872 }
1873 }
1874
1875
1882 @Override
1883 public void removeByUuid_C(String uuid, long companyId)
1884 throws SystemException {
1885 for (AnnouncementsEntry announcementsEntry : findByUuid_C(uuid,
1886 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1887 remove(announcementsEntry);
1888 }
1889 }
1890
1891
1899 @Override
1900 public int countByUuid_C(String uuid, long companyId)
1901 throws SystemException {
1902 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1903
1904 Object[] finderArgs = new Object[] { uuid, companyId };
1905
1906 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1907 this);
1908
1909 if (count == null) {
1910 StringBundler query = new StringBundler(3);
1911
1912 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
1913
1914 boolean bindUuid = false;
1915
1916 if (uuid == null) {
1917 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1918 }
1919 else if (uuid.equals(StringPool.BLANK)) {
1920 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1921 }
1922 else {
1923 bindUuid = true;
1924
1925 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1926 }
1927
1928 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1929
1930 String sql = query.toString();
1931
1932 Session session = null;
1933
1934 try {
1935 session = openSession();
1936
1937 Query q = session.createQuery(sql);
1938
1939 QueryPos qPos = QueryPos.getInstance(q);
1940
1941 if (bindUuid) {
1942 qPos.add(uuid);
1943 }
1944
1945 qPos.add(companyId);
1946
1947 count = (Long)q.uniqueResult();
1948
1949 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1950 }
1951 catch (Exception e) {
1952 FinderCacheUtil.removeResult(finderPath, finderArgs);
1953
1954 throw processException(e);
1955 }
1956 finally {
1957 closeSession(session);
1958 }
1959 }
1960
1961 return count.intValue();
1962 }
1963
1964
1972 @Override
1973 public int filterCountByUuid_C(String uuid, long companyId)
1974 throws SystemException {
1975 if (!InlineSQLHelperUtil.isEnabled()) {
1976 return countByUuid_C(uuid, companyId);
1977 }
1978
1979 StringBundler query = new StringBundler(3);
1980
1981 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
1982
1983 boolean bindUuid = false;
1984
1985 if (uuid == null) {
1986 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1987 }
1988 else if (uuid.equals(StringPool.BLANK)) {
1989 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1990 }
1991 else {
1992 bindUuid = true;
1993
1994 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1995 }
1996
1997 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1998
1999 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2000 AnnouncementsEntry.class.getName(),
2001 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2002
2003 Session session = null;
2004
2005 try {
2006 session = openSession();
2007
2008 SQLQuery q = session.createSQLQuery(sql);
2009
2010 q.addScalar(COUNT_COLUMN_NAME,
2011 com.liferay.portal.kernel.dao.orm.Type.LONG);
2012
2013 QueryPos qPos = QueryPos.getInstance(q);
2014
2015 if (bindUuid) {
2016 qPos.add(uuid);
2017 }
2018
2019 qPos.add(companyId);
2020
2021 Long count = (Long)q.uniqueResult();
2022
2023 return count.intValue();
2024 }
2025 catch (Exception e) {
2026 throw processException(e);
2027 }
2028 finally {
2029 closeSession(session);
2030 }
2031 }
2032
2033 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "announcementsEntry.uuid IS NULL AND ";
2034 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "announcementsEntry.uuid = ? AND ";
2035 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(announcementsEntry.uuid IS NULL OR announcementsEntry.uuid = '') AND ";
2036 private static final String _FINDER_COLUMN_UUID_C_UUID_1_SQL = "announcementsEntry.uuid_ IS NULL AND ";
2037 private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "announcementsEntry.uuid_ = ? AND ";
2038 private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(announcementsEntry.uuid_ IS NULL OR announcementsEntry.uuid_ = '') AND ";
2039 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "announcementsEntry.companyId = ?";
2040 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2041 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2042 AnnouncementsEntryImpl.class,
2043 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
2044 new String[] {
2045 Long.class.getName(),
2046
2047 Integer.class.getName(), Integer.class.getName(),
2048 OrderByComparator.class.getName()
2049 });
2050 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
2051 new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2052 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2053 AnnouncementsEntryImpl.class,
2054 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
2055 new String[] { Long.class.getName() },
2056 AnnouncementsEntryModelImpl.USERID_COLUMN_BITMASK |
2057 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
2058 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
2059 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2060 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2061 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
2062 new String[] { Long.class.getName() });
2063
2064
2071 @Override
2072 public List<AnnouncementsEntry> findByUserId(long userId)
2073 throws SystemException {
2074 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2075 }
2076
2077
2090 @Override
2091 public List<AnnouncementsEntry> findByUserId(long userId, int start, int end)
2092 throws SystemException {
2093 return findByUserId(userId, start, end, null);
2094 }
2095
2096
2110 @Override
2111 public List<AnnouncementsEntry> findByUserId(long userId, int start,
2112 int end, OrderByComparator orderByComparator) throws SystemException {
2113 boolean pagination = true;
2114 FinderPath finderPath = null;
2115 Object[] finderArgs = null;
2116
2117 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2118 (orderByComparator == null)) {
2119 pagination = false;
2120 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
2121 finderArgs = new Object[] { userId };
2122 }
2123 else {
2124 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
2125 finderArgs = new Object[] { userId, start, end, orderByComparator };
2126 }
2127
2128 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
2129 finderArgs, this);
2130
2131 if ((list != null) && !list.isEmpty()) {
2132 for (AnnouncementsEntry announcementsEntry : list) {
2133 if ((userId != announcementsEntry.getUserId())) {
2134 list = null;
2135
2136 break;
2137 }
2138 }
2139 }
2140
2141 if (list == null) {
2142 StringBundler query = null;
2143
2144 if (orderByComparator != null) {
2145 query = new StringBundler(3 +
2146 (orderByComparator.getOrderByFields().length * 3));
2147 }
2148 else {
2149 query = new StringBundler(3);
2150 }
2151
2152 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2153
2154 query.append(_FINDER_COLUMN_USERID_USERID_2);
2155
2156 if (orderByComparator != null) {
2157 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2158 orderByComparator);
2159 }
2160 else
2161 if (pagination) {
2162 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2163 }
2164
2165 String sql = query.toString();
2166
2167 Session session = null;
2168
2169 try {
2170 session = openSession();
2171
2172 Query q = session.createQuery(sql);
2173
2174 QueryPos qPos = QueryPos.getInstance(q);
2175
2176 qPos.add(userId);
2177
2178 if (!pagination) {
2179 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2180 getDialect(), start, end, false);
2181
2182 Collections.sort(list);
2183
2184 list = new UnmodifiableList<AnnouncementsEntry>(list);
2185 }
2186 else {
2187 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2188 getDialect(), start, end);
2189 }
2190
2191 cacheResult(list);
2192
2193 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2194 }
2195 catch (Exception e) {
2196 FinderCacheUtil.removeResult(finderPath, finderArgs);
2197
2198 throw processException(e);
2199 }
2200 finally {
2201 closeSession(session);
2202 }
2203 }
2204
2205 return list;
2206 }
2207
2208
2217 @Override
2218 public AnnouncementsEntry findByUserId_First(long userId,
2219 OrderByComparator orderByComparator)
2220 throws NoSuchEntryException, SystemException {
2221 AnnouncementsEntry announcementsEntry = fetchByUserId_First(userId,
2222 orderByComparator);
2223
2224 if (announcementsEntry != null) {
2225 return announcementsEntry;
2226 }
2227
2228 StringBundler msg = new StringBundler(4);
2229
2230 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2231
2232 msg.append("userId=");
2233 msg.append(userId);
2234
2235 msg.append(StringPool.CLOSE_CURLY_BRACE);
2236
2237 throw new NoSuchEntryException(msg.toString());
2238 }
2239
2240
2248 @Override
2249 public AnnouncementsEntry fetchByUserId_First(long userId,
2250 OrderByComparator orderByComparator) throws SystemException {
2251 List<AnnouncementsEntry> list = findByUserId(userId, 0, 1,
2252 orderByComparator);
2253
2254 if (!list.isEmpty()) {
2255 return list.get(0);
2256 }
2257
2258 return null;
2259 }
2260
2261
2270 @Override
2271 public AnnouncementsEntry findByUserId_Last(long userId,
2272 OrderByComparator orderByComparator)
2273 throws NoSuchEntryException, SystemException {
2274 AnnouncementsEntry announcementsEntry = fetchByUserId_Last(userId,
2275 orderByComparator);
2276
2277 if (announcementsEntry != null) {
2278 return announcementsEntry;
2279 }
2280
2281 StringBundler msg = new StringBundler(4);
2282
2283 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2284
2285 msg.append("userId=");
2286 msg.append(userId);
2287
2288 msg.append(StringPool.CLOSE_CURLY_BRACE);
2289
2290 throw new NoSuchEntryException(msg.toString());
2291 }
2292
2293
2301 @Override
2302 public AnnouncementsEntry fetchByUserId_Last(long userId,
2303 OrderByComparator orderByComparator) throws SystemException {
2304 int count = countByUserId(userId);
2305
2306 if (count == 0) {
2307 return null;
2308 }
2309
2310 List<AnnouncementsEntry> list = findByUserId(userId, count - 1, count,
2311 orderByComparator);
2312
2313 if (!list.isEmpty()) {
2314 return list.get(0);
2315 }
2316
2317 return null;
2318 }
2319
2320
2330 @Override
2331 public AnnouncementsEntry[] findByUserId_PrevAndNext(long entryId,
2332 long userId, OrderByComparator orderByComparator)
2333 throws NoSuchEntryException, SystemException {
2334 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2335
2336 Session session = null;
2337
2338 try {
2339 session = openSession();
2340
2341 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2342
2343 array[0] = getByUserId_PrevAndNext(session, announcementsEntry,
2344 userId, orderByComparator, true);
2345
2346 array[1] = announcementsEntry;
2347
2348 array[2] = getByUserId_PrevAndNext(session, announcementsEntry,
2349 userId, orderByComparator, false);
2350
2351 return array;
2352 }
2353 catch (Exception e) {
2354 throw processException(e);
2355 }
2356 finally {
2357 closeSession(session);
2358 }
2359 }
2360
2361 protected AnnouncementsEntry getByUserId_PrevAndNext(Session session,
2362 AnnouncementsEntry announcementsEntry, long userId,
2363 OrderByComparator orderByComparator, boolean previous) {
2364 StringBundler query = null;
2365
2366 if (orderByComparator != null) {
2367 query = new StringBundler(6 +
2368 (orderByComparator.getOrderByFields().length * 6));
2369 }
2370 else {
2371 query = new StringBundler(3);
2372 }
2373
2374 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2375
2376 query.append(_FINDER_COLUMN_USERID_USERID_2);
2377
2378 if (orderByComparator != null) {
2379 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2380
2381 if (orderByConditionFields.length > 0) {
2382 query.append(WHERE_AND);
2383 }
2384
2385 for (int i = 0; i < orderByConditionFields.length; i++) {
2386 query.append(_ORDER_BY_ENTITY_ALIAS);
2387 query.append(orderByConditionFields[i]);
2388
2389 if ((i + 1) < orderByConditionFields.length) {
2390 if (orderByComparator.isAscending() ^ previous) {
2391 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2392 }
2393 else {
2394 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2395 }
2396 }
2397 else {
2398 if (orderByComparator.isAscending() ^ previous) {
2399 query.append(WHERE_GREATER_THAN);
2400 }
2401 else {
2402 query.append(WHERE_LESSER_THAN);
2403 }
2404 }
2405 }
2406
2407 query.append(ORDER_BY_CLAUSE);
2408
2409 String[] orderByFields = orderByComparator.getOrderByFields();
2410
2411 for (int i = 0; i < orderByFields.length; i++) {
2412 query.append(_ORDER_BY_ENTITY_ALIAS);
2413 query.append(orderByFields[i]);
2414
2415 if ((i + 1) < orderByFields.length) {
2416 if (orderByComparator.isAscending() ^ previous) {
2417 query.append(ORDER_BY_ASC_HAS_NEXT);
2418 }
2419 else {
2420 query.append(ORDER_BY_DESC_HAS_NEXT);
2421 }
2422 }
2423 else {
2424 if (orderByComparator.isAscending() ^ previous) {
2425 query.append(ORDER_BY_ASC);
2426 }
2427 else {
2428 query.append(ORDER_BY_DESC);
2429 }
2430 }
2431 }
2432 }
2433 else {
2434 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2435 }
2436
2437 String sql = query.toString();
2438
2439 Query q = session.createQuery(sql);
2440
2441 q.setFirstResult(0);
2442 q.setMaxResults(2);
2443
2444 QueryPos qPos = QueryPos.getInstance(q);
2445
2446 qPos.add(userId);
2447
2448 if (orderByComparator != null) {
2449 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2450
2451 for (Object value : values) {
2452 qPos.add(value);
2453 }
2454 }
2455
2456 List<AnnouncementsEntry> list = q.list();
2457
2458 if (list.size() == 2) {
2459 return list.get(1);
2460 }
2461 else {
2462 return null;
2463 }
2464 }
2465
2466
2473 @Override
2474 public List<AnnouncementsEntry> filterFindByUserId(long userId)
2475 throws SystemException {
2476 return filterFindByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2477 null);
2478 }
2479
2480
2493 @Override
2494 public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
2495 int end) throws SystemException {
2496 return filterFindByUserId(userId, start, end, null);
2497 }
2498
2499
2513 @Override
2514 public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
2515 int end, OrderByComparator orderByComparator) throws SystemException {
2516 if (!InlineSQLHelperUtil.isEnabled()) {
2517 return findByUserId(userId, start, end, orderByComparator);
2518 }
2519
2520 StringBundler query = null;
2521
2522 if (orderByComparator != null) {
2523 query = new StringBundler(3 +
2524 (orderByComparator.getOrderByFields().length * 3));
2525 }
2526 else {
2527 query = new StringBundler(3);
2528 }
2529
2530 if (getDB().isSupportsInlineDistinct()) {
2531 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2532 }
2533 else {
2534 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2535 }
2536
2537 query.append(_FINDER_COLUMN_USERID_USERID_2);
2538
2539 if (!getDB().isSupportsInlineDistinct()) {
2540 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2541 }
2542
2543 if (orderByComparator != null) {
2544 if (getDB().isSupportsInlineDistinct()) {
2545 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2546 orderByComparator, true);
2547 }
2548 else {
2549 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2550 orderByComparator, true);
2551 }
2552 }
2553 else {
2554 if (getDB().isSupportsInlineDistinct()) {
2555 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2556 }
2557 else {
2558 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2559 }
2560 }
2561
2562 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2563 AnnouncementsEntry.class.getName(),
2564 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2565
2566 Session session = null;
2567
2568 try {
2569 session = openSession();
2570
2571 SQLQuery q = session.createSQLQuery(sql);
2572
2573 if (getDB().isSupportsInlineDistinct()) {
2574 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2575 }
2576 else {
2577 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2578 }
2579
2580 QueryPos qPos = QueryPos.getInstance(q);
2581
2582 qPos.add(userId);
2583
2584 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
2585 start, end);
2586 }
2587 catch (Exception e) {
2588 throw processException(e);
2589 }
2590 finally {
2591 closeSession(session);
2592 }
2593 }
2594
2595
2605 @Override
2606 public AnnouncementsEntry[] filterFindByUserId_PrevAndNext(long entryId,
2607 long userId, OrderByComparator orderByComparator)
2608 throws NoSuchEntryException, SystemException {
2609 if (!InlineSQLHelperUtil.isEnabled()) {
2610 return findByUserId_PrevAndNext(entryId, userId, orderByComparator);
2611 }
2612
2613 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2614
2615 Session session = null;
2616
2617 try {
2618 session = openSession();
2619
2620 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2621
2622 array[0] = filterGetByUserId_PrevAndNext(session,
2623 announcementsEntry, userId, orderByComparator, true);
2624
2625 array[1] = announcementsEntry;
2626
2627 array[2] = filterGetByUserId_PrevAndNext(session,
2628 announcementsEntry, userId, orderByComparator, false);
2629
2630 return array;
2631 }
2632 catch (Exception e) {
2633 throw processException(e);
2634 }
2635 finally {
2636 closeSession(session);
2637 }
2638 }
2639
2640 protected AnnouncementsEntry filterGetByUserId_PrevAndNext(
2641 Session session, AnnouncementsEntry announcementsEntry, long userId,
2642 OrderByComparator orderByComparator, boolean previous) {
2643 StringBundler query = null;
2644
2645 if (orderByComparator != null) {
2646 query = new StringBundler(6 +
2647 (orderByComparator.getOrderByFields().length * 6));
2648 }
2649 else {
2650 query = new StringBundler(3);
2651 }
2652
2653 if (getDB().isSupportsInlineDistinct()) {
2654 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2655 }
2656 else {
2657 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2658 }
2659
2660 query.append(_FINDER_COLUMN_USERID_USERID_2);
2661
2662 if (!getDB().isSupportsInlineDistinct()) {
2663 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2664 }
2665
2666 if (orderByComparator != null) {
2667 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2668
2669 if (orderByConditionFields.length > 0) {
2670 query.append(WHERE_AND);
2671 }
2672
2673 for (int i = 0; i < orderByConditionFields.length; i++) {
2674 if (getDB().isSupportsInlineDistinct()) {
2675 query.append(_ORDER_BY_ENTITY_ALIAS);
2676 }
2677 else {
2678 query.append(_ORDER_BY_ENTITY_TABLE);
2679 }
2680
2681 query.append(orderByConditionFields[i]);
2682
2683 if ((i + 1) < orderByConditionFields.length) {
2684 if (orderByComparator.isAscending() ^ previous) {
2685 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2686 }
2687 else {
2688 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2689 }
2690 }
2691 else {
2692 if (orderByComparator.isAscending() ^ previous) {
2693 query.append(WHERE_GREATER_THAN);
2694 }
2695 else {
2696 query.append(WHERE_LESSER_THAN);
2697 }
2698 }
2699 }
2700
2701 query.append(ORDER_BY_CLAUSE);
2702
2703 String[] orderByFields = orderByComparator.getOrderByFields();
2704
2705 for (int i = 0; i < orderByFields.length; i++) {
2706 if (getDB().isSupportsInlineDistinct()) {
2707 query.append(_ORDER_BY_ENTITY_ALIAS);
2708 }
2709 else {
2710 query.append(_ORDER_BY_ENTITY_TABLE);
2711 }
2712
2713 query.append(orderByFields[i]);
2714
2715 if ((i + 1) < orderByFields.length) {
2716 if (orderByComparator.isAscending() ^ previous) {
2717 query.append(ORDER_BY_ASC_HAS_NEXT);
2718 }
2719 else {
2720 query.append(ORDER_BY_DESC_HAS_NEXT);
2721 }
2722 }
2723 else {
2724 if (orderByComparator.isAscending() ^ previous) {
2725 query.append(ORDER_BY_ASC);
2726 }
2727 else {
2728 query.append(ORDER_BY_DESC);
2729 }
2730 }
2731 }
2732 }
2733 else {
2734 if (getDB().isSupportsInlineDistinct()) {
2735 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2736 }
2737 else {
2738 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2739 }
2740 }
2741
2742 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2743 AnnouncementsEntry.class.getName(),
2744 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2745
2746 SQLQuery q = session.createSQLQuery(sql);
2747
2748 q.setFirstResult(0);
2749 q.setMaxResults(2);
2750
2751 if (getDB().isSupportsInlineDistinct()) {
2752 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2753 }
2754 else {
2755 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2756 }
2757
2758 QueryPos qPos = QueryPos.getInstance(q);
2759
2760 qPos.add(userId);
2761
2762 if (orderByComparator != null) {
2763 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2764
2765 for (Object value : values) {
2766 qPos.add(value);
2767 }
2768 }
2769
2770 List<AnnouncementsEntry> list = q.list();
2771
2772 if (list.size() == 2) {
2773 return list.get(1);
2774 }
2775 else {
2776 return null;
2777 }
2778 }
2779
2780
2786 @Override
2787 public void removeByUserId(long userId) throws SystemException {
2788 for (AnnouncementsEntry announcementsEntry : findByUserId(userId,
2789 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2790 remove(announcementsEntry);
2791 }
2792 }
2793
2794
2801 @Override
2802 public int countByUserId(long userId) throws SystemException {
2803 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
2804
2805 Object[] finderArgs = new Object[] { userId };
2806
2807 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2808 this);
2809
2810 if (count == null) {
2811 StringBundler query = new StringBundler(2);
2812
2813 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2814
2815 query.append(_FINDER_COLUMN_USERID_USERID_2);
2816
2817 String sql = query.toString();
2818
2819 Session session = null;
2820
2821 try {
2822 session = openSession();
2823
2824 Query q = session.createQuery(sql);
2825
2826 QueryPos qPos = QueryPos.getInstance(q);
2827
2828 qPos.add(userId);
2829
2830 count = (Long)q.uniqueResult();
2831
2832 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2833 }
2834 catch (Exception e) {
2835 FinderCacheUtil.removeResult(finderPath, finderArgs);
2836
2837 throw processException(e);
2838 }
2839 finally {
2840 closeSession(session);
2841 }
2842 }
2843
2844 return count.intValue();
2845 }
2846
2847
2854 @Override
2855 public int filterCountByUserId(long userId) throws SystemException {
2856 if (!InlineSQLHelperUtil.isEnabled()) {
2857 return countByUserId(userId);
2858 }
2859
2860 StringBundler query = new StringBundler(2);
2861
2862 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2863
2864 query.append(_FINDER_COLUMN_USERID_USERID_2);
2865
2866 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2867 AnnouncementsEntry.class.getName(),
2868 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2869
2870 Session session = null;
2871
2872 try {
2873 session = openSession();
2874
2875 SQLQuery q = session.createSQLQuery(sql);
2876
2877 q.addScalar(COUNT_COLUMN_NAME,
2878 com.liferay.portal.kernel.dao.orm.Type.LONG);
2879
2880 QueryPos qPos = QueryPos.getInstance(q);
2881
2882 qPos.add(userId);
2883
2884 Long count = (Long)q.uniqueResult();
2885
2886 return count.intValue();
2887 }
2888 catch (Exception e) {
2889 throw processException(e);
2890 }
2891 finally {
2892 closeSession(session);
2893 }
2894 }
2895
2896 private static final String _FINDER_COLUMN_USERID_USERID_2 = "announcementsEntry.userId = ?";
2897 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2898 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2899 AnnouncementsEntryImpl.class,
2900 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
2901 new String[] {
2902 Long.class.getName(), Long.class.getName(),
2903
2904 Integer.class.getName(), Integer.class.getName(),
2905 OrderByComparator.class.getName()
2906 });
2907 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2908 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2909 AnnouncementsEntryImpl.class,
2910 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
2911 new String[] { Long.class.getName(), Long.class.getName() },
2912 AnnouncementsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2913 AnnouncementsEntryModelImpl.CLASSPK_COLUMN_BITMASK |
2914 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
2915 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
2916 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2917 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2918 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
2919 new String[] { Long.class.getName(), Long.class.getName() });
2920
2921
2929 @Override
2930 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK)
2931 throws SystemException {
2932 return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
2933 QueryUtil.ALL_POS, null);
2934 }
2935
2936
2950 @Override
2951 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
2952 int start, int end) throws SystemException {
2953 return findByC_C(classNameId, classPK, start, end, null);
2954 }
2955
2956
2971 @Override
2972 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
2973 int start, int end, OrderByComparator orderByComparator)
2974 throws SystemException {
2975 boolean pagination = true;
2976 FinderPath finderPath = null;
2977 Object[] finderArgs = null;
2978
2979 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2980 (orderByComparator == null)) {
2981 pagination = false;
2982 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
2983 finderArgs = new Object[] { classNameId, classPK };
2984 }
2985 else {
2986 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
2987 finderArgs = new Object[] {
2988 classNameId, classPK,
2989
2990 start, end, orderByComparator
2991 };
2992 }
2993
2994 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
2995 finderArgs, this);
2996
2997 if ((list != null) && !list.isEmpty()) {
2998 for (AnnouncementsEntry announcementsEntry : list) {
2999 if ((classNameId != announcementsEntry.getClassNameId()) ||
3000 (classPK != announcementsEntry.getClassPK())) {
3001 list = null;
3002
3003 break;
3004 }
3005 }
3006 }
3007
3008 if (list == null) {
3009 StringBundler query = null;
3010
3011 if (orderByComparator != null) {
3012 query = new StringBundler(4 +
3013 (orderByComparator.getOrderByFields().length * 3));
3014 }
3015 else {
3016 query = new StringBundler(4);
3017 }
3018
3019 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3020
3021 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3022
3023 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3024
3025 if (orderByComparator != null) {
3026 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3027 orderByComparator);
3028 }
3029 else
3030 if (pagination) {
3031 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3032 }
3033
3034 String sql = query.toString();
3035
3036 Session session = null;
3037
3038 try {
3039 session = openSession();
3040
3041 Query q = session.createQuery(sql);
3042
3043 QueryPos qPos = QueryPos.getInstance(q);
3044
3045 qPos.add(classNameId);
3046
3047 qPos.add(classPK);
3048
3049 if (!pagination) {
3050 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3051 getDialect(), start, end, false);
3052
3053 Collections.sort(list);
3054
3055 list = new UnmodifiableList<AnnouncementsEntry>(list);
3056 }
3057 else {
3058 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3059 getDialect(), start, end);
3060 }
3061
3062 cacheResult(list);
3063
3064 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3065 }
3066 catch (Exception e) {
3067 FinderCacheUtil.removeResult(finderPath, finderArgs);
3068
3069 throw processException(e);
3070 }
3071 finally {
3072 closeSession(session);
3073 }
3074 }
3075
3076 return list;
3077 }
3078
3079
3089 @Override
3090 public AnnouncementsEntry findByC_C_First(long classNameId, long classPK,
3091 OrderByComparator orderByComparator)
3092 throws NoSuchEntryException, SystemException {
3093 AnnouncementsEntry announcementsEntry = fetchByC_C_First(classNameId,
3094 classPK, orderByComparator);
3095
3096 if (announcementsEntry != null) {
3097 return announcementsEntry;
3098 }
3099
3100 StringBundler msg = new StringBundler(6);
3101
3102 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3103
3104 msg.append("classNameId=");
3105 msg.append(classNameId);
3106
3107 msg.append(", classPK=");
3108 msg.append(classPK);
3109
3110 msg.append(StringPool.CLOSE_CURLY_BRACE);
3111
3112 throw new NoSuchEntryException(msg.toString());
3113 }
3114
3115
3124 @Override
3125 public AnnouncementsEntry fetchByC_C_First(long classNameId, long classPK,
3126 OrderByComparator orderByComparator) throws SystemException {
3127 List<AnnouncementsEntry> list = findByC_C(classNameId, classPK, 0, 1,
3128 orderByComparator);
3129
3130 if (!list.isEmpty()) {
3131 return list.get(0);
3132 }
3133
3134 return null;
3135 }
3136
3137
3147 @Override
3148 public AnnouncementsEntry findByC_C_Last(long classNameId, long classPK,
3149 OrderByComparator orderByComparator)
3150 throws NoSuchEntryException, SystemException {
3151 AnnouncementsEntry announcementsEntry = fetchByC_C_Last(classNameId,
3152 classPK, orderByComparator);
3153
3154 if (announcementsEntry != null) {
3155 return announcementsEntry;
3156 }
3157
3158 StringBundler msg = new StringBundler(6);
3159
3160 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3161
3162 msg.append("classNameId=");
3163 msg.append(classNameId);
3164
3165 msg.append(", classPK=");
3166 msg.append(classPK);
3167
3168 msg.append(StringPool.CLOSE_CURLY_BRACE);
3169
3170 throw new NoSuchEntryException(msg.toString());
3171 }
3172
3173
3182 @Override
3183 public AnnouncementsEntry fetchByC_C_Last(long classNameId, long classPK,
3184 OrderByComparator orderByComparator) throws SystemException {
3185 int count = countByC_C(classNameId, classPK);
3186
3187 if (count == 0) {
3188 return null;
3189 }
3190
3191 List<AnnouncementsEntry> list = findByC_C(classNameId, classPK,
3192 count - 1, count, orderByComparator);
3193
3194 if (!list.isEmpty()) {
3195 return list.get(0);
3196 }
3197
3198 return null;
3199 }
3200
3201
3212 @Override
3213 public AnnouncementsEntry[] findByC_C_PrevAndNext(long entryId,
3214 long classNameId, long classPK, OrderByComparator orderByComparator)
3215 throws NoSuchEntryException, SystemException {
3216 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
3217
3218 Session session = null;
3219
3220 try {
3221 session = openSession();
3222
3223 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
3224
3225 array[0] = getByC_C_PrevAndNext(session, announcementsEntry,
3226 classNameId, classPK, orderByComparator, true);
3227
3228 array[1] = announcementsEntry;
3229
3230 array[2] = getByC_C_PrevAndNext(session, announcementsEntry,
3231 classNameId, classPK, orderByComparator, false);
3232
3233 return array;
3234 }
3235 catch (Exception e) {
3236 throw processException(e);
3237 }
3238 finally {
3239 closeSession(session);
3240 }
3241 }
3242
3243 protected AnnouncementsEntry getByC_C_PrevAndNext(Session session,
3244 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
3245 OrderByComparator orderByComparator, boolean previous) {
3246 StringBundler query = null;
3247
3248 if (orderByComparator != null) {
3249 query = new StringBundler(6 +
3250 (orderByComparator.getOrderByFields().length * 6));
3251 }
3252 else {
3253 query = new StringBundler(3);
3254 }
3255
3256 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3257
3258 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3259
3260 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3261
3262 if (orderByComparator != null) {
3263 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3264
3265 if (orderByConditionFields.length > 0) {
3266 query.append(WHERE_AND);
3267 }
3268
3269 for (int i = 0; i < orderByConditionFields.length; i++) {
3270 query.append(_ORDER_BY_ENTITY_ALIAS);
3271 query.append(orderByConditionFields[i]);
3272
3273 if ((i + 1) < orderByConditionFields.length) {
3274 if (orderByComparator.isAscending() ^ previous) {
3275 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3276 }
3277 else {
3278 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3279 }
3280 }
3281 else {
3282 if (orderByComparator.isAscending() ^ previous) {
3283 query.append(WHERE_GREATER_THAN);
3284 }
3285 else {
3286 query.append(WHERE_LESSER_THAN);
3287 }
3288 }
3289 }
3290
3291 query.append(ORDER_BY_CLAUSE);
3292
3293 String[] orderByFields = orderByComparator.getOrderByFields();
3294
3295 for (int i = 0; i < orderByFields.length; i++) {
3296 query.append(_ORDER_BY_ENTITY_ALIAS);
3297 query.append(orderByFields[i]);
3298
3299 if ((i + 1) < orderByFields.length) {
3300 if (orderByComparator.isAscending() ^ previous) {
3301 query.append(ORDER_BY_ASC_HAS_NEXT);
3302 }
3303 else {
3304 query.append(ORDER_BY_DESC_HAS_NEXT);
3305 }
3306 }
3307 else {
3308 if (orderByComparator.isAscending() ^ previous) {
3309 query.append(ORDER_BY_ASC);
3310 }
3311 else {
3312 query.append(ORDER_BY_DESC);
3313 }
3314 }
3315 }
3316 }
3317 else {
3318 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3319 }
3320
3321 String sql = query.toString();
3322
3323 Query q = session.createQuery(sql);
3324
3325 q.setFirstResult(0);
3326 q.setMaxResults(2);
3327
3328 QueryPos qPos = QueryPos.getInstance(q);
3329
3330 qPos.add(classNameId);
3331
3332 qPos.add(classPK);
3333
3334 if (orderByComparator != null) {
3335 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
3336
3337 for (Object value : values) {
3338 qPos.add(value);
3339 }
3340 }
3341
3342 List<AnnouncementsEntry> list = q.list();
3343
3344 if (list.size() == 2) {
3345 return list.get(1);
3346 }
3347 else {
3348 return null;
3349 }
3350 }
3351
3352
3360 @Override
3361 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3362 long classPK) throws SystemException {
3363 return filterFindByC_C(classNameId, classPK, QueryUtil.ALL_POS,
3364 QueryUtil.ALL_POS, null);
3365 }
3366
3367
3381 @Override
3382 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3383 long classPK, int start, int end) throws SystemException {
3384 return filterFindByC_C(classNameId, classPK, start, end, null);
3385 }
3386
3387
3402 @Override
3403 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3404 long classPK, int start, int end, OrderByComparator orderByComparator)
3405 throws SystemException {
3406 if (!InlineSQLHelperUtil.isEnabled()) {
3407 return findByC_C(classNameId, classPK, start, end, orderByComparator);
3408 }
3409
3410 StringBundler query = null;
3411
3412 if (orderByComparator != null) {
3413 query = new StringBundler(4 +
3414 (orderByComparator.getOrderByFields().length * 3));
3415 }
3416 else {
3417 query = new StringBundler(4);
3418 }
3419
3420 if (getDB().isSupportsInlineDistinct()) {
3421 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3422 }
3423 else {
3424 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3425 }
3426
3427 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3428
3429 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3430
3431 if (!getDB().isSupportsInlineDistinct()) {
3432 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3433 }
3434
3435 if (orderByComparator != null) {
3436 if (getDB().isSupportsInlineDistinct()) {
3437 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3438 orderByComparator, true);
3439 }
3440 else {
3441 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3442 orderByComparator, true);
3443 }
3444 }
3445 else {
3446 if (getDB().isSupportsInlineDistinct()) {
3447 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3448 }
3449 else {
3450 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
3451 }
3452 }
3453
3454 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3455 AnnouncementsEntry.class.getName(),
3456 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3457
3458 Session session = null;
3459
3460 try {
3461 session = openSession();
3462
3463 SQLQuery q = session.createSQLQuery(sql);
3464
3465 if (getDB().isSupportsInlineDistinct()) {
3466 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
3467 }
3468 else {
3469 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
3470 }
3471
3472 QueryPos qPos = QueryPos.getInstance(q);
3473
3474 qPos.add(classNameId);
3475
3476 qPos.add(classPK);
3477
3478 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
3479 start, end);
3480 }
3481 catch (Exception e) {
3482 throw processException(e);
3483 }
3484 finally {
3485 closeSession(session);
3486 }
3487 }
3488
3489
3500 @Override
3501 public AnnouncementsEntry[] filterFindByC_C_PrevAndNext(long entryId,
3502 long classNameId, long classPK, OrderByComparator orderByComparator)
3503 throws NoSuchEntryException, SystemException {
3504 if (!InlineSQLHelperUtil.isEnabled()) {
3505 return findByC_C_PrevAndNext(entryId, classNameId, classPK,
3506 orderByComparator);
3507 }
3508
3509 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
3510
3511 Session session = null;
3512
3513 try {
3514 session = openSession();
3515
3516 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
3517
3518 array[0] = filterGetByC_C_PrevAndNext(session, announcementsEntry,
3519 classNameId, classPK, orderByComparator, true);
3520
3521 array[1] = announcementsEntry;
3522
3523 array[2] = filterGetByC_C_PrevAndNext(session, announcementsEntry,
3524 classNameId, classPK, orderByComparator, false);
3525
3526 return array;
3527 }
3528 catch (Exception e) {
3529 throw processException(e);
3530 }
3531 finally {
3532 closeSession(session);
3533 }
3534 }
3535
3536 protected AnnouncementsEntry filterGetByC_C_PrevAndNext(Session session,
3537 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
3538 OrderByComparator orderByComparator, boolean previous) {
3539 StringBundler query = null;
3540
3541 if (orderByComparator != null) {
3542 query = new StringBundler(6 +
3543 (orderByComparator.getOrderByFields().length * 6));
3544 }
3545 else {
3546 query = new StringBundler(3);
3547 }
3548
3549 if (getDB().isSupportsInlineDistinct()) {
3550 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3551 }
3552 else {
3553 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3554 }
3555
3556 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3557
3558 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3559
3560 if (!getDB().isSupportsInlineDistinct()) {
3561 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3562 }
3563
3564 if (orderByComparator != null) {
3565 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3566
3567 if (orderByConditionFields.length > 0) {
3568 query.append(WHERE_AND);
3569 }
3570
3571 for (int i = 0; i < orderByConditionFields.length; i++) {
3572 if (getDB().isSupportsInlineDistinct()) {
3573 query.append(_ORDER_BY_ENTITY_ALIAS);
3574 }
3575 else {
3576 query.append(_ORDER_BY_ENTITY_TABLE);
3577 }
3578
3579 query.append(orderByConditionFields[i]);
3580
3581 if ((i + 1) < orderByConditionFields.length) {
3582 if (orderByComparator.isAscending() ^ previous) {
3583 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3584 }
3585 else {
3586 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3587 }
3588 }
3589 else {
3590 if (orderByComparator.isAscending() ^ previous) {
3591 query.append(WHERE_GREATER_THAN);
3592 }
3593 else {
3594 query.append(WHERE_LESSER_THAN);
3595 }
3596 }
3597 }
3598
3599 query.append(ORDER_BY_CLAUSE);
3600
3601 String[] orderByFields = orderByComparator.getOrderByFields();
3602
3603 for (int i = 0; i < orderByFields.length; i++) {
3604 if (getDB().isSupportsInlineDistinct()) {
3605 query.append(_ORDER_BY_ENTITY_ALIAS);
3606 }
3607 else {
3608 query.append(_ORDER_BY_ENTITY_TABLE);
3609 }
3610
3611 query.append(orderByFields[i]);
3612
3613 if ((i + 1) < orderByFields.length) {
3614 if (orderByComparator.isAscending() ^ previous) {
3615 query.append(ORDER_BY_ASC_HAS_NEXT);
3616 }
3617 else {
3618 query.append(ORDER_BY_DESC_HAS_NEXT);
3619 }
3620 }
3621 else {
3622 if (orderByComparator.isAscending() ^ previous) {
3623 query.append(ORDER_BY_ASC);
3624 }
3625 else {
3626 query.append(ORDER_BY_DESC);
3627 }
3628 }
3629 }
3630 }
3631 else {
3632 if (getDB().isSupportsInlineDistinct()) {
3633 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3634 }
3635 else {
3636 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
3637 }
3638 }
3639
3640 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3641 AnnouncementsEntry.class.getName(),
3642 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3643
3644 SQLQuery q = session.createSQLQuery(sql);
3645
3646 q.setFirstResult(0);
3647 q.setMaxResults(2);
3648
3649 if (getDB().isSupportsInlineDistinct()) {
3650 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
3651 }
3652 else {
3653 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
3654 }
3655
3656 QueryPos qPos = QueryPos.getInstance(q);
3657
3658 qPos.add(classNameId);
3659
3660 qPos.add(classPK);
3661
3662 if (orderByComparator != null) {
3663 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
3664
3665 for (Object value : values) {
3666 qPos.add(value);
3667 }
3668 }
3669
3670 List<AnnouncementsEntry> list = q.list();
3671
3672 if (list.size() == 2) {
3673 return list.get(1);
3674 }
3675 else {
3676 return null;
3677 }
3678 }
3679
3680
3687 @Override
3688 public void removeByC_C(long classNameId, long classPK)
3689 throws SystemException {
3690 for (AnnouncementsEntry announcementsEntry : findByC_C(classNameId,
3691 classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3692 remove(announcementsEntry);
3693 }
3694 }
3695
3696
3704 @Override
3705 public int countByC_C(long classNameId, long classPK)
3706 throws SystemException {
3707 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
3708
3709 Object[] finderArgs = new Object[] { classNameId, classPK };
3710
3711 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3712 this);
3713
3714 if (count == null) {
3715 StringBundler query = new StringBundler(3);
3716
3717 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3718
3719 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3720
3721 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3722
3723 String sql = query.toString();
3724
3725 Session session = null;
3726
3727 try {
3728 session = openSession();
3729
3730 Query q = session.createQuery(sql);
3731
3732 QueryPos qPos = QueryPos.getInstance(q);
3733
3734 qPos.add(classNameId);
3735
3736 qPos.add(classPK);
3737
3738 count = (Long)q.uniqueResult();
3739
3740 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3741 }
3742 catch (Exception e) {
3743 FinderCacheUtil.removeResult(finderPath, finderArgs);
3744
3745 throw processException(e);
3746 }
3747 finally {
3748 closeSession(session);
3749 }
3750 }
3751
3752 return count.intValue();
3753 }
3754
3755
3763 @Override
3764 public int filterCountByC_C(long classNameId, long classPK)
3765 throws SystemException {
3766 if (!InlineSQLHelperUtil.isEnabled()) {
3767 return countByC_C(classNameId, classPK);
3768 }
3769
3770 StringBundler query = new StringBundler(3);
3771
3772 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3773
3774 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3775
3776 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3777
3778 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3779 AnnouncementsEntry.class.getName(),
3780 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3781
3782 Session session = null;
3783
3784 try {
3785 session = openSession();
3786
3787 SQLQuery q = session.createSQLQuery(sql);
3788
3789 q.addScalar(COUNT_COLUMN_NAME,
3790 com.liferay.portal.kernel.dao.orm.Type.LONG);
3791
3792 QueryPos qPos = QueryPos.getInstance(q);
3793
3794 qPos.add(classNameId);
3795
3796 qPos.add(classPK);
3797
3798 Long count = (Long)q.uniqueResult();
3799
3800 return count.intValue();
3801 }
3802 catch (Exception e) {
3803 throw processException(e);
3804 }
3805 finally {
3806 closeSession(session);
3807 }
3808 }
3809
3810 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
3811 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "announcementsEntry.classPK = ?";
3812 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
3813 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
3814 AnnouncementsEntryImpl.class,
3815 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_A",
3816 new String[] {
3817 Long.class.getName(), Long.class.getName(),
3818 Boolean.class.getName(),
3819
3820 Integer.class.getName(), Integer.class.getName(),
3821 OrderByComparator.class.getName()
3822 });
3823 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
3824 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
3825 AnnouncementsEntryImpl.class,
3826 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_A",
3827 new String[] {
3828 Long.class.getName(), Long.class.getName(),
3829 Boolean.class.getName()
3830 },
3831 AnnouncementsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
3832 AnnouncementsEntryModelImpl.CLASSPK_COLUMN_BITMASK |
3833 AnnouncementsEntryModelImpl.ALERT_COLUMN_BITMASK |
3834 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
3835 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
3836 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
3837 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3838 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_A",
3839 new String[] {
3840 Long.class.getName(), Long.class.getName(),
3841 Boolean.class.getName()
3842 });
3843
3844
3853 @Override
3854 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3855 boolean alert) throws SystemException {
3856 return findByC_C_A(classNameId, classPK, alert, QueryUtil.ALL_POS,
3857 QueryUtil.ALL_POS, null);
3858 }
3859
3860
3875 @Override
3876 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3877 boolean alert, int start, int end) throws SystemException {
3878 return findByC_C_A(classNameId, classPK, alert, start, end, null);
3879 }
3880
3881
3897 @Override
3898 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3899 boolean alert, int start, int end, OrderByComparator orderByComparator)
3900 throws SystemException {
3901 boolean pagination = true;
3902 FinderPath finderPath = null;
3903 Object[] finderArgs = null;
3904
3905 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3906 (orderByComparator == null)) {
3907 pagination = false;
3908 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A;
3909 finderArgs = new Object[] { classNameId, classPK, alert };
3910 }
3911 else {
3912 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_A;
3913 finderArgs = new Object[] {
3914 classNameId, classPK, alert,
3915
3916 start, end, orderByComparator
3917 };
3918 }
3919
3920 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
3921 finderArgs, this);
3922
3923 if ((list != null) && !list.isEmpty()) {
3924 for (AnnouncementsEntry announcementsEntry : list) {
3925 if ((classNameId != announcementsEntry.getClassNameId()) ||
3926 (classPK != announcementsEntry.getClassPK()) ||
3927 (alert != announcementsEntry.getAlert())) {
3928 list = null;
3929
3930 break;
3931 }
3932 }
3933 }
3934
3935 if (list == null) {
3936 StringBundler query = null;
3937
3938 if (orderByComparator != null) {
3939 query = new StringBundler(5 +
3940 (orderByComparator.getOrderByFields().length * 3));
3941 }
3942 else {
3943 query = new StringBundler(5);
3944 }
3945
3946 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3947
3948 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
3949
3950 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
3951
3952 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
3953
3954 if (orderByComparator != null) {
3955 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3956 orderByComparator);
3957 }
3958 else
3959 if (pagination) {
3960 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3961 }
3962
3963 String sql = query.toString();
3964
3965 Session session = null;
3966
3967 try {
3968 session = openSession();
3969
3970 Query q = session.createQuery(sql);
3971
3972 QueryPos qPos = QueryPos.getInstance(q);
3973
3974 qPos.add(classNameId);
3975
3976 qPos.add(classPK);
3977
3978 qPos.add(alert);
3979
3980 if (!pagination) {
3981 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3982 getDialect(), start, end, false);
3983
3984 Collections.sort(list);
3985
3986 list = new UnmodifiableList<AnnouncementsEntry>(list);
3987 }
3988 else {
3989 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3990 getDialect(), start, end);
3991 }
3992
3993 cacheResult(list);
3994
3995 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3996 }
3997 catch (Exception e) {
3998 FinderCacheUtil.removeResult(finderPath, finderArgs);
3999
4000 throw processException(e);
4001 }
4002 finally {
4003 closeSession(session);
4004 }
4005 }
4006
4007 return list;
4008 }
4009
4010
4021 @Override
4022 public AnnouncementsEntry findByC_C_A_First(long classNameId, long classPK,
4023 boolean alert, OrderByComparator orderByComparator)
4024 throws NoSuchEntryException, SystemException {
4025 AnnouncementsEntry announcementsEntry = fetchByC_C_A_First(classNameId,
4026 classPK, alert, orderByComparator);
4027
4028 if (announcementsEntry != null) {
4029 return announcementsEntry;
4030 }
4031
4032 StringBundler msg = new StringBundler(8);
4033
4034 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4035
4036 msg.append("classNameId=");
4037 msg.append(classNameId);
4038
4039 msg.append(", classPK=");
4040 msg.append(classPK);
4041
4042 msg.append(", alert=");
4043 msg.append(alert);
4044
4045 msg.append(StringPool.CLOSE_CURLY_BRACE);
4046
4047 throw new NoSuchEntryException(msg.toString());
4048 }
4049
4050
4060 @Override
4061 public AnnouncementsEntry fetchByC_C_A_First(long classNameId,
4062 long classPK, boolean alert, OrderByComparator orderByComparator)
4063 throws SystemException {
4064 List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
4065 alert, 0, 1, orderByComparator);
4066
4067 if (!list.isEmpty()) {
4068 return list.get(0);
4069 }
4070
4071 return null;
4072 }
4073
4074
4085 @Override
4086 public AnnouncementsEntry findByC_C_A_Last(long classNameId, long classPK,
4087 boolean alert, OrderByComparator orderByComparator)
4088 throws NoSuchEntryException, SystemException {
4089 AnnouncementsEntry announcementsEntry = fetchByC_C_A_Last(classNameId,
4090 classPK, alert, orderByComparator);
4091
4092 if (announcementsEntry != null) {
4093 return announcementsEntry;
4094 }
4095
4096 StringBundler msg = new StringBundler(8);
4097
4098 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4099
4100 msg.append("classNameId=");
4101 msg.append(classNameId);
4102
4103 msg.append(", classPK=");
4104 msg.append(classPK);
4105
4106 msg.append(", alert=");
4107 msg.append(alert);
4108
4109 msg.append(StringPool.CLOSE_CURLY_BRACE);
4110
4111 throw new NoSuchEntryException(msg.toString());
4112 }
4113
4114
4124 @Override
4125 public AnnouncementsEntry fetchByC_C_A_Last(long classNameId, long classPK,
4126 boolean alert, OrderByComparator orderByComparator)
4127 throws SystemException {
4128 int count = countByC_C_A(classNameId, classPK, alert);
4129
4130 if (count == 0) {
4131 return null;
4132 }
4133
4134 List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
4135 alert, count - 1, count, orderByComparator);
4136
4137 if (!list.isEmpty()) {
4138 return list.get(0);
4139 }
4140
4141 return null;
4142 }
4143
4144
4156 @Override
4157 public AnnouncementsEntry[] findByC_C_A_PrevAndNext(long entryId,
4158 long classNameId, long classPK, boolean alert,
4159 OrderByComparator orderByComparator)
4160 throws NoSuchEntryException, SystemException {
4161 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
4162
4163 Session session = null;
4164
4165 try {
4166 session = openSession();
4167
4168 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
4169
4170 array[0] = getByC_C_A_PrevAndNext(session, announcementsEntry,
4171 classNameId, classPK, alert, orderByComparator, true);
4172
4173 array[1] = announcementsEntry;
4174
4175 array[2] = getByC_C_A_PrevAndNext(session, announcementsEntry,
4176 classNameId, classPK, alert, orderByComparator, false);
4177
4178 return array;
4179 }
4180 catch (Exception e) {
4181 throw processException(e);
4182 }
4183 finally {
4184 closeSession(session);
4185 }
4186 }
4187
4188 protected AnnouncementsEntry getByC_C_A_PrevAndNext(Session session,
4189 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
4190 boolean alert, OrderByComparator orderByComparator, boolean previous) {
4191 StringBundler query = null;
4192
4193 if (orderByComparator != null) {
4194 query = new StringBundler(6 +
4195 (orderByComparator.getOrderByFields().length * 6));
4196 }
4197 else {
4198 query = new StringBundler(3);
4199 }
4200
4201 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4202
4203 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4204
4205 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4206
4207 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4208
4209 if (orderByComparator != null) {
4210 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4211
4212 if (orderByConditionFields.length > 0) {
4213 query.append(WHERE_AND);
4214 }
4215
4216 for (int i = 0; i < orderByConditionFields.length; i++) {
4217 query.append(_ORDER_BY_ENTITY_ALIAS);
4218 query.append(orderByConditionFields[i]);
4219
4220 if ((i + 1) < orderByConditionFields.length) {
4221 if (orderByComparator.isAscending() ^ previous) {
4222 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4223 }
4224 else {
4225 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4226 }
4227 }
4228 else {
4229 if (orderByComparator.isAscending() ^ previous) {
4230 query.append(WHERE_GREATER_THAN);
4231 }
4232 else {
4233 query.append(WHERE_LESSER_THAN);
4234 }
4235 }
4236 }
4237
4238 query.append(ORDER_BY_CLAUSE);
4239
4240 String[] orderByFields = orderByComparator.getOrderByFields();
4241
4242 for (int i = 0; i < orderByFields.length; i++) {
4243 query.append(_ORDER_BY_ENTITY_ALIAS);
4244 query.append(orderByFields[i]);
4245
4246 if ((i + 1) < orderByFields.length) {
4247 if (orderByComparator.isAscending() ^ previous) {
4248 query.append(ORDER_BY_ASC_HAS_NEXT);
4249 }
4250 else {
4251 query.append(ORDER_BY_DESC_HAS_NEXT);
4252 }
4253 }
4254 else {
4255 if (orderByComparator.isAscending() ^ previous) {
4256 query.append(ORDER_BY_ASC);
4257 }
4258 else {
4259 query.append(ORDER_BY_DESC);
4260 }
4261 }
4262 }
4263 }
4264 else {
4265 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4266 }
4267
4268 String sql = query.toString();
4269
4270 Query q = session.createQuery(sql);
4271
4272 q.setFirstResult(0);
4273 q.setMaxResults(2);
4274
4275 QueryPos qPos = QueryPos.getInstance(q);
4276
4277 qPos.add(classNameId);
4278
4279 qPos.add(classPK);
4280
4281 qPos.add(alert);
4282
4283 if (orderByComparator != null) {
4284 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
4285
4286 for (Object value : values) {
4287 qPos.add(value);
4288 }
4289 }
4290
4291 List<AnnouncementsEntry> list = q.list();
4292
4293 if (list.size() == 2) {
4294 return list.get(1);
4295 }
4296 else {
4297 return null;
4298 }
4299 }
4300
4301
4310 @Override
4311 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4312 long classPK, boolean alert) throws SystemException {
4313 return filterFindByC_C_A(classNameId, classPK, alert,
4314 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4315 }
4316
4317
4332 @Override
4333 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4334 long classPK, boolean alert, int start, int end)
4335 throws SystemException {
4336 return filterFindByC_C_A(classNameId, classPK, alert, start, end, null);
4337 }
4338
4339
4355 @Override
4356 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4357 long classPK, boolean alert, int start, int end,
4358 OrderByComparator orderByComparator) throws SystemException {
4359 if (!InlineSQLHelperUtil.isEnabled()) {
4360 return findByC_C_A(classNameId, classPK, alert, start, end,
4361 orderByComparator);
4362 }
4363
4364 StringBundler query = null;
4365
4366 if (orderByComparator != null) {
4367 query = new StringBundler(5 +
4368 (orderByComparator.getOrderByFields().length * 3));
4369 }
4370 else {
4371 query = new StringBundler(5);
4372 }
4373
4374 if (getDB().isSupportsInlineDistinct()) {
4375 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4376 }
4377 else {
4378 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4379 }
4380
4381 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4382
4383 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4384
4385 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4386
4387 if (!getDB().isSupportsInlineDistinct()) {
4388 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4389 }
4390
4391 if (orderByComparator != null) {
4392 if (getDB().isSupportsInlineDistinct()) {
4393 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4394 orderByComparator, true);
4395 }
4396 else {
4397 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4398 orderByComparator, true);
4399 }
4400 }
4401 else {
4402 if (getDB().isSupportsInlineDistinct()) {
4403 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4404 }
4405 else {
4406 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
4407 }
4408 }
4409
4410 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4411 AnnouncementsEntry.class.getName(),
4412 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4413
4414 Session session = null;
4415
4416 try {
4417 session = openSession();
4418
4419 SQLQuery q = session.createSQLQuery(sql);
4420
4421 if (getDB().isSupportsInlineDistinct()) {
4422 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
4423 }
4424 else {
4425 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
4426 }
4427
4428 QueryPos qPos = QueryPos.getInstance(q);
4429
4430 qPos.add(classNameId);
4431
4432 qPos.add(classPK);
4433
4434 qPos.add(alert);
4435
4436 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
4437 start, end);
4438 }
4439 catch (Exception e) {
4440 throw processException(e);
4441 }
4442 finally {
4443 closeSession(session);
4444 }
4445 }
4446
4447
4459 @Override
4460 public AnnouncementsEntry[] filterFindByC_C_A_PrevAndNext(long entryId,
4461 long classNameId, long classPK, boolean alert,
4462 OrderByComparator orderByComparator)
4463 throws NoSuchEntryException, SystemException {
4464 if (!InlineSQLHelperUtil.isEnabled()) {
4465 return findByC_C_A_PrevAndNext(entryId, classNameId, classPK,
4466 alert, orderByComparator);
4467 }
4468
4469 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
4470
4471 Session session = null;
4472
4473 try {
4474 session = openSession();
4475
4476 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
4477
4478 array[0] = filterGetByC_C_A_PrevAndNext(session,
4479 announcementsEntry, classNameId, classPK, alert,
4480 orderByComparator, true);
4481
4482 array[1] = announcementsEntry;
4483
4484 array[2] = filterGetByC_C_A_PrevAndNext(session,
4485 announcementsEntry, classNameId, classPK, alert,
4486 orderByComparator, false);
4487
4488 return array;
4489 }
4490 catch (Exception e) {
4491 throw processException(e);
4492 }
4493 finally {
4494 closeSession(session);
4495 }
4496 }
4497
4498 protected AnnouncementsEntry filterGetByC_C_A_PrevAndNext(Session session,
4499 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
4500 boolean alert, OrderByComparator orderByComparator, boolean previous) {
4501 StringBundler query = null;
4502
4503 if (orderByComparator != null) {
4504 query = new StringBundler(6 +
4505 (orderByComparator.getOrderByFields().length * 6));
4506 }
4507 else {
4508 query = new StringBundler(3);
4509 }
4510
4511 if (getDB().isSupportsInlineDistinct()) {
4512 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4513 }
4514 else {
4515 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4516 }
4517
4518 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4519
4520 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4521
4522 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4523
4524 if (!getDB().isSupportsInlineDistinct()) {
4525 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4526 }
4527
4528 if (orderByComparator != null) {
4529 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4530
4531 if (orderByConditionFields.length > 0) {
4532 query.append(WHERE_AND);
4533 }
4534
4535 for (int i = 0; i < orderByConditionFields.length; i++) {
4536 if (getDB().isSupportsInlineDistinct()) {
4537 query.append(_ORDER_BY_ENTITY_ALIAS);
4538 }
4539 else {
4540 query.append(_ORDER_BY_ENTITY_TABLE);
4541 }
4542
4543 query.append(orderByConditionFields[i]);
4544
4545 if ((i + 1) < orderByConditionFields.length) {
4546 if (orderByComparator.isAscending() ^ previous) {
4547 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4548 }
4549 else {
4550 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4551 }
4552 }
4553 else {
4554 if (orderByComparator.isAscending() ^ previous) {
4555 query.append(WHERE_GREATER_THAN);
4556 }
4557 else {
4558 query.append(WHERE_LESSER_THAN);
4559 }
4560 }
4561 }
4562
4563 query.append(ORDER_BY_CLAUSE);
4564
4565 String[] orderByFields = orderByComparator.getOrderByFields();
4566
4567 for (int i = 0; i < orderByFields.length; i++) {
4568 if (getDB().isSupportsInlineDistinct()) {
4569 query.append(_ORDER_BY_ENTITY_ALIAS);
4570 }
4571 else {
4572 query.append(_ORDER_BY_ENTITY_TABLE);
4573 }
4574
4575 query.append(orderByFields[i]);
4576
4577 if ((i + 1) < orderByFields.length) {
4578 if (orderByComparator.isAscending() ^ previous) {
4579 query.append(ORDER_BY_ASC_HAS_NEXT);
4580 }
4581 else {
4582 query.append(ORDER_BY_DESC_HAS_NEXT);
4583 }
4584 }
4585 else {
4586 if (orderByComparator.isAscending() ^ previous) {
4587 query.append(ORDER_BY_ASC);
4588 }
4589 else {
4590 query.append(ORDER_BY_DESC);
4591 }
4592 }
4593 }
4594 }
4595 else {
4596 if (getDB().isSupportsInlineDistinct()) {
4597 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4598 }
4599 else {
4600 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
4601 }
4602 }
4603
4604 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4605 AnnouncementsEntry.class.getName(),
4606 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4607
4608 SQLQuery q = session.createSQLQuery(sql);
4609
4610 q.setFirstResult(0);
4611 q.setMaxResults(2);
4612
4613 if (getDB().isSupportsInlineDistinct()) {
4614 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
4615 }
4616 else {
4617 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
4618 }
4619
4620 QueryPos qPos = QueryPos.getInstance(q);
4621
4622 qPos.add(classNameId);
4623
4624 qPos.add(classPK);
4625
4626 qPos.add(alert);
4627
4628 if (orderByComparator != null) {
4629 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
4630
4631 for (Object value : values) {
4632 qPos.add(value);
4633 }
4634 }
4635
4636 List<AnnouncementsEntry> list = q.list();
4637
4638 if (list.size() == 2) {
4639 return list.get(1);
4640 }
4641 else {
4642 return null;
4643 }
4644 }
4645
4646
4654 @Override
4655 public void removeByC_C_A(long classNameId, long classPK, boolean alert)
4656 throws SystemException {
4657 for (AnnouncementsEntry announcementsEntry : findByC_C_A(classNameId,
4658 classPK, alert, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4659 remove(announcementsEntry);
4660 }
4661 }
4662
4663
4672 @Override
4673 public int countByC_C_A(long classNameId, long classPK, boolean alert)
4674 throws SystemException {
4675 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_A;
4676
4677 Object[] finderArgs = new Object[] { classNameId, classPK, alert };
4678
4679 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4680 this);
4681
4682 if (count == null) {
4683 StringBundler query = new StringBundler(4);
4684
4685 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4686
4687 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4688
4689 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4690
4691 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4692
4693 String sql = query.toString();
4694
4695 Session session = null;
4696
4697 try {
4698 session = openSession();
4699
4700 Query q = session.createQuery(sql);
4701
4702 QueryPos qPos = QueryPos.getInstance(q);
4703
4704 qPos.add(classNameId);
4705
4706 qPos.add(classPK);
4707
4708 qPos.add(alert);
4709
4710 count = (Long)q.uniqueResult();
4711
4712 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4713 }
4714 catch (Exception e) {
4715 FinderCacheUtil.removeResult(finderPath, finderArgs);
4716
4717 throw processException(e);
4718 }
4719 finally {
4720 closeSession(session);
4721 }
4722 }
4723
4724 return count.intValue();
4725 }
4726
4727
4736 @Override
4737 public int filterCountByC_C_A(long classNameId, long classPK, boolean alert)
4738 throws SystemException {
4739 if (!InlineSQLHelperUtil.isEnabled()) {
4740 return countByC_C_A(classNameId, classPK, alert);
4741 }
4742
4743 StringBundler query = new StringBundler(4);
4744
4745 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4746
4747 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4748
4749 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4750
4751 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4752
4753 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4754 AnnouncementsEntry.class.getName(),
4755 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4756
4757 Session session = null;
4758
4759 try {
4760 session = openSession();
4761
4762 SQLQuery q = session.createSQLQuery(sql);
4763
4764 q.addScalar(COUNT_COLUMN_NAME,
4765 com.liferay.portal.kernel.dao.orm.Type.LONG);
4766
4767 QueryPos qPos = QueryPos.getInstance(q);
4768
4769 qPos.add(classNameId);
4770
4771 qPos.add(classPK);
4772
4773 qPos.add(alert);
4774
4775 Long count = (Long)q.uniqueResult();
4776
4777 return count.intValue();
4778 }
4779 catch (Exception e) {
4780 throw processException(e);
4781 }
4782 finally {
4783 closeSession(session);
4784 }
4785 }
4786
4787 private static final String _FINDER_COLUMN_C_C_A_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
4788 private static final String _FINDER_COLUMN_C_C_A_CLASSPK_2 = "announcementsEntry.classPK = ? AND ";
4789 private static final String _FINDER_COLUMN_C_C_A_ALERT_2 = "announcementsEntry.alert = ?";
4790
4791 public AnnouncementsEntryPersistenceImpl() {
4792 setModelClass(AnnouncementsEntry.class);
4793 }
4794
4795
4800 @Override
4801 public void cacheResult(AnnouncementsEntry announcementsEntry) {
4802 EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4803 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
4804 announcementsEntry);
4805
4806 announcementsEntry.resetOriginalValues();
4807 }
4808
4809
4814 @Override
4815 public void cacheResult(List<AnnouncementsEntry> announcementsEntries) {
4816 for (AnnouncementsEntry announcementsEntry : announcementsEntries) {
4817 if (EntityCacheUtil.getResult(
4818 AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4819 AnnouncementsEntryImpl.class,
4820 announcementsEntry.getPrimaryKey()) == null) {
4821 cacheResult(announcementsEntry);
4822 }
4823 else {
4824 announcementsEntry.resetOriginalValues();
4825 }
4826 }
4827 }
4828
4829
4836 @Override
4837 public void clearCache() {
4838 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
4839 CacheRegistryUtil.clear(AnnouncementsEntryImpl.class.getName());
4840 }
4841
4842 EntityCacheUtil.clearCache(AnnouncementsEntryImpl.class.getName());
4843
4844 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4845 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4846 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4847 }
4848
4849
4856 @Override
4857 public void clearCache(AnnouncementsEntry announcementsEntry) {
4858 EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4859 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
4860
4861 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4862 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4863 }
4864
4865 @Override
4866 public void clearCache(List<AnnouncementsEntry> announcementsEntries) {
4867 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4868 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4869
4870 for (AnnouncementsEntry announcementsEntry : announcementsEntries) {
4871 EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4872 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
4873 }
4874 }
4875
4876
4882 @Override
4883 public AnnouncementsEntry create(long entryId) {
4884 AnnouncementsEntry announcementsEntry = new AnnouncementsEntryImpl();
4885
4886 announcementsEntry.setNew(true);
4887 announcementsEntry.setPrimaryKey(entryId);
4888
4889 String uuid = PortalUUIDUtil.generate();
4890
4891 announcementsEntry.setUuid(uuid);
4892
4893 return announcementsEntry;
4894 }
4895
4896
4904 @Override
4905 public AnnouncementsEntry remove(long entryId)
4906 throws NoSuchEntryException, SystemException {
4907 return remove((Serializable)entryId);
4908 }
4909
4910
4918 @Override
4919 public AnnouncementsEntry remove(Serializable primaryKey)
4920 throws NoSuchEntryException, SystemException {
4921 Session session = null;
4922
4923 try {
4924 session = openSession();
4925
4926 AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
4927 primaryKey);
4928
4929 if (announcementsEntry == null) {
4930 if (_log.isWarnEnabled()) {
4931 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4932 }
4933
4934 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4935 primaryKey);
4936 }
4937
4938 return remove(announcementsEntry);
4939 }
4940 catch (NoSuchEntryException nsee) {
4941 throw nsee;
4942 }
4943 catch (Exception e) {
4944 throw processException(e);
4945 }
4946 finally {
4947 closeSession(session);
4948 }
4949 }
4950
4951 @Override
4952 protected AnnouncementsEntry removeImpl(
4953 AnnouncementsEntry announcementsEntry) throws SystemException {
4954 announcementsEntry = toUnwrappedModel(announcementsEntry);
4955
4956 Session session = null;
4957
4958 try {
4959 session = openSession();
4960
4961 if (!session.contains(announcementsEntry)) {
4962 announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
4963 announcementsEntry.getPrimaryKeyObj());
4964 }
4965
4966 if (announcementsEntry != null) {
4967 session.delete(announcementsEntry);
4968 }
4969 }
4970 catch (Exception e) {
4971 throw processException(e);
4972 }
4973 finally {
4974 closeSession(session);
4975 }
4976
4977 if (announcementsEntry != null) {
4978 clearCache(announcementsEntry);
4979 }
4980
4981 return announcementsEntry;
4982 }
4983
4984 @Override
4985 public AnnouncementsEntry updateImpl(
4986 com.liferay.portlet.announcements.model.AnnouncementsEntry announcementsEntry)
4987 throws SystemException {
4988 announcementsEntry = toUnwrappedModel(announcementsEntry);
4989
4990 boolean isNew = announcementsEntry.isNew();
4991
4992 AnnouncementsEntryModelImpl announcementsEntryModelImpl = (AnnouncementsEntryModelImpl)announcementsEntry;
4993
4994 if (Validator.isNull(announcementsEntry.getUuid())) {
4995 String uuid = PortalUUIDUtil.generate();
4996
4997 announcementsEntry.setUuid(uuid);
4998 }
4999
5000 Session session = null;
5001
5002 try {
5003 session = openSession();
5004
5005 if (announcementsEntry.isNew()) {
5006 session.save(announcementsEntry);
5007
5008 announcementsEntry.setNew(false);
5009 }
5010 else {
5011 session.merge(announcementsEntry);
5012 }
5013 }
5014 catch (Exception e) {
5015 throw processException(e);
5016 }
5017 finally {
5018 closeSession(session);
5019 }
5020
5021 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5022
5023 if (isNew || !AnnouncementsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
5024 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5025 }
5026
5027 else {
5028 if ((announcementsEntryModelImpl.getColumnBitmask() &
5029 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
5030 Object[] args = new Object[] {
5031 announcementsEntryModelImpl.getOriginalUuid()
5032 };
5033
5034 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
5035 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
5036 args);
5037
5038 args = new Object[] { announcementsEntryModelImpl.getUuid() };
5039
5040 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
5041 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
5042 args);
5043 }
5044
5045 if ((announcementsEntryModelImpl.getColumnBitmask() &
5046 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
5047 Object[] args = new Object[] {
5048 announcementsEntryModelImpl.getOriginalUuid(),
5049 announcementsEntryModelImpl.getOriginalCompanyId()
5050 };
5051
5052 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
5053 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
5054 args);
5055
5056 args = new Object[] {
5057 announcementsEntryModelImpl.getUuid(),
5058 announcementsEntryModelImpl.getCompanyId()
5059 };
5060
5061 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
5062 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
5063 args);
5064 }
5065
5066 if ((announcementsEntryModelImpl.getColumnBitmask() &
5067 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
5068 Object[] args = new Object[] {
5069 announcementsEntryModelImpl.getOriginalUserId()
5070 };
5071
5072 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
5073 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
5074 args);
5075
5076 args = new Object[] { announcementsEntryModelImpl.getUserId() };
5077
5078 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
5079 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
5080 args);
5081 }
5082
5083 if ((announcementsEntryModelImpl.getColumnBitmask() &
5084 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
5085 Object[] args = new Object[] {
5086 announcementsEntryModelImpl.getOriginalClassNameId(),
5087 announcementsEntryModelImpl.getOriginalClassPK()
5088 };
5089
5090 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
5091 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
5092 args);
5093
5094 args = new Object[] {
5095 announcementsEntryModelImpl.getClassNameId(),
5096 announcementsEntryModelImpl.getClassPK()
5097 };
5098
5099 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
5100 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
5101 args);
5102 }
5103
5104 if ((announcementsEntryModelImpl.getColumnBitmask() &
5105 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A.getColumnBitmask()) != 0) {
5106 Object[] args = new Object[] {
5107 announcementsEntryModelImpl.getOriginalClassNameId(),
5108 announcementsEntryModelImpl.getOriginalClassPK(),
5109 announcementsEntryModelImpl.getOriginalAlert()
5110 };
5111
5112 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_A, args);
5113 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A,
5114 args);
5115
5116 args = new Object[] {
5117 announcementsEntryModelImpl.getClassNameId(),
5118 announcementsEntryModelImpl.getClassPK(),
5119 announcementsEntryModelImpl.getAlert()
5120 };
5121
5122 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_A, args);
5123 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A,
5124 args);
5125 }
5126 }
5127
5128 EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5129 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
5130 announcementsEntry);
5131
5132 return announcementsEntry;
5133 }
5134
5135 protected AnnouncementsEntry toUnwrappedModel(
5136 AnnouncementsEntry announcementsEntry) {
5137 if (announcementsEntry instanceof AnnouncementsEntryImpl) {
5138 return announcementsEntry;
5139 }
5140
5141 AnnouncementsEntryImpl announcementsEntryImpl = new AnnouncementsEntryImpl();
5142
5143 announcementsEntryImpl.setNew(announcementsEntry.isNew());
5144 announcementsEntryImpl.setPrimaryKey(announcementsEntry.getPrimaryKey());
5145
5146 announcementsEntryImpl.setUuid(announcementsEntry.getUuid());
5147 announcementsEntryImpl.setEntryId(announcementsEntry.getEntryId());
5148 announcementsEntryImpl.setCompanyId(announcementsEntry.getCompanyId());
5149 announcementsEntryImpl.setUserId(announcementsEntry.getUserId());
5150 announcementsEntryImpl.setUserName(announcementsEntry.getUserName());
5151 announcementsEntryImpl.setCreateDate(announcementsEntry.getCreateDate());
5152 announcementsEntryImpl.setModifiedDate(announcementsEntry.getModifiedDate());
5153 announcementsEntryImpl.setClassNameId(announcementsEntry.getClassNameId());
5154 announcementsEntryImpl.setClassPK(announcementsEntry.getClassPK());
5155 announcementsEntryImpl.setTitle(announcementsEntry.getTitle());
5156 announcementsEntryImpl.setContent(announcementsEntry.getContent());
5157 announcementsEntryImpl.setUrl(announcementsEntry.getUrl());
5158 announcementsEntryImpl.setType(announcementsEntry.getType());
5159 announcementsEntryImpl.setDisplayDate(announcementsEntry.getDisplayDate());
5160 announcementsEntryImpl.setExpirationDate(announcementsEntry.getExpirationDate());
5161 announcementsEntryImpl.setPriority(announcementsEntry.getPriority());
5162 announcementsEntryImpl.setAlert(announcementsEntry.isAlert());
5163
5164 return announcementsEntryImpl;
5165 }
5166
5167
5175 @Override
5176 public AnnouncementsEntry findByPrimaryKey(Serializable primaryKey)
5177 throws NoSuchEntryException, SystemException {
5178 AnnouncementsEntry announcementsEntry = fetchByPrimaryKey(primaryKey);
5179
5180 if (announcementsEntry == null) {
5181 if (_log.isWarnEnabled()) {
5182 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5183 }
5184
5185 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5186 primaryKey);
5187 }
5188
5189 return announcementsEntry;
5190 }
5191
5192
5200 @Override
5201 public AnnouncementsEntry findByPrimaryKey(long entryId)
5202 throws NoSuchEntryException, SystemException {
5203 return findByPrimaryKey((Serializable)entryId);
5204 }
5205
5206
5213 @Override
5214 public AnnouncementsEntry fetchByPrimaryKey(Serializable primaryKey)
5215 throws SystemException {
5216 AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)EntityCacheUtil.getResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5217 AnnouncementsEntryImpl.class, primaryKey);
5218
5219 if (announcementsEntry == _nullAnnouncementsEntry) {
5220 return null;
5221 }
5222
5223 if (announcementsEntry == null) {
5224 Session session = null;
5225
5226 try {
5227 session = openSession();
5228
5229 announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
5230 primaryKey);
5231
5232 if (announcementsEntry != null) {
5233 cacheResult(announcementsEntry);
5234 }
5235 else {
5236 EntityCacheUtil.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5237 AnnouncementsEntryImpl.class, primaryKey,
5238 _nullAnnouncementsEntry);
5239 }
5240 }
5241 catch (Exception e) {
5242 EntityCacheUtil.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5243 AnnouncementsEntryImpl.class, primaryKey);
5244
5245 throw processException(e);
5246 }
5247 finally {
5248 closeSession(session);
5249 }
5250 }
5251
5252 return announcementsEntry;
5253 }
5254
5255
5262 @Override
5263 public AnnouncementsEntry fetchByPrimaryKey(long entryId)
5264 throws SystemException {
5265 return fetchByPrimaryKey((Serializable)entryId);
5266 }
5267
5268
5274 @Override
5275 public List<AnnouncementsEntry> findAll() throws SystemException {
5276 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5277 }
5278
5279
5291 @Override
5292 public List<AnnouncementsEntry> findAll(int start, int end)
5293 throws SystemException {
5294 return findAll(start, end, null);
5295 }
5296
5297
5310 @Override
5311 public List<AnnouncementsEntry> findAll(int start, int end,
5312 OrderByComparator orderByComparator) throws SystemException {
5313 boolean pagination = true;
5314 FinderPath finderPath = null;
5315 Object[] finderArgs = null;
5316
5317 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5318 (orderByComparator == null)) {
5319 pagination = false;
5320 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5321 finderArgs = FINDER_ARGS_EMPTY;
5322 }
5323 else {
5324 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5325 finderArgs = new Object[] { start, end, orderByComparator };
5326 }
5327
5328 List<AnnouncementsEntry> list = (List<AnnouncementsEntry>)FinderCacheUtil.getResult(finderPath,
5329 finderArgs, this);
5330
5331 if (list == null) {
5332 StringBundler query = null;
5333 String sql = null;
5334
5335 if (orderByComparator != null) {
5336 query = new StringBundler(2 +
5337 (orderByComparator.getOrderByFields().length * 3));
5338
5339 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY);
5340
5341 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5342 orderByComparator);
5343
5344 sql = query.toString();
5345 }
5346 else {
5347 sql = _SQL_SELECT_ANNOUNCEMENTSENTRY;
5348
5349 if (pagination) {
5350 sql = sql.concat(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
5351 }
5352 }
5353
5354 Session session = null;
5355
5356 try {
5357 session = openSession();
5358
5359 Query q = session.createQuery(sql);
5360
5361 if (!pagination) {
5362 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
5363 getDialect(), start, end, false);
5364
5365 Collections.sort(list);
5366
5367 list = new UnmodifiableList<AnnouncementsEntry>(list);
5368 }
5369 else {
5370 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
5371 getDialect(), start, end);
5372 }
5373
5374 cacheResult(list);
5375
5376 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5377 }
5378 catch (Exception e) {
5379 FinderCacheUtil.removeResult(finderPath, finderArgs);
5380
5381 throw processException(e);
5382 }
5383 finally {
5384 closeSession(session);
5385 }
5386 }
5387
5388 return list;
5389 }
5390
5391
5396 @Override
5397 public void removeAll() throws SystemException {
5398 for (AnnouncementsEntry announcementsEntry : findAll()) {
5399 remove(announcementsEntry);
5400 }
5401 }
5402
5403
5409 @Override
5410 public int countAll() throws SystemException {
5411 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5412 FINDER_ARGS_EMPTY, this);
5413
5414 if (count == null) {
5415 Session session = null;
5416
5417 try {
5418 session = openSession();
5419
5420 Query q = session.createQuery(_SQL_COUNT_ANNOUNCEMENTSENTRY);
5421
5422 count = (Long)q.uniqueResult();
5423
5424 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5425 FINDER_ARGS_EMPTY, count);
5426 }
5427 catch (Exception e) {
5428 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5429 FINDER_ARGS_EMPTY);
5430
5431 throw processException(e);
5432 }
5433 finally {
5434 closeSession(session);
5435 }
5436 }
5437
5438 return count.intValue();
5439 }
5440
5441 @Override
5442 protected Set<String> getBadColumnNames() {
5443 return _badColumnNames;
5444 }
5445
5446
5449 public void afterPropertiesSet() {
5450 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5451 com.liferay.portal.util.PropsUtil.get(
5452 "value.object.listener.com.liferay.portlet.announcements.model.AnnouncementsEntry")));
5453
5454 if (listenerClassNames.length > 0) {
5455 try {
5456 List<ModelListener<AnnouncementsEntry>> listenersList = new ArrayList<ModelListener<AnnouncementsEntry>>();
5457
5458 for (String listenerClassName : listenerClassNames) {
5459 listenersList.add((ModelListener<AnnouncementsEntry>)InstanceFactory.newInstance(
5460 getClassLoader(), listenerClassName));
5461 }
5462
5463 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5464 }
5465 catch (Exception e) {
5466 _log.error(e);
5467 }
5468 }
5469 }
5470
5471 public void destroy() {
5472 EntityCacheUtil.removeCache(AnnouncementsEntryImpl.class.getName());
5473 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5474 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5475 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5476 }
5477
5478 private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry";
5479 private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry WHERE ";
5480 private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry";
5481 private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry WHERE ";
5482 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "announcementsEntry.entryId";
5483 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT DISTINCT {announcementsEntry.*} FROM AnnouncementsEntry announcementsEntry WHERE ";
5484 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
5485 "SELECT {AnnouncementsEntry.*} FROM (SELECT DISTINCT announcementsEntry.entryId FROM AnnouncementsEntry announcementsEntry WHERE ";
5486 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
5487 ") TEMP_TABLE INNER JOIN AnnouncementsEntry ON TEMP_TABLE.entryId = AnnouncementsEntry.entryId";
5488 private static final String _FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(DISTINCT announcementsEntry.entryId) AS COUNT_VALUE FROM AnnouncementsEntry announcementsEntry WHERE ";
5489 private static final String _FILTER_ENTITY_ALIAS = "announcementsEntry";
5490 private static final String _FILTER_ENTITY_TABLE = "AnnouncementsEntry";
5491 private static final String _ORDER_BY_ENTITY_ALIAS = "announcementsEntry.";
5492 private static final String _ORDER_BY_ENTITY_TABLE = "AnnouncementsEntry.";
5493 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AnnouncementsEntry exists with the primary key ";
5494 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AnnouncementsEntry exists with the key {";
5495 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5496 private static Log _log = LogFactoryUtil.getLog(AnnouncementsEntryPersistenceImpl.class);
5497 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
5498 "uuid", "type"
5499 });
5500 private static AnnouncementsEntry _nullAnnouncementsEntry = new AnnouncementsEntryImpl() {
5501 @Override
5502 public Object clone() {
5503 return this;
5504 }
5505
5506 @Override
5507 public CacheModel<AnnouncementsEntry> toCacheModel() {
5508 return _nullAnnouncementsEntryCacheModel;
5509 }
5510 };
5511
5512 private static CacheModel<AnnouncementsEntry> _nullAnnouncementsEntryCacheModel =
5513 new CacheModel<AnnouncementsEntry>() {
5514 @Override
5515 public AnnouncementsEntry toEntityModel() {
5516 return _nullAnnouncementsEntry;
5517 }
5518 };
5519 }