001
014
015 package com.liferay.portlet.announcements.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.announcements.kernel.exception.NoSuchEntryException;
020 import com.liferay.announcements.kernel.model.AnnouncementsEntry;
021 import com.liferay.announcements.kernel.service.persistence.AnnouncementsEntryPersistence;
022
023 import com.liferay.portal.kernel.bean.BeanReference;
024 import com.liferay.portal.kernel.dao.orm.EntityCache;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCache;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.model.CacheModel;
038 import com.liferay.portal.kernel.sanitizer.Sanitizer;
039 import com.liferay.portal.kernel.sanitizer.SanitizerException;
040 import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
041 import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
042 import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
043 import com.liferay.portal.kernel.service.ServiceContext;
044 import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
045 import com.liferay.portal.kernel.service.persistence.CompanyProvider;
046 import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
047 import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
048 import com.liferay.portal.kernel.util.ContentTypes;
049 import com.liferay.portal.kernel.util.GetterUtil;
050 import com.liferay.portal.kernel.util.OrderByComparator;
051 import com.liferay.portal.kernel.util.SetUtil;
052 import com.liferay.portal.kernel.util.StringBundler;
053 import com.liferay.portal.kernel.util.StringPool;
054 import com.liferay.portal.kernel.util.Validator;
055 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
056
057 import com.liferay.portlet.announcements.model.impl.AnnouncementsEntryImpl;
058 import com.liferay.portlet.announcements.model.impl.AnnouncementsEntryModelImpl;
059
060 import java.io.Serializable;
061
062 import java.util.Collections;
063 import java.util.Date;
064 import java.util.HashMap;
065 import java.util.HashSet;
066 import java.util.Iterator;
067 import java.util.List;
068 import java.util.Map;
069 import java.util.Set;
070
071
083 @ProviderType
084 public class AnnouncementsEntryPersistenceImpl extends BasePersistenceImpl<AnnouncementsEntry>
085 implements AnnouncementsEntryPersistence {
086
091 public static final String FINDER_CLASS_NAME_ENTITY = AnnouncementsEntryImpl.class.getName();
092 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
093 ".List1";
094 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
095 ".List2";
096 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
097 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
098 AnnouncementsEntryImpl.class,
099 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
100 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
101 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
102 AnnouncementsEntryImpl.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
104 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
105 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
107 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
108 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
109 AnnouncementsEntryImpl.class,
110 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
111 new String[] {
112 String.class.getName(),
113
114 Integer.class.getName(), Integer.class.getName(),
115 OrderByComparator.class.getName()
116 });
117 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
118 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
119 AnnouncementsEntryImpl.class,
120 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
121 new String[] { String.class.getName() },
122 AnnouncementsEntryModelImpl.UUID_COLUMN_BITMASK |
123 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
124 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
125 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
126 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
128 new String[] { String.class.getName() });
129
130
136 @Override
137 public List<AnnouncementsEntry> findByUuid(String uuid) {
138 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
139 }
140
141
153 @Override
154 public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end) {
155 return findByUuid(uuid, start, end, null);
156 }
157
158
171 @Override
172 public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end,
173 OrderByComparator<AnnouncementsEntry> orderByComparator) {
174 return findByUuid(uuid, start, end, orderByComparator, true);
175 }
176
177
191 @Override
192 public List<AnnouncementsEntry> findByUuid(String uuid, int start, int end,
193 OrderByComparator<AnnouncementsEntry> orderByComparator,
194 boolean retrieveFromCache) {
195 boolean pagination = true;
196 FinderPath finderPath = null;
197 Object[] finderArgs = null;
198
199 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
200 (orderByComparator == null)) {
201 pagination = false;
202 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
203 finderArgs = new Object[] { uuid };
204 }
205 else {
206 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
207 finderArgs = new Object[] { uuid, start, end, orderByComparator };
208 }
209
210 List<AnnouncementsEntry> list = null;
211
212 if (retrieveFromCache) {
213 list = (List<AnnouncementsEntry>)finderCache.getResult(finderPath,
214 finderArgs, this);
215
216 if ((list != null) && !list.isEmpty()) {
217 for (AnnouncementsEntry announcementsEntry : list) {
218 if (!Validator.equals(uuid, announcementsEntry.getUuid())) {
219 list = null;
220
221 break;
222 }
223 }
224 }
225 }
226
227 if (list == null) {
228 StringBundler query = null;
229
230 if (orderByComparator != null) {
231 query = new StringBundler(3 +
232 (orderByComparator.getOrderByFields().length * 2));
233 }
234 else {
235 query = new StringBundler(3);
236 }
237
238 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
239
240 boolean bindUuid = false;
241
242 if (uuid == null) {
243 query.append(_FINDER_COLUMN_UUID_UUID_1);
244 }
245 else if (uuid.equals(StringPool.BLANK)) {
246 query.append(_FINDER_COLUMN_UUID_UUID_3);
247 }
248 else {
249 bindUuid = true;
250
251 query.append(_FINDER_COLUMN_UUID_UUID_2);
252 }
253
254 if (orderByComparator != null) {
255 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
256 orderByComparator);
257 }
258 else
259 if (pagination) {
260 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
261 }
262
263 String sql = query.toString();
264
265 Session session = null;
266
267 try {
268 session = openSession();
269
270 Query q = session.createQuery(sql);
271
272 QueryPos qPos = QueryPos.getInstance(q);
273
274 if (bindUuid) {
275 qPos.add(uuid);
276 }
277
278 if (!pagination) {
279 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
280 getDialect(), start, end, false);
281
282 Collections.sort(list);
283
284 list = Collections.unmodifiableList(list);
285 }
286 else {
287 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
288 getDialect(), start, end);
289 }
290
291 cacheResult(list);
292
293 finderCache.putResult(finderPath, finderArgs, list);
294 }
295 catch (Exception e) {
296 finderCache.removeResult(finderPath, finderArgs);
297
298 throw processException(e);
299 }
300 finally {
301 closeSession(session);
302 }
303 }
304
305 return list;
306 }
307
308
316 @Override
317 public AnnouncementsEntry findByUuid_First(String uuid,
318 OrderByComparator<AnnouncementsEntry> orderByComparator)
319 throws NoSuchEntryException {
320 AnnouncementsEntry announcementsEntry = fetchByUuid_First(uuid,
321 orderByComparator);
322
323 if (announcementsEntry != null) {
324 return announcementsEntry;
325 }
326
327 StringBundler msg = new StringBundler(4);
328
329 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
330
331 msg.append("uuid=");
332 msg.append(uuid);
333
334 msg.append(StringPool.CLOSE_CURLY_BRACE);
335
336 throw new NoSuchEntryException(msg.toString());
337 }
338
339
346 @Override
347 public AnnouncementsEntry fetchByUuid_First(String uuid,
348 OrderByComparator<AnnouncementsEntry> orderByComparator) {
349 List<AnnouncementsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
350
351 if (!list.isEmpty()) {
352 return list.get(0);
353 }
354
355 return null;
356 }
357
358
366 @Override
367 public AnnouncementsEntry findByUuid_Last(String uuid,
368 OrderByComparator<AnnouncementsEntry> orderByComparator)
369 throws NoSuchEntryException {
370 AnnouncementsEntry announcementsEntry = fetchByUuid_Last(uuid,
371 orderByComparator);
372
373 if (announcementsEntry != null) {
374 return announcementsEntry;
375 }
376
377 StringBundler msg = new StringBundler(4);
378
379 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
380
381 msg.append("uuid=");
382 msg.append(uuid);
383
384 msg.append(StringPool.CLOSE_CURLY_BRACE);
385
386 throw new NoSuchEntryException(msg.toString());
387 }
388
389
396 @Override
397 public AnnouncementsEntry fetchByUuid_Last(String uuid,
398 OrderByComparator<AnnouncementsEntry> orderByComparator) {
399 int count = countByUuid(uuid);
400
401 if (count == 0) {
402 return null;
403 }
404
405 List<AnnouncementsEntry> list = findByUuid(uuid, count - 1, count,
406 orderByComparator);
407
408 if (!list.isEmpty()) {
409 return list.get(0);
410 }
411
412 return null;
413 }
414
415
424 @Override
425 public AnnouncementsEntry[] findByUuid_PrevAndNext(long entryId,
426 String uuid, OrderByComparator<AnnouncementsEntry> orderByComparator)
427 throws NoSuchEntryException {
428 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
429
430 Session session = null;
431
432 try {
433 session = openSession();
434
435 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
436
437 array[0] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
438 orderByComparator, true);
439
440 array[1] = announcementsEntry;
441
442 array[2] = getByUuid_PrevAndNext(session, announcementsEntry, uuid,
443 orderByComparator, false);
444
445 return array;
446 }
447 catch (Exception e) {
448 throw processException(e);
449 }
450 finally {
451 closeSession(session);
452 }
453 }
454
455 protected AnnouncementsEntry getByUuid_PrevAndNext(Session session,
456 AnnouncementsEntry announcementsEntry, String uuid,
457 OrderByComparator<AnnouncementsEntry> orderByComparator,
458 boolean previous) {
459 StringBundler query = null;
460
461 if (orderByComparator != null) {
462 query = new StringBundler(4 +
463 (orderByComparator.getOrderByConditionFields().length * 3) +
464 (orderByComparator.getOrderByFields().length * 3));
465 }
466 else {
467 query = new StringBundler(3);
468 }
469
470 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
471
472 boolean bindUuid = false;
473
474 if (uuid == null) {
475 query.append(_FINDER_COLUMN_UUID_UUID_1);
476 }
477 else if (uuid.equals(StringPool.BLANK)) {
478 query.append(_FINDER_COLUMN_UUID_UUID_3);
479 }
480 else {
481 bindUuid = true;
482
483 query.append(_FINDER_COLUMN_UUID_UUID_2);
484 }
485
486 if (orderByComparator != null) {
487 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
488
489 if (orderByConditionFields.length > 0) {
490 query.append(WHERE_AND);
491 }
492
493 for (int i = 0; i < orderByConditionFields.length; i++) {
494 query.append(_ORDER_BY_ENTITY_ALIAS);
495 query.append(orderByConditionFields[i]);
496
497 if ((i + 1) < orderByConditionFields.length) {
498 if (orderByComparator.isAscending() ^ previous) {
499 query.append(WHERE_GREATER_THAN_HAS_NEXT);
500 }
501 else {
502 query.append(WHERE_LESSER_THAN_HAS_NEXT);
503 }
504 }
505 else {
506 if (orderByComparator.isAscending() ^ previous) {
507 query.append(WHERE_GREATER_THAN);
508 }
509 else {
510 query.append(WHERE_LESSER_THAN);
511 }
512 }
513 }
514
515 query.append(ORDER_BY_CLAUSE);
516
517 String[] orderByFields = orderByComparator.getOrderByFields();
518
519 for (int i = 0; i < orderByFields.length; i++) {
520 query.append(_ORDER_BY_ENTITY_ALIAS);
521 query.append(orderByFields[i]);
522
523 if ((i + 1) < orderByFields.length) {
524 if (orderByComparator.isAscending() ^ previous) {
525 query.append(ORDER_BY_ASC_HAS_NEXT);
526 }
527 else {
528 query.append(ORDER_BY_DESC_HAS_NEXT);
529 }
530 }
531 else {
532 if (orderByComparator.isAscending() ^ previous) {
533 query.append(ORDER_BY_ASC);
534 }
535 else {
536 query.append(ORDER_BY_DESC);
537 }
538 }
539 }
540 }
541 else {
542 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
543 }
544
545 String sql = query.toString();
546
547 Query q = session.createQuery(sql);
548
549 q.setFirstResult(0);
550 q.setMaxResults(2);
551
552 QueryPos qPos = QueryPos.getInstance(q);
553
554 if (bindUuid) {
555 qPos.add(uuid);
556 }
557
558 if (orderByComparator != null) {
559 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
560
561 for (Object value : values) {
562 qPos.add(value);
563 }
564 }
565
566 List<AnnouncementsEntry> list = q.list();
567
568 if (list.size() == 2) {
569 return list.get(1);
570 }
571 else {
572 return null;
573 }
574 }
575
576
582 @Override
583 public List<AnnouncementsEntry> filterFindByUuid(String uuid) {
584 return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
585 }
586
587
599 @Override
600 public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
601 int end) {
602 return filterFindByUuid(uuid, start, end, null);
603 }
604
605
618 @Override
619 public List<AnnouncementsEntry> filterFindByUuid(String uuid, int start,
620 int end, OrderByComparator<AnnouncementsEntry> orderByComparator) {
621 if (!InlineSQLHelperUtil.isEnabled()) {
622 return findByUuid(uuid, start, end, orderByComparator);
623 }
624
625 StringBundler query = null;
626
627 if (orderByComparator != null) {
628 query = new StringBundler(3 +
629 (orderByComparator.getOrderByFields().length * 2));
630 }
631 else {
632 query = new StringBundler(4);
633 }
634
635 if (getDB().isSupportsInlineDistinct()) {
636 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
637 }
638 else {
639 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
640 }
641
642 boolean bindUuid = false;
643
644 if (uuid == null) {
645 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
646 }
647 else if (uuid.equals(StringPool.BLANK)) {
648 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
649 }
650 else {
651 bindUuid = true;
652
653 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
654 }
655
656 if (!getDB().isSupportsInlineDistinct()) {
657 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
658 }
659
660 if (orderByComparator != null) {
661 if (getDB().isSupportsInlineDistinct()) {
662 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
663 orderByComparator, true);
664 }
665 else {
666 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
667 orderByComparator, true);
668 }
669 }
670 else {
671 if (getDB().isSupportsInlineDistinct()) {
672 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
673 }
674 else {
675 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
676 }
677 }
678
679 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
680 AnnouncementsEntry.class.getName(),
681 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
682
683 Session session = null;
684
685 try {
686 session = openSession();
687
688 SQLQuery q = session.createSynchronizedSQLQuery(sql);
689
690 if (getDB().isSupportsInlineDistinct()) {
691 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
692 }
693 else {
694 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
695 }
696
697 QueryPos qPos = QueryPos.getInstance(q);
698
699 if (bindUuid) {
700 qPos.add(uuid);
701 }
702
703 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
704 start, end);
705 }
706 catch (Exception e) {
707 throw processException(e);
708 }
709 finally {
710 closeSession(session);
711 }
712 }
713
714
723 @Override
724 public AnnouncementsEntry[] filterFindByUuid_PrevAndNext(long entryId,
725 String uuid, OrderByComparator<AnnouncementsEntry> orderByComparator)
726 throws NoSuchEntryException {
727 if (!InlineSQLHelperUtil.isEnabled()) {
728 return findByUuid_PrevAndNext(entryId, uuid, orderByComparator);
729 }
730
731 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
732
733 Session session = null;
734
735 try {
736 session = openSession();
737
738 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
739
740 array[0] = filterGetByUuid_PrevAndNext(session, announcementsEntry,
741 uuid, orderByComparator, true);
742
743 array[1] = announcementsEntry;
744
745 array[2] = filterGetByUuid_PrevAndNext(session, announcementsEntry,
746 uuid, orderByComparator, false);
747
748 return array;
749 }
750 catch (Exception e) {
751 throw processException(e);
752 }
753 finally {
754 closeSession(session);
755 }
756 }
757
758 protected AnnouncementsEntry filterGetByUuid_PrevAndNext(Session session,
759 AnnouncementsEntry announcementsEntry, String uuid,
760 OrderByComparator<AnnouncementsEntry> orderByComparator,
761 boolean previous) {
762 StringBundler query = null;
763
764 if (orderByComparator != null) {
765 query = new StringBundler(5 +
766 (orderByComparator.getOrderByConditionFields().length * 3) +
767 (orderByComparator.getOrderByFields().length * 3));
768 }
769 else {
770 query = new StringBundler(4);
771 }
772
773 if (getDB().isSupportsInlineDistinct()) {
774 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
775 }
776 else {
777 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
778 }
779
780 boolean bindUuid = false;
781
782 if (uuid == null) {
783 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
784 }
785 else if (uuid.equals(StringPool.BLANK)) {
786 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
787 }
788 else {
789 bindUuid = true;
790
791 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
792 }
793
794 if (!getDB().isSupportsInlineDistinct()) {
795 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
796 }
797
798 if (orderByComparator != null) {
799 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
800
801 if (orderByConditionFields.length > 0) {
802 query.append(WHERE_AND);
803 }
804
805 for (int i = 0; i < orderByConditionFields.length; i++) {
806 if (getDB().isSupportsInlineDistinct()) {
807 query.append(_ORDER_BY_ENTITY_ALIAS);
808 }
809 else {
810 query.append(_ORDER_BY_ENTITY_TABLE);
811 }
812
813 query.append(orderByConditionFields[i]);
814
815 if ((i + 1) < orderByConditionFields.length) {
816 if (orderByComparator.isAscending() ^ previous) {
817 query.append(WHERE_GREATER_THAN_HAS_NEXT);
818 }
819 else {
820 query.append(WHERE_LESSER_THAN_HAS_NEXT);
821 }
822 }
823 else {
824 if (orderByComparator.isAscending() ^ previous) {
825 query.append(WHERE_GREATER_THAN);
826 }
827 else {
828 query.append(WHERE_LESSER_THAN);
829 }
830 }
831 }
832
833 query.append(ORDER_BY_CLAUSE);
834
835 String[] orderByFields = orderByComparator.getOrderByFields();
836
837 for (int i = 0; i < orderByFields.length; i++) {
838 if (getDB().isSupportsInlineDistinct()) {
839 query.append(_ORDER_BY_ENTITY_ALIAS);
840 }
841 else {
842 query.append(_ORDER_BY_ENTITY_TABLE);
843 }
844
845 query.append(orderByFields[i]);
846
847 if ((i + 1) < orderByFields.length) {
848 if (orderByComparator.isAscending() ^ previous) {
849 query.append(ORDER_BY_ASC_HAS_NEXT);
850 }
851 else {
852 query.append(ORDER_BY_DESC_HAS_NEXT);
853 }
854 }
855 else {
856 if (orderByComparator.isAscending() ^ previous) {
857 query.append(ORDER_BY_ASC);
858 }
859 else {
860 query.append(ORDER_BY_DESC);
861 }
862 }
863 }
864 }
865 else {
866 if (getDB().isSupportsInlineDistinct()) {
867 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
868 }
869 else {
870 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
871 }
872 }
873
874 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
875 AnnouncementsEntry.class.getName(),
876 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
877
878 SQLQuery q = session.createSynchronizedSQLQuery(sql);
879
880 q.setFirstResult(0);
881 q.setMaxResults(2);
882
883 if (getDB().isSupportsInlineDistinct()) {
884 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
885 }
886 else {
887 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
888 }
889
890 QueryPos qPos = QueryPos.getInstance(q);
891
892 if (bindUuid) {
893 qPos.add(uuid);
894 }
895
896 if (orderByComparator != null) {
897 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
898
899 for (Object value : values) {
900 qPos.add(value);
901 }
902 }
903
904 List<AnnouncementsEntry> list = q.list();
905
906 if (list.size() == 2) {
907 return list.get(1);
908 }
909 else {
910 return null;
911 }
912 }
913
914
919 @Override
920 public void removeByUuid(String uuid) {
921 for (AnnouncementsEntry announcementsEntry : findByUuid(uuid,
922 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
923 remove(announcementsEntry);
924 }
925 }
926
927
933 @Override
934 public int countByUuid(String uuid) {
935 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
936
937 Object[] finderArgs = new Object[] { uuid };
938
939 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
940
941 if (count == null) {
942 StringBundler query = new StringBundler(2);
943
944 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
945
946 boolean bindUuid = false;
947
948 if (uuid == null) {
949 query.append(_FINDER_COLUMN_UUID_UUID_1);
950 }
951 else if (uuid.equals(StringPool.BLANK)) {
952 query.append(_FINDER_COLUMN_UUID_UUID_3);
953 }
954 else {
955 bindUuid = true;
956
957 query.append(_FINDER_COLUMN_UUID_UUID_2);
958 }
959
960 String sql = query.toString();
961
962 Session session = null;
963
964 try {
965 session = openSession();
966
967 Query q = session.createQuery(sql);
968
969 QueryPos qPos = QueryPos.getInstance(q);
970
971 if (bindUuid) {
972 qPos.add(uuid);
973 }
974
975 count = (Long)q.uniqueResult();
976
977 finderCache.putResult(finderPath, finderArgs, count);
978 }
979 catch (Exception e) {
980 finderCache.removeResult(finderPath, finderArgs);
981
982 throw processException(e);
983 }
984 finally {
985 closeSession(session);
986 }
987 }
988
989 return count.intValue();
990 }
991
992
998 @Override
999 public int filterCountByUuid(String uuid) {
1000 if (!InlineSQLHelperUtil.isEnabled()) {
1001 return countByUuid(uuid);
1002 }
1003
1004 StringBundler query = new StringBundler(2);
1005
1006 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
1007
1008 boolean bindUuid = false;
1009
1010 if (uuid == null) {
1011 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
1012 }
1013 else if (uuid.equals(StringPool.BLANK)) {
1014 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
1015 }
1016 else {
1017 bindUuid = true;
1018
1019 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
1020 }
1021
1022 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1023 AnnouncementsEntry.class.getName(),
1024 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1025
1026 Session session = null;
1027
1028 try {
1029 session = openSession();
1030
1031 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1032
1033 q.addScalar(COUNT_COLUMN_NAME,
1034 com.liferay.portal.kernel.dao.orm.Type.LONG);
1035
1036 QueryPos qPos = QueryPos.getInstance(q);
1037
1038 if (bindUuid) {
1039 qPos.add(uuid);
1040 }
1041
1042 Long count = (Long)q.uniqueResult();
1043
1044 return count.intValue();
1045 }
1046 catch (Exception e) {
1047 throw processException(e);
1048 }
1049 finally {
1050 closeSession(session);
1051 }
1052 }
1053
1054 private static final String _FINDER_COLUMN_UUID_UUID_1 = "announcementsEntry.uuid IS NULL";
1055 private static final String _FINDER_COLUMN_UUID_UUID_2 = "announcementsEntry.uuid = ?";
1056 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(announcementsEntry.uuid IS NULL OR announcementsEntry.uuid = '')";
1057 private static final String _FINDER_COLUMN_UUID_UUID_1_SQL = "announcementsEntry.uuid_ IS NULL";
1058 private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "announcementsEntry.uuid_ = ?";
1059 private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(announcementsEntry.uuid_ IS NULL OR announcementsEntry.uuid_ = '')";
1060 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
1061 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
1062 AnnouncementsEntryImpl.class,
1063 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
1064 new String[] {
1065 String.class.getName(), Long.class.getName(),
1066
1067 Integer.class.getName(), Integer.class.getName(),
1068 OrderByComparator.class.getName()
1069 });
1070 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1071 new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
1072 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
1073 AnnouncementsEntryImpl.class,
1074 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1075 new String[] { String.class.getName(), Long.class.getName() },
1076 AnnouncementsEntryModelImpl.UUID_COLUMN_BITMASK |
1077 AnnouncementsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
1078 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
1079 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
1080 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
1081 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1082 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1083 new String[] { String.class.getName(), Long.class.getName() });
1084
1085
1092 @Override
1093 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId) {
1094 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1095 QueryUtil.ALL_POS, null);
1096 }
1097
1098
1111 @Override
1112 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId,
1113 int start, int end) {
1114 return findByUuid_C(uuid, companyId, start, end, null);
1115 }
1116
1117
1131 @Override
1132 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId,
1133 int start, int end,
1134 OrderByComparator<AnnouncementsEntry> orderByComparator) {
1135 return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
1136 }
1137
1138
1153 @Override
1154 public List<AnnouncementsEntry> findByUuid_C(String uuid, long companyId,
1155 int start, int end,
1156 OrderByComparator<AnnouncementsEntry> orderByComparator,
1157 boolean retrieveFromCache) {
1158 boolean pagination = true;
1159 FinderPath finderPath = null;
1160 Object[] finderArgs = null;
1161
1162 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1163 (orderByComparator == null)) {
1164 pagination = false;
1165 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1166 finderArgs = new Object[] { uuid, companyId };
1167 }
1168 else {
1169 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1170 finderArgs = new Object[] {
1171 uuid, companyId,
1172
1173 start, end, orderByComparator
1174 };
1175 }
1176
1177 List<AnnouncementsEntry> list = null;
1178
1179 if (retrieveFromCache) {
1180 list = (List<AnnouncementsEntry>)finderCache.getResult(finderPath,
1181 finderArgs, this);
1182
1183 if ((list != null) && !list.isEmpty()) {
1184 for (AnnouncementsEntry announcementsEntry : list) {
1185 if (!Validator.equals(uuid, announcementsEntry.getUuid()) ||
1186 (companyId != announcementsEntry.getCompanyId())) {
1187 list = null;
1188
1189 break;
1190 }
1191 }
1192 }
1193 }
1194
1195 if (list == null) {
1196 StringBundler query = null;
1197
1198 if (orderByComparator != null) {
1199 query = new StringBundler(4 +
1200 (orderByComparator.getOrderByFields().length * 2));
1201 }
1202 else {
1203 query = new StringBundler(4);
1204 }
1205
1206 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1207
1208 boolean bindUuid = false;
1209
1210 if (uuid == null) {
1211 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1212 }
1213 else if (uuid.equals(StringPool.BLANK)) {
1214 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1215 }
1216 else {
1217 bindUuid = true;
1218
1219 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1220 }
1221
1222 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1223
1224 if (orderByComparator != null) {
1225 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1226 orderByComparator);
1227 }
1228 else
1229 if (pagination) {
1230 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1231 }
1232
1233 String sql = query.toString();
1234
1235 Session session = null;
1236
1237 try {
1238 session = openSession();
1239
1240 Query q = session.createQuery(sql);
1241
1242 QueryPos qPos = QueryPos.getInstance(q);
1243
1244 if (bindUuid) {
1245 qPos.add(uuid);
1246 }
1247
1248 qPos.add(companyId);
1249
1250 if (!pagination) {
1251 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
1252 getDialect(), start, end, false);
1253
1254 Collections.sort(list);
1255
1256 list = Collections.unmodifiableList(list);
1257 }
1258 else {
1259 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
1260 getDialect(), start, end);
1261 }
1262
1263 cacheResult(list);
1264
1265 finderCache.putResult(finderPath, finderArgs, list);
1266 }
1267 catch (Exception e) {
1268 finderCache.removeResult(finderPath, finderArgs);
1269
1270 throw processException(e);
1271 }
1272 finally {
1273 closeSession(session);
1274 }
1275 }
1276
1277 return list;
1278 }
1279
1280
1289 @Override
1290 public AnnouncementsEntry findByUuid_C_First(String uuid, long companyId,
1291 OrderByComparator<AnnouncementsEntry> orderByComparator)
1292 throws NoSuchEntryException {
1293 AnnouncementsEntry announcementsEntry = fetchByUuid_C_First(uuid,
1294 companyId, orderByComparator);
1295
1296 if (announcementsEntry != null) {
1297 return announcementsEntry;
1298 }
1299
1300 StringBundler msg = new StringBundler(6);
1301
1302 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1303
1304 msg.append("uuid=");
1305 msg.append(uuid);
1306
1307 msg.append(", companyId=");
1308 msg.append(companyId);
1309
1310 msg.append(StringPool.CLOSE_CURLY_BRACE);
1311
1312 throw new NoSuchEntryException(msg.toString());
1313 }
1314
1315
1323 @Override
1324 public AnnouncementsEntry fetchByUuid_C_First(String uuid, long companyId,
1325 OrderByComparator<AnnouncementsEntry> orderByComparator) {
1326 List<AnnouncementsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1327 orderByComparator);
1328
1329 if (!list.isEmpty()) {
1330 return list.get(0);
1331 }
1332
1333 return null;
1334 }
1335
1336
1345 @Override
1346 public AnnouncementsEntry findByUuid_C_Last(String uuid, long companyId,
1347 OrderByComparator<AnnouncementsEntry> orderByComparator)
1348 throws NoSuchEntryException {
1349 AnnouncementsEntry announcementsEntry = fetchByUuid_C_Last(uuid,
1350 companyId, orderByComparator);
1351
1352 if (announcementsEntry != null) {
1353 return announcementsEntry;
1354 }
1355
1356 StringBundler msg = new StringBundler(6);
1357
1358 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1359
1360 msg.append("uuid=");
1361 msg.append(uuid);
1362
1363 msg.append(", companyId=");
1364 msg.append(companyId);
1365
1366 msg.append(StringPool.CLOSE_CURLY_BRACE);
1367
1368 throw new NoSuchEntryException(msg.toString());
1369 }
1370
1371
1379 @Override
1380 public AnnouncementsEntry fetchByUuid_C_Last(String uuid, long companyId,
1381 OrderByComparator<AnnouncementsEntry> orderByComparator) {
1382 int count = countByUuid_C(uuid, companyId);
1383
1384 if (count == 0) {
1385 return null;
1386 }
1387
1388 List<AnnouncementsEntry> list = findByUuid_C(uuid, companyId,
1389 count - 1, count, orderByComparator);
1390
1391 if (!list.isEmpty()) {
1392 return list.get(0);
1393 }
1394
1395 return null;
1396 }
1397
1398
1408 @Override
1409 public AnnouncementsEntry[] findByUuid_C_PrevAndNext(long entryId,
1410 String uuid, long companyId,
1411 OrderByComparator<AnnouncementsEntry> orderByComparator)
1412 throws NoSuchEntryException {
1413 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1414
1415 Session session = null;
1416
1417 try {
1418 session = openSession();
1419
1420 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1421
1422 array[0] = getByUuid_C_PrevAndNext(session, announcementsEntry,
1423 uuid, companyId, orderByComparator, true);
1424
1425 array[1] = announcementsEntry;
1426
1427 array[2] = getByUuid_C_PrevAndNext(session, announcementsEntry,
1428 uuid, companyId, orderByComparator, false);
1429
1430 return array;
1431 }
1432 catch (Exception e) {
1433 throw processException(e);
1434 }
1435 finally {
1436 closeSession(session);
1437 }
1438 }
1439
1440 protected AnnouncementsEntry getByUuid_C_PrevAndNext(Session session,
1441 AnnouncementsEntry announcementsEntry, String uuid, long companyId,
1442 OrderByComparator<AnnouncementsEntry> orderByComparator,
1443 boolean previous) {
1444 StringBundler query = null;
1445
1446 if (orderByComparator != null) {
1447 query = new StringBundler(5 +
1448 (orderByComparator.getOrderByConditionFields().length * 3) +
1449 (orderByComparator.getOrderByFields().length * 3));
1450 }
1451 else {
1452 query = new StringBundler(4);
1453 }
1454
1455 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1456
1457 boolean bindUuid = false;
1458
1459 if (uuid == null) {
1460 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1461 }
1462 else if (uuid.equals(StringPool.BLANK)) {
1463 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1464 }
1465 else {
1466 bindUuid = true;
1467
1468 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1469 }
1470
1471 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1472
1473 if (orderByComparator != null) {
1474 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1475
1476 if (orderByConditionFields.length > 0) {
1477 query.append(WHERE_AND);
1478 }
1479
1480 for (int i = 0; i < orderByConditionFields.length; i++) {
1481 query.append(_ORDER_BY_ENTITY_ALIAS);
1482 query.append(orderByConditionFields[i]);
1483
1484 if ((i + 1) < orderByConditionFields.length) {
1485 if (orderByComparator.isAscending() ^ previous) {
1486 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1487 }
1488 else {
1489 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1490 }
1491 }
1492 else {
1493 if (orderByComparator.isAscending() ^ previous) {
1494 query.append(WHERE_GREATER_THAN);
1495 }
1496 else {
1497 query.append(WHERE_LESSER_THAN);
1498 }
1499 }
1500 }
1501
1502 query.append(ORDER_BY_CLAUSE);
1503
1504 String[] orderByFields = orderByComparator.getOrderByFields();
1505
1506 for (int i = 0; i < orderByFields.length; i++) {
1507 query.append(_ORDER_BY_ENTITY_ALIAS);
1508 query.append(orderByFields[i]);
1509
1510 if ((i + 1) < orderByFields.length) {
1511 if (orderByComparator.isAscending() ^ previous) {
1512 query.append(ORDER_BY_ASC_HAS_NEXT);
1513 }
1514 else {
1515 query.append(ORDER_BY_DESC_HAS_NEXT);
1516 }
1517 }
1518 else {
1519 if (orderByComparator.isAscending() ^ previous) {
1520 query.append(ORDER_BY_ASC);
1521 }
1522 else {
1523 query.append(ORDER_BY_DESC);
1524 }
1525 }
1526 }
1527 }
1528 else {
1529 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1530 }
1531
1532 String sql = query.toString();
1533
1534 Query q = session.createQuery(sql);
1535
1536 q.setFirstResult(0);
1537 q.setMaxResults(2);
1538
1539 QueryPos qPos = QueryPos.getInstance(q);
1540
1541 if (bindUuid) {
1542 qPos.add(uuid);
1543 }
1544
1545 qPos.add(companyId);
1546
1547 if (orderByComparator != null) {
1548 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1549
1550 for (Object value : values) {
1551 qPos.add(value);
1552 }
1553 }
1554
1555 List<AnnouncementsEntry> list = q.list();
1556
1557 if (list.size() == 2) {
1558 return list.get(1);
1559 }
1560 else {
1561 return null;
1562 }
1563 }
1564
1565
1572 @Override
1573 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1574 long companyId) {
1575 return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1576 QueryUtil.ALL_POS, null);
1577 }
1578
1579
1592 @Override
1593 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1594 long companyId, int start, int end) {
1595 return filterFindByUuid_C(uuid, companyId, start, end, null);
1596 }
1597
1598
1612 @Override
1613 public List<AnnouncementsEntry> filterFindByUuid_C(String uuid,
1614 long companyId, int start, int end,
1615 OrderByComparator<AnnouncementsEntry> orderByComparator) {
1616 if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
1617 return findByUuid_C(uuid, companyId, start, end, orderByComparator);
1618 }
1619
1620 StringBundler query = null;
1621
1622 if (orderByComparator != null) {
1623 query = new StringBundler(4 +
1624 (orderByComparator.getOrderByFields().length * 2));
1625 }
1626 else {
1627 query = new StringBundler(5);
1628 }
1629
1630 if (getDB().isSupportsInlineDistinct()) {
1631 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1632 }
1633 else {
1634 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1635 }
1636
1637 boolean bindUuid = false;
1638
1639 if (uuid == null) {
1640 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1641 }
1642 else if (uuid.equals(StringPool.BLANK)) {
1643 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1644 }
1645 else {
1646 bindUuid = true;
1647
1648 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1649 }
1650
1651 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1652
1653 if (!getDB().isSupportsInlineDistinct()) {
1654 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1655 }
1656
1657 if (orderByComparator != null) {
1658 if (getDB().isSupportsInlineDistinct()) {
1659 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1660 orderByComparator, true);
1661 }
1662 else {
1663 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1664 orderByComparator, true);
1665 }
1666 }
1667 else {
1668 if (getDB().isSupportsInlineDistinct()) {
1669 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1670 }
1671 else {
1672 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1673 }
1674 }
1675
1676 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1677 AnnouncementsEntry.class.getName(),
1678 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1679
1680 Session session = null;
1681
1682 try {
1683 session = openSession();
1684
1685 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1686
1687 if (getDB().isSupportsInlineDistinct()) {
1688 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1689 }
1690 else {
1691 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1692 }
1693
1694 QueryPos qPos = QueryPos.getInstance(q);
1695
1696 if (bindUuid) {
1697 qPos.add(uuid);
1698 }
1699
1700 qPos.add(companyId);
1701
1702 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
1703 start, end);
1704 }
1705 catch (Exception e) {
1706 throw processException(e);
1707 }
1708 finally {
1709 closeSession(session);
1710 }
1711 }
1712
1713
1723 @Override
1724 public AnnouncementsEntry[] filterFindByUuid_C_PrevAndNext(long entryId,
1725 String uuid, long companyId,
1726 OrderByComparator<AnnouncementsEntry> orderByComparator)
1727 throws NoSuchEntryException {
1728 if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
1729 return findByUuid_C_PrevAndNext(entryId, uuid, companyId,
1730 orderByComparator);
1731 }
1732
1733 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
1734
1735 Session session = null;
1736
1737 try {
1738 session = openSession();
1739
1740 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
1741
1742 array[0] = filterGetByUuid_C_PrevAndNext(session,
1743 announcementsEntry, uuid, companyId, orderByComparator, true);
1744
1745 array[1] = announcementsEntry;
1746
1747 array[2] = filterGetByUuid_C_PrevAndNext(session,
1748 announcementsEntry, uuid, companyId, orderByComparator,
1749 false);
1750
1751 return array;
1752 }
1753 catch (Exception e) {
1754 throw processException(e);
1755 }
1756 finally {
1757 closeSession(session);
1758 }
1759 }
1760
1761 protected AnnouncementsEntry filterGetByUuid_C_PrevAndNext(
1762 Session session, AnnouncementsEntry announcementsEntry, String uuid,
1763 long companyId,
1764 OrderByComparator<AnnouncementsEntry> orderByComparator,
1765 boolean previous) {
1766 StringBundler query = null;
1767
1768 if (orderByComparator != null) {
1769 query = new StringBundler(6 +
1770 (orderByComparator.getOrderByConditionFields().length * 3) +
1771 (orderByComparator.getOrderByFields().length * 3));
1772 }
1773 else {
1774 query = new StringBundler(5);
1775 }
1776
1777 if (getDB().isSupportsInlineDistinct()) {
1778 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
1779 }
1780 else {
1781 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1782 }
1783
1784 boolean bindUuid = false;
1785
1786 if (uuid == null) {
1787 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1788 }
1789 else if (uuid.equals(StringPool.BLANK)) {
1790 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1791 }
1792 else {
1793 bindUuid = true;
1794
1795 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1796 }
1797
1798 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1799
1800 if (!getDB().isSupportsInlineDistinct()) {
1801 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1802 }
1803
1804 if (orderByComparator != null) {
1805 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1806
1807 if (orderByConditionFields.length > 0) {
1808 query.append(WHERE_AND);
1809 }
1810
1811 for (int i = 0; i < orderByConditionFields.length; i++) {
1812 if (getDB().isSupportsInlineDistinct()) {
1813 query.append(_ORDER_BY_ENTITY_ALIAS);
1814 }
1815 else {
1816 query.append(_ORDER_BY_ENTITY_TABLE);
1817 }
1818
1819 query.append(orderByConditionFields[i]);
1820
1821 if ((i + 1) < orderByConditionFields.length) {
1822 if (orderByComparator.isAscending() ^ previous) {
1823 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1824 }
1825 else {
1826 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1827 }
1828 }
1829 else {
1830 if (orderByComparator.isAscending() ^ previous) {
1831 query.append(WHERE_GREATER_THAN);
1832 }
1833 else {
1834 query.append(WHERE_LESSER_THAN);
1835 }
1836 }
1837 }
1838
1839 query.append(ORDER_BY_CLAUSE);
1840
1841 String[] orderByFields = orderByComparator.getOrderByFields();
1842
1843 for (int i = 0; i < orderByFields.length; i++) {
1844 if (getDB().isSupportsInlineDistinct()) {
1845 query.append(_ORDER_BY_ENTITY_ALIAS);
1846 }
1847 else {
1848 query.append(_ORDER_BY_ENTITY_TABLE);
1849 }
1850
1851 query.append(orderByFields[i]);
1852
1853 if ((i + 1) < orderByFields.length) {
1854 if (orderByComparator.isAscending() ^ previous) {
1855 query.append(ORDER_BY_ASC_HAS_NEXT);
1856 }
1857 else {
1858 query.append(ORDER_BY_DESC_HAS_NEXT);
1859 }
1860 }
1861 else {
1862 if (orderByComparator.isAscending() ^ previous) {
1863 query.append(ORDER_BY_ASC);
1864 }
1865 else {
1866 query.append(ORDER_BY_DESC);
1867 }
1868 }
1869 }
1870 }
1871 else {
1872 if (getDB().isSupportsInlineDistinct()) {
1873 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
1874 }
1875 else {
1876 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
1877 }
1878 }
1879
1880 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1881 AnnouncementsEntry.class.getName(),
1882 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1883
1884 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1885
1886 q.setFirstResult(0);
1887 q.setMaxResults(2);
1888
1889 if (getDB().isSupportsInlineDistinct()) {
1890 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
1891 }
1892 else {
1893 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
1894 }
1895
1896 QueryPos qPos = QueryPos.getInstance(q);
1897
1898 if (bindUuid) {
1899 qPos.add(uuid);
1900 }
1901
1902 qPos.add(companyId);
1903
1904 if (orderByComparator != null) {
1905 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
1906
1907 for (Object value : values) {
1908 qPos.add(value);
1909 }
1910 }
1911
1912 List<AnnouncementsEntry> list = q.list();
1913
1914 if (list.size() == 2) {
1915 return list.get(1);
1916 }
1917 else {
1918 return null;
1919 }
1920 }
1921
1922
1928 @Override
1929 public void removeByUuid_C(String uuid, long companyId) {
1930 for (AnnouncementsEntry announcementsEntry : findByUuid_C(uuid,
1931 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1932 remove(announcementsEntry);
1933 }
1934 }
1935
1936
1943 @Override
1944 public int countByUuid_C(String uuid, long companyId) {
1945 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1946
1947 Object[] finderArgs = new Object[] { uuid, companyId };
1948
1949 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1950
1951 if (count == null) {
1952 StringBundler query = new StringBundler(3);
1953
1954 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
1955
1956 boolean bindUuid = false;
1957
1958 if (uuid == null) {
1959 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1960 }
1961 else if (uuid.equals(StringPool.BLANK)) {
1962 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1963 }
1964 else {
1965 bindUuid = true;
1966
1967 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1968 }
1969
1970 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1971
1972 String sql = query.toString();
1973
1974 Session session = null;
1975
1976 try {
1977 session = openSession();
1978
1979 Query q = session.createQuery(sql);
1980
1981 QueryPos qPos = QueryPos.getInstance(q);
1982
1983 if (bindUuid) {
1984 qPos.add(uuid);
1985 }
1986
1987 qPos.add(companyId);
1988
1989 count = (Long)q.uniqueResult();
1990
1991 finderCache.putResult(finderPath, finderArgs, count);
1992 }
1993 catch (Exception e) {
1994 finderCache.removeResult(finderPath, finderArgs);
1995
1996 throw processException(e);
1997 }
1998 finally {
1999 closeSession(session);
2000 }
2001 }
2002
2003 return count.intValue();
2004 }
2005
2006
2013 @Override
2014 public int filterCountByUuid_C(String uuid, long companyId) {
2015 if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
2016 return countByUuid_C(uuid, companyId);
2017 }
2018
2019 StringBundler query = new StringBundler(3);
2020
2021 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2022
2023 boolean bindUuid = false;
2024
2025 if (uuid == null) {
2026 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
2027 }
2028 else if (uuid.equals(StringPool.BLANK)) {
2029 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
2030 }
2031 else {
2032 bindUuid = true;
2033
2034 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
2035 }
2036
2037 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
2038
2039 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2040 AnnouncementsEntry.class.getName(),
2041 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2042
2043 Session session = null;
2044
2045 try {
2046 session = openSession();
2047
2048 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2049
2050 q.addScalar(COUNT_COLUMN_NAME,
2051 com.liferay.portal.kernel.dao.orm.Type.LONG);
2052
2053 QueryPos qPos = QueryPos.getInstance(q);
2054
2055 if (bindUuid) {
2056 qPos.add(uuid);
2057 }
2058
2059 qPos.add(companyId);
2060
2061 Long count = (Long)q.uniqueResult();
2062
2063 return count.intValue();
2064 }
2065 catch (Exception e) {
2066 throw processException(e);
2067 }
2068 finally {
2069 closeSession(session);
2070 }
2071 }
2072
2073 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "announcementsEntry.uuid IS NULL AND ";
2074 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "announcementsEntry.uuid = ? AND ";
2075 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(announcementsEntry.uuid IS NULL OR announcementsEntry.uuid = '') AND ";
2076 private static final String _FINDER_COLUMN_UUID_C_UUID_1_SQL = "announcementsEntry.uuid_ IS NULL AND ";
2077 private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "announcementsEntry.uuid_ = ? AND ";
2078 private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(announcementsEntry.uuid_ IS NULL OR announcementsEntry.uuid_ = '') AND ";
2079 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "announcementsEntry.companyId = ?";
2080 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2081 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2082 AnnouncementsEntryImpl.class,
2083 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
2084 new String[] {
2085 Long.class.getName(),
2086
2087 Integer.class.getName(), Integer.class.getName(),
2088 OrderByComparator.class.getName()
2089 });
2090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
2091 new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2092 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2093 AnnouncementsEntryImpl.class,
2094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
2095 new String[] { Long.class.getName() },
2096 AnnouncementsEntryModelImpl.USERID_COLUMN_BITMASK |
2097 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
2098 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
2099 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2100 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
2102 new String[] { Long.class.getName() });
2103
2104
2110 @Override
2111 public List<AnnouncementsEntry> findByUserId(long userId) {
2112 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2113 }
2114
2115
2127 @Override
2128 public List<AnnouncementsEntry> findByUserId(long userId, int start, int end) {
2129 return findByUserId(userId, start, end, null);
2130 }
2131
2132
2145 @Override
2146 public List<AnnouncementsEntry> findByUserId(long userId, int start,
2147 int end, OrderByComparator<AnnouncementsEntry> orderByComparator) {
2148 return findByUserId(userId, start, end, orderByComparator, true);
2149 }
2150
2151
2165 @Override
2166 public List<AnnouncementsEntry> findByUserId(long userId, int start,
2167 int end, OrderByComparator<AnnouncementsEntry> orderByComparator,
2168 boolean retrieveFromCache) {
2169 boolean pagination = true;
2170 FinderPath finderPath = null;
2171 Object[] finderArgs = null;
2172
2173 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2174 (orderByComparator == null)) {
2175 pagination = false;
2176 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
2177 finderArgs = new Object[] { userId };
2178 }
2179 else {
2180 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
2181 finderArgs = new Object[] { userId, start, end, orderByComparator };
2182 }
2183
2184 List<AnnouncementsEntry> list = null;
2185
2186 if (retrieveFromCache) {
2187 list = (List<AnnouncementsEntry>)finderCache.getResult(finderPath,
2188 finderArgs, this);
2189
2190 if ((list != null) && !list.isEmpty()) {
2191 for (AnnouncementsEntry announcementsEntry : list) {
2192 if ((userId != announcementsEntry.getUserId())) {
2193 list = null;
2194
2195 break;
2196 }
2197 }
2198 }
2199 }
2200
2201 if (list == null) {
2202 StringBundler query = null;
2203
2204 if (orderByComparator != null) {
2205 query = new StringBundler(3 +
2206 (orderByComparator.getOrderByFields().length * 2));
2207 }
2208 else {
2209 query = new StringBundler(3);
2210 }
2211
2212 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2213
2214 query.append(_FINDER_COLUMN_USERID_USERID_2);
2215
2216 if (orderByComparator != null) {
2217 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2218 orderByComparator);
2219 }
2220 else
2221 if (pagination) {
2222 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2223 }
2224
2225 String sql = query.toString();
2226
2227 Session session = null;
2228
2229 try {
2230 session = openSession();
2231
2232 Query q = session.createQuery(sql);
2233
2234 QueryPos qPos = QueryPos.getInstance(q);
2235
2236 qPos.add(userId);
2237
2238 if (!pagination) {
2239 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2240 getDialect(), start, end, false);
2241
2242 Collections.sort(list);
2243
2244 list = Collections.unmodifiableList(list);
2245 }
2246 else {
2247 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
2248 getDialect(), start, end);
2249 }
2250
2251 cacheResult(list);
2252
2253 finderCache.putResult(finderPath, finderArgs, list);
2254 }
2255 catch (Exception e) {
2256 finderCache.removeResult(finderPath, finderArgs);
2257
2258 throw processException(e);
2259 }
2260 finally {
2261 closeSession(session);
2262 }
2263 }
2264
2265 return list;
2266 }
2267
2268
2276 @Override
2277 public AnnouncementsEntry findByUserId_First(long userId,
2278 OrderByComparator<AnnouncementsEntry> orderByComparator)
2279 throws NoSuchEntryException {
2280 AnnouncementsEntry announcementsEntry = fetchByUserId_First(userId,
2281 orderByComparator);
2282
2283 if (announcementsEntry != null) {
2284 return announcementsEntry;
2285 }
2286
2287 StringBundler msg = new StringBundler(4);
2288
2289 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2290
2291 msg.append("userId=");
2292 msg.append(userId);
2293
2294 msg.append(StringPool.CLOSE_CURLY_BRACE);
2295
2296 throw new NoSuchEntryException(msg.toString());
2297 }
2298
2299
2306 @Override
2307 public AnnouncementsEntry fetchByUserId_First(long userId,
2308 OrderByComparator<AnnouncementsEntry> orderByComparator) {
2309 List<AnnouncementsEntry> list = findByUserId(userId, 0, 1,
2310 orderByComparator);
2311
2312 if (!list.isEmpty()) {
2313 return list.get(0);
2314 }
2315
2316 return null;
2317 }
2318
2319
2327 @Override
2328 public AnnouncementsEntry findByUserId_Last(long userId,
2329 OrderByComparator<AnnouncementsEntry> orderByComparator)
2330 throws NoSuchEntryException {
2331 AnnouncementsEntry announcementsEntry = fetchByUserId_Last(userId,
2332 orderByComparator);
2333
2334 if (announcementsEntry != null) {
2335 return announcementsEntry;
2336 }
2337
2338 StringBundler msg = new StringBundler(4);
2339
2340 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2341
2342 msg.append("userId=");
2343 msg.append(userId);
2344
2345 msg.append(StringPool.CLOSE_CURLY_BRACE);
2346
2347 throw new NoSuchEntryException(msg.toString());
2348 }
2349
2350
2357 @Override
2358 public AnnouncementsEntry fetchByUserId_Last(long userId,
2359 OrderByComparator<AnnouncementsEntry> orderByComparator) {
2360 int count = countByUserId(userId);
2361
2362 if (count == 0) {
2363 return null;
2364 }
2365
2366 List<AnnouncementsEntry> list = findByUserId(userId, count - 1, count,
2367 orderByComparator);
2368
2369 if (!list.isEmpty()) {
2370 return list.get(0);
2371 }
2372
2373 return null;
2374 }
2375
2376
2385 @Override
2386 public AnnouncementsEntry[] findByUserId_PrevAndNext(long entryId,
2387 long userId, OrderByComparator<AnnouncementsEntry> orderByComparator)
2388 throws NoSuchEntryException {
2389 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2390
2391 Session session = null;
2392
2393 try {
2394 session = openSession();
2395
2396 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2397
2398 array[0] = getByUserId_PrevAndNext(session, announcementsEntry,
2399 userId, orderByComparator, true);
2400
2401 array[1] = announcementsEntry;
2402
2403 array[2] = getByUserId_PrevAndNext(session, announcementsEntry,
2404 userId, orderByComparator, false);
2405
2406 return array;
2407 }
2408 catch (Exception e) {
2409 throw processException(e);
2410 }
2411 finally {
2412 closeSession(session);
2413 }
2414 }
2415
2416 protected AnnouncementsEntry getByUserId_PrevAndNext(Session session,
2417 AnnouncementsEntry announcementsEntry, long userId,
2418 OrderByComparator<AnnouncementsEntry> orderByComparator,
2419 boolean previous) {
2420 StringBundler query = null;
2421
2422 if (orderByComparator != null) {
2423 query = new StringBundler(4 +
2424 (orderByComparator.getOrderByConditionFields().length * 3) +
2425 (orderByComparator.getOrderByFields().length * 3));
2426 }
2427 else {
2428 query = new StringBundler(3);
2429 }
2430
2431 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2432
2433 query.append(_FINDER_COLUMN_USERID_USERID_2);
2434
2435 if (orderByComparator != null) {
2436 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2437
2438 if (orderByConditionFields.length > 0) {
2439 query.append(WHERE_AND);
2440 }
2441
2442 for (int i = 0; i < orderByConditionFields.length; i++) {
2443 query.append(_ORDER_BY_ENTITY_ALIAS);
2444 query.append(orderByConditionFields[i]);
2445
2446 if ((i + 1) < orderByConditionFields.length) {
2447 if (orderByComparator.isAscending() ^ previous) {
2448 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2449 }
2450 else {
2451 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2452 }
2453 }
2454 else {
2455 if (orderByComparator.isAscending() ^ previous) {
2456 query.append(WHERE_GREATER_THAN);
2457 }
2458 else {
2459 query.append(WHERE_LESSER_THAN);
2460 }
2461 }
2462 }
2463
2464 query.append(ORDER_BY_CLAUSE);
2465
2466 String[] orderByFields = orderByComparator.getOrderByFields();
2467
2468 for (int i = 0; i < orderByFields.length; i++) {
2469 query.append(_ORDER_BY_ENTITY_ALIAS);
2470 query.append(orderByFields[i]);
2471
2472 if ((i + 1) < orderByFields.length) {
2473 if (orderByComparator.isAscending() ^ previous) {
2474 query.append(ORDER_BY_ASC_HAS_NEXT);
2475 }
2476 else {
2477 query.append(ORDER_BY_DESC_HAS_NEXT);
2478 }
2479 }
2480 else {
2481 if (orderByComparator.isAscending() ^ previous) {
2482 query.append(ORDER_BY_ASC);
2483 }
2484 else {
2485 query.append(ORDER_BY_DESC);
2486 }
2487 }
2488 }
2489 }
2490 else {
2491 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2492 }
2493
2494 String sql = query.toString();
2495
2496 Query q = session.createQuery(sql);
2497
2498 q.setFirstResult(0);
2499 q.setMaxResults(2);
2500
2501 QueryPos qPos = QueryPos.getInstance(q);
2502
2503 qPos.add(userId);
2504
2505 if (orderByComparator != null) {
2506 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2507
2508 for (Object value : values) {
2509 qPos.add(value);
2510 }
2511 }
2512
2513 List<AnnouncementsEntry> list = q.list();
2514
2515 if (list.size() == 2) {
2516 return list.get(1);
2517 }
2518 else {
2519 return null;
2520 }
2521 }
2522
2523
2529 @Override
2530 public List<AnnouncementsEntry> filterFindByUserId(long userId) {
2531 return filterFindByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2532 null);
2533 }
2534
2535
2547 @Override
2548 public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
2549 int end) {
2550 return filterFindByUserId(userId, start, end, null);
2551 }
2552
2553
2566 @Override
2567 public List<AnnouncementsEntry> filterFindByUserId(long userId, int start,
2568 int end, OrderByComparator<AnnouncementsEntry> orderByComparator) {
2569 if (!InlineSQLHelperUtil.isEnabled()) {
2570 return findByUserId(userId, start, end, orderByComparator);
2571 }
2572
2573 StringBundler query = null;
2574
2575 if (orderByComparator != null) {
2576 query = new StringBundler(3 +
2577 (orderByComparator.getOrderByFields().length * 2));
2578 }
2579 else {
2580 query = new StringBundler(4);
2581 }
2582
2583 if (getDB().isSupportsInlineDistinct()) {
2584 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2585 }
2586 else {
2587 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2588 }
2589
2590 query.append(_FINDER_COLUMN_USERID_USERID_2);
2591
2592 if (!getDB().isSupportsInlineDistinct()) {
2593 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2594 }
2595
2596 if (orderByComparator != null) {
2597 if (getDB().isSupportsInlineDistinct()) {
2598 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2599 orderByComparator, true);
2600 }
2601 else {
2602 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2603 orderByComparator, true);
2604 }
2605 }
2606 else {
2607 if (getDB().isSupportsInlineDistinct()) {
2608 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2609 }
2610 else {
2611 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2612 }
2613 }
2614
2615 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2616 AnnouncementsEntry.class.getName(),
2617 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2618
2619 Session session = null;
2620
2621 try {
2622 session = openSession();
2623
2624 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2625
2626 if (getDB().isSupportsInlineDistinct()) {
2627 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2628 }
2629 else {
2630 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2631 }
2632
2633 QueryPos qPos = QueryPos.getInstance(q);
2634
2635 qPos.add(userId);
2636
2637 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
2638 start, end);
2639 }
2640 catch (Exception e) {
2641 throw processException(e);
2642 }
2643 finally {
2644 closeSession(session);
2645 }
2646 }
2647
2648
2657 @Override
2658 public AnnouncementsEntry[] filterFindByUserId_PrevAndNext(long entryId,
2659 long userId, OrderByComparator<AnnouncementsEntry> orderByComparator)
2660 throws NoSuchEntryException {
2661 if (!InlineSQLHelperUtil.isEnabled()) {
2662 return findByUserId_PrevAndNext(entryId, userId, orderByComparator);
2663 }
2664
2665 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
2666
2667 Session session = null;
2668
2669 try {
2670 session = openSession();
2671
2672 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
2673
2674 array[0] = filterGetByUserId_PrevAndNext(session,
2675 announcementsEntry, userId, orderByComparator, true);
2676
2677 array[1] = announcementsEntry;
2678
2679 array[2] = filterGetByUserId_PrevAndNext(session,
2680 announcementsEntry, userId, orderByComparator, false);
2681
2682 return array;
2683 }
2684 catch (Exception e) {
2685 throw processException(e);
2686 }
2687 finally {
2688 closeSession(session);
2689 }
2690 }
2691
2692 protected AnnouncementsEntry filterGetByUserId_PrevAndNext(
2693 Session session, AnnouncementsEntry announcementsEntry, long userId,
2694 OrderByComparator<AnnouncementsEntry> orderByComparator,
2695 boolean previous) {
2696 StringBundler query = null;
2697
2698 if (orderByComparator != null) {
2699 query = new StringBundler(5 +
2700 (orderByComparator.getOrderByConditionFields().length * 3) +
2701 (orderByComparator.getOrderByFields().length * 3));
2702 }
2703 else {
2704 query = new StringBundler(4);
2705 }
2706
2707 if (getDB().isSupportsInlineDistinct()) {
2708 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
2709 }
2710 else {
2711 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2712 }
2713
2714 query.append(_FINDER_COLUMN_USERID_USERID_2);
2715
2716 if (!getDB().isSupportsInlineDistinct()) {
2717 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2718 }
2719
2720 if (orderByComparator != null) {
2721 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2722
2723 if (orderByConditionFields.length > 0) {
2724 query.append(WHERE_AND);
2725 }
2726
2727 for (int i = 0; i < orderByConditionFields.length; i++) {
2728 if (getDB().isSupportsInlineDistinct()) {
2729 query.append(_ORDER_BY_ENTITY_ALIAS);
2730 }
2731 else {
2732 query.append(_ORDER_BY_ENTITY_TABLE);
2733 }
2734
2735 query.append(orderByConditionFields[i]);
2736
2737 if ((i + 1) < orderByConditionFields.length) {
2738 if (orderByComparator.isAscending() ^ previous) {
2739 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2740 }
2741 else {
2742 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2743 }
2744 }
2745 else {
2746 if (orderByComparator.isAscending() ^ previous) {
2747 query.append(WHERE_GREATER_THAN);
2748 }
2749 else {
2750 query.append(WHERE_LESSER_THAN);
2751 }
2752 }
2753 }
2754
2755 query.append(ORDER_BY_CLAUSE);
2756
2757 String[] orderByFields = orderByComparator.getOrderByFields();
2758
2759 for (int i = 0; i < orderByFields.length; i++) {
2760 if (getDB().isSupportsInlineDistinct()) {
2761 query.append(_ORDER_BY_ENTITY_ALIAS);
2762 }
2763 else {
2764 query.append(_ORDER_BY_ENTITY_TABLE);
2765 }
2766
2767 query.append(orderByFields[i]);
2768
2769 if ((i + 1) < orderByFields.length) {
2770 if (orderByComparator.isAscending() ^ previous) {
2771 query.append(ORDER_BY_ASC_HAS_NEXT);
2772 }
2773 else {
2774 query.append(ORDER_BY_DESC_HAS_NEXT);
2775 }
2776 }
2777 else {
2778 if (orderByComparator.isAscending() ^ previous) {
2779 query.append(ORDER_BY_ASC);
2780 }
2781 else {
2782 query.append(ORDER_BY_DESC);
2783 }
2784 }
2785 }
2786 }
2787 else {
2788 if (getDB().isSupportsInlineDistinct()) {
2789 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
2790 }
2791 else {
2792 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
2793 }
2794 }
2795
2796 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2797 AnnouncementsEntry.class.getName(),
2798 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2799
2800 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2801
2802 q.setFirstResult(0);
2803 q.setMaxResults(2);
2804
2805 if (getDB().isSupportsInlineDistinct()) {
2806 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
2807 }
2808 else {
2809 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
2810 }
2811
2812 QueryPos qPos = QueryPos.getInstance(q);
2813
2814 qPos.add(userId);
2815
2816 if (orderByComparator != null) {
2817 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
2818
2819 for (Object value : values) {
2820 qPos.add(value);
2821 }
2822 }
2823
2824 List<AnnouncementsEntry> list = q.list();
2825
2826 if (list.size() == 2) {
2827 return list.get(1);
2828 }
2829 else {
2830 return null;
2831 }
2832 }
2833
2834
2839 @Override
2840 public void removeByUserId(long userId) {
2841 for (AnnouncementsEntry announcementsEntry : findByUserId(userId,
2842 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2843 remove(announcementsEntry);
2844 }
2845 }
2846
2847
2853 @Override
2854 public int countByUserId(long userId) {
2855 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
2856
2857 Object[] finderArgs = new Object[] { userId };
2858
2859 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2860
2861 if (count == null) {
2862 StringBundler query = new StringBundler(2);
2863
2864 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2865
2866 query.append(_FINDER_COLUMN_USERID_USERID_2);
2867
2868 String sql = query.toString();
2869
2870 Session session = null;
2871
2872 try {
2873 session = openSession();
2874
2875 Query q = session.createQuery(sql);
2876
2877 QueryPos qPos = QueryPos.getInstance(q);
2878
2879 qPos.add(userId);
2880
2881 count = (Long)q.uniqueResult();
2882
2883 finderCache.putResult(finderPath, finderArgs, count);
2884 }
2885 catch (Exception e) {
2886 finderCache.removeResult(finderPath, finderArgs);
2887
2888 throw processException(e);
2889 }
2890 finally {
2891 closeSession(session);
2892 }
2893 }
2894
2895 return count.intValue();
2896 }
2897
2898
2904 @Override
2905 public int filterCountByUserId(long userId) {
2906 if (!InlineSQLHelperUtil.isEnabled()) {
2907 return countByUserId(userId);
2908 }
2909
2910 StringBundler query = new StringBundler(2);
2911
2912 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
2913
2914 query.append(_FINDER_COLUMN_USERID_USERID_2);
2915
2916 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2917 AnnouncementsEntry.class.getName(),
2918 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2919
2920 Session session = null;
2921
2922 try {
2923 session = openSession();
2924
2925 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2926
2927 q.addScalar(COUNT_COLUMN_NAME,
2928 com.liferay.portal.kernel.dao.orm.Type.LONG);
2929
2930 QueryPos qPos = QueryPos.getInstance(q);
2931
2932 qPos.add(userId);
2933
2934 Long count = (Long)q.uniqueResult();
2935
2936 return count.intValue();
2937 }
2938 catch (Exception e) {
2939 throw processException(e);
2940 }
2941 finally {
2942 closeSession(session);
2943 }
2944 }
2945
2946 private static final String _FINDER_COLUMN_USERID_USERID_2 = "announcementsEntry.userId = ?";
2947 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2948 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2949 AnnouncementsEntryImpl.class,
2950 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
2951 new String[] {
2952 Long.class.getName(), Long.class.getName(),
2953
2954 Integer.class.getName(), Integer.class.getName(),
2955 OrderByComparator.class.getName()
2956 });
2957 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2958 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
2959 AnnouncementsEntryImpl.class,
2960 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
2961 new String[] { Long.class.getName(), Long.class.getName() },
2962 AnnouncementsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2963 AnnouncementsEntryModelImpl.CLASSPK_COLUMN_BITMASK |
2964 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
2965 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
2966 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
2967 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2968 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
2969 new String[] { Long.class.getName(), Long.class.getName() });
2970
2971
2978 @Override
2979 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK) {
2980 return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
2981 QueryUtil.ALL_POS, null);
2982 }
2983
2984
2997 @Override
2998 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
2999 int start, int end) {
3000 return findByC_C(classNameId, classPK, start, end, null);
3001 }
3002
3003
3017 @Override
3018 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
3019 int start, int end,
3020 OrderByComparator<AnnouncementsEntry> orderByComparator) {
3021 return findByC_C(classNameId, classPK, start, end, orderByComparator,
3022 true);
3023 }
3024
3025
3040 @Override
3041 public List<AnnouncementsEntry> findByC_C(long classNameId, long classPK,
3042 int start, int end,
3043 OrderByComparator<AnnouncementsEntry> orderByComparator,
3044 boolean retrieveFromCache) {
3045 boolean pagination = true;
3046 FinderPath finderPath = null;
3047 Object[] finderArgs = null;
3048
3049 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3050 (orderByComparator == null)) {
3051 pagination = false;
3052 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
3053 finderArgs = new Object[] { classNameId, classPK };
3054 }
3055 else {
3056 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
3057 finderArgs = new Object[] {
3058 classNameId, classPK,
3059
3060 start, end, orderByComparator
3061 };
3062 }
3063
3064 List<AnnouncementsEntry> list = null;
3065
3066 if (retrieveFromCache) {
3067 list = (List<AnnouncementsEntry>)finderCache.getResult(finderPath,
3068 finderArgs, this);
3069
3070 if ((list != null) && !list.isEmpty()) {
3071 for (AnnouncementsEntry announcementsEntry : list) {
3072 if ((classNameId != announcementsEntry.getClassNameId()) ||
3073 (classPK != announcementsEntry.getClassPK())) {
3074 list = null;
3075
3076 break;
3077 }
3078 }
3079 }
3080 }
3081
3082 if (list == null) {
3083 StringBundler query = null;
3084
3085 if (orderByComparator != null) {
3086 query = new StringBundler(4 +
3087 (orderByComparator.getOrderByFields().length * 2));
3088 }
3089 else {
3090 query = new StringBundler(4);
3091 }
3092
3093 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3094
3095 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3096
3097 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3098
3099 if (orderByComparator != null) {
3100 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3101 orderByComparator);
3102 }
3103 else
3104 if (pagination) {
3105 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3106 }
3107
3108 String sql = query.toString();
3109
3110 Session session = null;
3111
3112 try {
3113 session = openSession();
3114
3115 Query q = session.createQuery(sql);
3116
3117 QueryPos qPos = QueryPos.getInstance(q);
3118
3119 qPos.add(classNameId);
3120
3121 qPos.add(classPK);
3122
3123 if (!pagination) {
3124 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3125 getDialect(), start, end, false);
3126
3127 Collections.sort(list);
3128
3129 list = Collections.unmodifiableList(list);
3130 }
3131 else {
3132 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
3133 getDialect(), start, end);
3134 }
3135
3136 cacheResult(list);
3137
3138 finderCache.putResult(finderPath, finderArgs, list);
3139 }
3140 catch (Exception e) {
3141 finderCache.removeResult(finderPath, finderArgs);
3142
3143 throw processException(e);
3144 }
3145 finally {
3146 closeSession(session);
3147 }
3148 }
3149
3150 return list;
3151 }
3152
3153
3162 @Override
3163 public AnnouncementsEntry findByC_C_First(long classNameId, long classPK,
3164 OrderByComparator<AnnouncementsEntry> orderByComparator)
3165 throws NoSuchEntryException {
3166 AnnouncementsEntry announcementsEntry = fetchByC_C_First(classNameId,
3167 classPK, orderByComparator);
3168
3169 if (announcementsEntry != null) {
3170 return announcementsEntry;
3171 }
3172
3173 StringBundler msg = new StringBundler(6);
3174
3175 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3176
3177 msg.append("classNameId=");
3178 msg.append(classNameId);
3179
3180 msg.append(", classPK=");
3181 msg.append(classPK);
3182
3183 msg.append(StringPool.CLOSE_CURLY_BRACE);
3184
3185 throw new NoSuchEntryException(msg.toString());
3186 }
3187
3188
3196 @Override
3197 public AnnouncementsEntry fetchByC_C_First(long classNameId, long classPK,
3198 OrderByComparator<AnnouncementsEntry> orderByComparator) {
3199 List<AnnouncementsEntry> list = findByC_C(classNameId, classPK, 0, 1,
3200 orderByComparator);
3201
3202 if (!list.isEmpty()) {
3203 return list.get(0);
3204 }
3205
3206 return null;
3207 }
3208
3209
3218 @Override
3219 public AnnouncementsEntry findByC_C_Last(long classNameId, long classPK,
3220 OrderByComparator<AnnouncementsEntry> orderByComparator)
3221 throws NoSuchEntryException {
3222 AnnouncementsEntry announcementsEntry = fetchByC_C_Last(classNameId,
3223 classPK, orderByComparator);
3224
3225 if (announcementsEntry != null) {
3226 return announcementsEntry;
3227 }
3228
3229 StringBundler msg = new StringBundler(6);
3230
3231 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3232
3233 msg.append("classNameId=");
3234 msg.append(classNameId);
3235
3236 msg.append(", classPK=");
3237 msg.append(classPK);
3238
3239 msg.append(StringPool.CLOSE_CURLY_BRACE);
3240
3241 throw new NoSuchEntryException(msg.toString());
3242 }
3243
3244
3252 @Override
3253 public AnnouncementsEntry fetchByC_C_Last(long classNameId, long classPK,
3254 OrderByComparator<AnnouncementsEntry> orderByComparator) {
3255 int count = countByC_C(classNameId, classPK);
3256
3257 if (count == 0) {
3258 return null;
3259 }
3260
3261 List<AnnouncementsEntry> list = findByC_C(classNameId, classPK,
3262 count - 1, count, orderByComparator);
3263
3264 if (!list.isEmpty()) {
3265 return list.get(0);
3266 }
3267
3268 return null;
3269 }
3270
3271
3281 @Override
3282 public AnnouncementsEntry[] findByC_C_PrevAndNext(long entryId,
3283 long classNameId, long classPK,
3284 OrderByComparator<AnnouncementsEntry> orderByComparator)
3285 throws NoSuchEntryException {
3286 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
3287
3288 Session session = null;
3289
3290 try {
3291 session = openSession();
3292
3293 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
3294
3295 array[0] = getByC_C_PrevAndNext(session, announcementsEntry,
3296 classNameId, classPK, orderByComparator, true);
3297
3298 array[1] = announcementsEntry;
3299
3300 array[2] = getByC_C_PrevAndNext(session, announcementsEntry,
3301 classNameId, classPK, orderByComparator, false);
3302
3303 return array;
3304 }
3305 catch (Exception e) {
3306 throw processException(e);
3307 }
3308 finally {
3309 closeSession(session);
3310 }
3311 }
3312
3313 protected AnnouncementsEntry getByC_C_PrevAndNext(Session session,
3314 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
3315 OrderByComparator<AnnouncementsEntry> orderByComparator,
3316 boolean previous) {
3317 StringBundler query = null;
3318
3319 if (orderByComparator != null) {
3320 query = new StringBundler(5 +
3321 (orderByComparator.getOrderByConditionFields().length * 3) +
3322 (orderByComparator.getOrderByFields().length * 3));
3323 }
3324 else {
3325 query = new StringBundler(4);
3326 }
3327
3328 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3329
3330 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3331
3332 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3333
3334 if (orderByComparator != null) {
3335 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3336
3337 if (orderByConditionFields.length > 0) {
3338 query.append(WHERE_AND);
3339 }
3340
3341 for (int i = 0; i < orderByConditionFields.length; i++) {
3342 query.append(_ORDER_BY_ENTITY_ALIAS);
3343 query.append(orderByConditionFields[i]);
3344
3345 if ((i + 1) < orderByConditionFields.length) {
3346 if (orderByComparator.isAscending() ^ previous) {
3347 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3348 }
3349 else {
3350 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3351 }
3352 }
3353 else {
3354 if (orderByComparator.isAscending() ^ previous) {
3355 query.append(WHERE_GREATER_THAN);
3356 }
3357 else {
3358 query.append(WHERE_LESSER_THAN);
3359 }
3360 }
3361 }
3362
3363 query.append(ORDER_BY_CLAUSE);
3364
3365 String[] orderByFields = orderByComparator.getOrderByFields();
3366
3367 for (int i = 0; i < orderByFields.length; i++) {
3368 query.append(_ORDER_BY_ENTITY_ALIAS);
3369 query.append(orderByFields[i]);
3370
3371 if ((i + 1) < orderByFields.length) {
3372 if (orderByComparator.isAscending() ^ previous) {
3373 query.append(ORDER_BY_ASC_HAS_NEXT);
3374 }
3375 else {
3376 query.append(ORDER_BY_DESC_HAS_NEXT);
3377 }
3378 }
3379 else {
3380 if (orderByComparator.isAscending() ^ previous) {
3381 query.append(ORDER_BY_ASC);
3382 }
3383 else {
3384 query.append(ORDER_BY_DESC);
3385 }
3386 }
3387 }
3388 }
3389 else {
3390 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3391 }
3392
3393 String sql = query.toString();
3394
3395 Query q = session.createQuery(sql);
3396
3397 q.setFirstResult(0);
3398 q.setMaxResults(2);
3399
3400 QueryPos qPos = QueryPos.getInstance(q);
3401
3402 qPos.add(classNameId);
3403
3404 qPos.add(classPK);
3405
3406 if (orderByComparator != null) {
3407 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
3408
3409 for (Object value : values) {
3410 qPos.add(value);
3411 }
3412 }
3413
3414 List<AnnouncementsEntry> list = q.list();
3415
3416 if (list.size() == 2) {
3417 return list.get(1);
3418 }
3419 else {
3420 return null;
3421 }
3422 }
3423
3424
3431 @Override
3432 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3433 long classPK) {
3434 return filterFindByC_C(classNameId, classPK, QueryUtil.ALL_POS,
3435 QueryUtil.ALL_POS, null);
3436 }
3437
3438
3451 @Override
3452 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3453 long classPK, int start, int end) {
3454 return filterFindByC_C(classNameId, classPK, start, end, null);
3455 }
3456
3457
3471 @Override
3472 public List<AnnouncementsEntry> filterFindByC_C(long classNameId,
3473 long classPK, int start, int end,
3474 OrderByComparator<AnnouncementsEntry> orderByComparator) {
3475 if (!InlineSQLHelperUtil.isEnabled()) {
3476 return findByC_C(classNameId, classPK, start, end, orderByComparator);
3477 }
3478
3479 StringBundler query = null;
3480
3481 if (orderByComparator != null) {
3482 query = new StringBundler(4 +
3483 (orderByComparator.getOrderByFields().length * 2));
3484 }
3485 else {
3486 query = new StringBundler(5);
3487 }
3488
3489 if (getDB().isSupportsInlineDistinct()) {
3490 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3491 }
3492 else {
3493 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3494 }
3495
3496 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3497
3498 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3499
3500 if (!getDB().isSupportsInlineDistinct()) {
3501 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3502 }
3503
3504 if (orderByComparator != null) {
3505 if (getDB().isSupportsInlineDistinct()) {
3506 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3507 orderByComparator, true);
3508 }
3509 else {
3510 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3511 orderByComparator, true);
3512 }
3513 }
3514 else {
3515 if (getDB().isSupportsInlineDistinct()) {
3516 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3517 }
3518 else {
3519 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
3520 }
3521 }
3522
3523 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3524 AnnouncementsEntry.class.getName(),
3525 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3526
3527 Session session = null;
3528
3529 try {
3530 session = openSession();
3531
3532 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3533
3534 if (getDB().isSupportsInlineDistinct()) {
3535 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
3536 }
3537 else {
3538 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
3539 }
3540
3541 QueryPos qPos = QueryPos.getInstance(q);
3542
3543 qPos.add(classNameId);
3544
3545 qPos.add(classPK);
3546
3547 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
3548 start, end);
3549 }
3550 catch (Exception e) {
3551 throw processException(e);
3552 }
3553 finally {
3554 closeSession(session);
3555 }
3556 }
3557
3558
3568 @Override
3569 public AnnouncementsEntry[] filterFindByC_C_PrevAndNext(long entryId,
3570 long classNameId, long classPK,
3571 OrderByComparator<AnnouncementsEntry> orderByComparator)
3572 throws NoSuchEntryException {
3573 if (!InlineSQLHelperUtil.isEnabled()) {
3574 return findByC_C_PrevAndNext(entryId, classNameId, classPK,
3575 orderByComparator);
3576 }
3577
3578 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
3579
3580 Session session = null;
3581
3582 try {
3583 session = openSession();
3584
3585 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
3586
3587 array[0] = filterGetByC_C_PrevAndNext(session, announcementsEntry,
3588 classNameId, classPK, orderByComparator, true);
3589
3590 array[1] = announcementsEntry;
3591
3592 array[2] = filterGetByC_C_PrevAndNext(session, announcementsEntry,
3593 classNameId, classPK, orderByComparator, false);
3594
3595 return array;
3596 }
3597 catch (Exception e) {
3598 throw processException(e);
3599 }
3600 finally {
3601 closeSession(session);
3602 }
3603 }
3604
3605 protected AnnouncementsEntry filterGetByC_C_PrevAndNext(Session session,
3606 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
3607 OrderByComparator<AnnouncementsEntry> orderByComparator,
3608 boolean previous) {
3609 StringBundler query = null;
3610
3611 if (orderByComparator != null) {
3612 query = new StringBundler(6 +
3613 (orderByComparator.getOrderByConditionFields().length * 3) +
3614 (orderByComparator.getOrderByFields().length * 3));
3615 }
3616 else {
3617 query = new StringBundler(5);
3618 }
3619
3620 if (getDB().isSupportsInlineDistinct()) {
3621 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
3622 }
3623 else {
3624 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3625 }
3626
3627 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3628
3629 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3630
3631 if (!getDB().isSupportsInlineDistinct()) {
3632 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3633 }
3634
3635 if (orderByComparator != null) {
3636 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3637
3638 if (orderByConditionFields.length > 0) {
3639 query.append(WHERE_AND);
3640 }
3641
3642 for (int i = 0; i < orderByConditionFields.length; i++) {
3643 if (getDB().isSupportsInlineDistinct()) {
3644 query.append(_ORDER_BY_ENTITY_ALIAS);
3645 }
3646 else {
3647 query.append(_ORDER_BY_ENTITY_TABLE);
3648 }
3649
3650 query.append(orderByConditionFields[i]);
3651
3652 if ((i + 1) < orderByConditionFields.length) {
3653 if (orderByComparator.isAscending() ^ previous) {
3654 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3655 }
3656 else {
3657 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3658 }
3659 }
3660 else {
3661 if (orderByComparator.isAscending() ^ previous) {
3662 query.append(WHERE_GREATER_THAN);
3663 }
3664 else {
3665 query.append(WHERE_LESSER_THAN);
3666 }
3667 }
3668 }
3669
3670 query.append(ORDER_BY_CLAUSE);
3671
3672 String[] orderByFields = orderByComparator.getOrderByFields();
3673
3674 for (int i = 0; i < orderByFields.length; i++) {
3675 if (getDB().isSupportsInlineDistinct()) {
3676 query.append(_ORDER_BY_ENTITY_ALIAS);
3677 }
3678 else {
3679 query.append(_ORDER_BY_ENTITY_TABLE);
3680 }
3681
3682 query.append(orderByFields[i]);
3683
3684 if ((i + 1) < orderByFields.length) {
3685 if (orderByComparator.isAscending() ^ previous) {
3686 query.append(ORDER_BY_ASC_HAS_NEXT);
3687 }
3688 else {
3689 query.append(ORDER_BY_DESC_HAS_NEXT);
3690 }
3691 }
3692 else {
3693 if (orderByComparator.isAscending() ^ previous) {
3694 query.append(ORDER_BY_ASC);
3695 }
3696 else {
3697 query.append(ORDER_BY_DESC);
3698 }
3699 }
3700 }
3701 }
3702 else {
3703 if (getDB().isSupportsInlineDistinct()) {
3704 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
3705 }
3706 else {
3707 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
3708 }
3709 }
3710
3711 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3712 AnnouncementsEntry.class.getName(),
3713 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3714
3715 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3716
3717 q.setFirstResult(0);
3718 q.setMaxResults(2);
3719
3720 if (getDB().isSupportsInlineDistinct()) {
3721 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
3722 }
3723 else {
3724 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
3725 }
3726
3727 QueryPos qPos = QueryPos.getInstance(q);
3728
3729 qPos.add(classNameId);
3730
3731 qPos.add(classPK);
3732
3733 if (orderByComparator != null) {
3734 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
3735
3736 for (Object value : values) {
3737 qPos.add(value);
3738 }
3739 }
3740
3741 List<AnnouncementsEntry> list = q.list();
3742
3743 if (list.size() == 2) {
3744 return list.get(1);
3745 }
3746 else {
3747 return null;
3748 }
3749 }
3750
3751
3757 @Override
3758 public void removeByC_C(long classNameId, long classPK) {
3759 for (AnnouncementsEntry announcementsEntry : findByC_C(classNameId,
3760 classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3761 remove(announcementsEntry);
3762 }
3763 }
3764
3765
3772 @Override
3773 public int countByC_C(long classNameId, long classPK) {
3774 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
3775
3776 Object[] finderArgs = new Object[] { classNameId, classPK };
3777
3778 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3779
3780 if (count == null) {
3781 StringBundler query = new StringBundler(3);
3782
3783 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3784
3785 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3786
3787 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3788
3789 String sql = query.toString();
3790
3791 Session session = null;
3792
3793 try {
3794 session = openSession();
3795
3796 Query q = session.createQuery(sql);
3797
3798 QueryPos qPos = QueryPos.getInstance(q);
3799
3800 qPos.add(classNameId);
3801
3802 qPos.add(classPK);
3803
3804 count = (Long)q.uniqueResult();
3805
3806 finderCache.putResult(finderPath, finderArgs, count);
3807 }
3808 catch (Exception e) {
3809 finderCache.removeResult(finderPath, finderArgs);
3810
3811 throw processException(e);
3812 }
3813 finally {
3814 closeSession(session);
3815 }
3816 }
3817
3818 return count.intValue();
3819 }
3820
3821
3828 @Override
3829 public int filterCountByC_C(long classNameId, long classPK) {
3830 if (!InlineSQLHelperUtil.isEnabled()) {
3831 return countByC_C(classNameId, classPK);
3832 }
3833
3834 StringBundler query = new StringBundler(3);
3835
3836 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
3837
3838 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3839
3840 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3841
3842 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3843 AnnouncementsEntry.class.getName(),
3844 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3845
3846 Session session = null;
3847
3848 try {
3849 session = openSession();
3850
3851 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3852
3853 q.addScalar(COUNT_COLUMN_NAME,
3854 com.liferay.portal.kernel.dao.orm.Type.LONG);
3855
3856 QueryPos qPos = QueryPos.getInstance(q);
3857
3858 qPos.add(classNameId);
3859
3860 qPos.add(classPK);
3861
3862 Long count = (Long)q.uniqueResult();
3863
3864 return count.intValue();
3865 }
3866 catch (Exception e) {
3867 throw processException(e);
3868 }
3869 finally {
3870 closeSession(session);
3871 }
3872 }
3873
3874 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
3875 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "announcementsEntry.classPK = ?";
3876 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
3877 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
3878 AnnouncementsEntryImpl.class,
3879 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_A",
3880 new String[] {
3881 Long.class.getName(), Long.class.getName(),
3882 Boolean.class.getName(),
3883
3884 Integer.class.getName(), Integer.class.getName(),
3885 OrderByComparator.class.getName()
3886 });
3887 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
3888 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED,
3889 AnnouncementsEntryImpl.class,
3890 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_A",
3891 new String[] {
3892 Long.class.getName(), Long.class.getName(),
3893 Boolean.class.getName()
3894 },
3895 AnnouncementsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
3896 AnnouncementsEntryModelImpl.CLASSPK_COLUMN_BITMASK |
3897 AnnouncementsEntryModelImpl.ALERT_COLUMN_BITMASK |
3898 AnnouncementsEntryModelImpl.PRIORITY_COLUMN_BITMASK |
3899 AnnouncementsEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
3900 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_A = new FinderPath(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
3901 AnnouncementsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3902 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_A",
3903 new String[] {
3904 Long.class.getName(), Long.class.getName(),
3905 Boolean.class.getName()
3906 });
3907
3908
3916 @Override
3917 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3918 boolean alert) {
3919 return findByC_C_A(classNameId, classPK, alert, QueryUtil.ALL_POS,
3920 QueryUtil.ALL_POS, null);
3921 }
3922
3923
3937 @Override
3938 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3939 boolean alert, int start, int end) {
3940 return findByC_C_A(classNameId, classPK, alert, start, end, null);
3941 }
3942
3943
3958 @Override
3959 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3960 boolean alert, int start, int end,
3961 OrderByComparator<AnnouncementsEntry> orderByComparator) {
3962 return findByC_C_A(classNameId, classPK, alert, start, end,
3963 orderByComparator, true);
3964 }
3965
3966
3982 @Override
3983 public List<AnnouncementsEntry> findByC_C_A(long classNameId, long classPK,
3984 boolean alert, int start, int end,
3985 OrderByComparator<AnnouncementsEntry> orderByComparator,
3986 boolean retrieveFromCache) {
3987 boolean pagination = true;
3988 FinderPath finderPath = null;
3989 Object[] finderArgs = null;
3990
3991 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3992 (orderByComparator == null)) {
3993 pagination = false;
3994 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A;
3995 finderArgs = new Object[] { classNameId, classPK, alert };
3996 }
3997 else {
3998 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_A;
3999 finderArgs = new Object[] {
4000 classNameId, classPK, alert,
4001
4002 start, end, orderByComparator
4003 };
4004 }
4005
4006 List<AnnouncementsEntry> list = null;
4007
4008 if (retrieveFromCache) {
4009 list = (List<AnnouncementsEntry>)finderCache.getResult(finderPath,
4010 finderArgs, this);
4011
4012 if ((list != null) && !list.isEmpty()) {
4013 for (AnnouncementsEntry announcementsEntry : list) {
4014 if ((classNameId != announcementsEntry.getClassNameId()) ||
4015 (classPK != announcementsEntry.getClassPK()) ||
4016 (alert != announcementsEntry.getAlert())) {
4017 list = null;
4018
4019 break;
4020 }
4021 }
4022 }
4023 }
4024
4025 if (list == null) {
4026 StringBundler query = null;
4027
4028 if (orderByComparator != null) {
4029 query = new StringBundler(5 +
4030 (orderByComparator.getOrderByFields().length * 2));
4031 }
4032 else {
4033 query = new StringBundler(5);
4034 }
4035
4036 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4037
4038 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4039
4040 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4041
4042 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4043
4044 if (orderByComparator != null) {
4045 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4046 orderByComparator);
4047 }
4048 else
4049 if (pagination) {
4050 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4051 }
4052
4053 String sql = query.toString();
4054
4055 Session session = null;
4056
4057 try {
4058 session = openSession();
4059
4060 Query q = session.createQuery(sql);
4061
4062 QueryPos qPos = QueryPos.getInstance(q);
4063
4064 qPos.add(classNameId);
4065
4066 qPos.add(classPK);
4067
4068 qPos.add(alert);
4069
4070 if (!pagination) {
4071 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
4072 getDialect(), start, end, false);
4073
4074 Collections.sort(list);
4075
4076 list = Collections.unmodifiableList(list);
4077 }
4078 else {
4079 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
4080 getDialect(), start, end);
4081 }
4082
4083 cacheResult(list);
4084
4085 finderCache.putResult(finderPath, finderArgs, list);
4086 }
4087 catch (Exception e) {
4088 finderCache.removeResult(finderPath, finderArgs);
4089
4090 throw processException(e);
4091 }
4092 finally {
4093 closeSession(session);
4094 }
4095 }
4096
4097 return list;
4098 }
4099
4100
4110 @Override
4111 public AnnouncementsEntry findByC_C_A_First(long classNameId, long classPK,
4112 boolean alert, OrderByComparator<AnnouncementsEntry> orderByComparator)
4113 throws NoSuchEntryException {
4114 AnnouncementsEntry announcementsEntry = fetchByC_C_A_First(classNameId,
4115 classPK, alert, orderByComparator);
4116
4117 if (announcementsEntry != null) {
4118 return announcementsEntry;
4119 }
4120
4121 StringBundler msg = new StringBundler(8);
4122
4123 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4124
4125 msg.append("classNameId=");
4126 msg.append(classNameId);
4127
4128 msg.append(", classPK=");
4129 msg.append(classPK);
4130
4131 msg.append(", alert=");
4132 msg.append(alert);
4133
4134 msg.append(StringPool.CLOSE_CURLY_BRACE);
4135
4136 throw new NoSuchEntryException(msg.toString());
4137 }
4138
4139
4148 @Override
4149 public AnnouncementsEntry fetchByC_C_A_First(long classNameId,
4150 long classPK, boolean alert,
4151 OrderByComparator<AnnouncementsEntry> orderByComparator) {
4152 List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
4153 alert, 0, 1, orderByComparator);
4154
4155 if (!list.isEmpty()) {
4156 return list.get(0);
4157 }
4158
4159 return null;
4160 }
4161
4162
4172 @Override
4173 public AnnouncementsEntry findByC_C_A_Last(long classNameId, long classPK,
4174 boolean alert, OrderByComparator<AnnouncementsEntry> orderByComparator)
4175 throws NoSuchEntryException {
4176 AnnouncementsEntry announcementsEntry = fetchByC_C_A_Last(classNameId,
4177 classPK, alert, orderByComparator);
4178
4179 if (announcementsEntry != null) {
4180 return announcementsEntry;
4181 }
4182
4183 StringBundler msg = new StringBundler(8);
4184
4185 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4186
4187 msg.append("classNameId=");
4188 msg.append(classNameId);
4189
4190 msg.append(", classPK=");
4191 msg.append(classPK);
4192
4193 msg.append(", alert=");
4194 msg.append(alert);
4195
4196 msg.append(StringPool.CLOSE_CURLY_BRACE);
4197
4198 throw new NoSuchEntryException(msg.toString());
4199 }
4200
4201
4210 @Override
4211 public AnnouncementsEntry fetchByC_C_A_Last(long classNameId, long classPK,
4212 boolean alert, OrderByComparator<AnnouncementsEntry> orderByComparator) {
4213 int count = countByC_C_A(classNameId, classPK, alert);
4214
4215 if (count == 0) {
4216 return null;
4217 }
4218
4219 List<AnnouncementsEntry> list = findByC_C_A(classNameId, classPK,
4220 alert, count - 1, count, orderByComparator);
4221
4222 if (!list.isEmpty()) {
4223 return list.get(0);
4224 }
4225
4226 return null;
4227 }
4228
4229
4240 @Override
4241 public AnnouncementsEntry[] findByC_C_A_PrevAndNext(long entryId,
4242 long classNameId, long classPK, boolean alert,
4243 OrderByComparator<AnnouncementsEntry> orderByComparator)
4244 throws NoSuchEntryException {
4245 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
4246
4247 Session session = null;
4248
4249 try {
4250 session = openSession();
4251
4252 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
4253
4254 array[0] = getByC_C_A_PrevAndNext(session, announcementsEntry,
4255 classNameId, classPK, alert, orderByComparator, true);
4256
4257 array[1] = announcementsEntry;
4258
4259 array[2] = getByC_C_A_PrevAndNext(session, announcementsEntry,
4260 classNameId, classPK, alert, orderByComparator, false);
4261
4262 return array;
4263 }
4264 catch (Exception e) {
4265 throw processException(e);
4266 }
4267 finally {
4268 closeSession(session);
4269 }
4270 }
4271
4272 protected AnnouncementsEntry getByC_C_A_PrevAndNext(Session session,
4273 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
4274 boolean alert, OrderByComparator<AnnouncementsEntry> orderByComparator,
4275 boolean previous) {
4276 StringBundler query = null;
4277
4278 if (orderByComparator != null) {
4279 query = new StringBundler(6 +
4280 (orderByComparator.getOrderByConditionFields().length * 3) +
4281 (orderByComparator.getOrderByFields().length * 3));
4282 }
4283 else {
4284 query = new StringBundler(5);
4285 }
4286
4287 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4288
4289 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4290
4291 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4292
4293 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4294
4295 if (orderByComparator != null) {
4296 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4297
4298 if (orderByConditionFields.length > 0) {
4299 query.append(WHERE_AND);
4300 }
4301
4302 for (int i = 0; i < orderByConditionFields.length; i++) {
4303 query.append(_ORDER_BY_ENTITY_ALIAS);
4304 query.append(orderByConditionFields[i]);
4305
4306 if ((i + 1) < orderByConditionFields.length) {
4307 if (orderByComparator.isAscending() ^ previous) {
4308 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4309 }
4310 else {
4311 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4312 }
4313 }
4314 else {
4315 if (orderByComparator.isAscending() ^ previous) {
4316 query.append(WHERE_GREATER_THAN);
4317 }
4318 else {
4319 query.append(WHERE_LESSER_THAN);
4320 }
4321 }
4322 }
4323
4324 query.append(ORDER_BY_CLAUSE);
4325
4326 String[] orderByFields = orderByComparator.getOrderByFields();
4327
4328 for (int i = 0; i < orderByFields.length; i++) {
4329 query.append(_ORDER_BY_ENTITY_ALIAS);
4330 query.append(orderByFields[i]);
4331
4332 if ((i + 1) < orderByFields.length) {
4333 if (orderByComparator.isAscending() ^ previous) {
4334 query.append(ORDER_BY_ASC_HAS_NEXT);
4335 }
4336 else {
4337 query.append(ORDER_BY_DESC_HAS_NEXT);
4338 }
4339 }
4340 else {
4341 if (orderByComparator.isAscending() ^ previous) {
4342 query.append(ORDER_BY_ASC);
4343 }
4344 else {
4345 query.append(ORDER_BY_DESC);
4346 }
4347 }
4348 }
4349 }
4350 else {
4351 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4352 }
4353
4354 String sql = query.toString();
4355
4356 Query q = session.createQuery(sql);
4357
4358 q.setFirstResult(0);
4359 q.setMaxResults(2);
4360
4361 QueryPos qPos = QueryPos.getInstance(q);
4362
4363 qPos.add(classNameId);
4364
4365 qPos.add(classPK);
4366
4367 qPos.add(alert);
4368
4369 if (orderByComparator != null) {
4370 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
4371
4372 for (Object value : values) {
4373 qPos.add(value);
4374 }
4375 }
4376
4377 List<AnnouncementsEntry> list = q.list();
4378
4379 if (list.size() == 2) {
4380 return list.get(1);
4381 }
4382 else {
4383 return null;
4384 }
4385 }
4386
4387
4395 @Override
4396 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4397 long classPK, boolean alert) {
4398 return filterFindByC_C_A(classNameId, classPK, alert,
4399 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4400 }
4401
4402
4416 @Override
4417 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4418 long classPK, boolean alert, int start, int end) {
4419 return filterFindByC_C_A(classNameId, classPK, alert, start, end, null);
4420 }
4421
4422
4437 @Override
4438 public List<AnnouncementsEntry> filterFindByC_C_A(long classNameId,
4439 long classPK, boolean alert, int start, int end,
4440 OrderByComparator<AnnouncementsEntry> orderByComparator) {
4441 if (!InlineSQLHelperUtil.isEnabled()) {
4442 return findByC_C_A(classNameId, classPK, alert, start, end,
4443 orderByComparator);
4444 }
4445
4446 StringBundler query = null;
4447
4448 if (orderByComparator != null) {
4449 query = new StringBundler(5 +
4450 (orderByComparator.getOrderByFields().length * 2));
4451 }
4452 else {
4453 query = new StringBundler(6);
4454 }
4455
4456 if (getDB().isSupportsInlineDistinct()) {
4457 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4458 }
4459 else {
4460 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4461 }
4462
4463 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4464
4465 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4466
4467 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4468
4469 if (!getDB().isSupportsInlineDistinct()) {
4470 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4471 }
4472
4473 if (orderByComparator != null) {
4474 if (getDB().isSupportsInlineDistinct()) {
4475 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4476 orderByComparator, true);
4477 }
4478 else {
4479 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4480 orderByComparator, true);
4481 }
4482 }
4483 else {
4484 if (getDB().isSupportsInlineDistinct()) {
4485 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4486 }
4487 else {
4488 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
4489 }
4490 }
4491
4492 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4493 AnnouncementsEntry.class.getName(),
4494 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4495
4496 Session session = null;
4497
4498 try {
4499 session = openSession();
4500
4501 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4502
4503 if (getDB().isSupportsInlineDistinct()) {
4504 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
4505 }
4506 else {
4507 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
4508 }
4509
4510 QueryPos qPos = QueryPos.getInstance(q);
4511
4512 qPos.add(classNameId);
4513
4514 qPos.add(classPK);
4515
4516 qPos.add(alert);
4517
4518 return (List<AnnouncementsEntry>)QueryUtil.list(q, getDialect(),
4519 start, end);
4520 }
4521 catch (Exception e) {
4522 throw processException(e);
4523 }
4524 finally {
4525 closeSession(session);
4526 }
4527 }
4528
4529
4540 @Override
4541 public AnnouncementsEntry[] filterFindByC_C_A_PrevAndNext(long entryId,
4542 long classNameId, long classPK, boolean alert,
4543 OrderByComparator<AnnouncementsEntry> orderByComparator)
4544 throws NoSuchEntryException {
4545 if (!InlineSQLHelperUtil.isEnabled()) {
4546 return findByC_C_A_PrevAndNext(entryId, classNameId, classPK,
4547 alert, orderByComparator);
4548 }
4549
4550 AnnouncementsEntry announcementsEntry = findByPrimaryKey(entryId);
4551
4552 Session session = null;
4553
4554 try {
4555 session = openSession();
4556
4557 AnnouncementsEntry[] array = new AnnouncementsEntryImpl[3];
4558
4559 array[0] = filterGetByC_C_A_PrevAndNext(session,
4560 announcementsEntry, classNameId, classPK, alert,
4561 orderByComparator, true);
4562
4563 array[1] = announcementsEntry;
4564
4565 array[2] = filterGetByC_C_A_PrevAndNext(session,
4566 announcementsEntry, classNameId, classPK, alert,
4567 orderByComparator, false);
4568
4569 return array;
4570 }
4571 catch (Exception e) {
4572 throw processException(e);
4573 }
4574 finally {
4575 closeSession(session);
4576 }
4577 }
4578
4579 protected AnnouncementsEntry filterGetByC_C_A_PrevAndNext(Session session,
4580 AnnouncementsEntry announcementsEntry, long classNameId, long classPK,
4581 boolean alert, OrderByComparator<AnnouncementsEntry> orderByComparator,
4582 boolean previous) {
4583 StringBundler query = null;
4584
4585 if (orderByComparator != null) {
4586 query = new StringBundler(7 +
4587 (orderByComparator.getOrderByConditionFields().length * 3) +
4588 (orderByComparator.getOrderByFields().length * 3));
4589 }
4590 else {
4591 query = new StringBundler(6);
4592 }
4593
4594 if (getDB().isSupportsInlineDistinct()) {
4595 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE);
4596 }
4597 else {
4598 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4599 }
4600
4601 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4602
4603 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4604
4605 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4606
4607 if (!getDB().isSupportsInlineDistinct()) {
4608 query.append(_FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4609 }
4610
4611 if (orderByComparator != null) {
4612 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4613
4614 if (orderByConditionFields.length > 0) {
4615 query.append(WHERE_AND);
4616 }
4617
4618 for (int i = 0; i < orderByConditionFields.length; i++) {
4619 if (getDB().isSupportsInlineDistinct()) {
4620 query.append(_ORDER_BY_ENTITY_ALIAS);
4621 }
4622 else {
4623 query.append(_ORDER_BY_ENTITY_TABLE);
4624 }
4625
4626 query.append(orderByConditionFields[i]);
4627
4628 if ((i + 1) < orderByConditionFields.length) {
4629 if (orderByComparator.isAscending() ^ previous) {
4630 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4631 }
4632 else {
4633 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4634 }
4635 }
4636 else {
4637 if (orderByComparator.isAscending() ^ previous) {
4638 query.append(WHERE_GREATER_THAN);
4639 }
4640 else {
4641 query.append(WHERE_LESSER_THAN);
4642 }
4643 }
4644 }
4645
4646 query.append(ORDER_BY_CLAUSE);
4647
4648 String[] orderByFields = orderByComparator.getOrderByFields();
4649
4650 for (int i = 0; i < orderByFields.length; i++) {
4651 if (getDB().isSupportsInlineDistinct()) {
4652 query.append(_ORDER_BY_ENTITY_ALIAS);
4653 }
4654 else {
4655 query.append(_ORDER_BY_ENTITY_TABLE);
4656 }
4657
4658 query.append(orderByFields[i]);
4659
4660 if ((i + 1) < orderByFields.length) {
4661 if (orderByComparator.isAscending() ^ previous) {
4662 query.append(ORDER_BY_ASC_HAS_NEXT);
4663 }
4664 else {
4665 query.append(ORDER_BY_DESC_HAS_NEXT);
4666 }
4667 }
4668 else {
4669 if (orderByComparator.isAscending() ^ previous) {
4670 query.append(ORDER_BY_ASC);
4671 }
4672 else {
4673 query.append(ORDER_BY_DESC);
4674 }
4675 }
4676 }
4677 }
4678 else {
4679 if (getDB().isSupportsInlineDistinct()) {
4680 query.append(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
4681 }
4682 else {
4683 query.append(AnnouncementsEntryModelImpl.ORDER_BY_SQL);
4684 }
4685 }
4686
4687 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4688 AnnouncementsEntry.class.getName(),
4689 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4690
4691 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4692
4693 q.setFirstResult(0);
4694 q.setMaxResults(2);
4695
4696 if (getDB().isSupportsInlineDistinct()) {
4697 q.addEntity(_FILTER_ENTITY_ALIAS, AnnouncementsEntryImpl.class);
4698 }
4699 else {
4700 q.addEntity(_FILTER_ENTITY_TABLE, AnnouncementsEntryImpl.class);
4701 }
4702
4703 QueryPos qPos = QueryPos.getInstance(q);
4704
4705 qPos.add(classNameId);
4706
4707 qPos.add(classPK);
4708
4709 qPos.add(alert);
4710
4711 if (orderByComparator != null) {
4712 Object[] values = orderByComparator.getOrderByConditionValues(announcementsEntry);
4713
4714 for (Object value : values) {
4715 qPos.add(value);
4716 }
4717 }
4718
4719 List<AnnouncementsEntry> list = q.list();
4720
4721 if (list.size() == 2) {
4722 return list.get(1);
4723 }
4724 else {
4725 return null;
4726 }
4727 }
4728
4729
4736 @Override
4737 public void removeByC_C_A(long classNameId, long classPK, boolean alert) {
4738 for (AnnouncementsEntry announcementsEntry : findByC_C_A(classNameId,
4739 classPK, alert, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4740 remove(announcementsEntry);
4741 }
4742 }
4743
4744
4752 @Override
4753 public int countByC_C_A(long classNameId, long classPK, boolean alert) {
4754 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_A;
4755
4756 Object[] finderArgs = new Object[] { classNameId, classPK, alert };
4757
4758 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4759
4760 if (count == null) {
4761 StringBundler query = new StringBundler(4);
4762
4763 query.append(_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4764
4765 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4766
4767 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4768
4769 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4770
4771 String sql = query.toString();
4772
4773 Session session = null;
4774
4775 try {
4776 session = openSession();
4777
4778 Query q = session.createQuery(sql);
4779
4780 QueryPos qPos = QueryPos.getInstance(q);
4781
4782 qPos.add(classNameId);
4783
4784 qPos.add(classPK);
4785
4786 qPos.add(alert);
4787
4788 count = (Long)q.uniqueResult();
4789
4790 finderCache.putResult(finderPath, finderArgs, count);
4791 }
4792 catch (Exception e) {
4793 finderCache.removeResult(finderPath, finderArgs);
4794
4795 throw processException(e);
4796 }
4797 finally {
4798 closeSession(session);
4799 }
4800 }
4801
4802 return count.intValue();
4803 }
4804
4805
4813 @Override
4814 public int filterCountByC_C_A(long classNameId, long classPK, boolean alert) {
4815 if (!InlineSQLHelperUtil.isEnabled()) {
4816 return countByC_C_A(classNameId, classPK, alert);
4817 }
4818
4819 StringBundler query = new StringBundler(4);
4820
4821 query.append(_FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE);
4822
4823 query.append(_FINDER_COLUMN_C_C_A_CLASSNAMEID_2);
4824
4825 query.append(_FINDER_COLUMN_C_C_A_CLASSPK_2);
4826
4827 query.append(_FINDER_COLUMN_C_C_A_ALERT_2);
4828
4829 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4830 AnnouncementsEntry.class.getName(),
4831 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4832
4833 Session session = null;
4834
4835 try {
4836 session = openSession();
4837
4838 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4839
4840 q.addScalar(COUNT_COLUMN_NAME,
4841 com.liferay.portal.kernel.dao.orm.Type.LONG);
4842
4843 QueryPos qPos = QueryPos.getInstance(q);
4844
4845 qPos.add(classNameId);
4846
4847 qPos.add(classPK);
4848
4849 qPos.add(alert);
4850
4851 Long count = (Long)q.uniqueResult();
4852
4853 return count.intValue();
4854 }
4855 catch (Exception e) {
4856 throw processException(e);
4857 }
4858 finally {
4859 closeSession(session);
4860 }
4861 }
4862
4863 private static final String _FINDER_COLUMN_C_C_A_CLASSNAMEID_2 = "announcementsEntry.classNameId = ? AND ";
4864 private static final String _FINDER_COLUMN_C_C_A_CLASSPK_2 = "announcementsEntry.classPK = ? AND ";
4865 private static final String _FINDER_COLUMN_C_C_A_ALERT_2 = "announcementsEntry.alert = ?";
4866
4867 public AnnouncementsEntryPersistenceImpl() {
4868 setModelClass(AnnouncementsEntry.class);
4869 }
4870
4871
4876 @Override
4877 public void cacheResult(AnnouncementsEntry announcementsEntry) {
4878 entityCache.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4879 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
4880 announcementsEntry);
4881
4882 announcementsEntry.resetOriginalValues();
4883 }
4884
4885
4890 @Override
4891 public void cacheResult(List<AnnouncementsEntry> announcementsEntries) {
4892 for (AnnouncementsEntry announcementsEntry : announcementsEntries) {
4893 if (entityCache.getResult(
4894 AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4895 AnnouncementsEntryImpl.class,
4896 announcementsEntry.getPrimaryKey()) == null) {
4897 cacheResult(announcementsEntry);
4898 }
4899 else {
4900 announcementsEntry.resetOriginalValues();
4901 }
4902 }
4903 }
4904
4905
4912 @Override
4913 public void clearCache() {
4914 entityCache.clearCache(AnnouncementsEntryImpl.class);
4915
4916 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
4917 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4918 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4919 }
4920
4921
4928 @Override
4929 public void clearCache(AnnouncementsEntry announcementsEntry) {
4930 entityCache.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4931 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
4932
4933 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4934 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4935 }
4936
4937 @Override
4938 public void clearCache(List<AnnouncementsEntry> announcementsEntries) {
4939 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4940 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4941
4942 for (AnnouncementsEntry announcementsEntry : announcementsEntries) {
4943 entityCache.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
4944 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey());
4945 }
4946 }
4947
4948
4954 @Override
4955 public AnnouncementsEntry create(long entryId) {
4956 AnnouncementsEntry announcementsEntry = new AnnouncementsEntryImpl();
4957
4958 announcementsEntry.setNew(true);
4959 announcementsEntry.setPrimaryKey(entryId);
4960
4961 String uuid = PortalUUIDUtil.generate();
4962
4963 announcementsEntry.setUuid(uuid);
4964
4965 announcementsEntry.setCompanyId(companyProvider.getCompanyId());
4966
4967 return announcementsEntry;
4968 }
4969
4970
4977 @Override
4978 public AnnouncementsEntry remove(long entryId) throws NoSuchEntryException {
4979 return remove((Serializable)entryId);
4980 }
4981
4982
4989 @Override
4990 public AnnouncementsEntry remove(Serializable primaryKey)
4991 throws NoSuchEntryException {
4992 Session session = null;
4993
4994 try {
4995 session = openSession();
4996
4997 AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
4998 primaryKey);
4999
5000 if (announcementsEntry == null) {
5001 if (_log.isWarnEnabled()) {
5002 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5003 }
5004
5005 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5006 primaryKey);
5007 }
5008
5009 return remove(announcementsEntry);
5010 }
5011 catch (NoSuchEntryException nsee) {
5012 throw nsee;
5013 }
5014 catch (Exception e) {
5015 throw processException(e);
5016 }
5017 finally {
5018 closeSession(session);
5019 }
5020 }
5021
5022 @Override
5023 protected AnnouncementsEntry removeImpl(
5024 AnnouncementsEntry announcementsEntry) {
5025 announcementsEntry = toUnwrappedModel(announcementsEntry);
5026
5027 Session session = null;
5028
5029 try {
5030 session = openSession();
5031
5032 if (!session.contains(announcementsEntry)) {
5033 announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
5034 announcementsEntry.getPrimaryKeyObj());
5035 }
5036
5037 if (announcementsEntry != null) {
5038 session.delete(announcementsEntry);
5039 }
5040 }
5041 catch (Exception e) {
5042 throw processException(e);
5043 }
5044 finally {
5045 closeSession(session);
5046 }
5047
5048 if (announcementsEntry != null) {
5049 clearCache(announcementsEntry);
5050 }
5051
5052 return announcementsEntry;
5053 }
5054
5055 @Override
5056 public AnnouncementsEntry updateImpl(AnnouncementsEntry announcementsEntry) {
5057 announcementsEntry = toUnwrappedModel(announcementsEntry);
5058
5059 boolean isNew = announcementsEntry.isNew();
5060
5061 AnnouncementsEntryModelImpl announcementsEntryModelImpl = (AnnouncementsEntryModelImpl)announcementsEntry;
5062
5063 if (Validator.isNull(announcementsEntry.getUuid())) {
5064 String uuid = PortalUUIDUtil.generate();
5065
5066 announcementsEntry.setUuid(uuid);
5067 }
5068
5069 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
5070
5071 Date now = new Date();
5072
5073 if (isNew && (announcementsEntry.getCreateDate() == null)) {
5074 if (serviceContext == null) {
5075 announcementsEntry.setCreateDate(now);
5076 }
5077 else {
5078 announcementsEntry.setCreateDate(serviceContext.getCreateDate(
5079 now));
5080 }
5081 }
5082
5083 if (!announcementsEntryModelImpl.hasSetModifiedDate()) {
5084 if (serviceContext == null) {
5085 announcementsEntry.setModifiedDate(now);
5086 }
5087 else {
5088 announcementsEntry.setModifiedDate(serviceContext.getModifiedDate(
5089 now));
5090 }
5091 }
5092
5093 long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
5094
5095 if (userId > 0) {
5096 long companyId = announcementsEntry.getCompanyId();
5097
5098 long groupId = 0;
5099
5100 long entryId = 0;
5101
5102 if (!isNew) {
5103 entryId = announcementsEntry.getPrimaryKey();
5104 }
5105
5106 try {
5107 announcementsEntry.setContent(SanitizerUtil.sanitize(
5108 companyId, groupId, userId,
5109 com.liferay.announcements.kernel.model.AnnouncementsEntry.class.getName(),
5110 entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
5111 announcementsEntry.getContent(), null));
5112 }
5113 catch (SanitizerException se) {
5114 throw new SystemException(se);
5115 }
5116 }
5117
5118 Session session = null;
5119
5120 try {
5121 session = openSession();
5122
5123 if (announcementsEntry.isNew()) {
5124 session.save(announcementsEntry);
5125
5126 announcementsEntry.setNew(false);
5127 }
5128 else {
5129 announcementsEntry = (AnnouncementsEntry)session.merge(announcementsEntry);
5130 }
5131 }
5132 catch (Exception e) {
5133 throw processException(e);
5134 }
5135 finally {
5136 closeSession(session);
5137 }
5138
5139 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5140
5141 if (isNew || !AnnouncementsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
5142 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5143 }
5144
5145 else {
5146 if ((announcementsEntryModelImpl.getColumnBitmask() &
5147 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
5148 Object[] args = new Object[] {
5149 announcementsEntryModelImpl.getOriginalUuid()
5150 };
5151
5152 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
5153 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
5154 args);
5155
5156 args = new Object[] { announcementsEntryModelImpl.getUuid() };
5157
5158 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
5159 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
5160 args);
5161 }
5162
5163 if ((announcementsEntryModelImpl.getColumnBitmask() &
5164 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
5165 Object[] args = new Object[] {
5166 announcementsEntryModelImpl.getOriginalUuid(),
5167 announcementsEntryModelImpl.getOriginalCompanyId()
5168 };
5169
5170 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
5171 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
5172 args);
5173
5174 args = new Object[] {
5175 announcementsEntryModelImpl.getUuid(),
5176 announcementsEntryModelImpl.getCompanyId()
5177 };
5178
5179 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
5180 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
5181 args);
5182 }
5183
5184 if ((announcementsEntryModelImpl.getColumnBitmask() &
5185 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
5186 Object[] args = new Object[] {
5187 announcementsEntryModelImpl.getOriginalUserId()
5188 };
5189
5190 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
5191 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
5192 args);
5193
5194 args = new Object[] { announcementsEntryModelImpl.getUserId() };
5195
5196 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
5197 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
5198 args);
5199 }
5200
5201 if ((announcementsEntryModelImpl.getColumnBitmask() &
5202 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
5203 Object[] args = new Object[] {
5204 announcementsEntryModelImpl.getOriginalClassNameId(),
5205 announcementsEntryModelImpl.getOriginalClassPK()
5206 };
5207
5208 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
5209 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
5210 args);
5211
5212 args = new Object[] {
5213 announcementsEntryModelImpl.getClassNameId(),
5214 announcementsEntryModelImpl.getClassPK()
5215 };
5216
5217 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
5218 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
5219 args);
5220 }
5221
5222 if ((announcementsEntryModelImpl.getColumnBitmask() &
5223 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A.getColumnBitmask()) != 0) {
5224 Object[] args = new Object[] {
5225 announcementsEntryModelImpl.getOriginalClassNameId(),
5226 announcementsEntryModelImpl.getOriginalClassPK(),
5227 announcementsEntryModelImpl.getOriginalAlert()
5228 };
5229
5230 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_A, args);
5231 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A,
5232 args);
5233
5234 args = new Object[] {
5235 announcementsEntryModelImpl.getClassNameId(),
5236 announcementsEntryModelImpl.getClassPK(),
5237 announcementsEntryModelImpl.getAlert()
5238 };
5239
5240 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_A, args);
5241 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_A,
5242 args);
5243 }
5244 }
5245
5246 entityCache.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5247 AnnouncementsEntryImpl.class, announcementsEntry.getPrimaryKey(),
5248 announcementsEntry, false);
5249
5250 announcementsEntry.resetOriginalValues();
5251
5252 return announcementsEntry;
5253 }
5254
5255 protected AnnouncementsEntry toUnwrappedModel(
5256 AnnouncementsEntry announcementsEntry) {
5257 if (announcementsEntry instanceof AnnouncementsEntryImpl) {
5258 return announcementsEntry;
5259 }
5260
5261 AnnouncementsEntryImpl announcementsEntryImpl = new AnnouncementsEntryImpl();
5262
5263 announcementsEntryImpl.setNew(announcementsEntry.isNew());
5264 announcementsEntryImpl.setPrimaryKey(announcementsEntry.getPrimaryKey());
5265
5266 announcementsEntryImpl.setUuid(announcementsEntry.getUuid());
5267 announcementsEntryImpl.setEntryId(announcementsEntry.getEntryId());
5268 announcementsEntryImpl.setCompanyId(announcementsEntry.getCompanyId());
5269 announcementsEntryImpl.setUserId(announcementsEntry.getUserId());
5270 announcementsEntryImpl.setUserName(announcementsEntry.getUserName());
5271 announcementsEntryImpl.setCreateDate(announcementsEntry.getCreateDate());
5272 announcementsEntryImpl.setModifiedDate(announcementsEntry.getModifiedDate());
5273 announcementsEntryImpl.setClassNameId(announcementsEntry.getClassNameId());
5274 announcementsEntryImpl.setClassPK(announcementsEntry.getClassPK());
5275 announcementsEntryImpl.setTitle(announcementsEntry.getTitle());
5276 announcementsEntryImpl.setContent(announcementsEntry.getContent());
5277 announcementsEntryImpl.setUrl(announcementsEntry.getUrl());
5278 announcementsEntryImpl.setType(announcementsEntry.getType());
5279 announcementsEntryImpl.setDisplayDate(announcementsEntry.getDisplayDate());
5280 announcementsEntryImpl.setExpirationDate(announcementsEntry.getExpirationDate());
5281 announcementsEntryImpl.setPriority(announcementsEntry.getPriority());
5282 announcementsEntryImpl.setAlert(announcementsEntry.isAlert());
5283
5284 return announcementsEntryImpl;
5285 }
5286
5287
5294 @Override
5295 public AnnouncementsEntry findByPrimaryKey(Serializable primaryKey)
5296 throws NoSuchEntryException {
5297 AnnouncementsEntry announcementsEntry = fetchByPrimaryKey(primaryKey);
5298
5299 if (announcementsEntry == null) {
5300 if (_log.isWarnEnabled()) {
5301 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5302 }
5303
5304 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5305 primaryKey);
5306 }
5307
5308 return announcementsEntry;
5309 }
5310
5311
5318 @Override
5319 public AnnouncementsEntry findByPrimaryKey(long entryId)
5320 throws NoSuchEntryException {
5321 return findByPrimaryKey((Serializable)entryId);
5322 }
5323
5324
5330 @Override
5331 public AnnouncementsEntry fetchByPrimaryKey(Serializable primaryKey) {
5332 AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)entityCache.getResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5333 AnnouncementsEntryImpl.class, primaryKey);
5334
5335 if (announcementsEntry == _nullAnnouncementsEntry) {
5336 return null;
5337 }
5338
5339 if (announcementsEntry == null) {
5340 Session session = null;
5341
5342 try {
5343 session = openSession();
5344
5345 announcementsEntry = (AnnouncementsEntry)session.get(AnnouncementsEntryImpl.class,
5346 primaryKey);
5347
5348 if (announcementsEntry != null) {
5349 cacheResult(announcementsEntry);
5350 }
5351 else {
5352 entityCache.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5353 AnnouncementsEntryImpl.class, primaryKey,
5354 _nullAnnouncementsEntry);
5355 }
5356 }
5357 catch (Exception e) {
5358 entityCache.removeResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5359 AnnouncementsEntryImpl.class, primaryKey);
5360
5361 throw processException(e);
5362 }
5363 finally {
5364 closeSession(session);
5365 }
5366 }
5367
5368 return announcementsEntry;
5369 }
5370
5371
5377 @Override
5378 public AnnouncementsEntry fetchByPrimaryKey(long entryId) {
5379 return fetchByPrimaryKey((Serializable)entryId);
5380 }
5381
5382 @Override
5383 public Map<Serializable, AnnouncementsEntry> fetchByPrimaryKeys(
5384 Set<Serializable> primaryKeys) {
5385 if (primaryKeys.isEmpty()) {
5386 return Collections.emptyMap();
5387 }
5388
5389 Map<Serializable, AnnouncementsEntry> map = new HashMap<Serializable, AnnouncementsEntry>();
5390
5391 if (primaryKeys.size() == 1) {
5392 Iterator<Serializable> iterator = primaryKeys.iterator();
5393
5394 Serializable primaryKey = iterator.next();
5395
5396 AnnouncementsEntry announcementsEntry = fetchByPrimaryKey(primaryKey);
5397
5398 if (announcementsEntry != null) {
5399 map.put(primaryKey, announcementsEntry);
5400 }
5401
5402 return map;
5403 }
5404
5405 Set<Serializable> uncachedPrimaryKeys = null;
5406
5407 for (Serializable primaryKey : primaryKeys) {
5408 AnnouncementsEntry announcementsEntry = (AnnouncementsEntry)entityCache.getResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5409 AnnouncementsEntryImpl.class, primaryKey);
5410
5411 if (announcementsEntry == null) {
5412 if (uncachedPrimaryKeys == null) {
5413 uncachedPrimaryKeys = new HashSet<Serializable>();
5414 }
5415
5416 uncachedPrimaryKeys.add(primaryKey);
5417 }
5418 else {
5419 map.put(primaryKey, announcementsEntry);
5420 }
5421 }
5422
5423 if (uncachedPrimaryKeys == null) {
5424 return map;
5425 }
5426
5427 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
5428 1);
5429
5430 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE_PKS_IN);
5431
5432 for (Serializable primaryKey : uncachedPrimaryKeys) {
5433 query.append(String.valueOf(primaryKey));
5434
5435 query.append(StringPool.COMMA);
5436 }
5437
5438 query.setIndex(query.index() - 1);
5439
5440 query.append(StringPool.CLOSE_PARENTHESIS);
5441
5442 String sql = query.toString();
5443
5444 Session session = null;
5445
5446 try {
5447 session = openSession();
5448
5449 Query q = session.createQuery(sql);
5450
5451 for (AnnouncementsEntry announcementsEntry : (List<AnnouncementsEntry>)q.list()) {
5452 map.put(announcementsEntry.getPrimaryKeyObj(),
5453 announcementsEntry);
5454
5455 cacheResult(announcementsEntry);
5456
5457 uncachedPrimaryKeys.remove(announcementsEntry.getPrimaryKeyObj());
5458 }
5459
5460 for (Serializable primaryKey : uncachedPrimaryKeys) {
5461 entityCache.putResult(AnnouncementsEntryModelImpl.ENTITY_CACHE_ENABLED,
5462 AnnouncementsEntryImpl.class, primaryKey,
5463 _nullAnnouncementsEntry);
5464 }
5465 }
5466 catch (Exception e) {
5467 throw processException(e);
5468 }
5469 finally {
5470 closeSession(session);
5471 }
5472
5473 return map;
5474 }
5475
5476
5481 @Override
5482 public List<AnnouncementsEntry> findAll() {
5483 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5484 }
5485
5486
5497 @Override
5498 public List<AnnouncementsEntry> findAll(int start, int end) {
5499 return findAll(start, end, null);
5500 }
5501
5502
5514 @Override
5515 public List<AnnouncementsEntry> findAll(int start, int end,
5516 OrderByComparator<AnnouncementsEntry> orderByComparator) {
5517 return findAll(start, end, orderByComparator, true);
5518 }
5519
5520
5533 @Override
5534 public List<AnnouncementsEntry> findAll(int start, int end,
5535 OrderByComparator<AnnouncementsEntry> orderByComparator,
5536 boolean retrieveFromCache) {
5537 boolean pagination = true;
5538 FinderPath finderPath = null;
5539 Object[] finderArgs = null;
5540
5541 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5542 (orderByComparator == null)) {
5543 pagination = false;
5544 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5545 finderArgs = FINDER_ARGS_EMPTY;
5546 }
5547 else {
5548 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5549 finderArgs = new Object[] { start, end, orderByComparator };
5550 }
5551
5552 List<AnnouncementsEntry> list = null;
5553
5554 if (retrieveFromCache) {
5555 list = (List<AnnouncementsEntry>)finderCache.getResult(finderPath,
5556 finderArgs, this);
5557 }
5558
5559 if (list == null) {
5560 StringBundler query = null;
5561 String sql = null;
5562
5563 if (orderByComparator != null) {
5564 query = new StringBundler(2 +
5565 (orderByComparator.getOrderByFields().length * 2));
5566
5567 query.append(_SQL_SELECT_ANNOUNCEMENTSENTRY);
5568
5569 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5570 orderByComparator);
5571
5572 sql = query.toString();
5573 }
5574 else {
5575 sql = _SQL_SELECT_ANNOUNCEMENTSENTRY;
5576
5577 if (pagination) {
5578 sql = sql.concat(AnnouncementsEntryModelImpl.ORDER_BY_JPQL);
5579 }
5580 }
5581
5582 Session session = null;
5583
5584 try {
5585 session = openSession();
5586
5587 Query q = session.createQuery(sql);
5588
5589 if (!pagination) {
5590 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
5591 getDialect(), start, end, false);
5592
5593 Collections.sort(list);
5594
5595 list = Collections.unmodifiableList(list);
5596 }
5597 else {
5598 list = (List<AnnouncementsEntry>)QueryUtil.list(q,
5599 getDialect(), start, end);
5600 }
5601
5602 cacheResult(list);
5603
5604 finderCache.putResult(finderPath, finderArgs, list);
5605 }
5606 catch (Exception e) {
5607 finderCache.removeResult(finderPath, finderArgs);
5608
5609 throw processException(e);
5610 }
5611 finally {
5612 closeSession(session);
5613 }
5614 }
5615
5616 return list;
5617 }
5618
5619
5623 @Override
5624 public void removeAll() {
5625 for (AnnouncementsEntry announcementsEntry : findAll()) {
5626 remove(announcementsEntry);
5627 }
5628 }
5629
5630
5635 @Override
5636 public int countAll() {
5637 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
5638 FINDER_ARGS_EMPTY, this);
5639
5640 if (count == null) {
5641 Session session = null;
5642
5643 try {
5644 session = openSession();
5645
5646 Query q = session.createQuery(_SQL_COUNT_ANNOUNCEMENTSENTRY);
5647
5648 count = (Long)q.uniqueResult();
5649
5650 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
5651 count);
5652 }
5653 catch (Exception e) {
5654 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
5655 FINDER_ARGS_EMPTY);
5656
5657 throw processException(e);
5658 }
5659 finally {
5660 closeSession(session);
5661 }
5662 }
5663
5664 return count.intValue();
5665 }
5666
5667 @Override
5668 public Set<String> getBadColumnNames() {
5669 return _badColumnNames;
5670 }
5671
5672 @Override
5673 protected Map<String, Integer> getTableColumnsMap() {
5674 return AnnouncementsEntryModelImpl.TABLE_COLUMNS_MAP;
5675 }
5676
5677
5680 public void afterPropertiesSet() {
5681 }
5682
5683 public void destroy() {
5684 entityCache.removeCache(AnnouncementsEntryImpl.class.getName());
5685 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
5686 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5687 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5688 }
5689
5690 @BeanReference(type = CompanyProviderWrapper.class)
5691 protected CompanyProvider companyProvider;
5692 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
5693 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
5694 private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry";
5695 private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE_PKS_IN = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry WHERE entryId IN (";
5696 private static final String _SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT announcementsEntry FROM AnnouncementsEntry announcementsEntry WHERE ";
5697 private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry";
5698 private static final String _SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(announcementsEntry) FROM AnnouncementsEntry announcementsEntry WHERE ";
5699 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "announcementsEntry.entryId";
5700 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_WHERE = "SELECT DISTINCT {announcementsEntry.*} FROM AnnouncementsEntry announcementsEntry WHERE ";
5701 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
5702 "SELECT {AnnouncementsEntry.*} FROM (SELECT DISTINCT announcementsEntry.entryId FROM AnnouncementsEntry announcementsEntry WHERE ";
5703 private static final String _FILTER_SQL_SELECT_ANNOUNCEMENTSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
5704 ") TEMP_TABLE INNER JOIN AnnouncementsEntry ON TEMP_TABLE.entryId = AnnouncementsEntry.entryId";
5705 private static final String _FILTER_SQL_COUNT_ANNOUNCEMENTSENTRY_WHERE = "SELECT COUNT(DISTINCT announcementsEntry.entryId) AS COUNT_VALUE FROM AnnouncementsEntry announcementsEntry WHERE ";
5706 private static final String _FILTER_ENTITY_ALIAS = "announcementsEntry";
5707 private static final String _FILTER_ENTITY_TABLE = "AnnouncementsEntry";
5708 private static final String _ORDER_BY_ENTITY_ALIAS = "announcementsEntry.";
5709 private static final String _ORDER_BY_ENTITY_TABLE = "AnnouncementsEntry.";
5710 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AnnouncementsEntry exists with the primary key ";
5711 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AnnouncementsEntry exists with the key {";
5712 private static final Log _log = LogFactoryUtil.getLog(AnnouncementsEntryPersistenceImpl.class);
5713 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
5714 "uuid", "type"
5715 });
5716 private static final AnnouncementsEntry _nullAnnouncementsEntry = new AnnouncementsEntryImpl() {
5717 @Override
5718 public Object clone() {
5719 return this;
5720 }
5721
5722 @Override
5723 public CacheModel<AnnouncementsEntry> toCacheModel() {
5724 return _nullAnnouncementsEntryCacheModel;
5725 }
5726 };
5727
5728 private static final CacheModel<AnnouncementsEntry> _nullAnnouncementsEntryCacheModel =
5729 new CacheModel<AnnouncementsEntry>() {
5730 @Override
5731 public AnnouncementsEntry toEntityModel() {
5732 return _nullAnnouncementsEntry;
5733 }
5734 };
5735 }