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