001
014
015 package com.liferay.portlet.blogs.service.persistence;
016
017 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderPath;
021 import com.liferay.portal.kernel.dao.orm.Query;
022 import com.liferay.portal.kernel.dao.orm.QueryPos;
023 import com.liferay.portal.kernel.dao.orm.QueryUtil;
024 import com.liferay.portal.kernel.dao.orm.SQLQuery;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.sanitizer.Sanitizer;
030 import com.liferay.portal.kernel.sanitizer.SanitizerException;
031 import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
032 import com.liferay.portal.kernel.util.CalendarUtil;
033 import com.liferay.portal.kernel.util.ContentTypes;
034 import com.liferay.portal.kernel.util.GetterUtil;
035 import com.liferay.portal.kernel.util.InstanceFactory;
036 import com.liferay.portal.kernel.util.OrderByComparator;
037 import com.liferay.portal.kernel.util.SetUtil;
038 import com.liferay.portal.kernel.util.StringBundler;
039 import com.liferay.portal.kernel.util.StringPool;
040 import com.liferay.portal.kernel.util.StringUtil;
041 import com.liferay.portal.kernel.util.UnmodifiableList;
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.model.ModelListener;
046 import com.liferay.portal.security.auth.PrincipalThreadLocal;
047 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
048 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049
050 import com.liferay.portlet.blogs.NoSuchEntryException;
051 import com.liferay.portlet.blogs.model.BlogsEntry;
052 import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
053 import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
054
055 import java.io.Serializable;
056
057 import java.util.ArrayList;
058 import java.util.Collections;
059 import java.util.Date;
060 import java.util.List;
061 import java.util.Set;
062
063
075 public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
076 implements BlogsEntryPersistence {
077
082 public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
083 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List1";
085 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086 ".List2";
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
088 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
089 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
091 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
093 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
094 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
096 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
097 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
098 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
099 new String[] {
100 String.class.getName(),
101
102 Integer.class.getName(), Integer.class.getName(),
103 OrderByComparator.class.getName()
104 });
105 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
106 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
108 new String[] { String.class.getName() },
109 BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
110 BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
111 BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
112 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
113 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
115 new String[] { String.class.getName() });
116
117
124 public List<BlogsEntry> findByUuid(String uuid) throws SystemException {
125 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
126 }
127
128
141 public List<BlogsEntry> findByUuid(String uuid, int start, int end)
142 throws SystemException {
143 return findByUuid(uuid, start, end, null);
144 }
145
146
160 public List<BlogsEntry> findByUuid(String uuid, int start, int end,
161 OrderByComparator orderByComparator) throws SystemException {
162 boolean pagination = true;
163 FinderPath finderPath = null;
164 Object[] finderArgs = null;
165
166 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
167 (orderByComparator == null)) {
168 pagination = false;
169 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
170 finderArgs = new Object[] { uuid };
171 }
172 else {
173 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
174 finderArgs = new Object[] { uuid, start, end, orderByComparator };
175 }
176
177 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
178 finderArgs, this);
179
180 if ((list != null) && !list.isEmpty()) {
181 for (BlogsEntry blogsEntry : list) {
182 if (!Validator.equals(uuid, blogsEntry.getUuid())) {
183 list = null;
184
185 break;
186 }
187 }
188 }
189
190 if (list == null) {
191 StringBundler query = null;
192
193 if (orderByComparator != null) {
194 query = new StringBundler(3 +
195 (orderByComparator.getOrderByFields().length * 3));
196 }
197 else {
198 query = new StringBundler(3);
199 }
200
201 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
202
203 boolean bindUuid = false;
204
205 if (uuid == null) {
206 query.append(_FINDER_COLUMN_UUID_UUID_1);
207 }
208 else if (uuid.equals(StringPool.BLANK)) {
209 query.append(_FINDER_COLUMN_UUID_UUID_3);
210 }
211 else {
212 bindUuid = true;
213
214 query.append(_FINDER_COLUMN_UUID_UUID_2);
215 }
216
217 if (orderByComparator != null) {
218 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
219 orderByComparator);
220 }
221 else
222 if (pagination) {
223 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
224 }
225
226 String sql = query.toString();
227
228 Session session = null;
229
230 try {
231 session = openSession();
232
233 Query q = session.createQuery(sql);
234
235 QueryPos qPos = QueryPos.getInstance(q);
236
237 if (bindUuid) {
238 qPos.add(uuid);
239 }
240
241 if (!pagination) {
242 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
243 start, end, false);
244
245 Collections.sort(list);
246
247 list = new UnmodifiableList<BlogsEntry>(list);
248 }
249 else {
250 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
251 start, end);
252 }
253
254 cacheResult(list);
255
256 FinderCacheUtil.putResult(finderPath, finderArgs, list);
257 }
258 catch (Exception e) {
259 FinderCacheUtil.removeResult(finderPath, finderArgs);
260
261 throw processException(e);
262 }
263 finally {
264 closeSession(session);
265 }
266 }
267
268 return list;
269 }
270
271
280 public BlogsEntry findByUuid_First(String uuid,
281 OrderByComparator orderByComparator)
282 throws NoSuchEntryException, SystemException {
283 BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
284
285 if (blogsEntry != null) {
286 return blogsEntry;
287 }
288
289 StringBundler msg = new StringBundler(4);
290
291 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
292
293 msg.append("uuid=");
294 msg.append(uuid);
295
296 msg.append(StringPool.CLOSE_CURLY_BRACE);
297
298 throw new NoSuchEntryException(msg.toString());
299 }
300
301
309 public BlogsEntry fetchByUuid_First(String uuid,
310 OrderByComparator orderByComparator) throws SystemException {
311 List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
312
313 if (!list.isEmpty()) {
314 return list.get(0);
315 }
316
317 return null;
318 }
319
320
329 public BlogsEntry findByUuid_Last(String uuid,
330 OrderByComparator orderByComparator)
331 throws NoSuchEntryException, SystemException {
332 BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
333
334 if (blogsEntry != null) {
335 return blogsEntry;
336 }
337
338 StringBundler msg = new StringBundler(4);
339
340 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
341
342 msg.append("uuid=");
343 msg.append(uuid);
344
345 msg.append(StringPool.CLOSE_CURLY_BRACE);
346
347 throw new NoSuchEntryException(msg.toString());
348 }
349
350
358 public BlogsEntry fetchByUuid_Last(String uuid,
359 OrderByComparator orderByComparator) throws SystemException {
360 int count = countByUuid(uuid);
361
362 List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
363 orderByComparator);
364
365 if (!list.isEmpty()) {
366 return list.get(0);
367 }
368
369 return null;
370 }
371
372
382 public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
383 OrderByComparator orderByComparator)
384 throws NoSuchEntryException, SystemException {
385 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
386
387 Session session = null;
388
389 try {
390 session = openSession();
391
392 BlogsEntry[] array = new BlogsEntryImpl[3];
393
394 array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
395 orderByComparator, true);
396
397 array[1] = blogsEntry;
398
399 array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
400 orderByComparator, false);
401
402 return array;
403 }
404 catch (Exception e) {
405 throw processException(e);
406 }
407 finally {
408 closeSession(session);
409 }
410 }
411
412 protected BlogsEntry getByUuid_PrevAndNext(Session session,
413 BlogsEntry blogsEntry, String uuid,
414 OrderByComparator orderByComparator, boolean previous) {
415 StringBundler query = null;
416
417 if (orderByComparator != null) {
418 query = new StringBundler(6 +
419 (orderByComparator.getOrderByFields().length * 6));
420 }
421 else {
422 query = new StringBundler(3);
423 }
424
425 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
426
427 boolean bindUuid = false;
428
429 if (uuid == null) {
430 query.append(_FINDER_COLUMN_UUID_UUID_1);
431 }
432 else if (uuid.equals(StringPool.BLANK)) {
433 query.append(_FINDER_COLUMN_UUID_UUID_3);
434 }
435 else {
436 bindUuid = true;
437
438 query.append(_FINDER_COLUMN_UUID_UUID_2);
439 }
440
441 if (orderByComparator != null) {
442 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
443
444 if (orderByConditionFields.length > 0) {
445 query.append(WHERE_AND);
446 }
447
448 for (int i = 0; i < orderByConditionFields.length; i++) {
449 query.append(_ORDER_BY_ENTITY_ALIAS);
450 query.append(orderByConditionFields[i]);
451
452 if ((i + 1) < orderByConditionFields.length) {
453 if (orderByComparator.isAscending() ^ previous) {
454 query.append(WHERE_GREATER_THAN_HAS_NEXT);
455 }
456 else {
457 query.append(WHERE_LESSER_THAN_HAS_NEXT);
458 }
459 }
460 else {
461 if (orderByComparator.isAscending() ^ previous) {
462 query.append(WHERE_GREATER_THAN);
463 }
464 else {
465 query.append(WHERE_LESSER_THAN);
466 }
467 }
468 }
469
470 query.append(ORDER_BY_CLAUSE);
471
472 String[] orderByFields = orderByComparator.getOrderByFields();
473
474 for (int i = 0; i < orderByFields.length; i++) {
475 query.append(_ORDER_BY_ENTITY_ALIAS);
476 query.append(orderByFields[i]);
477
478 if ((i + 1) < orderByFields.length) {
479 if (orderByComparator.isAscending() ^ previous) {
480 query.append(ORDER_BY_ASC_HAS_NEXT);
481 }
482 else {
483 query.append(ORDER_BY_DESC_HAS_NEXT);
484 }
485 }
486 else {
487 if (orderByComparator.isAscending() ^ previous) {
488 query.append(ORDER_BY_ASC);
489 }
490 else {
491 query.append(ORDER_BY_DESC);
492 }
493 }
494 }
495 }
496 else {
497 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
498 }
499
500 String sql = query.toString();
501
502 Query q = session.createQuery(sql);
503
504 q.setFirstResult(0);
505 q.setMaxResults(2);
506
507 QueryPos qPos = QueryPos.getInstance(q);
508
509 if (bindUuid) {
510 qPos.add(uuid);
511 }
512
513 if (orderByComparator != null) {
514 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
515
516 for (Object value : values) {
517 qPos.add(value);
518 }
519 }
520
521 List<BlogsEntry> list = q.list();
522
523 if (list.size() == 2) {
524 return list.get(1);
525 }
526 else {
527 return null;
528 }
529 }
530
531
537 public void removeByUuid(String uuid) throws SystemException {
538 for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
539 QueryUtil.ALL_POS, null)) {
540 remove(blogsEntry);
541 }
542 }
543
544
551 public int countByUuid(String uuid) throws SystemException {
552 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
553
554 Object[] finderArgs = new Object[] { uuid };
555
556 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
557 this);
558
559 if (count == null) {
560 StringBundler query = new StringBundler(2);
561
562 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
563
564 boolean bindUuid = false;
565
566 if (uuid == null) {
567 query.append(_FINDER_COLUMN_UUID_UUID_1);
568 }
569 else if (uuid.equals(StringPool.BLANK)) {
570 query.append(_FINDER_COLUMN_UUID_UUID_3);
571 }
572 else {
573 bindUuid = true;
574
575 query.append(_FINDER_COLUMN_UUID_UUID_2);
576 }
577
578 String sql = query.toString();
579
580 Session session = null;
581
582 try {
583 session = openSession();
584
585 Query q = session.createQuery(sql);
586
587 QueryPos qPos = QueryPos.getInstance(q);
588
589 if (bindUuid) {
590 qPos.add(uuid);
591 }
592
593 count = (Long)q.uniqueResult();
594
595 FinderCacheUtil.putResult(finderPath, finderArgs, count);
596 }
597 catch (Exception e) {
598 FinderCacheUtil.removeResult(finderPath, finderArgs);
599
600 throw processException(e);
601 }
602 finally {
603 closeSession(session);
604 }
605 }
606
607 return count.intValue();
608 }
609
610 private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
611 private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
612 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
613 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
614 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
615 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
616 new String[] { String.class.getName(), Long.class.getName() },
617 BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
618 BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
619 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
620 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
621 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
622 new String[] { String.class.getName(), Long.class.getName() });
623
624
633 public BlogsEntry findByUUID_G(String uuid, long groupId)
634 throws NoSuchEntryException, SystemException {
635 BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
636
637 if (blogsEntry == null) {
638 StringBundler msg = new StringBundler(6);
639
640 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
641
642 msg.append("uuid=");
643 msg.append(uuid);
644
645 msg.append(", groupId=");
646 msg.append(groupId);
647
648 msg.append(StringPool.CLOSE_CURLY_BRACE);
649
650 if (_log.isWarnEnabled()) {
651 _log.warn(msg.toString());
652 }
653
654 throw new NoSuchEntryException(msg.toString());
655 }
656
657 return blogsEntry;
658 }
659
660
668 public BlogsEntry fetchByUUID_G(String uuid, long groupId)
669 throws SystemException {
670 return fetchByUUID_G(uuid, groupId, true);
671 }
672
673
682 public BlogsEntry fetchByUUID_G(String uuid, long groupId,
683 boolean retrieveFromCache) throws SystemException {
684 Object[] finderArgs = new Object[] { uuid, groupId };
685
686 Object result = null;
687
688 if (retrieveFromCache) {
689 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
690 finderArgs, this);
691 }
692
693 if (result instanceof BlogsEntry) {
694 BlogsEntry blogsEntry = (BlogsEntry)result;
695
696 if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
697 (groupId != blogsEntry.getGroupId())) {
698 result = null;
699 }
700 }
701
702 if (result == null) {
703 StringBundler query = new StringBundler(4);
704
705 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
706
707 boolean bindUuid = false;
708
709 if (uuid == null) {
710 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
711 }
712 else if (uuid.equals(StringPool.BLANK)) {
713 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
714 }
715 else {
716 bindUuid = true;
717
718 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
719 }
720
721 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
722
723 String sql = query.toString();
724
725 Session session = null;
726
727 try {
728 session = openSession();
729
730 Query q = session.createQuery(sql);
731
732 QueryPos qPos = QueryPos.getInstance(q);
733
734 if (bindUuid) {
735 qPos.add(uuid);
736 }
737
738 qPos.add(groupId);
739
740 List<BlogsEntry> list = q.list();
741
742 if (list.isEmpty()) {
743 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
744 finderArgs, list);
745 }
746 else {
747 BlogsEntry blogsEntry = list.get(0);
748
749 result = blogsEntry;
750
751 cacheResult(blogsEntry);
752
753 if ((blogsEntry.getUuid() == null) ||
754 !blogsEntry.getUuid().equals(uuid) ||
755 (blogsEntry.getGroupId() != groupId)) {
756 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
757 finderArgs, blogsEntry);
758 }
759 }
760 }
761 catch (Exception e) {
762 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
763 finderArgs);
764
765 throw processException(e);
766 }
767 finally {
768 closeSession(session);
769 }
770 }
771
772 if (result instanceof List<?>) {
773 return null;
774 }
775 else {
776 return (BlogsEntry)result;
777 }
778 }
779
780
788 public BlogsEntry removeByUUID_G(String uuid, long groupId)
789 throws NoSuchEntryException, SystemException {
790 BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
791
792 return remove(blogsEntry);
793 }
794
795
803 public int countByUUID_G(String uuid, long groupId)
804 throws SystemException {
805 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
806
807 Object[] finderArgs = new Object[] { uuid, groupId };
808
809 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
810 this);
811
812 if (count == null) {
813 StringBundler query = new StringBundler(3);
814
815 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
816
817 boolean bindUuid = false;
818
819 if (uuid == null) {
820 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
821 }
822 else if (uuid.equals(StringPool.BLANK)) {
823 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
824 }
825 else {
826 bindUuid = true;
827
828 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
829 }
830
831 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
832
833 String sql = query.toString();
834
835 Session session = null;
836
837 try {
838 session = openSession();
839
840 Query q = session.createQuery(sql);
841
842 QueryPos qPos = QueryPos.getInstance(q);
843
844 if (bindUuid) {
845 qPos.add(uuid);
846 }
847
848 qPos.add(groupId);
849
850 count = (Long)q.uniqueResult();
851
852 FinderCacheUtil.putResult(finderPath, finderArgs, count);
853 }
854 catch (Exception e) {
855 FinderCacheUtil.removeResult(finderPath, finderArgs);
856
857 throw processException(e);
858 }
859 finally {
860 closeSession(session);
861 }
862 }
863
864 return count.intValue();
865 }
866
867 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
868 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
869 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
870 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
871 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
872 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
873 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
874 new String[] {
875 String.class.getName(), Long.class.getName(),
876
877 Integer.class.getName(), Integer.class.getName(),
878 OrderByComparator.class.getName()
879 });
880 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
881 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
882 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
883 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
884 new String[] { String.class.getName(), Long.class.getName() },
885 BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
886 BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
887 BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
888 BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
889 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
890 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
891 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
892 new String[] { String.class.getName(), Long.class.getName() });
893
894
902 public List<BlogsEntry> findByUuid_C(String uuid, long companyId)
903 throws SystemException {
904 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
905 QueryUtil.ALL_POS, null);
906 }
907
908
922 public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
923 int start, int end) throws SystemException {
924 return findByUuid_C(uuid, companyId, start, end, null);
925 }
926
927
942 public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
943 int start, int end, OrderByComparator orderByComparator)
944 throws SystemException {
945 boolean pagination = true;
946 FinderPath finderPath = null;
947 Object[] finderArgs = null;
948
949 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
950 (orderByComparator == null)) {
951 pagination = false;
952 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
953 finderArgs = new Object[] { uuid, companyId };
954 }
955 else {
956 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
957 finderArgs = new Object[] {
958 uuid, companyId,
959
960 start, end, orderByComparator
961 };
962 }
963
964 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
965 finderArgs, this);
966
967 if ((list != null) && !list.isEmpty()) {
968 for (BlogsEntry blogsEntry : list) {
969 if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
970 (companyId != blogsEntry.getCompanyId())) {
971 list = null;
972
973 break;
974 }
975 }
976 }
977
978 if (list == null) {
979 StringBundler query = null;
980
981 if (orderByComparator != null) {
982 query = new StringBundler(4 +
983 (orderByComparator.getOrderByFields().length * 3));
984 }
985 else {
986 query = new StringBundler(4);
987 }
988
989 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
990
991 boolean bindUuid = false;
992
993 if (uuid == null) {
994 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
995 }
996 else if (uuid.equals(StringPool.BLANK)) {
997 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
998 }
999 else {
1000 bindUuid = true;
1001
1002 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1003 }
1004
1005 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1006
1007 if (orderByComparator != null) {
1008 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1009 orderByComparator);
1010 }
1011 else
1012 if (pagination) {
1013 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1014 }
1015
1016 String sql = query.toString();
1017
1018 Session session = null;
1019
1020 try {
1021 session = openSession();
1022
1023 Query q = session.createQuery(sql);
1024
1025 QueryPos qPos = QueryPos.getInstance(q);
1026
1027 if (bindUuid) {
1028 qPos.add(uuid);
1029 }
1030
1031 qPos.add(companyId);
1032
1033 if (!pagination) {
1034 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1035 start, end, false);
1036
1037 Collections.sort(list);
1038
1039 list = new UnmodifiableList<BlogsEntry>(list);
1040 }
1041 else {
1042 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1043 start, end);
1044 }
1045
1046 cacheResult(list);
1047
1048 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1049 }
1050 catch (Exception e) {
1051 FinderCacheUtil.removeResult(finderPath, finderArgs);
1052
1053 throw processException(e);
1054 }
1055 finally {
1056 closeSession(session);
1057 }
1058 }
1059
1060 return list;
1061 }
1062
1063
1073 public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1074 OrderByComparator orderByComparator)
1075 throws NoSuchEntryException, SystemException {
1076 BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1077 orderByComparator);
1078
1079 if (blogsEntry != null) {
1080 return blogsEntry;
1081 }
1082
1083 StringBundler msg = new StringBundler(6);
1084
1085 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1086
1087 msg.append("uuid=");
1088 msg.append(uuid);
1089
1090 msg.append(", companyId=");
1091 msg.append(companyId);
1092
1093 msg.append(StringPool.CLOSE_CURLY_BRACE);
1094
1095 throw new NoSuchEntryException(msg.toString());
1096 }
1097
1098
1107 public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1108 OrderByComparator orderByComparator) throws SystemException {
1109 List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1110 orderByComparator);
1111
1112 if (!list.isEmpty()) {
1113 return list.get(0);
1114 }
1115
1116 return null;
1117 }
1118
1119
1129 public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1130 OrderByComparator orderByComparator)
1131 throws NoSuchEntryException, SystemException {
1132 BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1133 orderByComparator);
1134
1135 if (blogsEntry != null) {
1136 return blogsEntry;
1137 }
1138
1139 StringBundler msg = new StringBundler(6);
1140
1141 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1142
1143 msg.append("uuid=");
1144 msg.append(uuid);
1145
1146 msg.append(", companyId=");
1147 msg.append(companyId);
1148
1149 msg.append(StringPool.CLOSE_CURLY_BRACE);
1150
1151 throw new NoSuchEntryException(msg.toString());
1152 }
1153
1154
1163 public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1164 OrderByComparator orderByComparator) throws SystemException {
1165 int count = countByUuid_C(uuid, companyId);
1166
1167 List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1168 orderByComparator);
1169
1170 if (!list.isEmpty()) {
1171 return list.get(0);
1172 }
1173
1174 return null;
1175 }
1176
1177
1188 public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1189 long companyId, OrderByComparator orderByComparator)
1190 throws NoSuchEntryException, SystemException {
1191 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1192
1193 Session session = null;
1194
1195 try {
1196 session = openSession();
1197
1198 BlogsEntry[] array = new BlogsEntryImpl[3];
1199
1200 array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1201 companyId, orderByComparator, true);
1202
1203 array[1] = blogsEntry;
1204
1205 array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1206 companyId, orderByComparator, false);
1207
1208 return array;
1209 }
1210 catch (Exception e) {
1211 throw processException(e);
1212 }
1213 finally {
1214 closeSession(session);
1215 }
1216 }
1217
1218 protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1219 BlogsEntry blogsEntry, String uuid, long companyId,
1220 OrderByComparator orderByComparator, boolean previous) {
1221 StringBundler query = null;
1222
1223 if (orderByComparator != null) {
1224 query = new StringBundler(6 +
1225 (orderByComparator.getOrderByFields().length * 6));
1226 }
1227 else {
1228 query = new StringBundler(3);
1229 }
1230
1231 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1232
1233 boolean bindUuid = false;
1234
1235 if (uuid == null) {
1236 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1237 }
1238 else if (uuid.equals(StringPool.BLANK)) {
1239 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1240 }
1241 else {
1242 bindUuid = true;
1243
1244 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1245 }
1246
1247 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1248
1249 if (orderByComparator != null) {
1250 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1251
1252 if (orderByConditionFields.length > 0) {
1253 query.append(WHERE_AND);
1254 }
1255
1256 for (int i = 0; i < orderByConditionFields.length; i++) {
1257 query.append(_ORDER_BY_ENTITY_ALIAS);
1258 query.append(orderByConditionFields[i]);
1259
1260 if ((i + 1) < orderByConditionFields.length) {
1261 if (orderByComparator.isAscending() ^ previous) {
1262 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1263 }
1264 else {
1265 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1266 }
1267 }
1268 else {
1269 if (orderByComparator.isAscending() ^ previous) {
1270 query.append(WHERE_GREATER_THAN);
1271 }
1272 else {
1273 query.append(WHERE_LESSER_THAN);
1274 }
1275 }
1276 }
1277
1278 query.append(ORDER_BY_CLAUSE);
1279
1280 String[] orderByFields = orderByComparator.getOrderByFields();
1281
1282 for (int i = 0; i < orderByFields.length; i++) {
1283 query.append(_ORDER_BY_ENTITY_ALIAS);
1284 query.append(orderByFields[i]);
1285
1286 if ((i + 1) < orderByFields.length) {
1287 if (orderByComparator.isAscending() ^ previous) {
1288 query.append(ORDER_BY_ASC_HAS_NEXT);
1289 }
1290 else {
1291 query.append(ORDER_BY_DESC_HAS_NEXT);
1292 }
1293 }
1294 else {
1295 if (orderByComparator.isAscending() ^ previous) {
1296 query.append(ORDER_BY_ASC);
1297 }
1298 else {
1299 query.append(ORDER_BY_DESC);
1300 }
1301 }
1302 }
1303 }
1304 else {
1305 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1306 }
1307
1308 String sql = query.toString();
1309
1310 Query q = session.createQuery(sql);
1311
1312 q.setFirstResult(0);
1313 q.setMaxResults(2);
1314
1315 QueryPos qPos = QueryPos.getInstance(q);
1316
1317 if (bindUuid) {
1318 qPos.add(uuid);
1319 }
1320
1321 qPos.add(companyId);
1322
1323 if (orderByComparator != null) {
1324 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1325
1326 for (Object value : values) {
1327 qPos.add(value);
1328 }
1329 }
1330
1331 List<BlogsEntry> list = q.list();
1332
1333 if (list.size() == 2) {
1334 return list.get(1);
1335 }
1336 else {
1337 return null;
1338 }
1339 }
1340
1341
1348 public void removeByUuid_C(String uuid, long companyId)
1349 throws SystemException {
1350 for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1351 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1352 remove(blogsEntry);
1353 }
1354 }
1355
1356
1364 public int countByUuid_C(String uuid, long companyId)
1365 throws SystemException {
1366 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1367
1368 Object[] finderArgs = new Object[] { uuid, companyId };
1369
1370 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1371 this);
1372
1373 if (count == null) {
1374 StringBundler query = new StringBundler(3);
1375
1376 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1377
1378 boolean bindUuid = false;
1379
1380 if (uuid == null) {
1381 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1382 }
1383 else if (uuid.equals(StringPool.BLANK)) {
1384 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1385 }
1386 else {
1387 bindUuid = true;
1388
1389 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1390 }
1391
1392 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1393
1394 String sql = query.toString();
1395
1396 Session session = null;
1397
1398 try {
1399 session = openSession();
1400
1401 Query q = session.createQuery(sql);
1402
1403 QueryPos qPos = QueryPos.getInstance(q);
1404
1405 if (bindUuid) {
1406 qPos.add(uuid);
1407 }
1408
1409 qPos.add(companyId);
1410
1411 count = (Long)q.uniqueResult();
1412
1413 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1414 }
1415 catch (Exception e) {
1416 FinderCacheUtil.removeResult(finderPath, finderArgs);
1417
1418 throw processException(e);
1419 }
1420 finally {
1421 closeSession(session);
1422 }
1423 }
1424
1425 return count.intValue();
1426 }
1427
1428 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1429 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1430 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
1431 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1432 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1433 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1434 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1435 new String[] {
1436 Long.class.getName(),
1437
1438 Integer.class.getName(), Integer.class.getName(),
1439 OrderByComparator.class.getName()
1440 });
1441 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1442 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1443 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1444 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1445 new String[] { Long.class.getName() },
1446 BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1447 BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1448 BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1449 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1450 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1451 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1452 new String[] { Long.class.getName() });
1453
1454
1461 public List<BlogsEntry> findByGroupId(long groupId)
1462 throws SystemException {
1463 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1464 }
1465
1466
1479 public List<BlogsEntry> findByGroupId(long groupId, int start, int end)
1480 throws SystemException {
1481 return findByGroupId(groupId, start, end, null);
1482 }
1483
1484
1498 public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1499 OrderByComparator orderByComparator) throws SystemException {
1500 boolean pagination = true;
1501 FinderPath finderPath = null;
1502 Object[] finderArgs = null;
1503
1504 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1505 (orderByComparator == null)) {
1506 pagination = false;
1507 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1508 finderArgs = new Object[] { groupId };
1509 }
1510 else {
1511 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1512 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1513 }
1514
1515 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
1516 finderArgs, this);
1517
1518 if ((list != null) && !list.isEmpty()) {
1519 for (BlogsEntry blogsEntry : list) {
1520 if ((groupId != blogsEntry.getGroupId())) {
1521 list = null;
1522
1523 break;
1524 }
1525 }
1526 }
1527
1528 if (list == null) {
1529 StringBundler query = null;
1530
1531 if (orderByComparator != null) {
1532 query = new StringBundler(3 +
1533 (orderByComparator.getOrderByFields().length * 3));
1534 }
1535 else {
1536 query = new StringBundler(3);
1537 }
1538
1539 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1540
1541 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1542
1543 if (orderByComparator != null) {
1544 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1545 orderByComparator);
1546 }
1547 else
1548 if (pagination) {
1549 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1550 }
1551
1552 String sql = query.toString();
1553
1554 Session session = null;
1555
1556 try {
1557 session = openSession();
1558
1559 Query q = session.createQuery(sql);
1560
1561 QueryPos qPos = QueryPos.getInstance(q);
1562
1563 qPos.add(groupId);
1564
1565 if (!pagination) {
1566 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1567 start, end, false);
1568
1569 Collections.sort(list);
1570
1571 list = new UnmodifiableList<BlogsEntry>(list);
1572 }
1573 else {
1574 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1575 start, end);
1576 }
1577
1578 cacheResult(list);
1579
1580 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1581 }
1582 catch (Exception e) {
1583 FinderCacheUtil.removeResult(finderPath, finderArgs);
1584
1585 throw processException(e);
1586 }
1587 finally {
1588 closeSession(session);
1589 }
1590 }
1591
1592 return list;
1593 }
1594
1595
1604 public BlogsEntry findByGroupId_First(long groupId,
1605 OrderByComparator orderByComparator)
1606 throws NoSuchEntryException, SystemException {
1607 BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1608
1609 if (blogsEntry != null) {
1610 return blogsEntry;
1611 }
1612
1613 StringBundler msg = new StringBundler(4);
1614
1615 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1616
1617 msg.append("groupId=");
1618 msg.append(groupId);
1619
1620 msg.append(StringPool.CLOSE_CURLY_BRACE);
1621
1622 throw new NoSuchEntryException(msg.toString());
1623 }
1624
1625
1633 public BlogsEntry fetchByGroupId_First(long groupId,
1634 OrderByComparator orderByComparator) throws SystemException {
1635 List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1636
1637 if (!list.isEmpty()) {
1638 return list.get(0);
1639 }
1640
1641 return null;
1642 }
1643
1644
1653 public BlogsEntry findByGroupId_Last(long groupId,
1654 OrderByComparator orderByComparator)
1655 throws NoSuchEntryException, SystemException {
1656 BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1657
1658 if (blogsEntry != null) {
1659 return blogsEntry;
1660 }
1661
1662 StringBundler msg = new StringBundler(4);
1663
1664 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1665
1666 msg.append("groupId=");
1667 msg.append(groupId);
1668
1669 msg.append(StringPool.CLOSE_CURLY_BRACE);
1670
1671 throw new NoSuchEntryException(msg.toString());
1672 }
1673
1674
1682 public BlogsEntry fetchByGroupId_Last(long groupId,
1683 OrderByComparator orderByComparator) throws SystemException {
1684 int count = countByGroupId(groupId);
1685
1686 List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1687 orderByComparator);
1688
1689 if (!list.isEmpty()) {
1690 return list.get(0);
1691 }
1692
1693 return null;
1694 }
1695
1696
1706 public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1707 OrderByComparator orderByComparator)
1708 throws NoSuchEntryException, SystemException {
1709 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1710
1711 Session session = null;
1712
1713 try {
1714 session = openSession();
1715
1716 BlogsEntry[] array = new BlogsEntryImpl[3];
1717
1718 array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1719 orderByComparator, true);
1720
1721 array[1] = blogsEntry;
1722
1723 array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1724 orderByComparator, false);
1725
1726 return array;
1727 }
1728 catch (Exception e) {
1729 throw processException(e);
1730 }
1731 finally {
1732 closeSession(session);
1733 }
1734 }
1735
1736 protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1737 BlogsEntry blogsEntry, long groupId,
1738 OrderByComparator orderByComparator, boolean previous) {
1739 StringBundler query = null;
1740
1741 if (orderByComparator != null) {
1742 query = new StringBundler(6 +
1743 (orderByComparator.getOrderByFields().length * 6));
1744 }
1745 else {
1746 query = new StringBundler(3);
1747 }
1748
1749 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1750
1751 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1752
1753 if (orderByComparator != null) {
1754 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1755
1756 if (orderByConditionFields.length > 0) {
1757 query.append(WHERE_AND);
1758 }
1759
1760 for (int i = 0; i < orderByConditionFields.length; i++) {
1761 query.append(_ORDER_BY_ENTITY_ALIAS);
1762 query.append(orderByConditionFields[i]);
1763
1764 if ((i + 1) < orderByConditionFields.length) {
1765 if (orderByComparator.isAscending() ^ previous) {
1766 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1767 }
1768 else {
1769 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1770 }
1771 }
1772 else {
1773 if (orderByComparator.isAscending() ^ previous) {
1774 query.append(WHERE_GREATER_THAN);
1775 }
1776 else {
1777 query.append(WHERE_LESSER_THAN);
1778 }
1779 }
1780 }
1781
1782 query.append(ORDER_BY_CLAUSE);
1783
1784 String[] orderByFields = orderByComparator.getOrderByFields();
1785
1786 for (int i = 0; i < orderByFields.length; i++) {
1787 query.append(_ORDER_BY_ENTITY_ALIAS);
1788 query.append(orderByFields[i]);
1789
1790 if ((i + 1) < orderByFields.length) {
1791 if (orderByComparator.isAscending() ^ previous) {
1792 query.append(ORDER_BY_ASC_HAS_NEXT);
1793 }
1794 else {
1795 query.append(ORDER_BY_DESC_HAS_NEXT);
1796 }
1797 }
1798 else {
1799 if (orderByComparator.isAscending() ^ previous) {
1800 query.append(ORDER_BY_ASC);
1801 }
1802 else {
1803 query.append(ORDER_BY_DESC);
1804 }
1805 }
1806 }
1807 }
1808 else {
1809 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1810 }
1811
1812 String sql = query.toString();
1813
1814 Query q = session.createQuery(sql);
1815
1816 q.setFirstResult(0);
1817 q.setMaxResults(2);
1818
1819 QueryPos qPos = QueryPos.getInstance(q);
1820
1821 qPos.add(groupId);
1822
1823 if (orderByComparator != null) {
1824 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1825
1826 for (Object value : values) {
1827 qPos.add(value);
1828 }
1829 }
1830
1831 List<BlogsEntry> list = q.list();
1832
1833 if (list.size() == 2) {
1834 return list.get(1);
1835 }
1836 else {
1837 return null;
1838 }
1839 }
1840
1841
1848 public List<BlogsEntry> filterFindByGroupId(long groupId)
1849 throws SystemException {
1850 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1851 QueryUtil.ALL_POS, null);
1852 }
1853
1854
1867 public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end)
1868 throws SystemException {
1869 return filterFindByGroupId(groupId, start, end, null);
1870 }
1871
1872
1886 public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1887 int end, OrderByComparator orderByComparator) throws SystemException {
1888 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1889 return findByGroupId(groupId, start, end, orderByComparator);
1890 }
1891
1892 StringBundler query = null;
1893
1894 if (orderByComparator != null) {
1895 query = new StringBundler(3 +
1896 (orderByComparator.getOrderByFields().length * 3));
1897 }
1898 else {
1899 query = new StringBundler(3);
1900 }
1901
1902 if (getDB().isSupportsInlineDistinct()) {
1903 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1904 }
1905 else {
1906 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1907 }
1908
1909 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1910
1911 if (!getDB().isSupportsInlineDistinct()) {
1912 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1913 }
1914
1915 if (orderByComparator != null) {
1916 if (getDB().isSupportsInlineDistinct()) {
1917 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1918 orderByComparator, true);
1919 }
1920 else {
1921 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1922 orderByComparator, true);
1923 }
1924 }
1925 else {
1926 if (getDB().isSupportsInlineDistinct()) {
1927 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1928 }
1929 else {
1930 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
1931 }
1932 }
1933
1934 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1935 BlogsEntry.class.getName(),
1936 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1937
1938 Session session = null;
1939
1940 try {
1941 session = openSession();
1942
1943 SQLQuery q = session.createSQLQuery(sql);
1944
1945 if (getDB().isSupportsInlineDistinct()) {
1946 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
1947 }
1948 else {
1949 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
1950 }
1951
1952 QueryPos qPos = QueryPos.getInstance(q);
1953
1954 qPos.add(groupId);
1955
1956 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
1957 }
1958 catch (Exception e) {
1959 throw processException(e);
1960 }
1961 finally {
1962 closeSession(session);
1963 }
1964 }
1965
1966
1976 public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
1977 long groupId, OrderByComparator orderByComparator)
1978 throws NoSuchEntryException, SystemException {
1979 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1980 return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
1981 }
1982
1983 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1984
1985 Session session = null;
1986
1987 try {
1988 session = openSession();
1989
1990 BlogsEntry[] array = new BlogsEntryImpl[3];
1991
1992 array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
1993 groupId, orderByComparator, true);
1994
1995 array[1] = blogsEntry;
1996
1997 array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
1998 groupId, orderByComparator, false);
1999
2000 return array;
2001 }
2002 catch (Exception e) {
2003 throw processException(e);
2004 }
2005 finally {
2006 closeSession(session);
2007 }
2008 }
2009
2010 protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2011 BlogsEntry blogsEntry, long groupId,
2012 OrderByComparator orderByComparator, boolean previous) {
2013 StringBundler query = null;
2014
2015 if (orderByComparator != null) {
2016 query = new StringBundler(6 +
2017 (orderByComparator.getOrderByFields().length * 6));
2018 }
2019 else {
2020 query = new StringBundler(3);
2021 }
2022
2023 if (getDB().isSupportsInlineDistinct()) {
2024 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2025 }
2026 else {
2027 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2028 }
2029
2030 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2031
2032 if (!getDB().isSupportsInlineDistinct()) {
2033 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2034 }
2035
2036 if (orderByComparator != null) {
2037 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2038
2039 if (orderByConditionFields.length > 0) {
2040 query.append(WHERE_AND);
2041 }
2042
2043 for (int i = 0; i < orderByConditionFields.length; i++) {
2044 if (getDB().isSupportsInlineDistinct()) {
2045 query.append(_ORDER_BY_ENTITY_ALIAS);
2046 }
2047 else {
2048 query.append(_ORDER_BY_ENTITY_TABLE);
2049 }
2050
2051 query.append(orderByConditionFields[i]);
2052
2053 if ((i + 1) < orderByConditionFields.length) {
2054 if (orderByComparator.isAscending() ^ previous) {
2055 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2056 }
2057 else {
2058 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2059 }
2060 }
2061 else {
2062 if (orderByComparator.isAscending() ^ previous) {
2063 query.append(WHERE_GREATER_THAN);
2064 }
2065 else {
2066 query.append(WHERE_LESSER_THAN);
2067 }
2068 }
2069 }
2070
2071 query.append(ORDER_BY_CLAUSE);
2072
2073 String[] orderByFields = orderByComparator.getOrderByFields();
2074
2075 for (int i = 0; i < orderByFields.length; i++) {
2076 if (getDB().isSupportsInlineDistinct()) {
2077 query.append(_ORDER_BY_ENTITY_ALIAS);
2078 }
2079 else {
2080 query.append(_ORDER_BY_ENTITY_TABLE);
2081 }
2082
2083 query.append(orderByFields[i]);
2084
2085 if ((i + 1) < orderByFields.length) {
2086 if (orderByComparator.isAscending() ^ previous) {
2087 query.append(ORDER_BY_ASC_HAS_NEXT);
2088 }
2089 else {
2090 query.append(ORDER_BY_DESC_HAS_NEXT);
2091 }
2092 }
2093 else {
2094 if (orderByComparator.isAscending() ^ previous) {
2095 query.append(ORDER_BY_ASC);
2096 }
2097 else {
2098 query.append(ORDER_BY_DESC);
2099 }
2100 }
2101 }
2102 }
2103 else {
2104 if (getDB().isSupportsInlineDistinct()) {
2105 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2106 }
2107 else {
2108 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2109 }
2110 }
2111
2112 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2113 BlogsEntry.class.getName(),
2114 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2115
2116 SQLQuery q = session.createSQLQuery(sql);
2117
2118 q.setFirstResult(0);
2119 q.setMaxResults(2);
2120
2121 if (getDB().isSupportsInlineDistinct()) {
2122 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2123 }
2124 else {
2125 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2126 }
2127
2128 QueryPos qPos = QueryPos.getInstance(q);
2129
2130 qPos.add(groupId);
2131
2132 if (orderByComparator != null) {
2133 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2134
2135 for (Object value : values) {
2136 qPos.add(value);
2137 }
2138 }
2139
2140 List<BlogsEntry> list = q.list();
2141
2142 if (list.size() == 2) {
2143 return list.get(1);
2144 }
2145 else {
2146 return null;
2147 }
2148 }
2149
2150
2156 public void removeByGroupId(long groupId) throws SystemException {
2157 for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2158 QueryUtil.ALL_POS, null)) {
2159 remove(blogsEntry);
2160 }
2161 }
2162
2163
2170 public int countByGroupId(long groupId) throws SystemException {
2171 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2172
2173 Object[] finderArgs = new Object[] { groupId };
2174
2175 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2176 this);
2177
2178 if (count == null) {
2179 StringBundler query = new StringBundler(2);
2180
2181 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2182
2183 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2184
2185 String sql = query.toString();
2186
2187 Session session = null;
2188
2189 try {
2190 session = openSession();
2191
2192 Query q = session.createQuery(sql);
2193
2194 QueryPos qPos = QueryPos.getInstance(q);
2195
2196 qPos.add(groupId);
2197
2198 count = (Long)q.uniqueResult();
2199
2200 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2201 }
2202 catch (Exception e) {
2203 FinderCacheUtil.removeResult(finderPath, finderArgs);
2204
2205 throw processException(e);
2206 }
2207 finally {
2208 closeSession(session);
2209 }
2210 }
2211
2212 return count.intValue();
2213 }
2214
2215
2222 public int filterCountByGroupId(long groupId) throws SystemException {
2223 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2224 return countByGroupId(groupId);
2225 }
2226
2227 StringBundler query = new StringBundler(2);
2228
2229 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2230
2231 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2232
2233 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2234 BlogsEntry.class.getName(),
2235 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2236
2237 Session session = null;
2238
2239 try {
2240 session = openSession();
2241
2242 SQLQuery q = session.createSQLQuery(sql);
2243
2244 q.addScalar(COUNT_COLUMN_NAME,
2245 com.liferay.portal.kernel.dao.orm.Type.LONG);
2246
2247 QueryPos qPos = QueryPos.getInstance(q);
2248
2249 qPos.add(groupId);
2250
2251 Long count = (Long)q.uniqueResult();
2252
2253 return count.intValue();
2254 }
2255 catch (Exception e) {
2256 throw processException(e);
2257 }
2258 finally {
2259 closeSession(session);
2260 }
2261 }
2262
2263 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2264 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2265 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2266 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2267 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2268 new String[] {
2269 Long.class.getName(),
2270
2271 Integer.class.getName(), Integer.class.getName(),
2272 OrderByComparator.class.getName()
2273 });
2274 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2275 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2276 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2277 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2278 new String[] { Long.class.getName() },
2279 BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2280 BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2281 BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2282 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2283 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2284 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2285 new String[] { Long.class.getName() });
2286
2287
2294 public List<BlogsEntry> findByCompanyId(long companyId)
2295 throws SystemException {
2296 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2297 null);
2298 }
2299
2300
2313 public List<BlogsEntry> findByCompanyId(long companyId, int start, int end)
2314 throws SystemException {
2315 return findByCompanyId(companyId, start, end, null);
2316 }
2317
2318
2332 public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2333 OrderByComparator orderByComparator) throws SystemException {
2334 boolean pagination = true;
2335 FinderPath finderPath = null;
2336 Object[] finderArgs = null;
2337
2338 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2339 (orderByComparator == null)) {
2340 pagination = false;
2341 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2342 finderArgs = new Object[] { companyId };
2343 }
2344 else {
2345 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2346 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2347 }
2348
2349 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2350 finderArgs, this);
2351
2352 if ((list != null) && !list.isEmpty()) {
2353 for (BlogsEntry blogsEntry : list) {
2354 if ((companyId != blogsEntry.getCompanyId())) {
2355 list = null;
2356
2357 break;
2358 }
2359 }
2360 }
2361
2362 if (list == null) {
2363 StringBundler query = null;
2364
2365 if (orderByComparator != null) {
2366 query = new StringBundler(3 +
2367 (orderByComparator.getOrderByFields().length * 3));
2368 }
2369 else {
2370 query = new StringBundler(3);
2371 }
2372
2373 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2374
2375 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2376
2377 if (orderByComparator != null) {
2378 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2379 orderByComparator);
2380 }
2381 else
2382 if (pagination) {
2383 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2384 }
2385
2386 String sql = query.toString();
2387
2388 Session session = null;
2389
2390 try {
2391 session = openSession();
2392
2393 Query q = session.createQuery(sql);
2394
2395 QueryPos qPos = QueryPos.getInstance(q);
2396
2397 qPos.add(companyId);
2398
2399 if (!pagination) {
2400 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2401 start, end, false);
2402
2403 Collections.sort(list);
2404
2405 list = new UnmodifiableList<BlogsEntry>(list);
2406 }
2407 else {
2408 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2409 start, end);
2410 }
2411
2412 cacheResult(list);
2413
2414 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2415 }
2416 catch (Exception e) {
2417 FinderCacheUtil.removeResult(finderPath, finderArgs);
2418
2419 throw processException(e);
2420 }
2421 finally {
2422 closeSession(session);
2423 }
2424 }
2425
2426 return list;
2427 }
2428
2429
2438 public BlogsEntry findByCompanyId_First(long companyId,
2439 OrderByComparator orderByComparator)
2440 throws NoSuchEntryException, SystemException {
2441 BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2442 orderByComparator);
2443
2444 if (blogsEntry != null) {
2445 return blogsEntry;
2446 }
2447
2448 StringBundler msg = new StringBundler(4);
2449
2450 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2451
2452 msg.append("companyId=");
2453 msg.append(companyId);
2454
2455 msg.append(StringPool.CLOSE_CURLY_BRACE);
2456
2457 throw new NoSuchEntryException(msg.toString());
2458 }
2459
2460
2468 public BlogsEntry fetchByCompanyId_First(long companyId,
2469 OrderByComparator orderByComparator) throws SystemException {
2470 List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2471 orderByComparator);
2472
2473 if (!list.isEmpty()) {
2474 return list.get(0);
2475 }
2476
2477 return null;
2478 }
2479
2480
2489 public BlogsEntry findByCompanyId_Last(long companyId,
2490 OrderByComparator orderByComparator)
2491 throws NoSuchEntryException, SystemException {
2492 BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2493 orderByComparator);
2494
2495 if (blogsEntry != null) {
2496 return blogsEntry;
2497 }
2498
2499 StringBundler msg = new StringBundler(4);
2500
2501 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2502
2503 msg.append("companyId=");
2504 msg.append(companyId);
2505
2506 msg.append(StringPool.CLOSE_CURLY_BRACE);
2507
2508 throw new NoSuchEntryException(msg.toString());
2509 }
2510
2511
2519 public BlogsEntry fetchByCompanyId_Last(long companyId,
2520 OrderByComparator orderByComparator) throws SystemException {
2521 int count = countByCompanyId(companyId);
2522
2523 List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2524 orderByComparator);
2525
2526 if (!list.isEmpty()) {
2527 return list.get(0);
2528 }
2529
2530 return null;
2531 }
2532
2533
2543 public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2544 long companyId, OrderByComparator orderByComparator)
2545 throws NoSuchEntryException, SystemException {
2546 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2547
2548 Session session = null;
2549
2550 try {
2551 session = openSession();
2552
2553 BlogsEntry[] array = new BlogsEntryImpl[3];
2554
2555 array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2556 companyId, orderByComparator, true);
2557
2558 array[1] = blogsEntry;
2559
2560 array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2561 companyId, orderByComparator, false);
2562
2563 return array;
2564 }
2565 catch (Exception e) {
2566 throw processException(e);
2567 }
2568 finally {
2569 closeSession(session);
2570 }
2571 }
2572
2573 protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2574 BlogsEntry blogsEntry, long companyId,
2575 OrderByComparator orderByComparator, boolean previous) {
2576 StringBundler query = null;
2577
2578 if (orderByComparator != null) {
2579 query = new StringBundler(6 +
2580 (orderByComparator.getOrderByFields().length * 6));
2581 }
2582 else {
2583 query = new StringBundler(3);
2584 }
2585
2586 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2587
2588 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2589
2590 if (orderByComparator != null) {
2591 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2592
2593 if (orderByConditionFields.length > 0) {
2594 query.append(WHERE_AND);
2595 }
2596
2597 for (int i = 0; i < orderByConditionFields.length; i++) {
2598 query.append(_ORDER_BY_ENTITY_ALIAS);
2599 query.append(orderByConditionFields[i]);
2600
2601 if ((i + 1) < orderByConditionFields.length) {
2602 if (orderByComparator.isAscending() ^ previous) {
2603 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2604 }
2605 else {
2606 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2607 }
2608 }
2609 else {
2610 if (orderByComparator.isAscending() ^ previous) {
2611 query.append(WHERE_GREATER_THAN);
2612 }
2613 else {
2614 query.append(WHERE_LESSER_THAN);
2615 }
2616 }
2617 }
2618
2619 query.append(ORDER_BY_CLAUSE);
2620
2621 String[] orderByFields = orderByComparator.getOrderByFields();
2622
2623 for (int i = 0; i < orderByFields.length; i++) {
2624 query.append(_ORDER_BY_ENTITY_ALIAS);
2625 query.append(orderByFields[i]);
2626
2627 if ((i + 1) < orderByFields.length) {
2628 if (orderByComparator.isAscending() ^ previous) {
2629 query.append(ORDER_BY_ASC_HAS_NEXT);
2630 }
2631 else {
2632 query.append(ORDER_BY_DESC_HAS_NEXT);
2633 }
2634 }
2635 else {
2636 if (orderByComparator.isAscending() ^ previous) {
2637 query.append(ORDER_BY_ASC);
2638 }
2639 else {
2640 query.append(ORDER_BY_DESC);
2641 }
2642 }
2643 }
2644 }
2645 else {
2646 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2647 }
2648
2649 String sql = query.toString();
2650
2651 Query q = session.createQuery(sql);
2652
2653 q.setFirstResult(0);
2654 q.setMaxResults(2);
2655
2656 QueryPos qPos = QueryPos.getInstance(q);
2657
2658 qPos.add(companyId);
2659
2660 if (orderByComparator != null) {
2661 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2662
2663 for (Object value : values) {
2664 qPos.add(value);
2665 }
2666 }
2667
2668 List<BlogsEntry> list = q.list();
2669
2670 if (list.size() == 2) {
2671 return list.get(1);
2672 }
2673 else {
2674 return null;
2675 }
2676 }
2677
2678
2684 public void removeByCompanyId(long companyId) throws SystemException {
2685 for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2686 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2687 remove(blogsEntry);
2688 }
2689 }
2690
2691
2698 public int countByCompanyId(long companyId) throws SystemException {
2699 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2700
2701 Object[] finderArgs = new Object[] { companyId };
2702
2703 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2704 this);
2705
2706 if (count == null) {
2707 StringBundler query = new StringBundler(2);
2708
2709 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2710
2711 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2712
2713 String sql = query.toString();
2714
2715 Session session = null;
2716
2717 try {
2718 session = openSession();
2719
2720 Query q = session.createQuery(sql);
2721
2722 QueryPos qPos = QueryPos.getInstance(q);
2723
2724 qPos.add(companyId);
2725
2726 count = (Long)q.uniqueResult();
2727
2728 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2729 }
2730 catch (Exception e) {
2731 FinderCacheUtil.removeResult(finderPath, finderArgs);
2732
2733 throw processException(e);
2734 }
2735 finally {
2736 closeSession(session);
2737 }
2738 }
2739
2740 return count.intValue();
2741 }
2742
2743 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2744 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2745 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2746 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
2747 new String[] {
2748 Long.class.getName(), Long.class.getName(),
2749
2750 Integer.class.getName(), Integer.class.getName(),
2751 OrderByComparator.class.getName()
2752 });
2753 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2754 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2755 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
2756 new String[] { Long.class.getName(), Long.class.getName() },
2757 BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2758 BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
2759 BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2760 BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2761 public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2762 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2763 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
2764 new String[] { Long.class.getName(), Long.class.getName() });
2765
2766
2774 public List<BlogsEntry> findByC_U(long companyId, long userId)
2775 throws SystemException {
2776 return findByC_U(companyId, userId, QueryUtil.ALL_POS,
2777 QueryUtil.ALL_POS, null);
2778 }
2779
2780
2794 public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
2795 int end) throws SystemException {
2796 return findByC_U(companyId, userId, start, end, null);
2797 }
2798
2799
2814 public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
2815 int end, OrderByComparator orderByComparator) throws SystemException {
2816 boolean pagination = true;
2817 FinderPath finderPath = null;
2818 Object[] finderArgs = null;
2819
2820 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2821 (orderByComparator == null)) {
2822 pagination = false;
2823 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
2824 finderArgs = new Object[] { companyId, userId };
2825 }
2826 else {
2827 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
2828 finderArgs = new Object[] {
2829 companyId, userId,
2830
2831 start, end, orderByComparator
2832 };
2833 }
2834
2835 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2836 finderArgs, this);
2837
2838 if ((list != null) && !list.isEmpty()) {
2839 for (BlogsEntry blogsEntry : list) {
2840 if ((companyId != blogsEntry.getCompanyId()) ||
2841 (userId != blogsEntry.getUserId())) {
2842 list = null;
2843
2844 break;
2845 }
2846 }
2847 }
2848
2849 if (list == null) {
2850 StringBundler query = null;
2851
2852 if (orderByComparator != null) {
2853 query = new StringBundler(4 +
2854 (orderByComparator.getOrderByFields().length * 3));
2855 }
2856 else {
2857 query = new StringBundler(4);
2858 }
2859
2860 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2861
2862 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
2863
2864 query.append(_FINDER_COLUMN_C_U_USERID_2);
2865
2866 if (orderByComparator != null) {
2867 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2868 orderByComparator);
2869 }
2870 else
2871 if (pagination) {
2872 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2873 }
2874
2875 String sql = query.toString();
2876
2877 Session session = null;
2878
2879 try {
2880 session = openSession();
2881
2882 Query q = session.createQuery(sql);
2883
2884 QueryPos qPos = QueryPos.getInstance(q);
2885
2886 qPos.add(companyId);
2887
2888 qPos.add(userId);
2889
2890 if (!pagination) {
2891 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2892 start, end, false);
2893
2894 Collections.sort(list);
2895
2896 list = new UnmodifiableList<BlogsEntry>(list);
2897 }
2898 else {
2899 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2900 start, end);
2901 }
2902
2903 cacheResult(list);
2904
2905 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2906 }
2907 catch (Exception e) {
2908 FinderCacheUtil.removeResult(finderPath, finderArgs);
2909
2910 throw processException(e);
2911 }
2912 finally {
2913 closeSession(session);
2914 }
2915 }
2916
2917 return list;
2918 }
2919
2920
2930 public BlogsEntry findByC_U_First(long companyId, long userId,
2931 OrderByComparator orderByComparator)
2932 throws NoSuchEntryException, SystemException {
2933 BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
2934 orderByComparator);
2935
2936 if (blogsEntry != null) {
2937 return blogsEntry;
2938 }
2939
2940 StringBundler msg = new StringBundler(6);
2941
2942 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2943
2944 msg.append("companyId=");
2945 msg.append(companyId);
2946
2947 msg.append(", userId=");
2948 msg.append(userId);
2949
2950 msg.append(StringPool.CLOSE_CURLY_BRACE);
2951
2952 throw new NoSuchEntryException(msg.toString());
2953 }
2954
2955
2964 public BlogsEntry fetchByC_U_First(long companyId, long userId,
2965 OrderByComparator orderByComparator) throws SystemException {
2966 List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
2967 orderByComparator);
2968
2969 if (!list.isEmpty()) {
2970 return list.get(0);
2971 }
2972
2973 return null;
2974 }
2975
2976
2986 public BlogsEntry findByC_U_Last(long companyId, long userId,
2987 OrderByComparator orderByComparator)
2988 throws NoSuchEntryException, SystemException {
2989 BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
2990 orderByComparator);
2991
2992 if (blogsEntry != null) {
2993 return blogsEntry;
2994 }
2995
2996 StringBundler msg = new StringBundler(6);
2997
2998 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2999
3000 msg.append("companyId=");
3001 msg.append(companyId);
3002
3003 msg.append(", userId=");
3004 msg.append(userId);
3005
3006 msg.append(StringPool.CLOSE_CURLY_BRACE);
3007
3008 throw new NoSuchEntryException(msg.toString());
3009 }
3010
3011
3020 public BlogsEntry fetchByC_U_Last(long companyId, long userId,
3021 OrderByComparator orderByComparator) throws SystemException {
3022 int count = countByC_U(companyId, userId);
3023
3024 List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
3025 orderByComparator);
3026
3027 if (!list.isEmpty()) {
3028 return list.get(0);
3029 }
3030
3031 return null;
3032 }
3033
3034
3045 public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
3046 long userId, OrderByComparator orderByComparator)
3047 throws NoSuchEntryException, SystemException {
3048 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3049
3050 Session session = null;
3051
3052 try {
3053 session = openSession();
3054
3055 BlogsEntry[] array = new BlogsEntryImpl[3];
3056
3057 array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
3058 userId, orderByComparator, true);
3059
3060 array[1] = blogsEntry;
3061
3062 array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
3063 userId, orderByComparator, false);
3064
3065 return array;
3066 }
3067 catch (Exception e) {
3068 throw processException(e);
3069 }
3070 finally {
3071 closeSession(session);
3072 }
3073 }
3074
3075 protected BlogsEntry getByC_U_PrevAndNext(Session session,
3076 BlogsEntry blogsEntry, long companyId, long userId,
3077 OrderByComparator orderByComparator, boolean previous) {
3078 StringBundler query = null;
3079
3080 if (orderByComparator != null) {
3081 query = new StringBundler(6 +
3082 (orderByComparator.getOrderByFields().length * 6));
3083 }
3084 else {
3085 query = new StringBundler(3);
3086 }
3087
3088 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3089
3090 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
3091
3092 query.append(_FINDER_COLUMN_C_U_USERID_2);
3093
3094 if (orderByComparator != null) {
3095 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3096
3097 if (orderByConditionFields.length > 0) {
3098 query.append(WHERE_AND);
3099 }
3100
3101 for (int i = 0; i < orderByConditionFields.length; i++) {
3102 query.append(_ORDER_BY_ENTITY_ALIAS);
3103 query.append(orderByConditionFields[i]);
3104
3105 if ((i + 1) < orderByConditionFields.length) {
3106 if (orderByComparator.isAscending() ^ previous) {
3107 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3108 }
3109 else {
3110 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3111 }
3112 }
3113 else {
3114 if (orderByComparator.isAscending() ^ previous) {
3115 query.append(WHERE_GREATER_THAN);
3116 }
3117 else {
3118 query.append(WHERE_LESSER_THAN);
3119 }
3120 }
3121 }
3122
3123 query.append(ORDER_BY_CLAUSE);
3124
3125 String[] orderByFields = orderByComparator.getOrderByFields();
3126
3127 for (int i = 0; i < orderByFields.length; i++) {
3128 query.append(_ORDER_BY_ENTITY_ALIAS);
3129 query.append(orderByFields[i]);
3130
3131 if ((i + 1) < orderByFields.length) {
3132 if (orderByComparator.isAscending() ^ previous) {
3133 query.append(ORDER_BY_ASC_HAS_NEXT);
3134 }
3135 else {
3136 query.append(ORDER_BY_DESC_HAS_NEXT);
3137 }
3138 }
3139 else {
3140 if (orderByComparator.isAscending() ^ previous) {
3141 query.append(ORDER_BY_ASC);
3142 }
3143 else {
3144 query.append(ORDER_BY_DESC);
3145 }
3146 }
3147 }
3148 }
3149 else {
3150 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3151 }
3152
3153 String sql = query.toString();
3154
3155 Query q = session.createQuery(sql);
3156
3157 q.setFirstResult(0);
3158 q.setMaxResults(2);
3159
3160 QueryPos qPos = QueryPos.getInstance(q);
3161
3162 qPos.add(companyId);
3163
3164 qPos.add(userId);
3165
3166 if (orderByComparator != null) {
3167 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3168
3169 for (Object value : values) {
3170 qPos.add(value);
3171 }
3172 }
3173
3174 List<BlogsEntry> list = q.list();
3175
3176 if (list.size() == 2) {
3177 return list.get(1);
3178 }
3179 else {
3180 return null;
3181 }
3182 }
3183
3184
3191 public void removeByC_U(long companyId, long userId)
3192 throws SystemException {
3193 for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
3194 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3195 remove(blogsEntry);
3196 }
3197 }
3198
3199
3207 public int countByC_U(long companyId, long userId)
3208 throws SystemException {
3209 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
3210
3211 Object[] finderArgs = new Object[] { companyId, userId };
3212
3213 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3214 this);
3215
3216 if (count == null) {
3217 StringBundler query = new StringBundler(3);
3218
3219 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3220
3221 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
3222
3223 query.append(_FINDER_COLUMN_C_U_USERID_2);
3224
3225 String sql = query.toString();
3226
3227 Session session = null;
3228
3229 try {
3230 session = openSession();
3231
3232 Query q = session.createQuery(sql);
3233
3234 QueryPos qPos = QueryPos.getInstance(q);
3235
3236 qPos.add(companyId);
3237
3238 qPos.add(userId);
3239
3240 count = (Long)q.uniqueResult();
3241
3242 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3243 }
3244 catch (Exception e) {
3245 FinderCacheUtil.removeResult(finderPath, finderArgs);
3246
3247 throw processException(e);
3248 }
3249 finally {
3250 closeSession(session);
3251 }
3252 }
3253
3254 return count.intValue();
3255 }
3256
3257 private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
3258 private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
3259 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3260 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3261 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
3262 new String[] {
3263 Long.class.getName(), Date.class.getName(),
3264
3265 Integer.class.getName(), Integer.class.getName(),
3266 OrderByComparator.class.getName()
3267 });
3268 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3269 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3270 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
3271 new String[] { Long.class.getName(), Date.class.getName() });
3272
3273
3281 public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate)
3282 throws SystemException {
3283 return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
3284 QueryUtil.ALL_POS, null);
3285 }
3286
3287
3301 public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
3302 int start, int end) throws SystemException {
3303 return findByC_LtD(companyId, displayDate, start, end, null);
3304 }
3305
3306
3321 public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
3322 int start, int end, OrderByComparator orderByComparator)
3323 throws SystemException {
3324 boolean pagination = true;
3325 FinderPath finderPath = null;
3326 Object[] finderArgs = null;
3327
3328 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
3329 finderArgs = new Object[] {
3330 companyId, displayDate,
3331
3332 start, end, orderByComparator
3333 };
3334
3335 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3336 finderArgs, this);
3337
3338 if ((list != null) && !list.isEmpty()) {
3339 for (BlogsEntry blogsEntry : list) {
3340 if ((companyId != blogsEntry.getCompanyId()) ||
3341 !Validator.equals(displayDate,
3342 blogsEntry.getDisplayDate())) {
3343 list = null;
3344
3345 break;
3346 }
3347 }
3348 }
3349
3350 if (list == null) {
3351 StringBundler query = null;
3352
3353 if (orderByComparator != null) {
3354 query = new StringBundler(4 +
3355 (orderByComparator.getOrderByFields().length * 3));
3356 }
3357 else {
3358 query = new StringBundler(4);
3359 }
3360
3361 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3362
3363 query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3364
3365 boolean bindDisplayDate = false;
3366
3367 if (displayDate == null) {
3368 query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3369 }
3370 else {
3371 bindDisplayDate = true;
3372
3373 query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3374 }
3375
3376 if (orderByComparator != null) {
3377 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3378 orderByComparator);
3379 }
3380 else
3381 if (pagination) {
3382 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3383 }
3384
3385 String sql = query.toString();
3386
3387 Session session = null;
3388
3389 try {
3390 session = openSession();
3391
3392 Query q = session.createQuery(sql);
3393
3394 QueryPos qPos = QueryPos.getInstance(q);
3395
3396 qPos.add(companyId);
3397
3398 if (bindDisplayDate) {
3399 qPos.add(CalendarUtil.getTimestamp(displayDate));
3400 }
3401
3402 if (!pagination) {
3403 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3404 start, end, false);
3405
3406 Collections.sort(list);
3407
3408 list = new UnmodifiableList<BlogsEntry>(list);
3409 }
3410 else {
3411 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3412 start, end);
3413 }
3414
3415 cacheResult(list);
3416
3417 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3418 }
3419 catch (Exception e) {
3420 FinderCacheUtil.removeResult(finderPath, finderArgs);
3421
3422 throw processException(e);
3423 }
3424 finally {
3425 closeSession(session);
3426 }
3427 }
3428
3429 return list;
3430 }
3431
3432
3442 public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
3443 OrderByComparator orderByComparator)
3444 throws NoSuchEntryException, SystemException {
3445 BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
3446 orderByComparator);
3447
3448 if (blogsEntry != null) {
3449 return blogsEntry;
3450 }
3451
3452 StringBundler msg = new StringBundler(6);
3453
3454 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3455
3456 msg.append("companyId=");
3457 msg.append(companyId);
3458
3459 msg.append(", displayDate=");
3460 msg.append(displayDate);
3461
3462 msg.append(StringPool.CLOSE_CURLY_BRACE);
3463
3464 throw new NoSuchEntryException(msg.toString());
3465 }
3466
3467
3476 public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
3477 OrderByComparator orderByComparator) throws SystemException {
3478 List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
3479 orderByComparator);
3480
3481 if (!list.isEmpty()) {
3482 return list.get(0);
3483 }
3484
3485 return null;
3486 }
3487
3488
3498 public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
3499 OrderByComparator orderByComparator)
3500 throws NoSuchEntryException, SystemException {
3501 BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
3502 orderByComparator);
3503
3504 if (blogsEntry != null) {
3505 return blogsEntry;
3506 }
3507
3508 StringBundler msg = new StringBundler(6);
3509
3510 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3511
3512 msg.append("companyId=");
3513 msg.append(companyId);
3514
3515 msg.append(", displayDate=");
3516 msg.append(displayDate);
3517
3518 msg.append(StringPool.CLOSE_CURLY_BRACE);
3519
3520 throw new NoSuchEntryException(msg.toString());
3521 }
3522
3523
3532 public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
3533 OrderByComparator orderByComparator) throws SystemException {
3534 int count = countByC_LtD(companyId, displayDate);
3535
3536 List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
3537 count, orderByComparator);
3538
3539 if (!list.isEmpty()) {
3540 return list.get(0);
3541 }
3542
3543 return null;
3544 }
3545
3546
3557 public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
3558 Date displayDate, OrderByComparator orderByComparator)
3559 throws NoSuchEntryException, SystemException {
3560 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3561
3562 Session session = null;
3563
3564 try {
3565 session = openSession();
3566
3567 BlogsEntry[] array = new BlogsEntryImpl[3];
3568
3569 array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
3570 displayDate, orderByComparator, true);
3571
3572 array[1] = blogsEntry;
3573
3574 array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
3575 displayDate, orderByComparator, false);
3576
3577 return array;
3578 }
3579 catch (Exception e) {
3580 throw processException(e);
3581 }
3582 finally {
3583 closeSession(session);
3584 }
3585 }
3586
3587 protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
3588 BlogsEntry blogsEntry, long companyId, Date displayDate,
3589 OrderByComparator orderByComparator, boolean previous) {
3590 StringBundler query = null;
3591
3592 if (orderByComparator != null) {
3593 query = new StringBundler(6 +
3594 (orderByComparator.getOrderByFields().length * 6));
3595 }
3596 else {
3597 query = new StringBundler(3);
3598 }
3599
3600 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3601
3602 query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3603
3604 boolean bindDisplayDate = false;
3605
3606 if (displayDate == null) {
3607 query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3608 }
3609 else {
3610 bindDisplayDate = true;
3611
3612 query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3613 }
3614
3615 if (orderByComparator != null) {
3616 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3617
3618 if (orderByConditionFields.length > 0) {
3619 query.append(WHERE_AND);
3620 }
3621
3622 for (int i = 0; i < orderByConditionFields.length; i++) {
3623 query.append(_ORDER_BY_ENTITY_ALIAS);
3624 query.append(orderByConditionFields[i]);
3625
3626 if ((i + 1) < orderByConditionFields.length) {
3627 if (orderByComparator.isAscending() ^ previous) {
3628 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3629 }
3630 else {
3631 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3632 }
3633 }
3634 else {
3635 if (orderByComparator.isAscending() ^ previous) {
3636 query.append(WHERE_GREATER_THAN);
3637 }
3638 else {
3639 query.append(WHERE_LESSER_THAN);
3640 }
3641 }
3642 }
3643
3644 query.append(ORDER_BY_CLAUSE);
3645
3646 String[] orderByFields = orderByComparator.getOrderByFields();
3647
3648 for (int i = 0; i < orderByFields.length; i++) {
3649 query.append(_ORDER_BY_ENTITY_ALIAS);
3650 query.append(orderByFields[i]);
3651
3652 if ((i + 1) < orderByFields.length) {
3653 if (orderByComparator.isAscending() ^ previous) {
3654 query.append(ORDER_BY_ASC_HAS_NEXT);
3655 }
3656 else {
3657 query.append(ORDER_BY_DESC_HAS_NEXT);
3658 }
3659 }
3660 else {
3661 if (orderByComparator.isAscending() ^ previous) {
3662 query.append(ORDER_BY_ASC);
3663 }
3664 else {
3665 query.append(ORDER_BY_DESC);
3666 }
3667 }
3668 }
3669 }
3670 else {
3671 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3672 }
3673
3674 String sql = query.toString();
3675
3676 Query q = session.createQuery(sql);
3677
3678 q.setFirstResult(0);
3679 q.setMaxResults(2);
3680
3681 QueryPos qPos = QueryPos.getInstance(q);
3682
3683 qPos.add(companyId);
3684
3685 if (bindDisplayDate) {
3686 qPos.add(CalendarUtil.getTimestamp(displayDate));
3687 }
3688
3689 if (orderByComparator != null) {
3690 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3691
3692 for (Object value : values) {
3693 qPos.add(value);
3694 }
3695 }
3696
3697 List<BlogsEntry> list = q.list();
3698
3699 if (list.size() == 2) {
3700 return list.get(1);
3701 }
3702 else {
3703 return null;
3704 }
3705 }
3706
3707
3714 public void removeByC_LtD(long companyId, Date displayDate)
3715 throws SystemException {
3716 for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
3717 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3718 remove(blogsEntry);
3719 }
3720 }
3721
3722
3730 public int countByC_LtD(long companyId, Date displayDate)
3731 throws SystemException {
3732 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
3733
3734 Object[] finderArgs = new Object[] { companyId, displayDate };
3735
3736 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3737 this);
3738
3739 if (count == null) {
3740 StringBundler query = new StringBundler(3);
3741
3742 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3743
3744 query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3745
3746 boolean bindDisplayDate = false;
3747
3748 if (displayDate == null) {
3749 query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3750 }
3751 else {
3752 bindDisplayDate = true;
3753
3754 query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3755 }
3756
3757 String sql = query.toString();
3758
3759 Session session = null;
3760
3761 try {
3762 session = openSession();
3763
3764 Query q = session.createQuery(sql);
3765
3766 QueryPos qPos = QueryPos.getInstance(q);
3767
3768 qPos.add(companyId);
3769
3770 if (bindDisplayDate) {
3771 qPos.add(CalendarUtil.getTimestamp(displayDate));
3772 }
3773
3774 count = (Long)q.uniqueResult();
3775
3776 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3777 }
3778 catch (Exception e) {
3779 FinderCacheUtil.removeResult(finderPath, finderArgs);
3780
3781 throw processException(e);
3782 }
3783 finally {
3784 closeSession(session);
3785 }
3786 }
3787
3788 return count.intValue();
3789 }
3790
3791 private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
3792 private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
3793 private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
3794 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3795 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3796 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
3797 new String[] {
3798 Long.class.getName(), Integer.class.getName(),
3799
3800 Integer.class.getName(), Integer.class.getName(),
3801 OrderByComparator.class.getName()
3802 });
3803 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3804 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3805 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
3806 new String[] { Long.class.getName(), Integer.class.getName() });
3807
3808
3816 public List<BlogsEntry> findByC_NotS(long companyId, int status)
3817 throws SystemException {
3818 return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
3819 QueryUtil.ALL_POS, null);
3820 }
3821
3822
3836 public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
3837 int end) throws SystemException {
3838 return findByC_NotS(companyId, status, start, end, null);
3839 }
3840
3841
3856 public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
3857 int end, OrderByComparator orderByComparator) throws SystemException {
3858 boolean pagination = true;
3859 FinderPath finderPath = null;
3860 Object[] finderArgs = null;
3861
3862 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
3863 finderArgs = new Object[] {
3864 companyId, status,
3865
3866 start, end, orderByComparator
3867 };
3868
3869 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3870 finderArgs, this);
3871
3872 if ((list != null) && !list.isEmpty()) {
3873 for (BlogsEntry blogsEntry : list) {
3874 if ((companyId != blogsEntry.getCompanyId()) ||
3875 (status != blogsEntry.getStatus())) {
3876 list = null;
3877
3878 break;
3879 }
3880 }
3881 }
3882
3883 if (list == null) {
3884 StringBundler query = null;
3885
3886 if (orderByComparator != null) {
3887 query = new StringBundler(4 +
3888 (orderByComparator.getOrderByFields().length * 3));
3889 }
3890 else {
3891 query = new StringBundler(4);
3892 }
3893
3894 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3895
3896 query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
3897
3898 query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
3899
3900 if (orderByComparator != null) {
3901 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3902 orderByComparator);
3903 }
3904 else
3905 if (pagination) {
3906 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3907 }
3908
3909 String sql = query.toString();
3910
3911 Session session = null;
3912
3913 try {
3914 session = openSession();
3915
3916 Query q = session.createQuery(sql);
3917
3918 QueryPos qPos = QueryPos.getInstance(q);
3919
3920 qPos.add(companyId);
3921
3922 qPos.add(status);
3923
3924 if (!pagination) {
3925 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3926 start, end, false);
3927
3928 Collections.sort(list);
3929
3930 list = new UnmodifiableList<BlogsEntry>(list);
3931 }
3932 else {
3933 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3934 start, end);
3935 }
3936
3937 cacheResult(list);
3938
3939 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3940 }
3941 catch (Exception e) {
3942 FinderCacheUtil.removeResult(finderPath, finderArgs);
3943
3944 throw processException(e);
3945 }
3946 finally {
3947 closeSession(session);
3948 }
3949 }
3950
3951 return list;
3952 }
3953
3954
3964 public BlogsEntry findByC_NotS_First(long companyId, int status,
3965 OrderByComparator orderByComparator)
3966 throws NoSuchEntryException, SystemException {
3967 BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
3968 orderByComparator);
3969
3970 if (blogsEntry != null) {
3971 return blogsEntry;
3972 }
3973
3974 StringBundler msg = new StringBundler(6);
3975
3976 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3977
3978 msg.append("companyId=");
3979 msg.append(companyId);
3980
3981 msg.append(", status=");
3982 msg.append(status);
3983
3984 msg.append(StringPool.CLOSE_CURLY_BRACE);
3985
3986 throw new NoSuchEntryException(msg.toString());
3987 }
3988
3989
3998 public BlogsEntry fetchByC_NotS_First(long companyId, int status,
3999 OrderByComparator orderByComparator) throws SystemException {
4000 List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
4001 orderByComparator);
4002
4003 if (!list.isEmpty()) {
4004 return list.get(0);
4005 }
4006
4007 return null;
4008 }
4009
4010
4020 public BlogsEntry findByC_NotS_Last(long companyId, int status,
4021 OrderByComparator orderByComparator)
4022 throws NoSuchEntryException, SystemException {
4023 BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
4024 orderByComparator);
4025
4026 if (blogsEntry != null) {
4027 return blogsEntry;
4028 }
4029
4030 StringBundler msg = new StringBundler(6);
4031
4032 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4033
4034 msg.append("companyId=");
4035 msg.append(companyId);
4036
4037 msg.append(", status=");
4038 msg.append(status);
4039
4040 msg.append(StringPool.CLOSE_CURLY_BRACE);
4041
4042 throw new NoSuchEntryException(msg.toString());
4043 }
4044
4045
4054 public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
4055 OrderByComparator orderByComparator) throws SystemException {
4056 int count = countByC_NotS(companyId, status);
4057
4058 List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
4059 count, orderByComparator);
4060
4061 if (!list.isEmpty()) {
4062 return list.get(0);
4063 }
4064
4065 return null;
4066 }
4067
4068
4079 public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
4080 int status, OrderByComparator orderByComparator)
4081 throws NoSuchEntryException, SystemException {
4082 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4083
4084 Session session = null;
4085
4086 try {
4087 session = openSession();
4088
4089 BlogsEntry[] array = new BlogsEntryImpl[3];
4090
4091 array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
4092 status, orderByComparator, true);
4093
4094 array[1] = blogsEntry;
4095
4096 array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
4097 status, orderByComparator, false);
4098
4099 return array;
4100 }
4101 catch (Exception e) {
4102 throw processException(e);
4103 }
4104 finally {
4105 closeSession(session);
4106 }
4107 }
4108
4109 protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
4110 BlogsEntry blogsEntry, long companyId, int status,
4111 OrderByComparator orderByComparator, boolean previous) {
4112 StringBundler query = null;
4113
4114 if (orderByComparator != null) {
4115 query = new StringBundler(6 +
4116 (orderByComparator.getOrderByFields().length * 6));
4117 }
4118 else {
4119 query = new StringBundler(3);
4120 }
4121
4122 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4123
4124 query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4125
4126 query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4127
4128 if (orderByComparator != null) {
4129 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4130
4131 if (orderByConditionFields.length > 0) {
4132 query.append(WHERE_AND);
4133 }
4134
4135 for (int i = 0; i < orderByConditionFields.length; i++) {
4136 query.append(_ORDER_BY_ENTITY_ALIAS);
4137 query.append(orderByConditionFields[i]);
4138
4139 if ((i + 1) < orderByConditionFields.length) {
4140 if (orderByComparator.isAscending() ^ previous) {
4141 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4142 }
4143 else {
4144 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4145 }
4146 }
4147 else {
4148 if (orderByComparator.isAscending() ^ previous) {
4149 query.append(WHERE_GREATER_THAN);
4150 }
4151 else {
4152 query.append(WHERE_LESSER_THAN);
4153 }
4154 }
4155 }
4156
4157 query.append(ORDER_BY_CLAUSE);
4158
4159 String[] orderByFields = orderByComparator.getOrderByFields();
4160
4161 for (int i = 0; i < orderByFields.length; i++) {
4162 query.append(_ORDER_BY_ENTITY_ALIAS);
4163 query.append(orderByFields[i]);
4164
4165 if ((i + 1) < orderByFields.length) {
4166 if (orderByComparator.isAscending() ^ previous) {
4167 query.append(ORDER_BY_ASC_HAS_NEXT);
4168 }
4169 else {
4170 query.append(ORDER_BY_DESC_HAS_NEXT);
4171 }
4172 }
4173 else {
4174 if (orderByComparator.isAscending() ^ previous) {
4175 query.append(ORDER_BY_ASC);
4176 }
4177 else {
4178 query.append(ORDER_BY_DESC);
4179 }
4180 }
4181 }
4182 }
4183 else {
4184 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4185 }
4186
4187 String sql = query.toString();
4188
4189 Query q = session.createQuery(sql);
4190
4191 q.setFirstResult(0);
4192 q.setMaxResults(2);
4193
4194 QueryPos qPos = QueryPos.getInstance(q);
4195
4196 qPos.add(companyId);
4197
4198 qPos.add(status);
4199
4200 if (orderByComparator != null) {
4201 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4202
4203 for (Object value : values) {
4204 qPos.add(value);
4205 }
4206 }
4207
4208 List<BlogsEntry> list = q.list();
4209
4210 if (list.size() == 2) {
4211 return list.get(1);
4212 }
4213 else {
4214 return null;
4215 }
4216 }
4217
4218
4225 public void removeByC_NotS(long companyId, int status)
4226 throws SystemException {
4227 for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
4228 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4229 remove(blogsEntry);
4230 }
4231 }
4232
4233
4241 public int countByC_NotS(long companyId, int status)
4242 throws SystemException {
4243 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
4244
4245 Object[] finderArgs = new Object[] { companyId, status };
4246
4247 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4248 this);
4249
4250 if (count == null) {
4251 StringBundler query = new StringBundler(3);
4252
4253 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4254
4255 query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4256
4257 query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4258
4259 String sql = query.toString();
4260
4261 Session session = null;
4262
4263 try {
4264 session = openSession();
4265
4266 Query q = session.createQuery(sql);
4267
4268 QueryPos qPos = QueryPos.getInstance(q);
4269
4270 qPos.add(companyId);
4271
4272 qPos.add(status);
4273
4274 count = (Long)q.uniqueResult();
4275
4276 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4277 }
4278 catch (Exception e) {
4279 FinderCacheUtil.removeResult(finderPath, finderArgs);
4280
4281 throw processException(e);
4282 }
4283 finally {
4284 closeSession(session);
4285 }
4286 }
4287
4288 return count.intValue();
4289 }
4290
4291 private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
4292 private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
4293 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4294 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4295 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
4296 new String[] {
4297 Long.class.getName(), Integer.class.getName(),
4298
4299 Integer.class.getName(), Integer.class.getName(),
4300 OrderByComparator.class.getName()
4301 });
4302 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4303 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4304 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
4305 new String[] { Long.class.getName(), Integer.class.getName() },
4306 BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
4307 BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
4308 BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
4309 BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
4310 public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4311 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4312 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
4313 new String[] { Long.class.getName(), Integer.class.getName() });
4314
4315
4323 public List<BlogsEntry> findByC_S(long companyId, int status)
4324 throws SystemException {
4325 return findByC_S(companyId, status, QueryUtil.ALL_POS,
4326 QueryUtil.ALL_POS, null);
4327 }
4328
4329
4343 public List<BlogsEntry> findByC_S(long companyId, int status, int start,
4344 int end) throws SystemException {
4345 return findByC_S(companyId, status, start, end, null);
4346 }
4347
4348
4363 public List<BlogsEntry> findByC_S(long companyId, int status, int start,
4364 int end, OrderByComparator orderByComparator) throws SystemException {
4365 boolean pagination = true;
4366 FinderPath finderPath = null;
4367 Object[] finderArgs = null;
4368
4369 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4370 (orderByComparator == null)) {
4371 pagination = false;
4372 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
4373 finderArgs = new Object[] { companyId, status };
4374 }
4375 else {
4376 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
4377 finderArgs = new Object[] {
4378 companyId, status,
4379
4380 start, end, orderByComparator
4381 };
4382 }
4383
4384 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4385 finderArgs, this);
4386
4387 if ((list != null) && !list.isEmpty()) {
4388 for (BlogsEntry blogsEntry : list) {
4389 if ((companyId != blogsEntry.getCompanyId()) ||
4390 (status != blogsEntry.getStatus())) {
4391 list = null;
4392
4393 break;
4394 }
4395 }
4396 }
4397
4398 if (list == null) {
4399 StringBundler query = null;
4400
4401 if (orderByComparator != null) {
4402 query = new StringBundler(4 +
4403 (orderByComparator.getOrderByFields().length * 3));
4404 }
4405 else {
4406 query = new StringBundler(4);
4407 }
4408
4409 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4410
4411 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4412
4413 query.append(_FINDER_COLUMN_C_S_STATUS_2);
4414
4415 if (orderByComparator != null) {
4416 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4417 orderByComparator);
4418 }
4419 else
4420 if (pagination) {
4421 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4422 }
4423
4424 String sql = query.toString();
4425
4426 Session session = null;
4427
4428 try {
4429 session = openSession();
4430
4431 Query q = session.createQuery(sql);
4432
4433 QueryPos qPos = QueryPos.getInstance(q);
4434
4435 qPos.add(companyId);
4436
4437 qPos.add(status);
4438
4439 if (!pagination) {
4440 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4441 start, end, false);
4442
4443 Collections.sort(list);
4444
4445 list = new UnmodifiableList<BlogsEntry>(list);
4446 }
4447 else {
4448 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4449 start, end);
4450 }
4451
4452 cacheResult(list);
4453
4454 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4455 }
4456 catch (Exception e) {
4457 FinderCacheUtil.removeResult(finderPath, finderArgs);
4458
4459 throw processException(e);
4460 }
4461 finally {
4462 closeSession(session);
4463 }
4464 }
4465
4466 return list;
4467 }
4468
4469
4479 public BlogsEntry findByC_S_First(long companyId, int status,
4480 OrderByComparator orderByComparator)
4481 throws NoSuchEntryException, SystemException {
4482 BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
4483 orderByComparator);
4484
4485 if (blogsEntry != null) {
4486 return blogsEntry;
4487 }
4488
4489 StringBundler msg = new StringBundler(6);
4490
4491 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4492
4493 msg.append("companyId=");
4494 msg.append(companyId);
4495
4496 msg.append(", status=");
4497 msg.append(status);
4498
4499 msg.append(StringPool.CLOSE_CURLY_BRACE);
4500
4501 throw new NoSuchEntryException(msg.toString());
4502 }
4503
4504
4513 public BlogsEntry fetchByC_S_First(long companyId, int status,
4514 OrderByComparator orderByComparator) throws SystemException {
4515 List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
4516 orderByComparator);
4517
4518 if (!list.isEmpty()) {
4519 return list.get(0);
4520 }
4521
4522 return null;
4523 }
4524
4525
4535 public BlogsEntry findByC_S_Last(long companyId, int status,
4536 OrderByComparator orderByComparator)
4537 throws NoSuchEntryException, SystemException {
4538 BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
4539 orderByComparator);
4540
4541 if (blogsEntry != null) {
4542 return blogsEntry;
4543 }
4544
4545 StringBundler msg = new StringBundler(6);
4546
4547 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4548
4549 msg.append("companyId=");
4550 msg.append(companyId);
4551
4552 msg.append(", status=");
4553 msg.append(status);
4554
4555 msg.append(StringPool.CLOSE_CURLY_BRACE);
4556
4557 throw new NoSuchEntryException(msg.toString());
4558 }
4559
4560
4569 public BlogsEntry fetchByC_S_Last(long companyId, int status,
4570 OrderByComparator orderByComparator) throws SystemException {
4571 int count = countByC_S(companyId, status);
4572
4573 List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
4574 orderByComparator);
4575
4576 if (!list.isEmpty()) {
4577 return list.get(0);
4578 }
4579
4580 return null;
4581 }
4582
4583
4594 public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
4595 int status, OrderByComparator orderByComparator)
4596 throws NoSuchEntryException, SystemException {
4597 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4598
4599 Session session = null;
4600
4601 try {
4602 session = openSession();
4603
4604 BlogsEntry[] array = new BlogsEntryImpl[3];
4605
4606 array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
4607 status, orderByComparator, true);
4608
4609 array[1] = blogsEntry;
4610
4611 array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
4612 status, orderByComparator, false);
4613
4614 return array;
4615 }
4616 catch (Exception e) {
4617 throw processException(e);
4618 }
4619 finally {
4620 closeSession(session);
4621 }
4622 }
4623
4624 protected BlogsEntry getByC_S_PrevAndNext(Session session,
4625 BlogsEntry blogsEntry, long companyId, int status,
4626 OrderByComparator orderByComparator, boolean previous) {
4627 StringBundler query = null;
4628
4629 if (orderByComparator != null) {
4630 query = new StringBundler(6 +
4631 (orderByComparator.getOrderByFields().length * 6));
4632 }
4633 else {
4634 query = new StringBundler(3);
4635 }
4636
4637 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4638
4639 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4640
4641 query.append(_FINDER_COLUMN_C_S_STATUS_2);
4642
4643 if (orderByComparator != null) {
4644 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4645
4646 if (orderByConditionFields.length > 0) {
4647 query.append(WHERE_AND);
4648 }
4649
4650 for (int i = 0; i < orderByConditionFields.length; i++) {
4651 query.append(_ORDER_BY_ENTITY_ALIAS);
4652 query.append(orderByConditionFields[i]);
4653
4654 if ((i + 1) < orderByConditionFields.length) {
4655 if (orderByComparator.isAscending() ^ previous) {
4656 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4657 }
4658 else {
4659 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4660 }
4661 }
4662 else {
4663 if (orderByComparator.isAscending() ^ previous) {
4664 query.append(WHERE_GREATER_THAN);
4665 }
4666 else {
4667 query.append(WHERE_LESSER_THAN);
4668 }
4669 }
4670 }
4671
4672 query.append(ORDER_BY_CLAUSE);
4673
4674 String[] orderByFields = orderByComparator.getOrderByFields();
4675
4676 for (int i = 0; i < orderByFields.length; i++) {
4677 query.append(_ORDER_BY_ENTITY_ALIAS);
4678 query.append(orderByFields[i]);
4679
4680 if ((i + 1) < orderByFields.length) {
4681 if (orderByComparator.isAscending() ^ previous) {
4682 query.append(ORDER_BY_ASC_HAS_NEXT);
4683 }
4684 else {
4685 query.append(ORDER_BY_DESC_HAS_NEXT);
4686 }
4687 }
4688 else {
4689 if (orderByComparator.isAscending() ^ previous) {
4690 query.append(ORDER_BY_ASC);
4691 }
4692 else {
4693 query.append(ORDER_BY_DESC);
4694 }
4695 }
4696 }
4697 }
4698 else {
4699 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4700 }
4701
4702 String sql = query.toString();
4703
4704 Query q = session.createQuery(sql);
4705
4706 q.setFirstResult(0);
4707 q.setMaxResults(2);
4708
4709 QueryPos qPos = QueryPos.getInstance(q);
4710
4711 qPos.add(companyId);
4712
4713 qPos.add(status);
4714
4715 if (orderByComparator != null) {
4716 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4717
4718 for (Object value : values) {
4719 qPos.add(value);
4720 }
4721 }
4722
4723 List<BlogsEntry> list = q.list();
4724
4725 if (list.size() == 2) {
4726 return list.get(1);
4727 }
4728 else {
4729 return null;
4730 }
4731 }
4732
4733
4740 public void removeByC_S(long companyId, int status)
4741 throws SystemException {
4742 for (BlogsEntry blogsEntry : findByC_S(companyId, status,
4743 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4744 remove(blogsEntry);
4745 }
4746 }
4747
4748
4756 public int countByC_S(long companyId, int status) throws SystemException {
4757 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
4758
4759 Object[] finderArgs = new Object[] { companyId, status };
4760
4761 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4762 this);
4763
4764 if (count == null) {
4765 StringBundler query = new StringBundler(3);
4766
4767 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4768
4769 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4770
4771 query.append(_FINDER_COLUMN_C_S_STATUS_2);
4772
4773 String sql = query.toString();
4774
4775 Session session = null;
4776
4777 try {
4778 session = openSession();
4779
4780 Query q = session.createQuery(sql);
4781
4782 QueryPos qPos = QueryPos.getInstance(q);
4783
4784 qPos.add(companyId);
4785
4786 qPos.add(status);
4787
4788 count = (Long)q.uniqueResult();
4789
4790 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4791 }
4792 catch (Exception e) {
4793 FinderCacheUtil.removeResult(finderPath, finderArgs);
4794
4795 throw processException(e);
4796 }
4797 finally {
4798 closeSession(session);
4799 }
4800 }
4801
4802 return count.intValue();
4803 }
4804
4805 private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
4806 private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
4807 public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4808 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4809 FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
4810 new String[] { Long.class.getName(), String.class.getName() },
4811 BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
4812 BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
4813 public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4814 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4815 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
4816 new String[] { Long.class.getName(), String.class.getName() });
4817
4818
4827 public BlogsEntry findByG_UT(long groupId, String urlTitle)
4828 throws NoSuchEntryException, SystemException {
4829 BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
4830
4831 if (blogsEntry == null) {
4832 StringBundler msg = new StringBundler(6);
4833
4834 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4835
4836 msg.append("groupId=");
4837 msg.append(groupId);
4838
4839 msg.append(", urlTitle=");
4840 msg.append(urlTitle);
4841
4842 msg.append(StringPool.CLOSE_CURLY_BRACE);
4843
4844 if (_log.isWarnEnabled()) {
4845 _log.warn(msg.toString());
4846 }
4847
4848 throw new NoSuchEntryException(msg.toString());
4849 }
4850
4851 return blogsEntry;
4852 }
4853
4854
4862 public BlogsEntry fetchByG_UT(long groupId, String urlTitle)
4863 throws SystemException {
4864 return fetchByG_UT(groupId, urlTitle, true);
4865 }
4866
4867
4876 public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
4877 boolean retrieveFromCache) throws SystemException {
4878 Object[] finderArgs = new Object[] { groupId, urlTitle };
4879
4880 Object result = null;
4881
4882 if (retrieveFromCache) {
4883 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_UT,
4884 finderArgs, this);
4885 }
4886
4887 if (result instanceof BlogsEntry) {
4888 BlogsEntry blogsEntry = (BlogsEntry)result;
4889
4890 if ((groupId != blogsEntry.getGroupId()) ||
4891 !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
4892 result = null;
4893 }
4894 }
4895
4896 if (result == null) {
4897 StringBundler query = new StringBundler(4);
4898
4899 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4900
4901 query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
4902
4903 boolean bindUrlTitle = false;
4904
4905 if (urlTitle == null) {
4906 query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
4907 }
4908 else if (urlTitle.equals(StringPool.BLANK)) {
4909 query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
4910 }
4911 else {
4912 bindUrlTitle = true;
4913
4914 query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
4915 }
4916
4917 String sql = query.toString();
4918
4919 Session session = null;
4920
4921 try {
4922 session = openSession();
4923
4924 Query q = session.createQuery(sql);
4925
4926 QueryPos qPos = QueryPos.getInstance(q);
4927
4928 qPos.add(groupId);
4929
4930 if (bindUrlTitle) {
4931 qPos.add(urlTitle);
4932 }
4933
4934 List<BlogsEntry> list = q.list();
4935
4936 if (list.isEmpty()) {
4937 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
4938 finderArgs, list);
4939 }
4940 else {
4941 BlogsEntry blogsEntry = list.get(0);
4942
4943 result = blogsEntry;
4944
4945 cacheResult(blogsEntry);
4946
4947 if ((blogsEntry.getGroupId() != groupId) ||
4948 (blogsEntry.getUrlTitle() == null) ||
4949 !blogsEntry.getUrlTitle().equals(urlTitle)) {
4950 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
4951 finderArgs, blogsEntry);
4952 }
4953 }
4954 }
4955 catch (Exception e) {
4956 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT,
4957 finderArgs);
4958
4959 throw processException(e);
4960 }
4961 finally {
4962 closeSession(session);
4963 }
4964 }
4965
4966 if (result instanceof List<?>) {
4967 return null;
4968 }
4969 else {
4970 return (BlogsEntry)result;
4971 }
4972 }
4973
4974
4982 public BlogsEntry removeByG_UT(long groupId, String urlTitle)
4983 throws NoSuchEntryException, SystemException {
4984 BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
4985
4986 return remove(blogsEntry);
4987 }
4988
4989
4997 public int countByG_UT(long groupId, String urlTitle)
4998 throws SystemException {
4999 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
5000
5001 Object[] finderArgs = new Object[] { groupId, urlTitle };
5002
5003 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5004 this);
5005
5006 if (count == null) {
5007 StringBundler query = new StringBundler(3);
5008
5009 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5010
5011 query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5012
5013 boolean bindUrlTitle = false;
5014
5015 if (urlTitle == null) {
5016 query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5017 }
5018 else if (urlTitle.equals(StringPool.BLANK)) {
5019 query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5020 }
5021 else {
5022 bindUrlTitle = true;
5023
5024 query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5025 }
5026
5027 String sql = query.toString();
5028
5029 Session session = null;
5030
5031 try {
5032 session = openSession();
5033
5034 Query q = session.createQuery(sql);
5035
5036 QueryPos qPos = QueryPos.getInstance(q);
5037
5038 qPos.add(groupId);
5039
5040 if (bindUrlTitle) {
5041 qPos.add(urlTitle);
5042 }
5043
5044 count = (Long)q.uniqueResult();
5045
5046 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5047 }
5048 catch (Exception e) {
5049 FinderCacheUtil.removeResult(finderPath, finderArgs);
5050
5051 throw processException(e);
5052 }
5053 finally {
5054 closeSession(session);
5055 }
5056 }
5057
5058 return count.intValue();
5059 }
5060
5061 private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5062 private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
5063 private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
5064 private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
5065 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5066 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5067 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
5068 new String[] {
5069 Long.class.getName(), Date.class.getName(),
5070
5071 Integer.class.getName(), Integer.class.getName(),
5072 OrderByComparator.class.getName()
5073 });
5074 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5075 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5076 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
5077 new String[] { Long.class.getName(), Date.class.getName() });
5078
5079
5087 public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate)
5088 throws SystemException {
5089 return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
5090 QueryUtil.ALL_POS, null);
5091 }
5092
5093
5107 public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
5108 int start, int end) throws SystemException {
5109 return findByG_LtD(groupId, displayDate, start, end, null);
5110 }
5111
5112
5127 public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
5128 int start, int end, OrderByComparator orderByComparator)
5129 throws SystemException {
5130 boolean pagination = true;
5131 FinderPath finderPath = null;
5132 Object[] finderArgs = null;
5133
5134 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
5135 finderArgs = new Object[] {
5136 groupId, displayDate,
5137
5138 start, end, orderByComparator
5139 };
5140
5141 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
5142 finderArgs, this);
5143
5144 if ((list != null) && !list.isEmpty()) {
5145 for (BlogsEntry blogsEntry : list) {
5146 if ((groupId != blogsEntry.getGroupId()) ||
5147 !Validator.equals(displayDate,
5148 blogsEntry.getDisplayDate())) {
5149 list = null;
5150
5151 break;
5152 }
5153 }
5154 }
5155
5156 if (list == null) {
5157 StringBundler query = null;
5158
5159 if (orderByComparator != null) {
5160 query = new StringBundler(4 +
5161 (orderByComparator.getOrderByFields().length * 3));
5162 }
5163 else {
5164 query = new StringBundler(4);
5165 }
5166
5167 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5168
5169 query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5170
5171 boolean bindDisplayDate = false;
5172
5173 if (displayDate == null) {
5174 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5175 }
5176 else {
5177 bindDisplayDate = true;
5178
5179 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5180 }
5181
5182 if (orderByComparator != null) {
5183 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5184 orderByComparator);
5185 }
5186 else
5187 if (pagination) {
5188 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5189 }
5190
5191 String sql = query.toString();
5192
5193 Session session = null;
5194
5195 try {
5196 session = openSession();
5197
5198 Query q = session.createQuery(sql);
5199
5200 QueryPos qPos = QueryPos.getInstance(q);
5201
5202 qPos.add(groupId);
5203
5204 if (bindDisplayDate) {
5205 qPos.add(CalendarUtil.getTimestamp(displayDate));
5206 }
5207
5208 if (!pagination) {
5209 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5210 start, end, false);
5211
5212 Collections.sort(list);
5213
5214 list = new UnmodifiableList<BlogsEntry>(list);
5215 }
5216 else {
5217 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5218 start, end);
5219 }
5220
5221 cacheResult(list);
5222
5223 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5224 }
5225 catch (Exception e) {
5226 FinderCacheUtil.removeResult(finderPath, finderArgs);
5227
5228 throw processException(e);
5229 }
5230 finally {
5231 closeSession(session);
5232 }
5233 }
5234
5235 return list;
5236 }
5237
5238
5248 public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
5249 OrderByComparator orderByComparator)
5250 throws NoSuchEntryException, SystemException {
5251 BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
5252 orderByComparator);
5253
5254 if (blogsEntry != null) {
5255 return blogsEntry;
5256 }
5257
5258 StringBundler msg = new StringBundler(6);
5259
5260 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5261
5262 msg.append("groupId=");
5263 msg.append(groupId);
5264
5265 msg.append(", displayDate=");
5266 msg.append(displayDate);
5267
5268 msg.append(StringPool.CLOSE_CURLY_BRACE);
5269
5270 throw new NoSuchEntryException(msg.toString());
5271 }
5272
5273
5282 public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
5283 OrderByComparator orderByComparator) throws SystemException {
5284 List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
5285 orderByComparator);
5286
5287 if (!list.isEmpty()) {
5288 return list.get(0);
5289 }
5290
5291 return null;
5292 }
5293
5294
5304 public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
5305 OrderByComparator orderByComparator)
5306 throws NoSuchEntryException, SystemException {
5307 BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
5308 orderByComparator);
5309
5310 if (blogsEntry != null) {
5311 return blogsEntry;
5312 }
5313
5314 StringBundler msg = new StringBundler(6);
5315
5316 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5317
5318 msg.append("groupId=");
5319 msg.append(groupId);
5320
5321 msg.append(", displayDate=");
5322 msg.append(displayDate);
5323
5324 msg.append(StringPool.CLOSE_CURLY_BRACE);
5325
5326 throw new NoSuchEntryException(msg.toString());
5327 }
5328
5329
5338 public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
5339 OrderByComparator orderByComparator) throws SystemException {
5340 int count = countByG_LtD(groupId, displayDate);
5341
5342 List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
5343 count, orderByComparator);
5344
5345 if (!list.isEmpty()) {
5346 return list.get(0);
5347 }
5348
5349 return null;
5350 }
5351
5352
5363 public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
5364 Date displayDate, OrderByComparator orderByComparator)
5365 throws NoSuchEntryException, SystemException {
5366 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5367
5368 Session session = null;
5369
5370 try {
5371 session = openSession();
5372
5373 BlogsEntry[] array = new BlogsEntryImpl[3];
5374
5375 array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
5376 displayDate, orderByComparator, true);
5377
5378 array[1] = blogsEntry;
5379
5380 array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
5381 displayDate, orderByComparator, false);
5382
5383 return array;
5384 }
5385 catch (Exception e) {
5386 throw processException(e);
5387 }
5388 finally {
5389 closeSession(session);
5390 }
5391 }
5392
5393 protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
5394 BlogsEntry blogsEntry, long groupId, Date displayDate,
5395 OrderByComparator orderByComparator, boolean previous) {
5396 StringBundler query = null;
5397
5398 if (orderByComparator != null) {
5399 query = new StringBundler(6 +
5400 (orderByComparator.getOrderByFields().length * 6));
5401 }
5402 else {
5403 query = new StringBundler(3);
5404 }
5405
5406 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5407
5408 query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5409
5410 boolean bindDisplayDate = false;
5411
5412 if (displayDate == null) {
5413 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5414 }
5415 else {
5416 bindDisplayDate = true;
5417
5418 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5419 }
5420
5421 if (orderByComparator != null) {
5422 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5423
5424 if (orderByConditionFields.length > 0) {
5425 query.append(WHERE_AND);
5426 }
5427
5428 for (int i = 0; i < orderByConditionFields.length; i++) {
5429 query.append(_ORDER_BY_ENTITY_ALIAS);
5430 query.append(orderByConditionFields[i]);
5431
5432 if ((i + 1) < orderByConditionFields.length) {
5433 if (orderByComparator.isAscending() ^ previous) {
5434 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5435 }
5436 else {
5437 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5438 }
5439 }
5440 else {
5441 if (orderByComparator.isAscending() ^ previous) {
5442 query.append(WHERE_GREATER_THAN);
5443 }
5444 else {
5445 query.append(WHERE_LESSER_THAN);
5446 }
5447 }
5448 }
5449
5450 query.append(ORDER_BY_CLAUSE);
5451
5452 String[] orderByFields = orderByComparator.getOrderByFields();
5453
5454 for (int i = 0; i < orderByFields.length; i++) {
5455 query.append(_ORDER_BY_ENTITY_ALIAS);
5456 query.append(orderByFields[i]);
5457
5458 if ((i + 1) < orderByFields.length) {
5459 if (orderByComparator.isAscending() ^ previous) {
5460 query.append(ORDER_BY_ASC_HAS_NEXT);
5461 }
5462 else {
5463 query.append(ORDER_BY_DESC_HAS_NEXT);
5464 }
5465 }
5466 else {
5467 if (orderByComparator.isAscending() ^ previous) {
5468 query.append(ORDER_BY_ASC);
5469 }
5470 else {
5471 query.append(ORDER_BY_DESC);
5472 }
5473 }
5474 }
5475 }
5476 else {
5477 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5478 }
5479
5480 String sql = query.toString();
5481
5482 Query q = session.createQuery(sql);
5483
5484 q.setFirstResult(0);
5485 q.setMaxResults(2);
5486
5487 QueryPos qPos = QueryPos.getInstance(q);
5488
5489 qPos.add(groupId);
5490
5491 if (bindDisplayDate) {
5492 qPos.add(CalendarUtil.getTimestamp(displayDate));
5493 }
5494
5495 if (orderByComparator != null) {
5496 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5497
5498 for (Object value : values) {
5499 qPos.add(value);
5500 }
5501 }
5502
5503 List<BlogsEntry> list = q.list();
5504
5505 if (list.size() == 2) {
5506 return list.get(1);
5507 }
5508 else {
5509 return null;
5510 }
5511 }
5512
5513
5521 public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate)
5522 throws SystemException {
5523 return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
5524 QueryUtil.ALL_POS, null);
5525 }
5526
5527
5541 public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
5542 int start, int end) throws SystemException {
5543 return filterFindByG_LtD(groupId, displayDate, start, end, null);
5544 }
5545
5546
5561 public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
5562 int start, int end, OrderByComparator orderByComparator)
5563 throws SystemException {
5564 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5565 return findByG_LtD(groupId, displayDate, start, end,
5566 orderByComparator);
5567 }
5568
5569 StringBundler query = null;
5570
5571 if (orderByComparator != null) {
5572 query = new StringBundler(4 +
5573 (orderByComparator.getOrderByFields().length * 3));
5574 }
5575 else {
5576 query = new StringBundler(4);
5577 }
5578
5579 if (getDB().isSupportsInlineDistinct()) {
5580 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5581 }
5582 else {
5583 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5584 }
5585
5586 query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5587
5588 boolean bindDisplayDate = false;
5589
5590 if (displayDate == null) {
5591 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5592 }
5593 else {
5594 bindDisplayDate = true;
5595
5596 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5597 }
5598
5599 if (!getDB().isSupportsInlineDistinct()) {
5600 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5601 }
5602
5603 if (orderByComparator != null) {
5604 if (getDB().isSupportsInlineDistinct()) {
5605 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5606 orderByComparator, true);
5607 }
5608 else {
5609 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5610 orderByComparator, true);
5611 }
5612 }
5613 else {
5614 if (getDB().isSupportsInlineDistinct()) {
5615 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5616 }
5617 else {
5618 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5619 }
5620 }
5621
5622 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5623 BlogsEntry.class.getName(),
5624 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5625
5626 Session session = null;
5627
5628 try {
5629 session = openSession();
5630
5631 SQLQuery q = session.createSQLQuery(sql);
5632
5633 if (getDB().isSupportsInlineDistinct()) {
5634 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5635 }
5636 else {
5637 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5638 }
5639
5640 QueryPos qPos = QueryPos.getInstance(q);
5641
5642 qPos.add(groupId);
5643
5644 if (bindDisplayDate) {
5645 qPos.add(CalendarUtil.getTimestamp(displayDate));
5646 }
5647
5648 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5649 }
5650 catch (Exception e) {
5651 throw processException(e);
5652 }
5653 finally {
5654 closeSession(session);
5655 }
5656 }
5657
5658
5669 public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
5670 long groupId, Date displayDate, OrderByComparator orderByComparator)
5671 throws NoSuchEntryException, SystemException {
5672 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5673 return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
5674 orderByComparator);
5675 }
5676
5677 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5678
5679 Session session = null;
5680
5681 try {
5682 session = openSession();
5683
5684 BlogsEntry[] array = new BlogsEntryImpl[3];
5685
5686 array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
5687 groupId, displayDate, orderByComparator, true);
5688
5689 array[1] = blogsEntry;
5690
5691 array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
5692 groupId, displayDate, orderByComparator, false);
5693
5694 return array;
5695 }
5696 catch (Exception e) {
5697 throw processException(e);
5698 }
5699 finally {
5700 closeSession(session);
5701 }
5702 }
5703
5704 protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
5705 BlogsEntry blogsEntry, long groupId, Date displayDate,
5706 OrderByComparator orderByComparator, boolean previous) {
5707 StringBundler query = null;
5708
5709 if (orderByComparator != null) {
5710 query = new StringBundler(6 +
5711 (orderByComparator.getOrderByFields().length * 6));
5712 }
5713 else {
5714 query = new StringBundler(3);
5715 }
5716
5717 if (getDB().isSupportsInlineDistinct()) {
5718 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5719 }
5720 else {
5721 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5722 }
5723
5724 query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5725
5726 boolean bindDisplayDate = false;
5727
5728 if (displayDate == null) {
5729 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5730 }
5731 else {
5732 bindDisplayDate = true;
5733
5734 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5735 }
5736
5737 if (!getDB().isSupportsInlineDistinct()) {
5738 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5739 }
5740
5741 if (orderByComparator != null) {
5742 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5743
5744 if (orderByConditionFields.length > 0) {
5745 query.append(WHERE_AND);
5746 }
5747
5748 for (int i = 0; i < orderByConditionFields.length; i++) {
5749 if (getDB().isSupportsInlineDistinct()) {
5750 query.append(_ORDER_BY_ENTITY_ALIAS);
5751 }
5752 else {
5753 query.append(_ORDER_BY_ENTITY_TABLE);
5754 }
5755
5756 query.append(orderByConditionFields[i]);
5757
5758 if ((i + 1) < orderByConditionFields.length) {
5759 if (orderByComparator.isAscending() ^ previous) {
5760 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5761 }
5762 else {
5763 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5764 }
5765 }
5766 else {
5767 if (orderByComparator.isAscending() ^ previous) {
5768 query.append(WHERE_GREATER_THAN);
5769 }
5770 else {
5771 query.append(WHERE_LESSER_THAN);
5772 }
5773 }
5774 }
5775
5776 query.append(ORDER_BY_CLAUSE);
5777
5778 String[] orderByFields = orderByComparator.getOrderByFields();
5779
5780 for (int i = 0; i < orderByFields.length; i++) {
5781 if (getDB().isSupportsInlineDistinct()) {
5782 query.append(_ORDER_BY_ENTITY_ALIAS);
5783 }
5784 else {
5785 query.append(_ORDER_BY_ENTITY_TABLE);
5786 }
5787
5788 query.append(orderByFields[i]);
5789
5790 if ((i + 1) < orderByFields.length) {
5791 if (orderByComparator.isAscending() ^ previous) {
5792 query.append(ORDER_BY_ASC_HAS_NEXT);
5793 }
5794 else {
5795 query.append(ORDER_BY_DESC_HAS_NEXT);
5796 }
5797 }
5798 else {
5799 if (orderByComparator.isAscending() ^ previous) {
5800 query.append(ORDER_BY_ASC);
5801 }
5802 else {
5803 query.append(ORDER_BY_DESC);
5804 }
5805 }
5806 }
5807 }
5808 else {
5809 if (getDB().isSupportsInlineDistinct()) {
5810 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5811 }
5812 else {
5813 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5814 }
5815 }
5816
5817 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5818 BlogsEntry.class.getName(),
5819 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5820
5821 SQLQuery q = session.createSQLQuery(sql);
5822
5823 q.setFirstResult(0);
5824 q.setMaxResults(2);
5825
5826 if (getDB().isSupportsInlineDistinct()) {
5827 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5828 }
5829 else {
5830 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5831 }
5832
5833 QueryPos qPos = QueryPos.getInstance(q);
5834
5835 qPos.add(groupId);
5836
5837 if (bindDisplayDate) {
5838 qPos.add(CalendarUtil.getTimestamp(displayDate));
5839 }
5840
5841 if (orderByComparator != null) {
5842 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5843
5844 for (Object value : values) {
5845 qPos.add(value);
5846 }
5847 }
5848
5849 List<BlogsEntry> list = q.list();
5850
5851 if (list.size() == 2) {
5852 return list.get(1);
5853 }
5854 else {
5855 return null;
5856 }
5857 }
5858
5859
5866 public void removeByG_LtD(long groupId, Date displayDate)
5867 throws SystemException {
5868 for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
5869 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5870 remove(blogsEntry);
5871 }
5872 }
5873
5874
5882 public int countByG_LtD(long groupId, Date displayDate)
5883 throws SystemException {
5884 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
5885
5886 Object[] finderArgs = new Object[] { groupId, displayDate };
5887
5888 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5889 this);
5890
5891 if (count == null) {
5892 StringBundler query = new StringBundler(3);
5893
5894 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5895
5896 query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5897
5898 boolean bindDisplayDate = false;
5899
5900 if (displayDate == null) {
5901 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5902 }
5903 else {
5904 bindDisplayDate = true;
5905
5906 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5907 }
5908
5909 String sql = query.toString();
5910
5911 Session session = null;
5912
5913 try {
5914 session = openSession();
5915
5916 Query q = session.createQuery(sql);
5917
5918 QueryPos qPos = QueryPos.getInstance(q);
5919
5920 qPos.add(groupId);
5921
5922 if (bindDisplayDate) {
5923 qPos.add(CalendarUtil.getTimestamp(displayDate));
5924 }
5925
5926 count = (Long)q.uniqueResult();
5927
5928 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5929 }
5930 catch (Exception e) {
5931 FinderCacheUtil.removeResult(finderPath, finderArgs);
5932
5933 throw processException(e);
5934 }
5935 finally {
5936 closeSession(session);
5937 }
5938 }
5939
5940 return count.intValue();
5941 }
5942
5943
5951 public int filterCountByG_LtD(long groupId, Date displayDate)
5952 throws SystemException {
5953 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5954 return countByG_LtD(groupId, displayDate);
5955 }
5956
5957 StringBundler query = new StringBundler(3);
5958
5959 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
5960
5961 query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5962
5963 boolean bindDisplayDate = false;
5964
5965 if (displayDate == null) {
5966 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5967 }
5968 else {
5969 bindDisplayDate = true;
5970
5971 query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5972 }
5973
5974 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5975 BlogsEntry.class.getName(),
5976 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5977
5978 Session session = null;
5979
5980 try {
5981 session = openSession();
5982
5983 SQLQuery q = session.createSQLQuery(sql);
5984
5985 q.addScalar(COUNT_COLUMN_NAME,
5986 com.liferay.portal.kernel.dao.orm.Type.LONG);
5987
5988 QueryPos qPos = QueryPos.getInstance(q);
5989
5990 qPos.add(groupId);
5991
5992 if (bindDisplayDate) {
5993 qPos.add(CalendarUtil.getTimestamp(displayDate));
5994 }
5995
5996 Long count = (Long)q.uniqueResult();
5997
5998 return count.intValue();
5999 }
6000 catch (Exception e) {
6001 throw processException(e);
6002 }
6003 finally {
6004 closeSession(session);
6005 }
6006 }
6007
6008 private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
6009 private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
6010 private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
6011 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6012 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6013 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
6014 new String[] {
6015 Long.class.getName(), Integer.class.getName(),
6016
6017 Integer.class.getName(), Integer.class.getName(),
6018 OrderByComparator.class.getName()
6019 });
6020 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6021 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6022 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
6023 new String[] { Long.class.getName(), Integer.class.getName() });
6024
6025
6033 public List<BlogsEntry> findByG_NotS(long groupId, int status)
6034 throws SystemException {
6035 return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
6036 QueryUtil.ALL_POS, null);
6037 }
6038
6039
6053 public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
6054 int end) throws SystemException {
6055 return findByG_NotS(groupId, status, start, end, null);
6056 }
6057
6058
6073 public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
6074 int end, OrderByComparator orderByComparator) throws SystemException {
6075 boolean pagination = true;
6076 FinderPath finderPath = null;
6077 Object[] finderArgs = null;
6078
6079 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
6080 finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
6081
6082 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6083 finderArgs, this);
6084
6085 if ((list != null) && !list.isEmpty()) {
6086 for (BlogsEntry blogsEntry : list) {
6087 if ((groupId != blogsEntry.getGroupId()) ||
6088 (status != blogsEntry.getStatus())) {
6089 list = null;
6090
6091 break;
6092 }
6093 }
6094 }
6095
6096 if (list == null) {
6097 StringBundler query = null;
6098
6099 if (orderByComparator != null) {
6100 query = new StringBundler(4 +
6101 (orderByComparator.getOrderByFields().length * 3));
6102 }
6103 else {
6104 query = new StringBundler(4);
6105 }
6106
6107 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6108
6109 query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6110
6111 query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6112
6113 if (orderByComparator != null) {
6114 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6115 orderByComparator);
6116 }
6117 else
6118 if (pagination) {
6119 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6120 }
6121
6122 String sql = query.toString();
6123
6124 Session session = null;
6125
6126 try {
6127 session = openSession();
6128
6129 Query q = session.createQuery(sql);
6130
6131 QueryPos qPos = QueryPos.getInstance(q);
6132
6133 qPos.add(groupId);
6134
6135 qPos.add(status);
6136
6137 if (!pagination) {
6138 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6139 start, end, false);
6140
6141 Collections.sort(list);
6142
6143 list = new UnmodifiableList<BlogsEntry>(list);
6144 }
6145 else {
6146 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6147 start, end);
6148 }
6149
6150 cacheResult(list);
6151
6152 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6153 }
6154 catch (Exception e) {
6155 FinderCacheUtil.removeResult(finderPath, finderArgs);
6156
6157 throw processException(e);
6158 }
6159 finally {
6160 closeSession(session);
6161 }
6162 }
6163
6164 return list;
6165 }
6166
6167
6177 public BlogsEntry findByG_NotS_First(long groupId, int status,
6178 OrderByComparator orderByComparator)
6179 throws NoSuchEntryException, SystemException {
6180 BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
6181 orderByComparator);
6182
6183 if (blogsEntry != null) {
6184 return blogsEntry;
6185 }
6186
6187 StringBundler msg = new StringBundler(6);
6188
6189 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6190
6191 msg.append("groupId=");
6192 msg.append(groupId);
6193
6194 msg.append(", status=");
6195 msg.append(status);
6196
6197 msg.append(StringPool.CLOSE_CURLY_BRACE);
6198
6199 throw new NoSuchEntryException(msg.toString());
6200 }
6201
6202
6211 public BlogsEntry fetchByG_NotS_First(long groupId, int status,
6212 OrderByComparator orderByComparator) throws SystemException {
6213 List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
6214 orderByComparator);
6215
6216 if (!list.isEmpty()) {
6217 return list.get(0);
6218 }
6219
6220 return null;
6221 }
6222
6223
6233 public BlogsEntry findByG_NotS_Last(long groupId, int status,
6234 OrderByComparator orderByComparator)
6235 throws NoSuchEntryException, SystemException {
6236 BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
6237 orderByComparator);
6238
6239 if (blogsEntry != null) {
6240 return blogsEntry;
6241 }
6242
6243 StringBundler msg = new StringBundler(6);
6244
6245 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6246
6247 msg.append("groupId=");
6248 msg.append(groupId);
6249
6250 msg.append(", status=");
6251 msg.append(status);
6252
6253 msg.append(StringPool.CLOSE_CURLY_BRACE);
6254
6255 throw new NoSuchEntryException(msg.toString());
6256 }
6257
6258
6267 public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
6268 OrderByComparator orderByComparator) throws SystemException {
6269 int count = countByG_NotS(groupId, status);
6270
6271 List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
6272 orderByComparator);
6273
6274 if (!list.isEmpty()) {
6275 return list.get(0);
6276 }
6277
6278 return null;
6279 }
6280
6281
6292 public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
6293 int status, OrderByComparator orderByComparator)
6294 throws NoSuchEntryException, SystemException {
6295 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6296
6297 Session session = null;
6298
6299 try {
6300 session = openSession();
6301
6302 BlogsEntry[] array = new BlogsEntryImpl[3];
6303
6304 array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
6305 status, orderByComparator, true);
6306
6307 array[1] = blogsEntry;
6308
6309 array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
6310 status, orderByComparator, false);
6311
6312 return array;
6313 }
6314 catch (Exception e) {
6315 throw processException(e);
6316 }
6317 finally {
6318 closeSession(session);
6319 }
6320 }
6321
6322 protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
6323 BlogsEntry blogsEntry, long groupId, int status,
6324 OrderByComparator orderByComparator, boolean previous) {
6325 StringBundler query = null;
6326
6327 if (orderByComparator != null) {
6328 query = new StringBundler(6 +
6329 (orderByComparator.getOrderByFields().length * 6));
6330 }
6331 else {
6332 query = new StringBundler(3);
6333 }
6334
6335 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6336
6337 query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6338
6339 query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6340
6341 if (orderByComparator != null) {
6342 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6343
6344 if (orderByConditionFields.length > 0) {
6345 query.append(WHERE_AND);
6346 }
6347
6348 for (int i = 0; i < orderByConditionFields.length; i++) {
6349 query.append(_ORDER_BY_ENTITY_ALIAS);
6350 query.append(orderByConditionFields[i]);
6351
6352 if ((i + 1) < orderByConditionFields.length) {
6353 if (orderByComparator.isAscending() ^ previous) {
6354 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6355 }
6356 else {
6357 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6358 }
6359 }
6360 else {
6361 if (orderByComparator.isAscending() ^ previous) {
6362 query.append(WHERE_GREATER_THAN);
6363 }
6364 else {
6365 query.append(WHERE_LESSER_THAN);
6366 }
6367 }
6368 }
6369
6370 query.append(ORDER_BY_CLAUSE);
6371
6372 String[] orderByFields = orderByComparator.getOrderByFields();
6373
6374 for (int i = 0; i < orderByFields.length; i++) {
6375 query.append(_ORDER_BY_ENTITY_ALIAS);
6376 query.append(orderByFields[i]);
6377
6378 if ((i + 1) < orderByFields.length) {
6379 if (orderByComparator.isAscending() ^ previous) {
6380 query.append(ORDER_BY_ASC_HAS_NEXT);
6381 }
6382 else {
6383 query.append(ORDER_BY_DESC_HAS_NEXT);
6384 }
6385 }
6386 else {
6387 if (orderByComparator.isAscending() ^ previous) {
6388 query.append(ORDER_BY_ASC);
6389 }
6390 else {
6391 query.append(ORDER_BY_DESC);
6392 }
6393 }
6394 }
6395 }
6396 else {
6397 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6398 }
6399
6400 String sql = query.toString();
6401
6402 Query q = session.createQuery(sql);
6403
6404 q.setFirstResult(0);
6405 q.setMaxResults(2);
6406
6407 QueryPos qPos = QueryPos.getInstance(q);
6408
6409 qPos.add(groupId);
6410
6411 qPos.add(status);
6412
6413 if (orderByComparator != null) {
6414 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6415
6416 for (Object value : values) {
6417 qPos.add(value);
6418 }
6419 }
6420
6421 List<BlogsEntry> list = q.list();
6422
6423 if (list.size() == 2) {
6424 return list.get(1);
6425 }
6426 else {
6427 return null;
6428 }
6429 }
6430
6431
6439 public List<BlogsEntry> filterFindByG_NotS(long groupId, int status)
6440 throws SystemException {
6441 return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
6442 QueryUtil.ALL_POS, null);
6443 }
6444
6445
6459 public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
6460 int start, int end) throws SystemException {
6461 return filterFindByG_NotS(groupId, status, start, end, null);
6462 }
6463
6464
6479 public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
6480 int start, int end, OrderByComparator orderByComparator)
6481 throws SystemException {
6482 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6483 return findByG_NotS(groupId, status, start, end, orderByComparator);
6484 }
6485
6486 StringBundler query = null;
6487
6488 if (orderByComparator != null) {
6489 query = new StringBundler(4 +
6490 (orderByComparator.getOrderByFields().length * 3));
6491 }
6492 else {
6493 query = new StringBundler(4);
6494 }
6495
6496 if (getDB().isSupportsInlineDistinct()) {
6497 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
6498 }
6499 else {
6500 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
6501 }
6502
6503 query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6504
6505 query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6506
6507 if (!getDB().isSupportsInlineDistinct()) {
6508 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
6509 }
6510
6511 if (orderByComparator != null) {
6512 if (getDB().isSupportsInlineDistinct()) {
6513 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6514 orderByComparator, true);
6515 }
6516 else {
6517 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6518 orderByComparator, true);
6519 }
6520 }
6521 else {
6522 if (getDB().isSupportsInlineDistinct()) {
6523 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6524 }
6525 else {
6526 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
6527 }
6528 }
6529
6530 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6531 BlogsEntry.class.getName(),
6532 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6533
6534 Session session = null;
6535
6536 try {
6537 session = openSession();
6538
6539 SQLQuery q = session.createSQLQuery(sql);
6540
6541 if (getDB().isSupportsInlineDistinct()) {
6542 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
6543 }
6544 else {
6545 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
6546 }
6547
6548 QueryPos qPos = QueryPos.getInstance(q);
6549
6550 qPos.add(groupId);
6551
6552 qPos.add(status);
6553
6554 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
6555 }
6556 catch (Exception e) {
6557 throw processException(e);
6558 }
6559 finally {
6560 closeSession(session);
6561 }
6562 }
6563
6564
6575 public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
6576 long groupId, int status, OrderByComparator orderByComparator)
6577 throws NoSuchEntryException, SystemException {
6578 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6579 return findByG_NotS_PrevAndNext(entryId, groupId, status,
6580 orderByComparator);
6581 }
6582
6583 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6584
6585 Session session = null;
6586
6587 try {
6588 session = openSession();
6589
6590 BlogsEntry[] array = new BlogsEntryImpl[3];
6591
6592 array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
6593 groupId, status, orderByComparator, true);
6594
6595 array[1] = blogsEntry;
6596
6597 array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
6598 groupId, status, orderByComparator, false);
6599
6600 return array;
6601 }
6602 catch (Exception e) {
6603 throw processException(e);
6604 }
6605 finally {
6606 closeSession(session);
6607 }
6608 }
6609
6610 protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
6611 BlogsEntry blogsEntry, long groupId, int status,
6612 OrderByComparator orderByComparator, boolean previous) {
6613 StringBundler query = null;
6614
6615 if (orderByComparator != null) {
6616 query = new StringBundler(6 +
6617 (orderByComparator.getOrderByFields().length * 6));
6618 }
6619 else {
6620 query = new StringBundler(3);
6621 }
6622
6623 if (getDB().isSupportsInlineDistinct()) {
6624 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
6625 }
6626 else {
6627 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
6628 }
6629
6630 query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6631
6632 query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6633
6634 if (!getDB().isSupportsInlineDistinct()) {
6635 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
6636 }
6637
6638 if (orderByComparator != null) {
6639 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6640
6641 if (orderByConditionFields.length > 0) {
6642 query.append(WHERE_AND);
6643 }
6644
6645 for (int i = 0; i < orderByConditionFields.length; i++) {
6646 if (getDB().isSupportsInlineDistinct()) {
6647 query.append(_ORDER_BY_ENTITY_ALIAS);
6648 }
6649 else {
6650 query.append(_ORDER_BY_ENTITY_TABLE);
6651 }
6652
6653 query.append(orderByConditionFields[i]);
6654
6655 if ((i + 1) < orderByConditionFields.length) {
6656 if (orderByComparator.isAscending() ^ previous) {
6657 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6658 }
6659 else {
6660 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6661 }
6662 }
6663 else {
6664 if (orderByComparator.isAscending() ^ previous) {
6665 query.append(WHERE_GREATER_THAN);
6666 }
6667 else {
6668 query.append(WHERE_LESSER_THAN);
6669 }
6670 }
6671 }
6672
6673 query.append(ORDER_BY_CLAUSE);
6674
6675 String[] orderByFields = orderByComparator.getOrderByFields();
6676
6677 for (int i = 0; i < orderByFields.length; i++) {
6678 if (getDB().isSupportsInlineDistinct()) {
6679 query.append(_ORDER_BY_ENTITY_ALIAS);
6680 }
6681 else {
6682 query.append(_ORDER_BY_ENTITY_TABLE);
6683 }
6684
6685 query.append(orderByFields[i]);
6686
6687 if ((i + 1) < orderByFields.length) {
6688 if (orderByComparator.isAscending() ^ previous) {
6689 query.append(ORDER_BY_ASC_HAS_NEXT);
6690 }
6691 else {
6692 query.append(ORDER_BY_DESC_HAS_NEXT);
6693 }
6694 }
6695 else {
6696 if (orderByComparator.isAscending() ^ previous) {
6697 query.append(ORDER_BY_ASC);
6698 }
6699 else {
6700 query.append(ORDER_BY_DESC);
6701 }
6702 }
6703 }
6704 }
6705 else {
6706 if (getDB().isSupportsInlineDistinct()) {
6707 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6708 }
6709 else {
6710 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
6711 }
6712 }
6713
6714 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6715 BlogsEntry.class.getName(),
6716 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6717
6718 SQLQuery q = session.createSQLQuery(sql);
6719
6720 q.setFirstResult(0);
6721 q.setMaxResults(2);
6722
6723 if (getDB().isSupportsInlineDistinct()) {
6724 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
6725 }
6726 else {
6727 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
6728 }
6729
6730 QueryPos qPos = QueryPos.getInstance(q);
6731
6732 qPos.add(groupId);
6733
6734 qPos.add(status);
6735
6736 if (orderByComparator != null) {
6737 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6738
6739 for (Object value : values) {
6740 qPos.add(value);
6741 }
6742 }
6743
6744 List<BlogsEntry> list = q.list();
6745
6746 if (list.size() == 2) {
6747 return list.get(1);
6748 }
6749 else {
6750 return null;
6751 }
6752 }
6753
6754
6761 public void removeByG_NotS(long groupId, int status)
6762 throws SystemException {
6763 for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
6764 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6765 remove(blogsEntry);
6766 }
6767 }
6768
6769
6777 public int countByG_NotS(long groupId, int status)
6778 throws SystemException {
6779 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
6780
6781 Object[] finderArgs = new Object[] { groupId, status };
6782
6783 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6784 this);
6785
6786 if (count == null) {
6787 StringBundler query = new StringBundler(3);
6788
6789 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6790
6791 query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6792
6793 query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6794
6795 String sql = query.toString();
6796
6797 Session session = null;
6798
6799 try {
6800 session = openSession();
6801
6802 Query q = session.createQuery(sql);
6803
6804 QueryPos qPos = QueryPos.getInstance(q);
6805
6806 qPos.add(groupId);
6807
6808 qPos.add(status);
6809
6810 count = (Long)q.uniqueResult();
6811
6812 FinderCacheUtil.putResult(finderPath, finderArgs, count);
6813 }
6814 catch (Exception e) {
6815 FinderCacheUtil.removeResult(finderPath, finderArgs);
6816
6817 throw processException(e);
6818 }
6819 finally {
6820 closeSession(session);
6821 }
6822 }
6823
6824 return count.intValue();
6825 }
6826
6827
6835 public int filterCountByG_NotS(long groupId, int status)
6836 throws SystemException {
6837 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6838 return countByG_NotS(groupId, status);
6839 }
6840
6841 StringBundler query = new StringBundler(3);
6842
6843 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
6844
6845 query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6846
6847 query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6848
6849 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6850 BlogsEntry.class.getName(),
6851 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6852
6853 Session session = null;
6854
6855 try {
6856 session = openSession();
6857
6858 SQLQuery q = session.createSQLQuery(sql);
6859
6860 q.addScalar(COUNT_COLUMN_NAME,
6861 com.liferay.portal.kernel.dao.orm.Type.LONG);
6862
6863 QueryPos qPos = QueryPos.getInstance(q);
6864
6865 qPos.add(groupId);
6866
6867 qPos.add(status);
6868
6869 Long count = (Long)q.uniqueResult();
6870
6871 return count.intValue();
6872 }
6873 catch (Exception e) {
6874 throw processException(e);
6875 }
6876 finally {
6877 closeSession(session);
6878 }
6879 }
6880
6881 private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
6882 private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
6883 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6884 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6885 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
6886 new String[] {
6887 Long.class.getName(), Integer.class.getName(),
6888
6889 Integer.class.getName(), Integer.class.getName(),
6890 OrderByComparator.class.getName()
6891 });
6892 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6893 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6894 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
6895 new String[] { Long.class.getName(), Integer.class.getName() },
6896 BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
6897 BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
6898 BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
6899 BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
6900 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6901 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6902 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
6903 new String[] { Long.class.getName(), Integer.class.getName() });
6904
6905
6913 public List<BlogsEntry> findByG_S(long groupId, int status)
6914 throws SystemException {
6915 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6916 null);
6917 }
6918
6919
6933 public List<BlogsEntry> findByG_S(long groupId, int status, int start,
6934 int end) throws SystemException {
6935 return findByG_S(groupId, status, start, end, null);
6936 }
6937
6938
6953 public List<BlogsEntry> findByG_S(long groupId, int status, int start,
6954 int end, OrderByComparator orderByComparator) throws SystemException {
6955 boolean pagination = true;
6956 FinderPath finderPath = null;
6957 Object[] finderArgs = null;
6958
6959 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6960 (orderByComparator == null)) {
6961 pagination = false;
6962 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
6963 finderArgs = new Object[] { groupId, status };
6964 }
6965 else {
6966 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
6967 finderArgs = new Object[] {
6968 groupId, status,
6969
6970 start, end, orderByComparator
6971 };
6972 }
6973
6974 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6975 finderArgs, this);
6976
6977 if ((list != null) && !list.isEmpty()) {
6978 for (BlogsEntry blogsEntry : list) {
6979 if ((groupId != blogsEntry.getGroupId()) ||
6980 (status != blogsEntry.getStatus())) {
6981 list = null;
6982
6983 break;
6984 }
6985 }
6986 }
6987
6988 if (list == null) {
6989 StringBundler query = null;
6990
6991 if (orderByComparator != null) {
6992 query = new StringBundler(4 +
6993 (orderByComparator.getOrderByFields().length * 3));
6994 }
6995 else {
6996 query = new StringBundler(4);
6997 }
6998
6999 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7000
7001 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7002
7003 query.append(_FINDER_COLUMN_G_S_STATUS_2);
7004
7005 if (orderByComparator != null) {
7006 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7007 orderByComparator);
7008 }
7009 else
7010 if (pagination) {
7011 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7012 }
7013
7014 String sql = query.toString();
7015
7016 Session session = null;
7017
7018 try {
7019 session = openSession();
7020
7021 Query q = session.createQuery(sql);
7022
7023 QueryPos qPos = QueryPos.getInstance(q);
7024
7025 qPos.add(groupId);
7026
7027 qPos.add(status);
7028
7029 if (!pagination) {
7030 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7031 start, end, false);
7032
7033 Collections.sort(list);
7034
7035 list = new UnmodifiableList<BlogsEntry>(list);
7036 }
7037 else {
7038 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7039 start, end);
7040 }
7041
7042 cacheResult(list);
7043
7044 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7045 }
7046 catch (Exception e) {
7047 FinderCacheUtil.removeResult(finderPath, finderArgs);
7048
7049 throw processException(e);
7050 }
7051 finally {
7052 closeSession(session);
7053 }
7054 }
7055
7056 return list;
7057 }
7058
7059
7069 public BlogsEntry findByG_S_First(long groupId, int status,
7070 OrderByComparator orderByComparator)
7071 throws NoSuchEntryException, SystemException {
7072 BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
7073 orderByComparator);
7074
7075 if (blogsEntry != null) {
7076 return blogsEntry;
7077 }
7078
7079 StringBundler msg = new StringBundler(6);
7080
7081 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7082
7083 msg.append("groupId=");
7084 msg.append(groupId);
7085
7086 msg.append(", status=");
7087 msg.append(status);
7088
7089 msg.append(StringPool.CLOSE_CURLY_BRACE);
7090
7091 throw new NoSuchEntryException(msg.toString());
7092 }
7093
7094
7103 public BlogsEntry fetchByG_S_First(long groupId, int status,
7104 OrderByComparator orderByComparator) throws SystemException {
7105 List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
7106 orderByComparator);
7107
7108 if (!list.isEmpty()) {
7109 return list.get(0);
7110 }
7111
7112 return null;
7113 }
7114
7115
7125 public BlogsEntry findByG_S_Last(long groupId, int status,
7126 OrderByComparator orderByComparator)
7127 throws NoSuchEntryException, SystemException {
7128 BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
7129 orderByComparator);
7130
7131 if (blogsEntry != null) {
7132 return blogsEntry;
7133 }
7134
7135 StringBundler msg = new StringBundler(6);
7136
7137 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7138
7139 msg.append("groupId=");
7140 msg.append(groupId);
7141
7142 msg.append(", status=");
7143 msg.append(status);
7144
7145 msg.append(StringPool.CLOSE_CURLY_BRACE);
7146
7147 throw new NoSuchEntryException(msg.toString());
7148 }
7149
7150
7159 public BlogsEntry fetchByG_S_Last(long groupId, int status,
7160 OrderByComparator orderByComparator) throws SystemException {
7161 int count = countByG_S(groupId, status);
7162
7163 List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
7164 orderByComparator);
7165
7166 if (!list.isEmpty()) {
7167 return list.get(0);
7168 }
7169
7170 return null;
7171 }
7172
7173
7184 public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
7185 int status, OrderByComparator orderByComparator)
7186 throws NoSuchEntryException, SystemException {
7187 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7188
7189 Session session = null;
7190
7191 try {
7192 session = openSession();
7193
7194 BlogsEntry[] array = new BlogsEntryImpl[3];
7195
7196 array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
7197 status, orderByComparator, true);
7198
7199 array[1] = blogsEntry;
7200
7201 array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
7202 status, orderByComparator, false);
7203
7204 return array;
7205 }
7206 catch (Exception e) {
7207 throw processException(e);
7208 }
7209 finally {
7210 closeSession(session);
7211 }
7212 }
7213
7214 protected BlogsEntry getByG_S_PrevAndNext(Session session,
7215 BlogsEntry blogsEntry, long groupId, int status,
7216 OrderByComparator orderByComparator, boolean previous) {
7217 StringBundler query = null;
7218
7219 if (orderByComparator != null) {
7220 query = new StringBundler(6 +
7221 (orderByComparator.getOrderByFields().length * 6));
7222 }
7223 else {
7224 query = new StringBundler(3);
7225 }
7226
7227 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7228
7229 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7230
7231 query.append(_FINDER_COLUMN_G_S_STATUS_2);
7232
7233 if (orderByComparator != null) {
7234 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7235
7236 if (orderByConditionFields.length > 0) {
7237 query.append(WHERE_AND);
7238 }
7239
7240 for (int i = 0; i < orderByConditionFields.length; i++) {
7241 query.append(_ORDER_BY_ENTITY_ALIAS);
7242 query.append(orderByConditionFields[i]);
7243
7244 if ((i + 1) < orderByConditionFields.length) {
7245 if (orderByComparator.isAscending() ^ previous) {
7246 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7247 }
7248 else {
7249 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7250 }
7251 }
7252 else {
7253 if (orderByComparator.isAscending() ^ previous) {
7254 query.append(WHERE_GREATER_THAN);
7255 }
7256 else {
7257 query.append(WHERE_LESSER_THAN);
7258 }
7259 }
7260 }
7261
7262 query.append(ORDER_BY_CLAUSE);
7263
7264 String[] orderByFields = orderByComparator.getOrderByFields();
7265
7266 for (int i = 0; i < orderByFields.length; i++) {
7267 query.append(_ORDER_BY_ENTITY_ALIAS);
7268 query.append(orderByFields[i]);
7269
7270 if ((i + 1) < orderByFields.length) {
7271 if (orderByComparator.isAscending() ^ previous) {
7272 query.append(ORDER_BY_ASC_HAS_NEXT);
7273 }
7274 else {
7275 query.append(ORDER_BY_DESC_HAS_NEXT);
7276 }
7277 }
7278 else {
7279 if (orderByComparator.isAscending() ^ previous) {
7280 query.append(ORDER_BY_ASC);
7281 }
7282 else {
7283 query.append(ORDER_BY_DESC);
7284 }
7285 }
7286 }
7287 }
7288 else {
7289 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7290 }
7291
7292 String sql = query.toString();
7293
7294 Query q = session.createQuery(sql);
7295
7296 q.setFirstResult(0);
7297 q.setMaxResults(2);
7298
7299 QueryPos qPos = QueryPos.getInstance(q);
7300
7301 qPos.add(groupId);
7302
7303 qPos.add(status);
7304
7305 if (orderByComparator != null) {
7306 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7307
7308 for (Object value : values) {
7309 qPos.add(value);
7310 }
7311 }
7312
7313 List<BlogsEntry> list = q.list();
7314
7315 if (list.size() == 2) {
7316 return list.get(1);
7317 }
7318 else {
7319 return null;
7320 }
7321 }
7322
7323
7331 public List<BlogsEntry> filterFindByG_S(long groupId, int status)
7332 throws SystemException {
7333 return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
7334 QueryUtil.ALL_POS, null);
7335 }
7336
7337
7351 public List<BlogsEntry> filterFindByG_S(long groupId, int status,
7352 int start, int end) throws SystemException {
7353 return filterFindByG_S(groupId, status, start, end, null);
7354 }
7355
7356
7371 public List<BlogsEntry> filterFindByG_S(long groupId, int status,
7372 int start, int end, OrderByComparator orderByComparator)
7373 throws SystemException {
7374 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7375 return findByG_S(groupId, status, start, end, orderByComparator);
7376 }
7377
7378 StringBundler query = null;
7379
7380 if (orderByComparator != null) {
7381 query = new StringBundler(4 +
7382 (orderByComparator.getOrderByFields().length * 3));
7383 }
7384 else {
7385 query = new StringBundler(4);
7386 }
7387
7388 if (getDB().isSupportsInlineDistinct()) {
7389 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
7390 }
7391 else {
7392 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
7393 }
7394
7395 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7396
7397 query.append(_FINDER_COLUMN_G_S_STATUS_2);
7398
7399 if (!getDB().isSupportsInlineDistinct()) {
7400 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
7401 }
7402
7403 if (orderByComparator != null) {
7404 if (getDB().isSupportsInlineDistinct()) {
7405 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7406 orderByComparator, true);
7407 }
7408 else {
7409 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7410 orderByComparator, true);
7411 }
7412 }
7413 else {
7414 if (getDB().isSupportsInlineDistinct()) {
7415 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7416 }
7417 else {
7418 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
7419 }
7420 }
7421
7422 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7423 BlogsEntry.class.getName(),
7424 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7425
7426 Session session = null;
7427
7428 try {
7429 session = openSession();
7430
7431 SQLQuery q = session.createSQLQuery(sql);
7432
7433 if (getDB().isSupportsInlineDistinct()) {
7434 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
7435 }
7436 else {
7437 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
7438 }
7439
7440 QueryPos qPos = QueryPos.getInstance(q);
7441
7442 qPos.add(groupId);
7443
7444 qPos.add(status);
7445
7446 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
7447 }
7448 catch (Exception e) {
7449 throw processException(e);
7450 }
7451 finally {
7452 closeSession(session);
7453 }
7454 }
7455
7456
7467 public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
7468 int status, OrderByComparator orderByComparator)
7469 throws NoSuchEntryException, SystemException {
7470 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7471 return findByG_S_PrevAndNext(entryId, groupId, status,
7472 orderByComparator);
7473 }
7474
7475 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7476
7477 Session session = null;
7478
7479 try {
7480 session = openSession();
7481
7482 BlogsEntry[] array = new BlogsEntryImpl[3];
7483
7484 array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
7485 status, orderByComparator, true);
7486
7487 array[1] = blogsEntry;
7488
7489 array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
7490 status, orderByComparator, false);
7491
7492 return array;
7493 }
7494 catch (Exception e) {
7495 throw processException(e);
7496 }
7497 finally {
7498 closeSession(session);
7499 }
7500 }
7501
7502 protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
7503 BlogsEntry blogsEntry, long groupId, int status,
7504 OrderByComparator orderByComparator, boolean previous) {
7505 StringBundler query = null;
7506
7507 if (orderByComparator != null) {
7508 query = new StringBundler(6 +
7509 (orderByComparator.getOrderByFields().length * 6));
7510 }
7511 else {
7512 query = new StringBundler(3);
7513 }
7514
7515 if (getDB().isSupportsInlineDistinct()) {
7516 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
7517 }
7518 else {
7519 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
7520 }
7521
7522 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7523
7524 query.append(_FINDER_COLUMN_G_S_STATUS_2);
7525
7526 if (!getDB().isSupportsInlineDistinct()) {
7527 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
7528 }
7529
7530 if (orderByComparator != null) {
7531 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7532
7533 if (orderByConditionFields.length > 0) {
7534 query.append(WHERE_AND);
7535 }
7536
7537 for (int i = 0; i < orderByConditionFields.length; i++) {
7538 if (getDB().isSupportsInlineDistinct()) {
7539 query.append(_ORDER_BY_ENTITY_ALIAS);
7540 }
7541 else {
7542 query.append(_ORDER_BY_ENTITY_TABLE);
7543 }
7544
7545 query.append(orderByConditionFields[i]);
7546
7547 if ((i + 1) < orderByConditionFields.length) {
7548 if (orderByComparator.isAscending() ^ previous) {
7549 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7550 }
7551 else {
7552 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7553 }
7554 }
7555 else {
7556 if (orderByComparator.isAscending() ^ previous) {
7557 query.append(WHERE_GREATER_THAN);
7558 }
7559 else {
7560 query.append(WHERE_LESSER_THAN);
7561 }
7562 }
7563 }
7564
7565 query.append(ORDER_BY_CLAUSE);
7566
7567 String[] orderByFields = orderByComparator.getOrderByFields();
7568
7569 for (int i = 0; i < orderByFields.length; i++) {
7570 if (getDB().isSupportsInlineDistinct()) {
7571 query.append(_ORDER_BY_ENTITY_ALIAS);
7572 }
7573 else {
7574 query.append(_ORDER_BY_ENTITY_TABLE);
7575 }
7576
7577 query.append(orderByFields[i]);
7578
7579 if ((i + 1) < orderByFields.length) {
7580 if (orderByComparator.isAscending() ^ previous) {
7581 query.append(ORDER_BY_ASC_HAS_NEXT);
7582 }
7583 else {
7584 query.append(ORDER_BY_DESC_HAS_NEXT);
7585 }
7586 }
7587 else {
7588 if (orderByComparator.isAscending() ^ previous) {
7589 query.append(ORDER_BY_ASC);
7590 }
7591 else {
7592 query.append(ORDER_BY_DESC);
7593 }
7594 }
7595 }
7596 }
7597 else {
7598 if (getDB().isSupportsInlineDistinct()) {
7599 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7600 }
7601 else {
7602 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
7603 }
7604 }
7605
7606 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7607 BlogsEntry.class.getName(),
7608 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7609
7610 SQLQuery q = session.createSQLQuery(sql);
7611
7612 q.setFirstResult(0);
7613 q.setMaxResults(2);
7614
7615 if (getDB().isSupportsInlineDistinct()) {
7616 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
7617 }
7618 else {
7619 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
7620 }
7621
7622 QueryPos qPos = QueryPos.getInstance(q);
7623
7624 qPos.add(groupId);
7625
7626 qPos.add(status);
7627
7628 if (orderByComparator != null) {
7629 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7630
7631 for (Object value : values) {
7632 qPos.add(value);
7633 }
7634 }
7635
7636 List<BlogsEntry> list = q.list();
7637
7638 if (list.size() == 2) {
7639 return list.get(1);
7640 }
7641 else {
7642 return null;
7643 }
7644 }
7645
7646
7653 public void removeByG_S(long groupId, int status) throws SystemException {
7654 for (BlogsEntry blogsEntry : findByG_S(groupId, status,
7655 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7656 remove(blogsEntry);
7657 }
7658 }
7659
7660
7668 public int countByG_S(long groupId, int status) throws SystemException {
7669 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
7670
7671 Object[] finderArgs = new Object[] { groupId, status };
7672
7673 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7674 this);
7675
7676 if (count == null) {
7677 StringBundler query = new StringBundler(3);
7678
7679 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7680
7681 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7682
7683 query.append(_FINDER_COLUMN_G_S_STATUS_2);
7684
7685 String sql = query.toString();
7686
7687 Session session = null;
7688
7689 try {
7690 session = openSession();
7691
7692 Query q = session.createQuery(sql);
7693
7694 QueryPos qPos = QueryPos.getInstance(q);
7695
7696 qPos.add(groupId);
7697
7698 qPos.add(status);
7699
7700 count = (Long)q.uniqueResult();
7701
7702 FinderCacheUtil.putResult(finderPath, finderArgs, count);
7703 }
7704 catch (Exception e) {
7705 FinderCacheUtil.removeResult(finderPath, finderArgs);
7706
7707 throw processException(e);
7708 }
7709 finally {
7710 closeSession(session);
7711 }
7712 }
7713
7714 return count.intValue();
7715 }
7716
7717
7725 public int filterCountByG_S(long groupId, int status)
7726 throws SystemException {
7727 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7728 return countByG_S(groupId, status);
7729 }
7730
7731 StringBundler query = new StringBundler(3);
7732
7733 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
7734
7735 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7736
7737 query.append(_FINDER_COLUMN_G_S_STATUS_2);
7738
7739 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7740 BlogsEntry.class.getName(),
7741 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7742
7743 Session session = null;
7744
7745 try {
7746 session = openSession();
7747
7748 SQLQuery q = session.createSQLQuery(sql);
7749
7750 q.addScalar(COUNT_COLUMN_NAME,
7751 com.liferay.portal.kernel.dao.orm.Type.LONG);
7752
7753 QueryPos qPos = QueryPos.getInstance(q);
7754
7755 qPos.add(groupId);
7756
7757 qPos.add(status);
7758
7759 Long count = (Long)q.uniqueResult();
7760
7761 return count.intValue();
7762 }
7763 catch (Exception e) {
7764 throw processException(e);
7765 }
7766 finally {
7767 closeSession(session);
7768 }
7769 }
7770
7771 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
7772 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
7773 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7774 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7775 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
7776 new String[] {
7777 Date.class.getName(), Integer.class.getName(),
7778
7779 Integer.class.getName(), Integer.class.getName(),
7780 OrderByComparator.class.getName()
7781 });
7782 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7783 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7784 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
7785 new String[] { Date.class.getName(), Integer.class.getName() });
7786
7787
7795 public List<BlogsEntry> findByLtD_S(Date displayDate, int status)
7796 throws SystemException {
7797 return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
7798 QueryUtil.ALL_POS, null);
7799 }
7800
7801
7815 public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
7816 int start, int end) throws SystemException {
7817 return findByLtD_S(displayDate, status, start, end, null);
7818 }
7819
7820
7835 public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
7836 int start, int end, OrderByComparator orderByComparator)
7837 throws SystemException {
7838 boolean pagination = true;
7839 FinderPath finderPath = null;
7840 Object[] finderArgs = null;
7841
7842 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
7843 finderArgs = new Object[] {
7844 displayDate, status,
7845
7846 start, end, orderByComparator
7847 };
7848
7849 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
7850 finderArgs, this);
7851
7852 if ((list != null) && !list.isEmpty()) {
7853 for (BlogsEntry blogsEntry : list) {
7854 if (!Validator.equals(displayDate, blogsEntry.getDisplayDate()) ||
7855 (status != blogsEntry.getStatus())) {
7856 list = null;
7857
7858 break;
7859 }
7860 }
7861 }
7862
7863 if (list == null) {
7864 StringBundler query = null;
7865
7866 if (orderByComparator != null) {
7867 query = new StringBundler(4 +
7868 (orderByComparator.getOrderByFields().length * 3));
7869 }
7870 else {
7871 query = new StringBundler(4);
7872 }
7873
7874 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7875
7876 boolean bindDisplayDate = false;
7877
7878 if (displayDate == null) {
7879 query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
7880 }
7881 else {
7882 bindDisplayDate = true;
7883
7884 query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
7885 }
7886
7887 query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
7888
7889 if (orderByComparator != null) {
7890 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7891 orderByComparator);
7892 }
7893 else
7894 if (pagination) {
7895 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7896 }
7897
7898 String sql = query.toString();
7899
7900 Session session = null;
7901
7902 try {
7903 session = openSession();
7904
7905 Query q = session.createQuery(sql);
7906
7907 QueryPos qPos = QueryPos.getInstance(q);
7908
7909 if (bindDisplayDate) {
7910 qPos.add(CalendarUtil.getTimestamp(displayDate));
7911 }
7912
7913 qPos.add(status);
7914
7915 if (!pagination) {
7916 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7917 start, end, false);
7918
7919 Collections.sort(list);
7920
7921 list = new UnmodifiableList<BlogsEntry>(list);
7922 }
7923 else {
7924 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7925 start, end);
7926 }
7927
7928 cacheResult(list);
7929
7930 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7931 }
7932 catch (Exception e) {
7933 FinderCacheUtil.removeResult(finderPath, finderArgs);
7934
7935 throw processException(e);
7936 }
7937 finally {
7938 closeSession(session);
7939 }
7940 }
7941
7942 return list;
7943 }
7944
7945
7955 public BlogsEntry findByLtD_S_First(Date displayDate, int status,
7956 OrderByComparator orderByComparator)
7957 throws NoSuchEntryException, SystemException {
7958 BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
7959 orderByComparator);
7960
7961 if (blogsEntry != null) {
7962 return blogsEntry;
7963 }
7964
7965 StringBundler msg = new StringBundler(6);
7966
7967 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7968
7969 msg.append("displayDate=");
7970 msg.append(displayDate);
7971
7972 msg.append(", status=");
7973 msg.append(status);
7974
7975 msg.append(StringPool.CLOSE_CURLY_BRACE);
7976
7977 throw new NoSuchEntryException(msg.toString());
7978 }
7979
7980
7989 public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
7990 OrderByComparator orderByComparator) throws SystemException {
7991 List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
7992 orderByComparator);
7993
7994 if (!list.isEmpty()) {
7995 return list.get(0);
7996 }
7997
7998 return null;
7999 }
8000
8001
8011 public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8012 OrderByComparator orderByComparator)
8013 throws NoSuchEntryException, SystemException {
8014 BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8015 orderByComparator);
8016
8017 if (blogsEntry != null) {
8018 return blogsEntry;
8019 }
8020
8021 StringBundler msg = new StringBundler(6);
8022
8023 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8024
8025 msg.append("displayDate=");
8026 msg.append(displayDate);
8027
8028 msg.append(", status=");
8029 msg.append(status);
8030
8031 msg.append(StringPool.CLOSE_CURLY_BRACE);
8032
8033 throw new NoSuchEntryException(msg.toString());
8034 }
8035
8036
8045 public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8046 OrderByComparator orderByComparator) throws SystemException {
8047 int count = countByLtD_S(displayDate, status);
8048
8049 List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8050 count, orderByComparator);
8051
8052 if (!list.isEmpty()) {
8053 return list.get(0);
8054 }
8055
8056 return null;
8057 }
8058
8059
8070 public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8071 int status, OrderByComparator orderByComparator)
8072 throws NoSuchEntryException, SystemException {
8073 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8074
8075 Session session = null;
8076
8077 try {
8078 session = openSession();
8079
8080 BlogsEntry[] array = new BlogsEntryImpl[3];
8081
8082 array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8083 status, orderByComparator, true);
8084
8085 array[1] = blogsEntry;
8086
8087 array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8088 status, orderByComparator, false);
8089
8090 return array;
8091 }
8092 catch (Exception e) {
8093 throw processException(e);
8094 }
8095 finally {
8096 closeSession(session);
8097 }
8098 }
8099
8100 protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8101 BlogsEntry blogsEntry, Date displayDate, int status,
8102 OrderByComparator orderByComparator, boolean previous) {
8103 StringBundler query = null;
8104
8105 if (orderByComparator != null) {
8106 query = new StringBundler(6 +
8107 (orderByComparator.getOrderByFields().length * 6));
8108 }
8109 else {
8110 query = new StringBundler(3);
8111 }
8112
8113 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8114
8115 boolean bindDisplayDate = false;
8116
8117 if (displayDate == null) {
8118 query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8119 }
8120 else {
8121 bindDisplayDate = true;
8122
8123 query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8124 }
8125
8126 query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8127
8128 if (orderByComparator != null) {
8129 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8130
8131 if (orderByConditionFields.length > 0) {
8132 query.append(WHERE_AND);
8133 }
8134
8135 for (int i = 0; i < orderByConditionFields.length; i++) {
8136 query.append(_ORDER_BY_ENTITY_ALIAS);
8137 query.append(orderByConditionFields[i]);
8138
8139 if ((i + 1) < orderByConditionFields.length) {
8140 if (orderByComparator.isAscending() ^ previous) {
8141 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8142 }
8143 else {
8144 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8145 }
8146 }
8147 else {
8148 if (orderByComparator.isAscending() ^ previous) {
8149 query.append(WHERE_GREATER_THAN);
8150 }
8151 else {
8152 query.append(WHERE_LESSER_THAN);
8153 }
8154 }
8155 }
8156
8157 query.append(ORDER_BY_CLAUSE);
8158
8159 String[] orderByFields = orderByComparator.getOrderByFields();
8160
8161 for (int i = 0; i < orderByFields.length; i++) {
8162 query.append(_ORDER_BY_ENTITY_ALIAS);
8163 query.append(orderByFields[i]);
8164
8165 if ((i + 1) < orderByFields.length) {
8166 if (orderByComparator.isAscending() ^ previous) {
8167 query.append(ORDER_BY_ASC_HAS_NEXT);
8168 }
8169 else {
8170 query.append(ORDER_BY_DESC_HAS_NEXT);
8171 }
8172 }
8173 else {
8174 if (orderByComparator.isAscending() ^ previous) {
8175 query.append(ORDER_BY_ASC);
8176 }
8177 else {
8178 query.append(ORDER_BY_DESC);
8179 }
8180 }
8181 }
8182 }
8183 else {
8184 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8185 }
8186
8187 String sql = query.toString();
8188
8189 Query q = session.createQuery(sql);
8190
8191 q.setFirstResult(0);
8192 q.setMaxResults(2);
8193
8194 QueryPos qPos = QueryPos.getInstance(q);
8195
8196 if (bindDisplayDate) {
8197 qPos.add(CalendarUtil.getTimestamp(displayDate));
8198 }
8199
8200 qPos.add(status);
8201
8202 if (orderByComparator != null) {
8203 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8204
8205 for (Object value : values) {
8206 qPos.add(value);
8207 }
8208 }
8209
8210 List<BlogsEntry> list = q.list();
8211
8212 if (list.size() == 2) {
8213 return list.get(1);
8214 }
8215 else {
8216 return null;
8217 }
8218 }
8219
8220
8227 public void removeByLtD_S(Date displayDate, int status)
8228 throws SystemException {
8229 for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8230 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8231 remove(blogsEntry);
8232 }
8233 }
8234
8235
8243 public int countByLtD_S(Date displayDate, int status)
8244 throws SystemException {
8245 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8246
8247 Object[] finderArgs = new Object[] { displayDate, status };
8248
8249 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8250 this);
8251
8252 if (count == null) {
8253 StringBundler query = new StringBundler(3);
8254
8255 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8256
8257 boolean bindDisplayDate = false;
8258
8259 if (displayDate == null) {
8260 query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8261 }
8262 else {
8263 bindDisplayDate = true;
8264
8265 query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8266 }
8267
8268 query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8269
8270 String sql = query.toString();
8271
8272 Session session = null;
8273
8274 try {
8275 session = openSession();
8276
8277 Query q = session.createQuery(sql);
8278
8279 QueryPos qPos = QueryPos.getInstance(q);
8280
8281 if (bindDisplayDate) {
8282 qPos.add(CalendarUtil.getTimestamp(displayDate));
8283 }
8284
8285 qPos.add(status);
8286
8287 count = (Long)q.uniqueResult();
8288
8289 FinderCacheUtil.putResult(finderPath, finderArgs, count);
8290 }
8291 catch (Exception e) {
8292 FinderCacheUtil.removeResult(finderPath, finderArgs);
8293
8294 throw processException(e);
8295 }
8296 finally {
8297 closeSession(session);
8298 }
8299 }
8300
8301 return count.intValue();
8302 }
8303
8304 private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
8305 private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8306 private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8307 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8308 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8309 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
8310 new String[] {
8311 Long.class.getName(), Long.class.getName(),
8312 Integer.class.getName(),
8313
8314 Integer.class.getName(), Integer.class.getName(),
8315 OrderByComparator.class.getName()
8316 });
8317 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
8318 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8319 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8320 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
8321 new String[] {
8322 Long.class.getName(), Long.class.getName(),
8323 Integer.class.getName()
8324 });
8325
8326
8335 public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8336 int status) throws SystemException {
8337 return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
8338 QueryUtil.ALL_POS, null);
8339 }
8340
8341
8356 public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8357 int status, int start, int end) throws SystemException {
8358 return findByC_U_NotS(companyId, userId, status, start, end, null);
8359 }
8360
8361
8377 public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8378 int status, int start, int end, OrderByComparator orderByComparator)
8379 throws SystemException {
8380 boolean pagination = true;
8381 FinderPath finderPath = null;
8382 Object[] finderArgs = null;
8383
8384 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
8385 finderArgs = new Object[] {
8386 companyId, userId, status,
8387
8388 start, end, orderByComparator
8389 };
8390
8391 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8392 finderArgs, this);
8393
8394 if ((list != null) && !list.isEmpty()) {
8395 for (BlogsEntry blogsEntry : list) {
8396 if ((companyId != blogsEntry.getCompanyId()) ||
8397 (userId != blogsEntry.getUserId()) ||
8398 (status != blogsEntry.getStatus())) {
8399 list = null;
8400
8401 break;
8402 }
8403 }
8404 }
8405
8406 if (list == null) {
8407 StringBundler query = null;
8408
8409 if (orderByComparator != null) {
8410 query = new StringBundler(5 +
8411 (orderByComparator.getOrderByFields().length * 3));
8412 }
8413 else {
8414 query = new StringBundler(5);
8415 }
8416
8417 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8418
8419 query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
8420
8421 query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
8422
8423 query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
8424
8425 if (orderByComparator != null) {
8426 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8427 orderByComparator);
8428 }
8429 else
8430 if (pagination) {
8431 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8432 }
8433
8434 String sql = query.toString();
8435
8436 Session session = null;
8437
8438 try {
8439 session = openSession();
8440
8441 Query q = session.createQuery(sql);
8442
8443 QueryPos qPos = QueryPos.getInstance(q);
8444
8445 qPos.add(companyId);
8446
8447 qPos.add(userId);
8448
8449 qPos.add(status);
8450
8451 if (!pagination) {
8452 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8453 start, end, false);
8454
8455 Collections.sort(list);
8456
8457 list = new UnmodifiableList<BlogsEntry>(list);
8458 }
8459 else {
8460 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8461 start, end);
8462 }
8463
8464 cacheResult(list);
8465
8466 FinderCacheUtil.putResult(finderPath, finderArgs, list);
8467 }
8468 catch (Exception e) {
8469 FinderCacheUtil.removeResult(finderPath, finderArgs);
8470
8471 throw processException(e);
8472 }
8473 finally {
8474 closeSession(session);
8475 }
8476 }
8477
8478 return list;
8479 }
8480
8481
8492 public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
8493 int status, OrderByComparator orderByComparator)
8494 throws NoSuchEntryException, SystemException {
8495 BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
8496 status, orderByComparator);
8497
8498 if (blogsEntry != null) {
8499 return blogsEntry;
8500 }
8501
8502 StringBundler msg = new StringBundler(8);
8503
8504 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8505
8506 msg.append("companyId=");
8507 msg.append(companyId);
8508
8509 msg.append(", userId=");
8510 msg.append(userId);
8511
8512 msg.append(", status=");
8513 msg.append(status);
8514
8515 msg.append(StringPool.CLOSE_CURLY_BRACE);
8516
8517 throw new NoSuchEntryException(msg.toString());
8518 }
8519
8520
8530 public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
8531 int status, OrderByComparator orderByComparator)
8532 throws SystemException {
8533 List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
8534 orderByComparator);
8535
8536 if (!list.isEmpty()) {
8537 return list.get(0);
8538 }
8539
8540 return null;
8541 }
8542
8543
8554 public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
8555 int status, OrderByComparator orderByComparator)
8556 throws NoSuchEntryException, SystemException {
8557 BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
8558 orderByComparator);
8559
8560 if (blogsEntry != null) {
8561 return blogsEntry;
8562 }
8563
8564 StringBundler msg = new StringBundler(8);
8565
8566 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8567
8568 msg.append("companyId=");
8569 msg.append(companyId);
8570
8571 msg.append(", userId=");
8572 msg.append(userId);
8573
8574 msg.append(", status=");
8575 msg.append(status);
8576
8577 msg.append(StringPool.CLOSE_CURLY_BRACE);
8578
8579 throw new NoSuchEntryException(msg.toString());
8580 }
8581
8582
8592 public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
8593 int status, OrderByComparator orderByComparator)
8594 throws SystemException {
8595 int count = countByC_U_NotS(companyId, userId, status);
8596
8597 List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
8598 count - 1, count, orderByComparator);
8599
8600 if (!list.isEmpty()) {
8601 return list.get(0);
8602 }
8603
8604 return null;
8605 }
8606
8607
8619 public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
8620 long companyId, long userId, int status,
8621 OrderByComparator orderByComparator)
8622 throws NoSuchEntryException, SystemException {
8623 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8624
8625 Session session = null;
8626
8627 try {
8628 session = openSession();
8629
8630 BlogsEntry[] array = new BlogsEntryImpl[3];
8631
8632 array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
8633 companyId, userId, status, orderByComparator, true);
8634
8635 array[1] = blogsEntry;
8636
8637 array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
8638 companyId, userId, status, orderByComparator, false);
8639
8640 return array;
8641 }
8642 catch (Exception e) {
8643 throw processException(e);
8644 }
8645 finally {
8646 closeSession(session);
8647 }
8648 }
8649
8650 protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
8651 BlogsEntry blogsEntry, long companyId, long userId, int status,
8652 OrderByComparator orderByComparator, boolean previous) {
8653 StringBundler query = null;
8654
8655 if (orderByComparator != null) {
8656 query = new StringBundler(6 +
8657 (orderByComparator.getOrderByFields().length * 6));
8658 }
8659 else {
8660 query = new StringBundler(3);
8661 }
8662
8663 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8664
8665 query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
8666
8667 query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
8668
8669 query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
8670
8671 if (orderByComparator != null) {
8672 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8673
8674 if (orderByConditionFields.length > 0) {
8675 query.append(WHERE_AND);
8676 }
8677
8678 for (int i = 0; i < orderByConditionFields.length; i++) {
8679 query.append(_ORDER_BY_ENTITY_ALIAS);
8680 query.append(orderByConditionFields[i]);
8681
8682 if ((i + 1) < orderByConditionFields.length) {
8683 if (orderByComparator.isAscending() ^ previous) {
8684 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8685 }
8686 else {
8687 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8688 }
8689 }
8690 else {
8691 if (orderByComparator.isAscending() ^ previous) {
8692 query.append(WHERE_GREATER_THAN);
8693 }
8694 else {
8695 query.append(WHERE_LESSER_THAN);
8696 }
8697 }
8698 }
8699
8700 query.append(ORDER_BY_CLAUSE);
8701
8702 String[] orderByFields = orderByComparator.getOrderByFields();
8703
8704 for (int i = 0; i < orderByFields.length; i++) {
8705 query.append(_ORDER_BY_ENTITY_ALIAS);
8706 query.append(orderByFields[i]);
8707
8708 if ((i + 1) < orderByFields.length) {
8709 if (orderByComparator.isAscending() ^ previous) {
8710 query.append(ORDER_BY_ASC_HAS_NEXT);
8711 }
8712 else {
8713 query.append(ORDER_BY_DESC_HAS_NEXT);
8714 }
8715 }
8716 else {
8717 if (orderByComparator.isAscending() ^ previous) {
8718 query.append(ORDER_BY_ASC);
8719 }
8720 else {
8721 query.append(ORDER_BY_DESC);
8722 }
8723 }
8724 }
8725 }
8726 else {
8727 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8728 }
8729
8730 String sql = query.toString();
8731
8732 Query q = session.createQuery(sql);
8733
8734 q.setFirstResult(0);
8735 q.setMaxResults(2);
8736
8737 QueryPos qPos = QueryPos.getInstance(q);
8738
8739 qPos.add(companyId);
8740
8741 qPos.add(userId);
8742
8743 qPos.add(status);
8744
8745 if (orderByComparator != null) {
8746 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8747
8748 for (Object value : values) {
8749 qPos.add(value);
8750 }
8751 }
8752
8753 List<BlogsEntry> list = q.list();
8754
8755 if (list.size() == 2) {
8756 return list.get(1);
8757 }
8758 else {
8759 return null;
8760 }
8761 }
8762
8763
8771 public void removeByC_U_NotS(long companyId, long userId, int status)
8772 throws SystemException {
8773 for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
8774 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8775 remove(blogsEntry);
8776 }
8777 }
8778
8779
8788 public int countByC_U_NotS(long companyId, long userId, int status)
8789 throws SystemException {
8790 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
8791
8792 Object[] finderArgs = new Object[] { companyId, userId, status };
8793
8794 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8795 this);
8796
8797 if (count == null) {
8798 StringBundler query = new StringBundler(4);
8799
8800 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8801
8802 query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
8803
8804 query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
8805
8806 query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
8807
8808 String sql = query.toString();
8809
8810 Session session = null;
8811
8812 try {
8813 session = openSession();
8814
8815 Query q = session.createQuery(sql);
8816
8817 QueryPos qPos = QueryPos.getInstance(q);
8818
8819 qPos.add(companyId);
8820
8821 qPos.add(userId);
8822
8823 qPos.add(status);
8824
8825 count = (Long)q.uniqueResult();
8826
8827 FinderCacheUtil.putResult(finderPath, finderArgs, count);
8828 }
8829 catch (Exception e) {
8830 FinderCacheUtil.removeResult(finderPath, finderArgs);
8831
8832 throw processException(e);
8833 }
8834 finally {
8835 closeSession(session);
8836 }
8837 }
8838
8839 return count.intValue();
8840 }
8841
8842 private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
8843 private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
8844 private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
8845 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8846 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8847 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
8848 new String[] {
8849 Long.class.getName(), Long.class.getName(),
8850 Integer.class.getName(),
8851
8852 Integer.class.getName(), Integer.class.getName(),
8853 OrderByComparator.class.getName()
8854 });
8855 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8856 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8857 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
8858 new String[] {
8859 Long.class.getName(), Long.class.getName(),
8860 Integer.class.getName()
8861 },
8862 BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
8863 BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
8864 BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
8865 BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
8866 BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
8867 public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8868 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8869 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
8870 new String[] {
8871 Long.class.getName(), Long.class.getName(),
8872 Integer.class.getName()
8873 });
8874
8875
8884 public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status)
8885 throws SystemException {
8886 return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
8887 QueryUtil.ALL_POS, null);
8888 }
8889
8890
8905 public List<BlogsEntry> findByC_U_S(long companyId, long userId,
8906 int status, int start, int end) throws SystemException {
8907 return findByC_U_S(companyId, userId, status, start, end, null);
8908 }
8909
8910
8926 public List<BlogsEntry> findByC_U_S(long companyId, long userId,
8927 int status, int start, int end, OrderByComparator orderByComparator)
8928 throws SystemException {
8929 boolean pagination = true;
8930 FinderPath finderPath = null;
8931 Object[] finderArgs = null;
8932
8933 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8934 (orderByComparator == null)) {
8935 pagination = false;
8936 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
8937 finderArgs = new Object[] { companyId, userId, status };
8938 }
8939 else {
8940 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
8941 finderArgs = new Object[] {
8942 companyId, userId, status,
8943
8944 start, end, orderByComparator
8945 };
8946 }
8947
8948 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8949 finderArgs, this);
8950
8951 if ((list != null) && !list.isEmpty()) {
8952 for (BlogsEntry blogsEntry : list) {
8953 if ((companyId != blogsEntry.getCompanyId()) ||
8954 (userId != blogsEntry.getUserId()) ||
8955 (status != blogsEntry.getStatus())) {
8956 list = null;
8957
8958 break;
8959 }
8960 }
8961 }
8962
8963 if (list == null) {
8964 StringBundler query = null;
8965
8966 if (orderByComparator != null) {
8967 query = new StringBundler(5 +
8968 (orderByComparator.getOrderByFields().length * 3));
8969 }
8970 else {
8971 query = new StringBundler(5);
8972 }
8973
8974 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8975
8976 query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
8977
8978 query.append(_FINDER_COLUMN_C_U_S_USERID_2);
8979
8980 query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
8981
8982 if (orderByComparator != null) {
8983 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8984 orderByComparator);
8985 }
8986 else
8987 if (pagination) {
8988 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8989 }
8990
8991 String sql = query.toString();
8992
8993 Session session = null;
8994
8995 try {
8996 session = openSession();
8997
8998 Query q = session.createQuery(sql);
8999
9000 QueryPos qPos = QueryPos.getInstance(q);
9001
9002 qPos.add(companyId);
9003
9004 qPos.add(userId);
9005
9006 qPos.add(status);
9007
9008 if (!pagination) {
9009 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9010 start, end, false);
9011
9012 Collections.sort(list);
9013
9014 list = new UnmodifiableList<BlogsEntry>(list);
9015 }
9016 else {
9017 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9018 start, end);
9019 }
9020
9021 cacheResult(list);
9022
9023 FinderCacheUtil.putResult(finderPath, finderArgs, list);
9024 }
9025 catch (Exception e) {
9026 FinderCacheUtil.removeResult(finderPath, finderArgs);
9027
9028 throw processException(e);
9029 }
9030 finally {
9031 closeSession(session);
9032 }
9033 }
9034
9035 return list;
9036 }
9037
9038
9049 public BlogsEntry findByC_U_S_First(long companyId, long userId,
9050 int status, OrderByComparator orderByComparator)
9051 throws NoSuchEntryException, SystemException {
9052 BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
9053 orderByComparator);
9054
9055 if (blogsEntry != null) {
9056 return blogsEntry;
9057 }
9058
9059 StringBundler msg = new StringBundler(8);
9060
9061 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9062
9063 msg.append("companyId=");
9064 msg.append(companyId);
9065
9066 msg.append(", userId=");
9067 msg.append(userId);
9068
9069 msg.append(", status=");
9070 msg.append(status);
9071
9072 msg.append(StringPool.CLOSE_CURLY_BRACE);
9073
9074 throw new NoSuchEntryException(msg.toString());
9075 }
9076
9077
9087 public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
9088 int status, OrderByComparator orderByComparator)
9089 throws SystemException {
9090 List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
9091 orderByComparator);
9092
9093 if (!list.isEmpty()) {
9094 return list.get(0);
9095 }
9096
9097 return null;
9098 }
9099
9100
9111 public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
9112 OrderByComparator orderByComparator)
9113 throws NoSuchEntryException, SystemException {
9114 BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
9115 orderByComparator);
9116
9117 if (blogsEntry != null) {
9118 return blogsEntry;
9119 }
9120
9121 StringBundler msg = new StringBundler(8);
9122
9123 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9124
9125 msg.append("companyId=");
9126 msg.append(companyId);
9127
9128 msg.append(", userId=");
9129 msg.append(userId);
9130
9131 msg.append(", status=");
9132 msg.append(status);
9133
9134 msg.append(StringPool.CLOSE_CURLY_BRACE);
9135
9136 throw new NoSuchEntryException(msg.toString());
9137 }
9138
9139
9149 public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
9150 int status, OrderByComparator orderByComparator)
9151 throws SystemException {
9152 int count = countByC_U_S(companyId, userId, status);
9153
9154 List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
9155 count - 1, count, orderByComparator);
9156
9157 if (!list.isEmpty()) {
9158 return list.get(0);
9159 }
9160
9161 return null;
9162 }
9163
9164
9176 public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
9177 long userId, int status, OrderByComparator orderByComparator)
9178 throws NoSuchEntryException, SystemException {
9179 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9180
9181 Session session = null;
9182
9183 try {
9184 session = openSession();
9185
9186 BlogsEntry[] array = new BlogsEntryImpl[3];
9187
9188 array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
9189 userId, status, orderByComparator, true);
9190
9191 array[1] = blogsEntry;
9192
9193 array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
9194 userId, status, orderByComparator, false);
9195
9196 return array;
9197 }
9198 catch (Exception e) {
9199 throw processException(e);
9200 }
9201 finally {
9202 closeSession(session);
9203 }
9204 }
9205
9206 protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
9207 BlogsEntry blogsEntry, long companyId, long userId, int status,
9208 OrderByComparator orderByComparator, boolean previous) {
9209 StringBundler query = null;
9210
9211 if (orderByComparator != null) {
9212 query = new StringBundler(6 +
9213 (orderByComparator.getOrderByFields().length * 6));
9214 }
9215 else {
9216 query = new StringBundler(3);
9217 }
9218
9219 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9220
9221 query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
9222
9223 query.append(_FINDER_COLUMN_C_U_S_USERID_2);
9224
9225 query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
9226
9227 if (orderByComparator != null) {
9228 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9229
9230 if (orderByConditionFields.length > 0) {
9231 query.append(WHERE_AND);
9232 }
9233
9234 for (int i = 0; i < orderByConditionFields.length; i++) {
9235 query.append(_ORDER_BY_ENTITY_ALIAS);
9236 query.append(orderByConditionFields[i]);
9237
9238 if ((i + 1) < orderByConditionFields.length) {
9239 if (orderByComparator.isAscending() ^ previous) {
9240 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9241 }
9242 else {
9243 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9244 }
9245 }
9246 else {
9247 if (orderByComparator.isAscending() ^ previous) {
9248 query.append(WHERE_GREATER_THAN);
9249 }
9250 else {
9251 query.append(WHERE_LESSER_THAN);
9252 }
9253 }
9254 }
9255
9256 query.append(ORDER_BY_CLAUSE);
9257
9258 String[] orderByFields = orderByComparator.getOrderByFields();
9259
9260 for (int i = 0; i < orderByFields.length; i++) {
9261 query.append(_ORDER_BY_ENTITY_ALIAS);
9262 query.append(orderByFields[i]);
9263
9264 if ((i + 1) < orderByFields.length) {
9265 if (orderByComparator.isAscending() ^ previous) {
9266 query.append(ORDER_BY_ASC_HAS_NEXT);
9267 }
9268 else {
9269 query.append(ORDER_BY_DESC_HAS_NEXT);
9270 }
9271 }
9272 else {
9273 if (orderByComparator.isAscending() ^ previous) {
9274 query.append(ORDER_BY_ASC);
9275 }
9276 else {
9277 query.append(ORDER_BY_DESC);
9278 }
9279 }
9280 }
9281 }
9282 else {
9283 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9284 }
9285
9286 String sql = query.toString();
9287
9288 Query q = session.createQuery(sql);
9289
9290 q.setFirstResult(0);
9291 q.setMaxResults(2);
9292
9293 QueryPos qPos = QueryPos.getInstance(q);
9294
9295 qPos.add(companyId);
9296
9297 qPos.add(userId);
9298
9299 qPos.add(status);
9300
9301 if (orderByComparator != null) {
9302 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9303
9304 for (Object value : values) {
9305 qPos.add(value);
9306 }
9307 }
9308
9309 List<BlogsEntry> list = q.list();
9310
9311 if (list.size() == 2) {
9312 return list.get(1);
9313 }
9314 else {
9315 return null;
9316 }
9317 }
9318
9319
9327 public void removeByC_U_S(long companyId, long userId, int status)
9328 throws SystemException {
9329 for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
9330 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9331 remove(blogsEntry);
9332 }
9333 }
9334
9335
9344 public int countByC_U_S(long companyId, long userId, int status)
9345 throws SystemException {
9346 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
9347
9348 Object[] finderArgs = new Object[] { companyId, userId, status };
9349
9350 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9351 this);
9352
9353 if (count == null) {
9354 StringBundler query = new StringBundler(4);
9355
9356 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9357
9358 query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
9359
9360 query.append(_FINDER_COLUMN_C_U_S_USERID_2);
9361
9362 query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
9363
9364 String sql = query.toString();
9365
9366 Session session = null;
9367
9368 try {
9369 session = openSession();
9370
9371 Query q = session.createQuery(sql);
9372
9373 QueryPos qPos = QueryPos.getInstance(q);
9374
9375 qPos.add(companyId);
9376
9377 qPos.add(userId);
9378
9379 qPos.add(status);
9380
9381 count = (Long)q.uniqueResult();
9382
9383 FinderCacheUtil.putResult(finderPath, finderArgs, count);
9384 }
9385 catch (Exception e) {
9386 FinderCacheUtil.removeResult(finderPath, finderArgs);
9387
9388 throw processException(e);
9389 }
9390 finally {
9391 closeSession(session);
9392 }
9393 }
9394
9395 return count.intValue();
9396 }
9397
9398 private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
9399 private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
9400 private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
9401 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
9402 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9403 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9404 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
9405 new String[] {
9406 Long.class.getName(), Date.class.getName(),
9407 Integer.class.getName(),
9408
9409 Integer.class.getName(), Integer.class.getName(),
9410 OrderByComparator.class.getName()
9411 });
9412 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
9413 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9414 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9415 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
9416 new String[] {
9417 Long.class.getName(), Date.class.getName(),
9418 Integer.class.getName()
9419 });
9420
9421
9430 public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9431 int status) throws SystemException {
9432 return findByC_LtD_NotS(companyId, displayDate, status,
9433 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9434 }
9435
9436
9451 public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9452 int status, int start, int end) throws SystemException {
9453 return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
9454 }
9455
9456
9472 public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9473 int status, int start, int end, OrderByComparator orderByComparator)
9474 throws SystemException {
9475 boolean pagination = true;
9476 FinderPath finderPath = null;
9477 Object[] finderArgs = null;
9478
9479 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
9480 finderArgs = new Object[] {
9481 companyId, displayDate, status,
9482
9483 start, end, orderByComparator
9484 };
9485
9486 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9487 finderArgs, this);
9488
9489 if ((list != null) && !list.isEmpty()) {
9490 for (BlogsEntry blogsEntry : list) {
9491 if ((companyId != blogsEntry.getCompanyId()) ||
9492 !Validator.equals(displayDate,
9493 blogsEntry.getDisplayDate()) ||
9494 (status != blogsEntry.getStatus())) {
9495 list = null;
9496
9497 break;
9498 }
9499 }
9500 }
9501
9502 if (list == null) {
9503 StringBundler query = null;
9504
9505 if (orderByComparator != null) {
9506 query = new StringBundler(5 +
9507 (orderByComparator.getOrderByFields().length * 3));
9508 }
9509 else {
9510 query = new StringBundler(5);
9511 }
9512
9513 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9514
9515 query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
9516
9517 boolean bindDisplayDate = false;
9518
9519 if (displayDate == null) {
9520 query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
9521 }
9522 else {
9523 bindDisplayDate = true;
9524
9525 query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
9526 }
9527
9528 query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
9529
9530 if (orderByComparator != null) {
9531 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9532 orderByComparator);
9533 }
9534 else
9535 if (pagination) {
9536 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9537 }
9538
9539 String sql = query.toString();
9540
9541 Session session = null;
9542
9543 try {
9544 session = openSession();
9545
9546 Query q = session.createQuery(sql);
9547
9548 QueryPos qPos = QueryPos.getInstance(q);
9549
9550 qPos.add(companyId);
9551
9552 if (bindDisplayDate) {
9553 qPos.add(CalendarUtil.getTimestamp(displayDate));
9554 }
9555
9556 qPos.add(status);
9557
9558 if (!pagination) {
9559 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9560 start, end, false);
9561
9562 Collections.sort(list);
9563
9564 list = new UnmodifiableList<BlogsEntry>(list);
9565 }
9566 else {
9567 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9568 start, end);
9569 }
9570
9571 cacheResult(list);
9572
9573 FinderCacheUtil.putResult(finderPath, finderArgs, list);
9574 }
9575 catch (Exception e) {
9576 FinderCacheUtil.removeResult(finderPath, finderArgs);
9577
9578 throw processException(e);
9579 }
9580 finally {
9581 closeSession(session);
9582 }
9583 }
9584
9585 return list;
9586 }
9587
9588
9599 public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
9600 int status, OrderByComparator orderByComparator)
9601 throws NoSuchEntryException, SystemException {
9602 BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
9603 status, orderByComparator);
9604
9605 if (blogsEntry != null) {
9606 return blogsEntry;
9607 }
9608
9609 StringBundler msg = new StringBundler(8);
9610
9611 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9612
9613 msg.append("companyId=");
9614 msg.append(companyId);
9615
9616 msg.append(", displayDate=");
9617 msg.append(displayDate);
9618
9619 msg.append(", status=");
9620 msg.append(status);
9621
9622 msg.append(StringPool.CLOSE_CURLY_BRACE);
9623
9624 throw new NoSuchEntryException(msg.toString());
9625 }
9626
9627
9637 public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
9638 int status, OrderByComparator orderByComparator)
9639 throws SystemException {
9640 List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
9641 status, 0, 1, orderByComparator);
9642
9643 if (!list.isEmpty()) {
9644 return list.get(0);
9645 }
9646
9647 return null;
9648 }
9649
9650
9661 public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
9662 int status, OrderByComparator orderByComparator)
9663 throws NoSuchEntryException, SystemException {
9664 BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
9665 status, orderByComparator);
9666
9667 if (blogsEntry != null) {
9668 return blogsEntry;
9669 }
9670
9671 StringBundler msg = new StringBundler(8);
9672
9673 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9674
9675 msg.append("companyId=");
9676 msg.append(companyId);
9677
9678 msg.append(", displayDate=");
9679 msg.append(displayDate);
9680
9681 msg.append(", status=");
9682 msg.append(status);
9683
9684 msg.append(StringPool.CLOSE_CURLY_BRACE);
9685
9686 throw new NoSuchEntryException(msg.toString());
9687 }
9688
9689
9699 public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
9700 int status, OrderByComparator orderByComparator)
9701 throws SystemException {
9702 int count = countByC_LtD_NotS(companyId, displayDate, status);
9703
9704 List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
9705 status, count - 1, count, orderByComparator);
9706
9707 if (!list.isEmpty()) {
9708 return list.get(0);
9709 }
9710
9711 return null;
9712 }
9713
9714
9726 public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
9727 long companyId, Date displayDate, int status,
9728 OrderByComparator orderByComparator)
9729 throws NoSuchEntryException, SystemException {
9730 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9731
9732 Session session = null;
9733
9734 try {
9735 session = openSession();
9736
9737 BlogsEntry[] array = new BlogsEntryImpl[3];
9738
9739 array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
9740 companyId, displayDate, status, orderByComparator, true);
9741
9742 array[1] = blogsEntry;
9743
9744 array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
9745 companyId, displayDate, status, orderByComparator, false);
9746
9747 return array;
9748 }
9749 catch (Exception e) {
9750 throw processException(e);
9751 }
9752 finally {
9753 closeSession(session);
9754 }
9755 }
9756
9757 protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
9758 BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
9759 OrderByComparator orderByComparator, boolean previous) {
9760 StringBundler query = null;
9761
9762 if (orderByComparator != null) {
9763 query = new StringBundler(6 +
9764 (orderByComparator.getOrderByFields().length * 6));
9765 }
9766 else {
9767 query = new StringBundler(3);
9768 }
9769
9770 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9771
9772 query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
9773
9774 boolean bindDisplayDate = false;
9775
9776 if (displayDate == null) {
9777 query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
9778 }
9779 else {
9780 bindDisplayDate = true;
9781
9782 query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
9783 }
9784
9785 query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
9786
9787 if (orderByComparator != null) {
9788 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9789
9790 if (orderByConditionFields.length > 0) {
9791 query.append(WHERE_AND);
9792 }
9793
9794 for (int i = 0; i < orderByConditionFields.length; i++) {
9795 query.append(_ORDER_BY_ENTITY_ALIAS);
9796 query.append(orderByConditionFields[i]);
9797
9798 if ((i + 1) < orderByConditionFields.length) {
9799 if (orderByComparator.isAscending() ^ previous) {
9800 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9801 }
9802 else {
9803 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9804 }
9805 }
9806 else {
9807 if (orderByComparator.isAscending() ^ previous) {
9808 query.append(WHERE_GREATER_THAN);
9809 }
9810 else {
9811 query.append(WHERE_LESSER_THAN);
9812 }
9813 }
9814 }
9815
9816 query.append(ORDER_BY_CLAUSE);
9817
9818 String[] orderByFields = orderByComparator.getOrderByFields();
9819
9820 for (int i = 0; i < orderByFields.length; i++) {
9821 query.append(_ORDER_BY_ENTITY_ALIAS);
9822 query.append(orderByFields[i]);
9823
9824 if ((i + 1) < orderByFields.length) {
9825 if (orderByComparator.isAscending() ^ previous) {
9826 query.append(ORDER_BY_ASC_HAS_NEXT);
9827 }
9828 else {
9829 query.append(ORDER_BY_DESC_HAS_NEXT);
9830 }
9831 }
9832 else {
9833 if (orderByComparator.isAscending() ^ previous) {
9834 query.append(ORDER_BY_ASC);
9835 }
9836 else {
9837 query.append(ORDER_BY_DESC);
9838 }
9839 }
9840 }
9841 }
9842 else {
9843 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9844 }
9845
9846 String sql = query.toString();
9847
9848 Query q = session.createQuery(sql);
9849
9850 q.setFirstResult(0);
9851 q.setMaxResults(2);
9852
9853 QueryPos qPos = QueryPos.getInstance(q);
9854
9855 qPos.add(companyId);
9856
9857 if (bindDisplayDate) {
9858 qPos.add(CalendarUtil.getTimestamp(displayDate));
9859 }
9860
9861 qPos.add(status);
9862
9863 if (orderByComparator != null) {
9864 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9865
9866 for (Object value : values) {
9867 qPos.add(value);
9868 }
9869 }
9870
9871 List<BlogsEntry> list = q.list();
9872
9873 if (list.size() == 2) {
9874 return list.get(1);
9875 }
9876 else {
9877 return null;
9878 }
9879 }
9880
9881
9889 public void removeByC_LtD_NotS(long companyId, Date displayDate, int status)
9890 throws SystemException {
9891 for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
9892 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9893 remove(blogsEntry);
9894 }
9895 }
9896
9897
9906 public int countByC_LtD_NotS(long companyId, Date displayDate, int status)
9907 throws SystemException {
9908 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
9909
9910 Object[] finderArgs = new Object[] { companyId, displayDate, status };
9911
9912 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9913 this);
9914
9915 if (count == null) {
9916 StringBundler query = new StringBundler(4);
9917
9918 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9919
9920 query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
9921
9922 boolean bindDisplayDate = false;
9923
9924 if (displayDate == null) {
9925 query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
9926 }
9927 else {
9928 bindDisplayDate = true;
9929
9930 query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
9931 }
9932
9933 query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
9934
9935 String sql = query.toString();
9936
9937 Session session = null;
9938
9939 try {
9940 session = openSession();
9941
9942 Query q = session.createQuery(sql);
9943
9944 QueryPos qPos = QueryPos.getInstance(q);
9945
9946 qPos.add(companyId);
9947
9948 if (bindDisplayDate) {
9949 qPos.add(CalendarUtil.getTimestamp(displayDate));
9950 }
9951
9952 qPos.add(status);
9953
9954 count = (Long)q.uniqueResult();
9955
9956 FinderCacheUtil.putResult(finderPath, finderArgs, count);
9957 }
9958 catch (Exception e) {
9959 FinderCacheUtil.removeResult(finderPath, finderArgs);
9960
9961 throw processException(e);
9962 }
9963 finally {
9964 closeSession(session);
9965 }
9966 }
9967
9968 return count.intValue();
9969 }
9970
9971 private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
9972 private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
9973 private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
9974 private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
9975 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9976 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9977 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
9978 new String[] {
9979 Long.class.getName(), Date.class.getName(),
9980 Integer.class.getName(),
9981
9982 Integer.class.getName(), Integer.class.getName(),
9983 OrderByComparator.class.getName()
9984 });
9985 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9986 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9987 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
9988 new String[] {
9989 Long.class.getName(), Date.class.getName(),
9990 Integer.class.getName()
9991 });
9992
9993
10002 public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
10003 int status) throws SystemException {
10004 return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
10005 QueryUtil.ALL_POS, null);
10006 }
10007
10008
10023 public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
10024 int status, int start, int end) throws SystemException {
10025 return findByC_LtD_S(companyId, displayDate, status, start, end, null);
10026 }
10027
10028
10044 public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
10045 int status, int start, int end, OrderByComparator orderByComparator)
10046 throws SystemException {
10047 boolean pagination = true;
10048 FinderPath finderPath = null;
10049 Object[] finderArgs = null;
10050
10051 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
10052 finderArgs = new Object[] {
10053 companyId, displayDate, status,
10054
10055 start, end, orderByComparator
10056 };
10057
10058 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10059 finderArgs, this);
10060
10061 if ((list != null) && !list.isEmpty()) {
10062 for (BlogsEntry blogsEntry : list) {
10063 if ((companyId != blogsEntry.getCompanyId()) ||
10064 !Validator.equals(displayDate,
10065 blogsEntry.getDisplayDate()) ||
10066 (status != blogsEntry.getStatus())) {
10067 list = null;
10068
10069 break;
10070 }
10071 }
10072 }
10073
10074 if (list == null) {
10075 StringBundler query = null;
10076
10077 if (orderByComparator != null) {
10078 query = new StringBundler(5 +
10079 (orderByComparator.getOrderByFields().length * 3));
10080 }
10081 else {
10082 query = new StringBundler(5);
10083 }
10084
10085 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10086
10087 query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10088
10089 boolean bindDisplayDate = false;
10090
10091 if (displayDate == null) {
10092 query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10093 }
10094 else {
10095 bindDisplayDate = true;
10096
10097 query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10098 }
10099
10100 query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10101
10102 if (orderByComparator != null) {
10103 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10104 orderByComparator);
10105 }
10106 else
10107 if (pagination) {
10108 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10109 }
10110
10111 String sql = query.toString();
10112
10113 Session session = null;
10114
10115 try {
10116 session = openSession();
10117
10118 Query q = session.createQuery(sql);
10119
10120 QueryPos qPos = QueryPos.getInstance(q);
10121
10122 qPos.add(companyId);
10123
10124 if (bindDisplayDate) {
10125 qPos.add(CalendarUtil.getTimestamp(displayDate));
10126 }
10127
10128 qPos.add(status);
10129
10130 if (!pagination) {
10131 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10132 start, end, false);
10133
10134 Collections.sort(list);
10135
10136 list = new UnmodifiableList<BlogsEntry>(list);
10137 }
10138 else {
10139 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10140 start, end);
10141 }
10142
10143 cacheResult(list);
10144
10145 FinderCacheUtil.putResult(finderPath, finderArgs, list);
10146 }
10147 catch (Exception e) {
10148 FinderCacheUtil.removeResult(finderPath, finderArgs);
10149
10150 throw processException(e);
10151 }
10152 finally {
10153 closeSession(session);
10154 }
10155 }
10156
10157 return list;
10158 }
10159
10160
10171 public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
10172 int status, OrderByComparator orderByComparator)
10173 throws NoSuchEntryException, SystemException {
10174 BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
10175 status, orderByComparator);
10176
10177 if (blogsEntry != null) {
10178 return blogsEntry;
10179 }
10180
10181 StringBundler msg = new StringBundler(8);
10182
10183 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10184
10185 msg.append("companyId=");
10186 msg.append(companyId);
10187
10188 msg.append(", displayDate=");
10189 msg.append(displayDate);
10190
10191 msg.append(", status=");
10192 msg.append(status);
10193
10194 msg.append(StringPool.CLOSE_CURLY_BRACE);
10195
10196 throw new NoSuchEntryException(msg.toString());
10197 }
10198
10199
10209 public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
10210 int status, OrderByComparator orderByComparator)
10211 throws SystemException {
10212 List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
10213 0, 1, orderByComparator);
10214
10215 if (!list.isEmpty()) {
10216 return list.get(0);
10217 }
10218
10219 return null;
10220 }
10221
10222
10233 public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
10234 int status, OrderByComparator orderByComparator)
10235 throws NoSuchEntryException, SystemException {
10236 BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
10237 status, orderByComparator);
10238
10239 if (blogsEntry != null) {
10240 return blogsEntry;
10241 }
10242
10243 StringBundler msg = new StringBundler(8);
10244
10245 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10246
10247 msg.append("companyId=");
10248 msg.append(companyId);
10249
10250 msg.append(", displayDate=");
10251 msg.append(displayDate);
10252
10253 msg.append(", status=");
10254 msg.append(status);
10255
10256 msg.append(StringPool.CLOSE_CURLY_BRACE);
10257
10258 throw new NoSuchEntryException(msg.toString());
10259 }
10260
10261
10271 public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
10272 int status, OrderByComparator orderByComparator)
10273 throws SystemException {
10274 int count = countByC_LtD_S(companyId, displayDate, status);
10275
10276 List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
10277 count - 1, count, orderByComparator);
10278
10279 if (!list.isEmpty()) {
10280 return list.get(0);
10281 }
10282
10283 return null;
10284 }
10285
10286
10298 public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
10299 Date displayDate, int status, OrderByComparator orderByComparator)
10300 throws NoSuchEntryException, SystemException {
10301 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10302
10303 Session session = null;
10304
10305 try {
10306 session = openSession();
10307
10308 BlogsEntry[] array = new BlogsEntryImpl[3];
10309
10310 array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
10311 displayDate, status, orderByComparator, true);
10312
10313 array[1] = blogsEntry;
10314
10315 array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
10316 displayDate, status, orderByComparator, false);
10317
10318 return array;
10319 }
10320 catch (Exception e) {
10321 throw processException(e);
10322 }
10323 finally {
10324 closeSession(session);
10325 }
10326 }
10327
10328 protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
10329 BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
10330 OrderByComparator orderByComparator, boolean previous) {
10331 StringBundler query = null;
10332
10333 if (orderByComparator != null) {
10334 query = new StringBundler(6 +
10335 (orderByComparator.getOrderByFields().length * 6));
10336 }
10337 else {
10338 query = new StringBundler(3);
10339 }
10340
10341 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10342
10343 query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10344
10345 boolean bindDisplayDate = false;
10346
10347 if (displayDate == null) {
10348 query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10349 }
10350 else {
10351 bindDisplayDate = true;
10352
10353 query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10354 }
10355
10356 query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10357
10358 if (orderByComparator != null) {
10359 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10360
10361 if (orderByConditionFields.length > 0) {
10362 query.append(WHERE_AND);
10363 }
10364
10365 for (int i = 0; i < orderByConditionFields.length; i++) {
10366 query.append(_ORDER_BY_ENTITY_ALIAS);
10367 query.append(orderByConditionFields[i]);
10368
10369 if ((i + 1) < orderByConditionFields.length) {
10370 if (orderByComparator.isAscending() ^ previous) {
10371 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10372 }
10373 else {
10374 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10375 }
10376 }
10377 else {
10378 if (orderByComparator.isAscending() ^ previous) {
10379 query.append(WHERE_GREATER_THAN);
10380 }
10381 else {
10382 query.append(WHERE_LESSER_THAN);
10383 }
10384 }
10385 }
10386
10387 query.append(ORDER_BY_CLAUSE);
10388
10389 String[] orderByFields = orderByComparator.getOrderByFields();
10390
10391 for (int i = 0; i < orderByFields.length; i++) {
10392 query.append(_ORDER_BY_ENTITY_ALIAS);
10393 query.append(orderByFields[i]);
10394
10395 if ((i + 1) < orderByFields.length) {
10396 if (orderByComparator.isAscending() ^ previous) {
10397 query.append(ORDER_BY_ASC_HAS_NEXT);
10398 }
10399 else {
10400 query.append(ORDER_BY_DESC_HAS_NEXT);
10401 }
10402 }
10403 else {
10404 if (orderByComparator.isAscending() ^ previous) {
10405 query.append(ORDER_BY_ASC);
10406 }
10407 else {
10408 query.append(ORDER_BY_DESC);
10409 }
10410 }
10411 }
10412 }
10413 else {
10414 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10415 }
10416
10417 String sql = query.toString();
10418
10419 Query q = session.createQuery(sql);
10420
10421 q.setFirstResult(0);
10422 q.setMaxResults(2);
10423
10424 QueryPos qPos = QueryPos.getInstance(q);
10425
10426 qPos.add(companyId);
10427
10428 if (bindDisplayDate) {
10429 qPos.add(CalendarUtil.getTimestamp(displayDate));
10430 }
10431
10432 qPos.add(status);
10433
10434 if (orderByComparator != null) {
10435 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10436
10437 for (Object value : values) {
10438 qPos.add(value);
10439 }
10440 }
10441
10442 List<BlogsEntry> list = q.list();
10443
10444 if (list.size() == 2) {
10445 return list.get(1);
10446 }
10447 else {
10448 return null;
10449 }
10450 }
10451
10452
10460 public void removeByC_LtD_S(long companyId, Date displayDate, int status)
10461 throws SystemException {
10462 for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
10463 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10464 remove(blogsEntry);
10465 }
10466 }
10467
10468
10477 public int countByC_LtD_S(long companyId, Date displayDate, int status)
10478 throws SystemException {
10479 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
10480
10481 Object[] finderArgs = new Object[] { companyId, displayDate, status };
10482
10483 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10484 this);
10485
10486 if (count == null) {
10487 StringBundler query = new StringBundler(4);
10488
10489 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10490
10491 query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10492
10493 boolean bindDisplayDate = false;
10494
10495 if (displayDate == null) {
10496 query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10497 }
10498 else {
10499 bindDisplayDate = true;
10500
10501 query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10502 }
10503
10504 query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10505
10506 String sql = query.toString();
10507
10508 Session session = null;
10509
10510 try {
10511 session = openSession();
10512
10513 Query q = session.createQuery(sql);
10514
10515 QueryPos qPos = QueryPos.getInstance(q);
10516
10517 qPos.add(companyId);
10518
10519 if (bindDisplayDate) {
10520 qPos.add(CalendarUtil.getTimestamp(displayDate));
10521 }
10522
10523 qPos.add(status);
10524
10525 count = (Long)q.uniqueResult();
10526
10527 FinderCacheUtil.putResult(finderPath, finderArgs, count);
10528 }
10529 catch (Exception e) {
10530 FinderCacheUtil.removeResult(finderPath, finderArgs);
10531
10532 throw processException(e);
10533 }
10534 finally {
10535 closeSession(session);
10536 }
10537 }
10538
10539 return count.intValue();
10540 }
10541
10542 private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
10543 private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
10544 private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
10545 private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
10546 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10547 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10548 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
10549 new String[] {
10550 Long.class.getName(), Long.class.getName(), Date.class.getName(),
10551
10552 Integer.class.getName(), Integer.class.getName(),
10553 OrderByComparator.class.getName()
10554 });
10555 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10556 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10557 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
10558 new String[] {
10559 Long.class.getName(), Long.class.getName(), Date.class.getName()
10560 });
10561
10562
10571 public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10572 Date displayDate) throws SystemException {
10573 return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
10574 QueryUtil.ALL_POS, null);
10575 }
10576
10577
10592 public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10593 Date displayDate, int start, int end) throws SystemException {
10594 return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
10595 }
10596
10597
10613 public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10614 Date displayDate, int start, int end,
10615 OrderByComparator orderByComparator) throws SystemException {
10616 boolean pagination = true;
10617 FinderPath finderPath = null;
10618 Object[] finderArgs = null;
10619
10620 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
10621 finderArgs = new Object[] {
10622 groupId, userId, displayDate,
10623
10624 start, end, orderByComparator
10625 };
10626
10627 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10628 finderArgs, this);
10629
10630 if ((list != null) && !list.isEmpty()) {
10631 for (BlogsEntry blogsEntry : list) {
10632 if ((groupId != blogsEntry.getGroupId()) ||
10633 (userId != blogsEntry.getUserId()) ||
10634 !Validator.equals(displayDate,
10635 blogsEntry.getDisplayDate())) {
10636 list = null;
10637
10638 break;
10639 }
10640 }
10641 }
10642
10643 if (list == null) {
10644 StringBundler query = null;
10645
10646 if (orderByComparator != null) {
10647 query = new StringBundler(5 +
10648 (orderByComparator.getOrderByFields().length * 3));
10649 }
10650 else {
10651 query = new StringBundler(5);
10652 }
10653
10654 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10655
10656 query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
10657
10658 query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
10659
10660 boolean bindDisplayDate = false;
10661
10662 if (displayDate == null) {
10663 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
10664 }
10665 else {
10666 bindDisplayDate = true;
10667
10668 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
10669 }
10670
10671 if (orderByComparator != null) {
10672 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10673 orderByComparator);
10674 }
10675 else
10676 if (pagination) {
10677 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10678 }
10679
10680 String sql = query.toString();
10681
10682 Session session = null;
10683
10684 try {
10685 session = openSession();
10686
10687 Query q = session.createQuery(sql);
10688
10689 QueryPos qPos = QueryPos.getInstance(q);
10690
10691 qPos.add(groupId);
10692
10693 qPos.add(userId);
10694
10695 if (bindDisplayDate) {
10696 qPos.add(CalendarUtil.getTimestamp(displayDate));
10697 }
10698
10699 if (!pagination) {
10700 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10701 start, end, false);
10702
10703 Collections.sort(list);
10704
10705 list = new UnmodifiableList<BlogsEntry>(list);
10706 }
10707 else {
10708 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10709 start, end);
10710 }
10711
10712 cacheResult(list);
10713
10714 FinderCacheUtil.putResult(finderPath, finderArgs, list);
10715 }
10716 catch (Exception e) {
10717 FinderCacheUtil.removeResult(finderPath, finderArgs);
10718
10719 throw processException(e);
10720 }
10721 finally {
10722 closeSession(session);
10723 }
10724 }
10725
10726 return list;
10727 }
10728
10729
10740 public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
10741 Date displayDate, OrderByComparator orderByComparator)
10742 throws NoSuchEntryException, SystemException {
10743 BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
10744 displayDate, orderByComparator);
10745
10746 if (blogsEntry != null) {
10747 return blogsEntry;
10748 }
10749
10750 StringBundler msg = new StringBundler(8);
10751
10752 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10753
10754 msg.append("groupId=");
10755 msg.append(groupId);
10756
10757 msg.append(", userId=");
10758 msg.append(userId);
10759
10760 msg.append(", displayDate=");
10761 msg.append(displayDate);
10762
10763 msg.append(StringPool.CLOSE_CURLY_BRACE);
10764
10765 throw new NoSuchEntryException(msg.toString());
10766 }
10767
10768
10778 public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
10779 Date displayDate, OrderByComparator orderByComparator)
10780 throws SystemException {
10781 List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
10782 1, orderByComparator);
10783
10784 if (!list.isEmpty()) {
10785 return list.get(0);
10786 }
10787
10788 return null;
10789 }
10790
10791
10802 public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
10803 Date displayDate, OrderByComparator orderByComparator)
10804 throws NoSuchEntryException, SystemException {
10805 BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
10806 displayDate, orderByComparator);
10807
10808 if (blogsEntry != null) {
10809 return blogsEntry;
10810 }
10811
10812 StringBundler msg = new StringBundler(8);
10813
10814 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10815
10816 msg.append("groupId=");
10817 msg.append(groupId);
10818
10819 msg.append(", userId=");
10820 msg.append(userId);
10821
10822 msg.append(", displayDate=");
10823 msg.append(displayDate);
10824
10825 msg.append(StringPool.CLOSE_CURLY_BRACE);
10826
10827 throw new NoSuchEntryException(msg.toString());
10828 }
10829
10830
10840 public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
10841 Date displayDate, OrderByComparator orderByComparator)
10842 throws SystemException {
10843 int count = countByG_U_LtD(groupId, userId, displayDate);
10844
10845 List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
10846 count - 1, count, orderByComparator);
10847
10848 if (!list.isEmpty()) {
10849 return list.get(0);
10850 }
10851
10852 return null;
10853 }
10854
10855
10867 public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
10868 long userId, Date displayDate, OrderByComparator orderByComparator)
10869 throws NoSuchEntryException, SystemException {
10870 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10871
10872 Session session = null;
10873
10874 try {
10875 session = openSession();
10876
10877 BlogsEntry[] array = new BlogsEntryImpl[3];
10878
10879 array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
10880 userId, displayDate, orderByComparator, true);
10881
10882 array[1] = blogsEntry;
10883
10884 array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
10885 userId, displayDate, orderByComparator, false);
10886
10887 return array;
10888 }
10889 catch (Exception e) {
10890 throw processException(e);
10891 }
10892 finally {
10893 closeSession(session);
10894 }
10895 }
10896
10897 protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
10898 BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
10899 OrderByComparator orderByComparator, boolean previous) {
10900 StringBundler query = null;
10901
10902 if (orderByComparator != null) {
10903 query = new StringBundler(6 +
10904 (orderByComparator.getOrderByFields().length * 6));
10905 }
10906 else {
10907 query = new StringBundler(3);
10908 }
10909
10910 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10911
10912 query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
10913
10914 query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
10915
10916 boolean bindDisplayDate = false;
10917
10918 if (displayDate == null) {
10919 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
10920 }
10921 else {
10922 bindDisplayDate = true;
10923
10924 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
10925 }
10926
10927 if (orderByComparator != null) {
10928 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10929
10930 if (orderByConditionFields.length > 0) {
10931 query.append(WHERE_AND);
10932 }
10933
10934 for (int i = 0; i < orderByConditionFields.length; i++) {
10935 query.append(_ORDER_BY_ENTITY_ALIAS);
10936 query.append(orderByConditionFields[i]);
10937
10938 if ((i + 1) < orderByConditionFields.length) {
10939 if (orderByComparator.isAscending() ^ previous) {
10940 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10941 }
10942 else {
10943 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10944 }
10945 }
10946 else {
10947 if (orderByComparator.isAscending() ^ previous) {
10948 query.append(WHERE_GREATER_THAN);
10949 }
10950 else {
10951 query.append(WHERE_LESSER_THAN);
10952 }
10953 }
10954 }
10955
10956 query.append(ORDER_BY_CLAUSE);
10957
10958 String[] orderByFields = orderByComparator.getOrderByFields();
10959
10960 for (int i = 0; i < orderByFields.length; i++) {
10961 query.append(_ORDER_BY_ENTITY_ALIAS);
10962 query.append(orderByFields[i]);
10963
10964 if ((i + 1) < orderByFields.length) {
10965 if (orderByComparator.isAscending() ^ previous) {
10966 query.append(ORDER_BY_ASC_HAS_NEXT);
10967 }
10968 else {
10969 query.append(ORDER_BY_DESC_HAS_NEXT);
10970 }
10971 }
10972 else {
10973 if (orderByComparator.isAscending() ^ previous) {
10974 query.append(ORDER_BY_ASC);
10975 }
10976 else {
10977 query.append(ORDER_BY_DESC);
10978 }
10979 }
10980 }
10981 }
10982 else {
10983 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10984 }
10985
10986 String sql = query.toString();
10987
10988 Query q = session.createQuery(sql);
10989
10990 q.setFirstResult(0);
10991 q.setMaxResults(2);
10992
10993 QueryPos qPos = QueryPos.getInstance(q);
10994
10995 qPos.add(groupId);
10996
10997 qPos.add(userId);
10998
10999 if (bindDisplayDate) {
11000 qPos.add(CalendarUtil.getTimestamp(displayDate));
11001 }
11002
11003 if (orderByComparator != null) {
11004 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11005
11006 for (Object value : values) {
11007 qPos.add(value);
11008 }
11009 }
11010
11011 List<BlogsEntry> list = q.list();
11012
11013 if (list.size() == 2) {
11014 return list.get(1);
11015 }
11016 else {
11017 return null;
11018 }
11019 }
11020
11021
11030 public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
11031 Date displayDate) throws SystemException {
11032 return filterFindByG_U_LtD(groupId, userId, displayDate,
11033 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11034 }
11035
11036
11051 public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
11052 Date displayDate, int start, int end) throws SystemException {
11053 return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
11054 null);
11055 }
11056
11057
11073 public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
11074 Date displayDate, int start, int end,
11075 OrderByComparator orderByComparator) throws SystemException {
11076 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11077 return findByG_U_LtD(groupId, userId, displayDate, start, end,
11078 orderByComparator);
11079 }
11080
11081 StringBundler query = null;
11082
11083 if (orderByComparator != null) {
11084 query = new StringBundler(5 +
11085 (orderByComparator.getOrderByFields().length * 3));
11086 }
11087 else {
11088 query = new StringBundler(5);
11089 }
11090
11091 if (getDB().isSupportsInlineDistinct()) {
11092 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11093 }
11094 else {
11095 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11096 }
11097
11098 query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11099
11100 query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11101
11102 boolean bindDisplayDate = false;
11103
11104 if (displayDate == null) {
11105 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11106 }
11107 else {
11108 bindDisplayDate = true;
11109
11110 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11111 }
11112
11113 if (!getDB().isSupportsInlineDistinct()) {
11114 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11115 }
11116
11117 if (orderByComparator != null) {
11118 if (getDB().isSupportsInlineDistinct()) {
11119 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11120 orderByComparator, true);
11121 }
11122 else {
11123 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11124 orderByComparator, true);
11125 }
11126 }
11127 else {
11128 if (getDB().isSupportsInlineDistinct()) {
11129 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11130 }
11131 else {
11132 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11133 }
11134 }
11135
11136 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11137 BlogsEntry.class.getName(),
11138 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11139
11140 Session session = null;
11141
11142 try {
11143 session = openSession();
11144
11145 SQLQuery q = session.createSQLQuery(sql);
11146
11147 if (getDB().isSupportsInlineDistinct()) {
11148 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11149 }
11150 else {
11151 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11152 }
11153
11154 QueryPos qPos = QueryPos.getInstance(q);
11155
11156 qPos.add(groupId);
11157
11158 qPos.add(userId);
11159
11160 if (bindDisplayDate) {
11161 qPos.add(CalendarUtil.getTimestamp(displayDate));
11162 }
11163
11164 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11165 }
11166 catch (Exception e) {
11167 throw processException(e);
11168 }
11169 finally {
11170 closeSession(session);
11171 }
11172 }
11173
11174
11186 public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
11187 long groupId, long userId, Date displayDate,
11188 OrderByComparator orderByComparator)
11189 throws NoSuchEntryException, SystemException {
11190 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11191 return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
11192 displayDate, orderByComparator);
11193 }
11194
11195 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11196
11197 Session session = null;
11198
11199 try {
11200 session = openSession();
11201
11202 BlogsEntry[] array = new BlogsEntryImpl[3];
11203
11204 array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
11205 groupId, userId, displayDate, orderByComparator, true);
11206
11207 array[1] = blogsEntry;
11208
11209 array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
11210 groupId, userId, displayDate, orderByComparator, false);
11211
11212 return array;
11213 }
11214 catch (Exception e) {
11215 throw processException(e);
11216 }
11217 finally {
11218 closeSession(session);
11219 }
11220 }
11221
11222 protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
11223 BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
11224 OrderByComparator orderByComparator, boolean previous) {
11225 StringBundler query = null;
11226
11227 if (orderByComparator != null) {
11228 query = new StringBundler(6 +
11229 (orderByComparator.getOrderByFields().length * 6));
11230 }
11231 else {
11232 query = new StringBundler(3);
11233 }
11234
11235 if (getDB().isSupportsInlineDistinct()) {
11236 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11237 }
11238 else {
11239 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11240 }
11241
11242 query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11243
11244 query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11245
11246 boolean bindDisplayDate = false;
11247
11248 if (displayDate == null) {
11249 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11250 }
11251 else {
11252 bindDisplayDate = true;
11253
11254 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11255 }
11256
11257 if (!getDB().isSupportsInlineDistinct()) {
11258 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11259 }
11260
11261 if (orderByComparator != null) {
11262 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11263
11264 if (orderByConditionFields.length > 0) {
11265 query.append(WHERE_AND);
11266 }
11267
11268 for (int i = 0; i < orderByConditionFields.length; i++) {
11269 if (getDB().isSupportsInlineDistinct()) {
11270 query.append(_ORDER_BY_ENTITY_ALIAS);
11271 }
11272 else {
11273 query.append(_ORDER_BY_ENTITY_TABLE);
11274 }
11275
11276 query.append(orderByConditionFields[i]);
11277
11278 if ((i + 1) < orderByConditionFields.length) {
11279 if (orderByComparator.isAscending() ^ previous) {
11280 query.append(WHERE_GREATER_THAN_HAS_NEXT);
11281 }
11282 else {
11283 query.append(WHERE_LESSER_THAN_HAS_NEXT);
11284 }
11285 }
11286 else {
11287 if (orderByComparator.isAscending() ^ previous) {
11288 query.append(WHERE_GREATER_THAN);
11289 }
11290 else {
11291 query.append(WHERE_LESSER_THAN);
11292 }
11293 }
11294 }
11295
11296 query.append(ORDER_BY_CLAUSE);
11297
11298 String[] orderByFields = orderByComparator.getOrderByFields();
11299
11300 for (int i = 0; i < orderByFields.length; i++) {
11301 if (getDB().isSupportsInlineDistinct()) {
11302 query.append(_ORDER_BY_ENTITY_ALIAS);
11303 }
11304 else {
11305 query.append(_ORDER_BY_ENTITY_TABLE);
11306 }
11307
11308 query.append(orderByFields[i]);
11309
11310 if ((i + 1) < orderByFields.length) {
11311 if (orderByComparator.isAscending() ^ previous) {
11312 query.append(ORDER_BY_ASC_HAS_NEXT);
11313 }
11314 else {
11315 query.append(ORDER_BY_DESC_HAS_NEXT);
11316 }
11317 }
11318 else {
11319 if (orderByComparator.isAscending() ^ previous) {
11320 query.append(ORDER_BY_ASC);
11321 }
11322 else {
11323 query.append(ORDER_BY_DESC);
11324 }
11325 }
11326 }
11327 }
11328 else {
11329 if (getDB().isSupportsInlineDistinct()) {
11330 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11331 }
11332 else {
11333 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11334 }
11335 }
11336
11337 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11338 BlogsEntry.class.getName(),
11339 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11340
11341 SQLQuery q = session.createSQLQuery(sql);
11342
11343 q.setFirstResult(0);
11344 q.setMaxResults(2);
11345
11346 if (getDB().isSupportsInlineDistinct()) {
11347 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11348 }
11349 else {
11350 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11351 }
11352
11353 QueryPos qPos = QueryPos.getInstance(q);
11354
11355 qPos.add(groupId);
11356
11357 qPos.add(userId);
11358
11359 if (bindDisplayDate) {
11360 qPos.add(CalendarUtil.getTimestamp(displayDate));
11361 }
11362
11363 if (orderByComparator != null) {
11364 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11365
11366 for (Object value : values) {
11367 qPos.add(value);
11368 }
11369 }
11370
11371 List<BlogsEntry> list = q.list();
11372
11373 if (list.size() == 2) {
11374 return list.get(1);
11375 }
11376 else {
11377 return null;
11378 }
11379 }
11380
11381
11389 public void removeByG_U_LtD(long groupId, long userId, Date displayDate)
11390 throws SystemException {
11391 for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
11392 displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11393 remove(blogsEntry);
11394 }
11395 }
11396
11397
11406 public int countByG_U_LtD(long groupId, long userId, Date displayDate)
11407 throws SystemException {
11408 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
11409
11410 Object[] finderArgs = new Object[] { groupId, userId, displayDate };
11411
11412 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11413 this);
11414
11415 if (count == null) {
11416 StringBundler query = new StringBundler(4);
11417
11418 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11419
11420 query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11421
11422 query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11423
11424 boolean bindDisplayDate = false;
11425
11426 if (displayDate == null) {
11427 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11428 }
11429 else {
11430 bindDisplayDate = true;
11431
11432 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11433 }
11434
11435 String sql = query.toString();
11436
11437 Session session = null;
11438
11439 try {
11440 session = openSession();
11441
11442 Query q = session.createQuery(sql);
11443
11444 QueryPos qPos = QueryPos.getInstance(q);
11445
11446 qPos.add(groupId);
11447
11448 qPos.add(userId);
11449
11450 if (bindDisplayDate) {
11451 qPos.add(CalendarUtil.getTimestamp(displayDate));
11452 }
11453
11454 count = (Long)q.uniqueResult();
11455
11456 FinderCacheUtil.putResult(finderPath, finderArgs, count);
11457 }
11458 catch (Exception e) {
11459 FinderCacheUtil.removeResult(finderPath, finderArgs);
11460
11461 throw processException(e);
11462 }
11463 finally {
11464 closeSession(session);
11465 }
11466 }
11467
11468 return count.intValue();
11469 }
11470
11471
11480 public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate)
11481 throws SystemException {
11482 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11483 return countByG_U_LtD(groupId, userId, displayDate);
11484 }
11485
11486 StringBundler query = new StringBundler(4);
11487
11488 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11489
11490 query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11491
11492 query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11493
11494 boolean bindDisplayDate = false;
11495
11496 if (displayDate == null) {
11497 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11498 }
11499 else {
11500 bindDisplayDate = true;
11501
11502 query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11503 }
11504
11505 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11506 BlogsEntry.class.getName(),
11507 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11508
11509 Session session = null;
11510
11511 try {
11512 session = openSession();
11513
11514 SQLQuery q = session.createSQLQuery(sql);
11515
11516 q.addScalar(COUNT_COLUMN_NAME,
11517 com.liferay.portal.kernel.dao.orm.Type.LONG);
11518
11519 QueryPos qPos = QueryPos.getInstance(q);
11520
11521 qPos.add(groupId);
11522
11523 qPos.add(userId);
11524
11525 if (bindDisplayDate) {
11526 qPos.add(CalendarUtil.getTimestamp(displayDate));
11527 }
11528
11529 Long count = (Long)q.uniqueResult();
11530
11531 return count.intValue();
11532 }
11533 catch (Exception e) {
11534 throw processException(e);
11535 }
11536 finally {
11537 closeSession(session);
11538 }
11539 }
11540
11541 private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11542 private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
11543 private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
11544 private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
11545 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11546 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11547 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
11548 new String[] {
11549 Long.class.getName(), Long.class.getName(),
11550 Integer.class.getName(),
11551
11552 Integer.class.getName(), Integer.class.getName(),
11553 OrderByComparator.class.getName()
11554 });
11555 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
11556 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11557 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11558 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
11559 new String[] {
11560 Long.class.getName(), Long.class.getName(),
11561 Integer.class.getName()
11562 });
11563
11564
11573 public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status)
11574 throws SystemException {
11575 return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11576 QueryUtil.ALL_POS, null);
11577 }
11578
11579
11594 public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11595 int status, int start, int end) throws SystemException {
11596 return findByG_U_NotS(groupId, userId, status, start, end, null);
11597 }
11598
11599
11615 public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11616 int status, int start, int end, OrderByComparator orderByComparator)
11617 throws SystemException {
11618 boolean pagination = true;
11619 FinderPath finderPath = null;
11620 Object[] finderArgs = null;
11621
11622 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
11623 finderArgs = new Object[] {
11624 groupId, userId, status,
11625
11626 start, end, orderByComparator
11627 };
11628
11629 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
11630 finderArgs, this);
11631
11632 if ((list != null) && !list.isEmpty()) {
11633 for (BlogsEntry blogsEntry : list) {
11634 if ((groupId != blogsEntry.getGroupId()) ||
11635 (userId != blogsEntry.getUserId()) ||
11636 (status != blogsEntry.getStatus())) {
11637 list = null;
11638
11639 break;
11640 }
11641 }
11642 }
11643
11644 if (list == null) {
11645 StringBundler query = null;
11646
11647 if (orderByComparator != null) {
11648 query = new StringBundler(5 +
11649 (orderByComparator.getOrderByFields().length * 3));
11650 }
11651 else {
11652 query = new StringBundler(5);
11653 }
11654
11655 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11656
11657 query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11658
11659 query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11660
11661 query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11662
11663 if (orderByComparator != null) {
11664 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11665 orderByComparator);
11666 }
11667 else
11668 if (pagination) {
11669 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11670 }
11671
11672 String sql = query.toString();
11673
11674 Session session = null;
11675
11676 try {
11677 session = openSession();
11678
11679 Query q = session.createQuery(sql);
11680
11681 QueryPos qPos = QueryPos.getInstance(q);
11682
11683 qPos.add(groupId);
11684
11685 qPos.add(userId);
11686
11687 qPos.add(status);
11688
11689 if (!pagination) {
11690 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11691 start, end, false);
11692
11693 Collections.sort(list);
11694
11695 list = new UnmodifiableList<BlogsEntry>(list);
11696 }
11697 else {
11698 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11699 start, end);
11700 }
11701
11702 cacheResult(list);
11703
11704 FinderCacheUtil.putResult(finderPath, finderArgs, list);
11705 }
11706 catch (Exception e) {
11707 FinderCacheUtil.removeResult(finderPath, finderArgs);
11708
11709 throw processException(e);
11710 }
11711 finally {
11712 closeSession(session);
11713 }
11714 }
11715
11716 return list;
11717 }
11718
11719
11730 public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
11731 int status, OrderByComparator orderByComparator)
11732 throws NoSuchEntryException, SystemException {
11733 BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
11734 orderByComparator);
11735
11736 if (blogsEntry != null) {
11737 return blogsEntry;
11738 }
11739
11740 StringBundler msg = new StringBundler(8);
11741
11742 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11743
11744 msg.append("groupId=");
11745 msg.append(groupId);
11746
11747 msg.append(", userId=");
11748 msg.append(userId);
11749
11750 msg.append(", status=");
11751 msg.append(status);
11752
11753 msg.append(StringPool.CLOSE_CURLY_BRACE);
11754
11755 throw new NoSuchEntryException(msg.toString());
11756 }
11757
11758
11768 public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
11769 int status, OrderByComparator orderByComparator)
11770 throws SystemException {
11771 List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
11772 orderByComparator);
11773
11774 if (!list.isEmpty()) {
11775 return list.get(0);
11776 }
11777
11778 return null;
11779 }
11780
11781
11792 public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
11793 int status, OrderByComparator orderByComparator)
11794 throws NoSuchEntryException, SystemException {
11795 BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
11796 orderByComparator);
11797
11798 if (blogsEntry != null) {
11799 return blogsEntry;
11800 }
11801
11802 StringBundler msg = new StringBundler(8);
11803
11804 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11805
11806 msg.append("groupId=");
11807 msg.append(groupId);
11808
11809 msg.append(", userId=");
11810 msg.append(userId);
11811
11812 msg.append(", status=");
11813 msg.append(status);
11814
11815 msg.append(StringPool.CLOSE_CURLY_BRACE);
11816
11817 throw new NoSuchEntryException(msg.toString());
11818 }
11819
11820
11830 public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
11831 int status, OrderByComparator orderByComparator)
11832 throws SystemException {
11833 int count = countByG_U_NotS(groupId, userId, status);
11834
11835 List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
11836 count - 1, count, orderByComparator);
11837
11838 if (!list.isEmpty()) {
11839 return list.get(0);
11840 }
11841
11842 return null;
11843 }
11844
11845
11857 public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
11858 long userId, int status, OrderByComparator orderByComparator)
11859 throws NoSuchEntryException, SystemException {
11860 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11861
11862 Session session = null;
11863
11864 try {
11865 session = openSession();
11866
11867 BlogsEntry[] array = new BlogsEntryImpl[3];
11868
11869 array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
11870 userId, status, orderByComparator, true);
11871
11872 array[1] = blogsEntry;
11873
11874 array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
11875 userId, status, orderByComparator, false);
11876
11877 return array;
11878 }
11879 catch (Exception e) {
11880 throw processException(e);
11881 }
11882 finally {
11883 closeSession(session);
11884 }
11885 }
11886
11887 protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
11888 BlogsEntry blogsEntry, long groupId, long userId, int status,
11889 OrderByComparator orderByComparator, boolean previous) {
11890 StringBundler query = null;
11891
11892 if (orderByComparator != null) {
11893 query = new StringBundler(6 +
11894 (orderByComparator.getOrderByFields().length * 6));
11895 }
11896 else {
11897 query = new StringBundler(3);
11898 }
11899
11900 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11901
11902 query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11903
11904 query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11905
11906 query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11907
11908 if (orderByComparator != null) {
11909 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11910
11911 if (orderByConditionFields.length > 0) {
11912 query.append(WHERE_AND);
11913 }
11914
11915 for (int i = 0; i < orderByConditionFields.length; i++) {
11916 query.append(_ORDER_BY_ENTITY_ALIAS);
11917 query.append(orderByConditionFields[i]);
11918
11919 if ((i + 1) < orderByConditionFields.length) {
11920 if (orderByComparator.isAscending() ^ previous) {
11921 query.append(WHERE_GREATER_THAN_HAS_NEXT);
11922 }
11923 else {
11924 query.append(WHERE_LESSER_THAN_HAS_NEXT);
11925 }
11926 }
11927 else {
11928 if (orderByComparator.isAscending() ^ previous) {
11929 query.append(WHERE_GREATER_THAN);
11930 }
11931 else {
11932 query.append(WHERE_LESSER_THAN);
11933 }
11934 }
11935 }
11936
11937 query.append(ORDER_BY_CLAUSE);
11938
11939 String[] orderByFields = orderByComparator.getOrderByFields();
11940
11941 for (int i = 0; i < orderByFields.length; i++) {
11942 query.append(_ORDER_BY_ENTITY_ALIAS);
11943 query.append(orderByFields[i]);
11944
11945 if ((i + 1) < orderByFields.length) {
11946 if (orderByComparator.isAscending() ^ previous) {
11947 query.append(ORDER_BY_ASC_HAS_NEXT);
11948 }
11949 else {
11950 query.append(ORDER_BY_DESC_HAS_NEXT);
11951 }
11952 }
11953 else {
11954 if (orderByComparator.isAscending() ^ previous) {
11955 query.append(ORDER_BY_ASC);
11956 }
11957 else {
11958 query.append(ORDER_BY_DESC);
11959 }
11960 }
11961 }
11962 }
11963 else {
11964 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11965 }
11966
11967 String sql = query.toString();
11968
11969 Query q = session.createQuery(sql);
11970
11971 q.setFirstResult(0);
11972 q.setMaxResults(2);
11973
11974 QueryPos qPos = QueryPos.getInstance(q);
11975
11976 qPos.add(groupId);
11977
11978 qPos.add(userId);
11979
11980 qPos.add(status);
11981
11982 if (orderByComparator != null) {
11983 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11984
11985 for (Object value : values) {
11986 qPos.add(value);
11987 }
11988 }
11989
11990 List<BlogsEntry> list = q.list();
11991
11992 if (list.size() == 2) {
11993 return list.get(1);
11994 }
11995 else {
11996 return null;
11997 }
11998 }
11999
12000
12009 public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
12010 int status) throws SystemException {
12011 return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
12012 QueryUtil.ALL_POS, null);
12013 }
12014
12015
12030 public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
12031 int status, int start, int end) throws SystemException {
12032 return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
12033 }
12034
12035
12051 public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
12052 int status, int start, int end, OrderByComparator orderByComparator)
12053 throws SystemException {
12054 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12055 return findByG_U_NotS(groupId, userId, status, start, end,
12056 orderByComparator);
12057 }
12058
12059 StringBundler query = null;
12060
12061 if (orderByComparator != null) {
12062 query = new StringBundler(5 +
12063 (orderByComparator.getOrderByFields().length * 3));
12064 }
12065 else {
12066 query = new StringBundler(5);
12067 }
12068
12069 if (getDB().isSupportsInlineDistinct()) {
12070 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12071 }
12072 else {
12073 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12074 }
12075
12076 query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12077
12078 query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12079
12080 query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12081
12082 if (!getDB().isSupportsInlineDistinct()) {
12083 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12084 }
12085
12086 if (orderByComparator != null) {
12087 if (getDB().isSupportsInlineDistinct()) {
12088 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12089 orderByComparator, true);
12090 }
12091 else {
12092 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12093 orderByComparator, true);
12094 }
12095 }
12096 else {
12097 if (getDB().isSupportsInlineDistinct()) {
12098 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12099 }
12100 else {
12101 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12102 }
12103 }
12104
12105 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12106 BlogsEntry.class.getName(),
12107 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12108
12109 Session session = null;
12110
12111 try {
12112 session = openSession();
12113
12114 SQLQuery q = session.createSQLQuery(sql);
12115
12116 if (getDB().isSupportsInlineDistinct()) {
12117 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12118 }
12119 else {
12120 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12121 }
12122
12123 QueryPos qPos = QueryPos.getInstance(q);
12124
12125 qPos.add(groupId);
12126
12127 qPos.add(userId);
12128
12129 qPos.add(status);
12130
12131 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12132 }
12133 catch (Exception e) {
12134 throw processException(e);
12135 }
12136 finally {
12137 closeSession(session);
12138 }
12139 }
12140
12141
12153 public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
12154 long groupId, long userId, int status,
12155 OrderByComparator orderByComparator)
12156 throws NoSuchEntryException, SystemException {
12157 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12158 return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
12159 orderByComparator);
12160 }
12161
12162 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12163
12164 Session session = null;
12165
12166 try {
12167 session = openSession();
12168
12169 BlogsEntry[] array = new BlogsEntryImpl[3];
12170
12171 array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
12172 groupId, userId, status, orderByComparator, true);
12173
12174 array[1] = blogsEntry;
12175
12176 array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
12177 groupId, userId, status, orderByComparator, false);
12178
12179 return array;
12180 }
12181 catch (Exception e) {
12182 throw processException(e);
12183 }
12184 finally {
12185 closeSession(session);
12186 }
12187 }
12188
12189 protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
12190 BlogsEntry blogsEntry, long groupId, long userId, int status,
12191 OrderByComparator orderByComparator, boolean previous) {
12192 StringBundler query = null;
12193
12194 if (orderByComparator != null) {
12195 query = new StringBundler(6 +
12196 (orderByComparator.getOrderByFields().length * 6));
12197 }
12198 else {
12199 query = new StringBundler(3);
12200 }
12201
12202 if (getDB().isSupportsInlineDistinct()) {
12203 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12204 }
12205 else {
12206 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12207 }
12208
12209 query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12210
12211 query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12212
12213 query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12214
12215 if (!getDB().isSupportsInlineDistinct()) {
12216 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12217 }
12218
12219 if (orderByComparator != null) {
12220 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12221
12222 if (orderByConditionFields.length > 0) {
12223 query.append(WHERE_AND);
12224 }
12225
12226 for (int i = 0; i < orderByConditionFields.length; i++) {
12227 if (getDB().isSupportsInlineDistinct()) {
12228 query.append(_ORDER_BY_ENTITY_ALIAS);
12229 }
12230 else {
12231 query.append(_ORDER_BY_ENTITY_TABLE);
12232 }
12233
12234 query.append(orderByConditionFields[i]);
12235
12236 if ((i + 1) < orderByConditionFields.length) {
12237 if (orderByComparator.isAscending() ^ previous) {
12238 query.append(WHERE_GREATER_THAN_HAS_NEXT);
12239 }
12240 else {
12241 query.append(WHERE_LESSER_THAN_HAS_NEXT);
12242 }
12243 }
12244 else {
12245 if (orderByComparator.isAscending() ^ previous) {
12246 query.append(WHERE_GREATER_THAN);
12247 }
12248 else {
12249 query.append(WHERE_LESSER_THAN);
12250 }
12251 }
12252 }
12253
12254 query.append(ORDER_BY_CLAUSE);
12255
12256 String[] orderByFields = orderByComparator.getOrderByFields();
12257
12258 for (int i = 0; i < orderByFields.length; i++) {
12259 if (getDB().isSupportsInlineDistinct()) {
12260 query.append(_ORDER_BY_ENTITY_ALIAS);
12261 }
12262 else {
12263 query.append(_ORDER_BY_ENTITY_TABLE);
12264 }
12265
12266 query.append(orderByFields[i]);
12267
12268 if ((i + 1) < orderByFields.length) {
12269 if (orderByComparator.isAscending() ^ previous) {
12270 query.append(ORDER_BY_ASC_HAS_NEXT);
12271 }
12272 else {
12273 query.append(ORDER_BY_DESC_HAS_NEXT);
12274 }
12275 }
12276 else {
12277 if (orderByComparator.isAscending() ^ previous) {
12278 query.append(ORDER_BY_ASC);
12279 }
12280 else {
12281 query.append(ORDER_BY_DESC);
12282 }
12283 }
12284 }
12285 }
12286 else {
12287 if (getDB().isSupportsInlineDistinct()) {
12288 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12289 }
12290 else {
12291 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12292 }
12293 }
12294
12295 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12296 BlogsEntry.class.getName(),
12297 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12298
12299 SQLQuery q = session.createSQLQuery(sql);
12300
12301 q.setFirstResult(0);
12302 q.setMaxResults(2);
12303
12304 if (getDB().isSupportsInlineDistinct()) {
12305 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12306 }
12307 else {
12308 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12309 }
12310
12311 QueryPos qPos = QueryPos.getInstance(q);
12312
12313 qPos.add(groupId);
12314
12315 qPos.add(userId);
12316
12317 qPos.add(status);
12318
12319 if (orderByComparator != null) {
12320 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12321
12322 for (Object value : values) {
12323 qPos.add(value);
12324 }
12325 }
12326
12327 List<BlogsEntry> list = q.list();
12328
12329 if (list.size() == 2) {
12330 return list.get(1);
12331 }
12332 else {
12333 return null;
12334 }
12335 }
12336
12337
12345 public void removeByG_U_NotS(long groupId, long userId, int status)
12346 throws SystemException {
12347 for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
12348 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12349 remove(blogsEntry);
12350 }
12351 }
12352
12353
12362 public int countByG_U_NotS(long groupId, long userId, int status)
12363 throws SystemException {
12364 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
12365
12366 Object[] finderArgs = new Object[] { groupId, userId, status };
12367
12368 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12369 this);
12370
12371 if (count == null) {
12372 StringBundler query = new StringBundler(4);
12373
12374 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12375
12376 query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12377
12378 query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12379
12380 query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12381
12382 String sql = query.toString();
12383
12384 Session session = null;
12385
12386 try {
12387 session = openSession();
12388
12389 Query q = session.createQuery(sql);
12390
12391 QueryPos qPos = QueryPos.getInstance(q);
12392
12393 qPos.add(groupId);
12394
12395 qPos.add(userId);
12396
12397 qPos.add(status);
12398
12399 count = (Long)q.uniqueResult();
12400
12401 FinderCacheUtil.putResult(finderPath, finderArgs, count);
12402 }
12403 catch (Exception e) {
12404 FinderCacheUtil.removeResult(finderPath, finderArgs);
12405
12406 throw processException(e);
12407 }
12408 finally {
12409 closeSession(session);
12410 }
12411 }
12412
12413 return count.intValue();
12414 }
12415
12416
12425 public int filterCountByG_U_NotS(long groupId, long userId, int status)
12426 throws SystemException {
12427 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12428 return countByG_U_NotS(groupId, userId, status);
12429 }
12430
12431 StringBundler query = new StringBundler(4);
12432
12433 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12434
12435 query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12436
12437 query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12438
12439 query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12440
12441 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12442 BlogsEntry.class.getName(),
12443 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12444
12445 Session session = null;
12446
12447 try {
12448 session = openSession();
12449
12450 SQLQuery q = session.createSQLQuery(sql);
12451
12452 q.addScalar(COUNT_COLUMN_NAME,
12453 com.liferay.portal.kernel.dao.orm.Type.LONG);
12454
12455 QueryPos qPos = QueryPos.getInstance(q);
12456
12457 qPos.add(groupId);
12458
12459 qPos.add(userId);
12460
12461 qPos.add(status);
12462
12463 Long count = (Long)q.uniqueResult();
12464
12465 return count.intValue();
12466 }
12467 catch (Exception e) {
12468 throw processException(e);
12469 }
12470 finally {
12471 closeSession(session);
12472 }
12473 }
12474
12475 private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12476 private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
12477 private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
12478 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12479 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12480 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
12481 new String[] {
12482 Long.class.getName(), Long.class.getName(),
12483 Integer.class.getName(),
12484
12485 Integer.class.getName(), Integer.class.getName(),
12486 OrderByComparator.class.getName()
12487 });
12488 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12489 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12490 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
12491 new String[] {
12492 Long.class.getName(), Long.class.getName(),
12493 Integer.class.getName()
12494 },
12495 BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
12496 BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
12497 BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
12498 BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
12499 BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
12500 public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12501 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12502 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
12503 new String[] {
12504 Long.class.getName(), Long.class.getName(),
12505 Integer.class.getName()
12506 });
12507
12508
12517 public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status)
12518 throws SystemException {
12519 return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
12520 QueryUtil.ALL_POS, null);
12521 }
12522
12523
12538 public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
12539 int start, int end) throws SystemException {
12540 return findByG_U_S(groupId, userId, status, start, end, null);
12541 }
12542
12543
12559 public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
12560 int start, int end, OrderByComparator orderByComparator)
12561 throws SystemException {
12562 boolean pagination = true;
12563 FinderPath finderPath = null;
12564 Object[] finderArgs = null;
12565
12566 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12567 (orderByComparator == null)) {
12568 pagination = false;
12569 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
12570 finderArgs = new Object[] { groupId, userId, status };
12571 }
12572 else {
12573 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
12574 finderArgs = new Object[] {
12575 groupId, userId, status,
12576
12577 start, end, orderByComparator
12578 };
12579 }
12580
12581 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
12582 finderArgs, this);
12583
12584 if ((list != null) && !list.isEmpty()) {
12585 for (BlogsEntry blogsEntry : list) {
12586 if ((groupId != blogsEntry.getGroupId()) ||
12587 (userId != blogsEntry.getUserId()) ||
12588 (status != blogsEntry.getStatus())) {
12589 list = null;
12590
12591 break;
12592 }
12593 }
12594 }
12595
12596 if (list == null) {
12597 StringBundler query = null;
12598
12599 if (orderByComparator != null) {
12600 query = new StringBundler(5 +
12601 (orderByComparator.getOrderByFields().length * 3));
12602 }
12603 else {
12604 query = new StringBundler(5);
12605 }
12606
12607 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12608
12609 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
12610
12611 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
12612
12613 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
12614
12615 if (orderByComparator != null) {
12616 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12617 orderByComparator);
12618 }
12619 else
12620 if (pagination) {
12621 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12622 }
12623
12624 String sql = query.toString();
12625
12626 Session session = null;
12627
12628 try {
12629 session = openSession();
12630
12631 Query q = session.createQuery(sql);
12632
12633 QueryPos qPos = QueryPos.getInstance(q);
12634
12635 qPos.add(groupId);
12636
12637 qPos.add(userId);
12638
12639 qPos.add(status);
12640
12641 if (!pagination) {
12642 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12643 start, end, false);
12644
12645 Collections.sort(list);
12646
12647 list = new UnmodifiableList<BlogsEntry>(list);
12648 }
12649 else {
12650 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12651 start, end);
12652 }
12653
12654 cacheResult(list);
12655
12656 FinderCacheUtil.putResult(finderPath, finderArgs, list);
12657 }
12658 catch (Exception e) {
12659 FinderCacheUtil.removeResult(finderPath, finderArgs);
12660
12661 throw processException(e);
12662 }
12663 finally {
12664 closeSession(session);
12665 }
12666 }
12667
12668 return list;
12669 }
12670
12671
12682 public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
12683 OrderByComparator orderByComparator)
12684 throws NoSuchEntryException, SystemException {
12685 BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
12686 orderByComparator);
12687
12688 if (blogsEntry != null) {
12689 return blogsEntry;
12690 }
12691
12692 StringBundler msg = new StringBundler(8);
12693
12694 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12695
12696 msg.append("groupId=");
12697 msg.append(groupId);
12698
12699 msg.append(", userId=");
12700 msg.append(userId);
12701
12702 msg.append(", status=");
12703 msg.append(status);
12704
12705 msg.append(StringPool.CLOSE_CURLY_BRACE);
12706
12707 throw new NoSuchEntryException(msg.toString());
12708 }
12709
12710
12720 public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
12721 OrderByComparator orderByComparator) throws SystemException {
12722 List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
12723 orderByComparator);
12724
12725 if (!list.isEmpty()) {
12726 return list.get(0);
12727 }
12728
12729 return null;
12730 }
12731
12732
12743 public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
12744 OrderByComparator orderByComparator)
12745 throws NoSuchEntryException, SystemException {
12746 BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
12747 orderByComparator);
12748
12749 if (blogsEntry != null) {
12750 return blogsEntry;
12751 }
12752
12753 StringBundler msg = new StringBundler(8);
12754
12755 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12756
12757 msg.append("groupId=");
12758 msg.append(groupId);
12759
12760 msg.append(", userId=");
12761 msg.append(userId);
12762
12763 msg.append(", status=");
12764 msg.append(status);
12765
12766 msg.append(StringPool.CLOSE_CURLY_BRACE);
12767
12768 throw new NoSuchEntryException(msg.toString());
12769 }
12770
12771
12781 public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
12782 OrderByComparator orderByComparator) throws SystemException {
12783 int count = countByG_U_S(groupId, userId, status);
12784
12785 List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
12786 count, orderByComparator);
12787
12788 if (!list.isEmpty()) {
12789 return list.get(0);
12790 }
12791
12792 return null;
12793 }
12794
12795
12807 public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
12808 long userId, int status, OrderByComparator orderByComparator)
12809 throws NoSuchEntryException, SystemException {
12810 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12811
12812 Session session = null;
12813
12814 try {
12815 session = openSession();
12816
12817 BlogsEntry[] array = new BlogsEntryImpl[3];
12818
12819 array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
12820 userId, status, orderByComparator, true);
12821
12822 array[1] = blogsEntry;
12823
12824 array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
12825 userId, status, orderByComparator, false);
12826
12827 return array;
12828 }
12829 catch (Exception e) {
12830 throw processException(e);
12831 }
12832 finally {
12833 closeSession(session);
12834 }
12835 }
12836
12837 protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
12838 BlogsEntry blogsEntry, long groupId, long userId, int status,
12839 OrderByComparator orderByComparator, boolean previous) {
12840 StringBundler query = null;
12841
12842 if (orderByComparator != null) {
12843 query = new StringBundler(6 +
12844 (orderByComparator.getOrderByFields().length * 6));
12845 }
12846 else {
12847 query = new StringBundler(3);
12848 }
12849
12850 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12851
12852 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
12853
12854 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
12855
12856 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
12857
12858 if (orderByComparator != null) {
12859 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12860
12861 if (orderByConditionFields.length > 0) {
12862 query.append(WHERE_AND);
12863 }
12864
12865 for (int i = 0; i < orderByConditionFields.length; i++) {
12866 query.append(_ORDER_BY_ENTITY_ALIAS);
12867 query.append(orderByConditionFields[i]);
12868
12869 if ((i + 1) < orderByConditionFields.length) {
12870 if (orderByComparator.isAscending() ^ previous) {
12871 query.append(WHERE_GREATER_THAN_HAS_NEXT);
12872 }
12873 else {
12874 query.append(WHERE_LESSER_THAN_HAS_NEXT);
12875 }
12876 }
12877 else {
12878 if (orderByComparator.isAscending() ^ previous) {
12879 query.append(WHERE_GREATER_THAN);
12880 }
12881 else {
12882 query.append(WHERE_LESSER_THAN);
12883 }
12884 }
12885 }
12886
12887 query.append(ORDER_BY_CLAUSE);
12888
12889 String[] orderByFields = orderByComparator.getOrderByFields();
12890
12891 for (int i = 0; i < orderByFields.length; i++) {
12892 query.append(_ORDER_BY_ENTITY_ALIAS);
12893 query.append(orderByFields[i]);
12894
12895 if ((i + 1) < orderByFields.length) {
12896 if (orderByComparator.isAscending() ^ previous) {
12897 query.append(ORDER_BY_ASC_HAS_NEXT);
12898 }
12899 else {
12900 query.append(ORDER_BY_DESC_HAS_NEXT);
12901 }
12902 }
12903 else {
12904 if (orderByComparator.isAscending() ^ previous) {
12905 query.append(ORDER_BY_ASC);
12906 }
12907 else {
12908 query.append(ORDER_BY_DESC);
12909 }
12910 }
12911 }
12912 }
12913 else {
12914 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12915 }
12916
12917 String sql = query.toString();
12918
12919 Query q = session.createQuery(sql);
12920
12921 q.setFirstResult(0);
12922 q.setMaxResults(2);
12923
12924 QueryPos qPos = QueryPos.getInstance(q);
12925
12926 qPos.add(groupId);
12927
12928 qPos.add(userId);
12929
12930 qPos.add(status);
12931
12932 if (orderByComparator != null) {
12933 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12934
12935 for (Object value : values) {
12936 qPos.add(value);
12937 }
12938 }
12939
12940 List<BlogsEntry> list = q.list();
12941
12942 if (list.size() == 2) {
12943 return list.get(1);
12944 }
12945 else {
12946 return null;
12947 }
12948 }
12949
12950
12959 public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
12960 int status) throws SystemException {
12961 return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
12962 QueryUtil.ALL_POS, null);
12963 }
12964
12965
12980 public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
12981 int status, int start, int end) throws SystemException {
12982 return filterFindByG_U_S(groupId, userId, status, start, end, null);
12983 }
12984
12985
13001 public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
13002 int status, int start, int end, OrderByComparator orderByComparator)
13003 throws SystemException {
13004 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13005 return findByG_U_S(groupId, userId, status, start, end,
13006 orderByComparator);
13007 }
13008
13009 StringBundler query = null;
13010
13011 if (orderByComparator != null) {
13012 query = new StringBundler(5 +
13013 (orderByComparator.getOrderByFields().length * 3));
13014 }
13015 else {
13016 query = new StringBundler(5);
13017 }
13018
13019 if (getDB().isSupportsInlineDistinct()) {
13020 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13021 }
13022 else {
13023 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13024 }
13025
13026 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13027
13028 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13029
13030 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13031
13032 if (!getDB().isSupportsInlineDistinct()) {
13033 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13034 }
13035
13036 if (orderByComparator != null) {
13037 if (getDB().isSupportsInlineDistinct()) {
13038 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13039 orderByComparator, true);
13040 }
13041 else {
13042 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13043 orderByComparator, true);
13044 }
13045 }
13046 else {
13047 if (getDB().isSupportsInlineDistinct()) {
13048 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13049 }
13050 else {
13051 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13052 }
13053 }
13054
13055 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13056 BlogsEntry.class.getName(),
13057 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13058
13059 Session session = null;
13060
13061 try {
13062 session = openSession();
13063
13064 SQLQuery q = session.createSQLQuery(sql);
13065
13066 if (getDB().isSupportsInlineDistinct()) {
13067 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13068 }
13069 else {
13070 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13071 }
13072
13073 QueryPos qPos = QueryPos.getInstance(q);
13074
13075 qPos.add(groupId);
13076
13077 qPos.add(userId);
13078
13079 qPos.add(status);
13080
13081 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13082 }
13083 catch (Exception e) {
13084 throw processException(e);
13085 }
13086 finally {
13087 closeSession(session);
13088 }
13089 }
13090
13091
13103 public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
13104 long groupId, long userId, int status,
13105 OrderByComparator orderByComparator)
13106 throws NoSuchEntryException, SystemException {
13107 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13108 return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
13109 orderByComparator);
13110 }
13111
13112 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13113
13114 Session session = null;
13115
13116 try {
13117 session = openSession();
13118
13119 BlogsEntry[] array = new BlogsEntryImpl[3];
13120
13121 array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
13122 groupId, userId, status, orderByComparator, true);
13123
13124 array[1] = blogsEntry;
13125
13126 array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
13127 groupId, userId, status, orderByComparator, false);
13128
13129 return array;
13130 }
13131 catch (Exception e) {
13132 throw processException(e);
13133 }
13134 finally {
13135 closeSession(session);
13136 }
13137 }
13138
13139 protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
13140 BlogsEntry blogsEntry, long groupId, long userId, int status,
13141 OrderByComparator orderByComparator, boolean previous) {
13142 StringBundler query = null;
13143
13144 if (orderByComparator != null) {
13145 query = new StringBundler(6 +
13146 (orderByComparator.getOrderByFields().length * 6));
13147 }
13148 else {
13149 query = new StringBundler(3);
13150 }
13151
13152 if (getDB().isSupportsInlineDistinct()) {
13153 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13154 }
13155 else {
13156 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13157 }
13158
13159 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13160
13161 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13162
13163 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13164
13165 if (!getDB().isSupportsInlineDistinct()) {
13166 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13167 }
13168
13169 if (orderByComparator != null) {
13170 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13171
13172 if (orderByConditionFields.length > 0) {
13173 query.append(WHERE_AND);
13174 }
13175
13176 for (int i = 0; i < orderByConditionFields.length; i++) {
13177 if (getDB().isSupportsInlineDistinct()) {
13178 query.append(_ORDER_BY_ENTITY_ALIAS);
13179 }
13180 else {
13181 query.append(_ORDER_BY_ENTITY_TABLE);
13182 }
13183
13184 query.append(orderByConditionFields[i]);
13185
13186 if ((i + 1) < orderByConditionFields.length) {
13187 if (orderByComparator.isAscending() ^ previous) {
13188 query.append(WHERE_GREATER_THAN_HAS_NEXT);
13189 }
13190 else {
13191 query.append(WHERE_LESSER_THAN_HAS_NEXT);
13192 }
13193 }
13194 else {
13195 if (orderByComparator.isAscending() ^ previous) {
13196 query.append(WHERE_GREATER_THAN);
13197 }
13198 else {
13199 query.append(WHERE_LESSER_THAN);
13200 }
13201 }
13202 }
13203
13204 query.append(ORDER_BY_CLAUSE);
13205
13206 String[] orderByFields = orderByComparator.getOrderByFields();
13207
13208 for (int i = 0; i < orderByFields.length; i++) {
13209 if (getDB().isSupportsInlineDistinct()) {
13210 query.append(_ORDER_BY_ENTITY_ALIAS);
13211 }
13212 else {
13213 query.append(_ORDER_BY_ENTITY_TABLE);
13214 }
13215
13216 query.append(orderByFields[i]);
13217
13218 if ((i + 1) < orderByFields.length) {
13219 if (orderByComparator.isAscending() ^ previous) {
13220 query.append(ORDER_BY_ASC_HAS_NEXT);
13221 }
13222 else {
13223 query.append(ORDER_BY_DESC_HAS_NEXT);
13224 }
13225 }
13226 else {
13227 if (orderByComparator.isAscending() ^ previous) {
13228 query.append(ORDER_BY_ASC);
13229 }
13230 else {
13231 query.append(ORDER_BY_DESC);
13232 }
13233 }
13234 }
13235 }
13236 else {
13237 if (getDB().isSupportsInlineDistinct()) {
13238 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13239 }
13240 else {
13241 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13242 }
13243 }
13244
13245 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13246 BlogsEntry.class.getName(),
13247 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13248
13249 SQLQuery q = session.createSQLQuery(sql);
13250
13251 q.setFirstResult(0);
13252 q.setMaxResults(2);
13253
13254 if (getDB().isSupportsInlineDistinct()) {
13255 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13256 }
13257 else {
13258 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13259 }
13260
13261 QueryPos qPos = QueryPos.getInstance(q);
13262
13263 qPos.add(groupId);
13264
13265 qPos.add(userId);
13266
13267 qPos.add(status);
13268
13269 if (orderByComparator != null) {
13270 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13271
13272 for (Object value : values) {
13273 qPos.add(value);
13274 }
13275 }
13276
13277 List<BlogsEntry> list = q.list();
13278
13279 if (list.size() == 2) {
13280 return list.get(1);
13281 }
13282 else {
13283 return null;
13284 }
13285 }
13286
13287
13295 public void removeByG_U_S(long groupId, long userId, int status)
13296 throws SystemException {
13297 for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
13298 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13299 remove(blogsEntry);
13300 }
13301 }
13302
13303
13312 public int countByG_U_S(long groupId, long userId, int status)
13313 throws SystemException {
13314 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
13315
13316 Object[] finderArgs = new Object[] { groupId, userId, status };
13317
13318 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13319 this);
13320
13321 if (count == null) {
13322 StringBundler query = new StringBundler(4);
13323
13324 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13325
13326 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13327
13328 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13329
13330 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13331
13332 String sql = query.toString();
13333
13334 Session session = null;
13335
13336 try {
13337 session = openSession();
13338
13339 Query q = session.createQuery(sql);
13340
13341 QueryPos qPos = QueryPos.getInstance(q);
13342
13343 qPos.add(groupId);
13344
13345 qPos.add(userId);
13346
13347 qPos.add(status);
13348
13349 count = (Long)q.uniqueResult();
13350
13351 FinderCacheUtil.putResult(finderPath, finderArgs, count);
13352 }
13353 catch (Exception e) {
13354 FinderCacheUtil.removeResult(finderPath, finderArgs);
13355
13356 throw processException(e);
13357 }
13358 finally {
13359 closeSession(session);
13360 }
13361 }
13362
13363 return count.intValue();
13364 }
13365
13366
13375 public int filterCountByG_U_S(long groupId, long userId, int status)
13376 throws SystemException {
13377 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13378 return countByG_U_S(groupId, userId, status);
13379 }
13380
13381 StringBundler query = new StringBundler(4);
13382
13383 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13384
13385 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13386
13387 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13388
13389 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13390
13391 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13392 BlogsEntry.class.getName(),
13393 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13394
13395 Session session = null;
13396
13397 try {
13398 session = openSession();
13399
13400 SQLQuery q = session.createSQLQuery(sql);
13401
13402 q.addScalar(COUNT_COLUMN_NAME,
13403 com.liferay.portal.kernel.dao.orm.Type.LONG);
13404
13405 QueryPos qPos = QueryPos.getInstance(q);
13406
13407 qPos.add(groupId);
13408
13409 qPos.add(userId);
13410
13411 qPos.add(status);
13412
13413 Long count = (Long)q.uniqueResult();
13414
13415 return count.intValue();
13416 }
13417 catch (Exception e) {
13418 throw processException(e);
13419 }
13420 finally {
13421 closeSession(session);
13422 }
13423 }
13424
13425 private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13426 private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
13427 private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
13428 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
13429 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13430 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13431 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
13432 new String[] {
13433 Long.class.getName(), Date.class.getName(),
13434 Integer.class.getName(),
13435
13436 Integer.class.getName(), Integer.class.getName(),
13437 OrderByComparator.class.getName()
13438 });
13439 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
13440 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13441 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13442 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
13443 new String[] {
13444 Long.class.getName(), Date.class.getName(),
13445 Integer.class.getName()
13446 });
13447
13448
13457 public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13458 int status) throws SystemException {
13459 return findByG_LtD_NotS(groupId, displayDate, status,
13460 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13461 }
13462
13463
13478 public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13479 int status, int start, int end) throws SystemException {
13480 return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
13481 }
13482
13483
13499 public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13500 int status, int start, int end, OrderByComparator orderByComparator)
13501 throws SystemException {
13502 boolean pagination = true;
13503 FinderPath finderPath = null;
13504 Object[] finderArgs = null;
13505
13506 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
13507 finderArgs = new Object[] {
13508 groupId, displayDate, status,
13509
13510 start, end, orderByComparator
13511 };
13512
13513 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
13514 finderArgs, this);
13515
13516 if ((list != null) && !list.isEmpty()) {
13517 for (BlogsEntry blogsEntry : list) {
13518 if ((groupId != blogsEntry.getGroupId()) ||
13519 !Validator.equals(displayDate,
13520 blogsEntry.getDisplayDate()) ||
13521 (status != blogsEntry.getStatus())) {
13522 list = null;
13523
13524 break;
13525 }
13526 }
13527 }
13528
13529 if (list == null) {
13530 StringBundler query = null;
13531
13532 if (orderByComparator != null) {
13533 query = new StringBundler(5 +
13534 (orderByComparator.getOrderByFields().length * 3));
13535 }
13536 else {
13537 query = new StringBundler(5);
13538 }
13539
13540 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13541
13542 query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13543
13544 boolean bindDisplayDate = false;
13545
13546 if (displayDate == null) {
13547 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13548 }
13549 else {
13550 bindDisplayDate = true;
13551
13552 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13553 }
13554
13555 query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13556
13557 if (orderByComparator != null) {
13558 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13559 orderByComparator);
13560 }
13561 else
13562 if (pagination) {
13563 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13564 }
13565
13566 String sql = query.toString();
13567
13568 Session session = null;
13569
13570 try {
13571 session = openSession();
13572
13573 Query q = session.createQuery(sql);
13574
13575 QueryPos qPos = QueryPos.getInstance(q);
13576
13577 qPos.add(groupId);
13578
13579 if (bindDisplayDate) {
13580 qPos.add(CalendarUtil.getTimestamp(displayDate));
13581 }
13582
13583 qPos.add(status);
13584
13585 if (!pagination) {
13586 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13587 start, end, false);
13588
13589 Collections.sort(list);
13590
13591 list = new UnmodifiableList<BlogsEntry>(list);
13592 }
13593 else {
13594 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13595 start, end);
13596 }
13597
13598 cacheResult(list);
13599
13600 FinderCacheUtil.putResult(finderPath, finderArgs, list);
13601 }
13602 catch (Exception e) {
13603 FinderCacheUtil.removeResult(finderPath, finderArgs);
13604
13605 throw processException(e);
13606 }
13607 finally {
13608 closeSession(session);
13609 }
13610 }
13611
13612 return list;
13613 }
13614
13615
13626 public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
13627 int status, OrderByComparator orderByComparator)
13628 throws NoSuchEntryException, SystemException {
13629 BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
13630 status, orderByComparator);
13631
13632 if (blogsEntry != null) {
13633 return blogsEntry;
13634 }
13635
13636 StringBundler msg = new StringBundler(8);
13637
13638 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13639
13640 msg.append("groupId=");
13641 msg.append(groupId);
13642
13643 msg.append(", displayDate=");
13644 msg.append(displayDate);
13645
13646 msg.append(", status=");
13647 msg.append(status);
13648
13649 msg.append(StringPool.CLOSE_CURLY_BRACE);
13650
13651 throw new NoSuchEntryException(msg.toString());
13652 }
13653
13654
13664 public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
13665 int status, OrderByComparator orderByComparator)
13666 throws SystemException {
13667 List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13668 0, 1, orderByComparator);
13669
13670 if (!list.isEmpty()) {
13671 return list.get(0);
13672 }
13673
13674 return null;
13675 }
13676
13677
13688 public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
13689 int status, OrderByComparator orderByComparator)
13690 throws NoSuchEntryException, SystemException {
13691 BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
13692 status, orderByComparator);
13693
13694 if (blogsEntry != null) {
13695 return blogsEntry;
13696 }
13697
13698 StringBundler msg = new StringBundler(8);
13699
13700 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13701
13702 msg.append("groupId=");
13703 msg.append(groupId);
13704
13705 msg.append(", displayDate=");
13706 msg.append(displayDate);
13707
13708 msg.append(", status=");
13709 msg.append(status);
13710
13711 msg.append(StringPool.CLOSE_CURLY_BRACE);
13712
13713 throw new NoSuchEntryException(msg.toString());
13714 }
13715
13716
13726 public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
13727 int status, OrderByComparator orderByComparator)
13728 throws SystemException {
13729 int count = countByG_LtD_NotS(groupId, displayDate, status);
13730
13731 List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13732 count - 1, count, orderByComparator);
13733
13734 if (!list.isEmpty()) {
13735 return list.get(0);
13736 }
13737
13738 return null;
13739 }
13740
13741
13753 public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
13754 long groupId, Date displayDate, int status,
13755 OrderByComparator orderByComparator)
13756 throws NoSuchEntryException, SystemException {
13757 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13758
13759 Session session = null;
13760
13761 try {
13762 session = openSession();
13763
13764 BlogsEntry[] array = new BlogsEntryImpl[3];
13765
13766 array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13767 groupId, displayDate, status, orderByComparator, true);
13768
13769 array[1] = blogsEntry;
13770
13771 array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13772 groupId, displayDate, status, orderByComparator, false);
13773
13774 return array;
13775 }
13776 catch (Exception e) {
13777 throw processException(e);
13778 }
13779 finally {
13780 closeSession(session);
13781 }
13782 }
13783
13784 protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
13785 BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13786 OrderByComparator orderByComparator, boolean previous) {
13787 StringBundler query = null;
13788
13789 if (orderByComparator != null) {
13790 query = new StringBundler(6 +
13791 (orderByComparator.getOrderByFields().length * 6));
13792 }
13793 else {
13794 query = new StringBundler(3);
13795 }
13796
13797 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13798
13799 query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13800
13801 boolean bindDisplayDate = false;
13802
13803 if (displayDate == null) {
13804 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13805 }
13806 else {
13807 bindDisplayDate = true;
13808
13809 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13810 }
13811
13812 query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13813
13814 if (orderByComparator != null) {
13815 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13816
13817 if (orderByConditionFields.length > 0) {
13818 query.append(WHERE_AND);
13819 }
13820
13821 for (int i = 0; i < orderByConditionFields.length; i++) {
13822 query.append(_ORDER_BY_ENTITY_ALIAS);
13823 query.append(orderByConditionFields[i]);
13824
13825 if ((i + 1) < orderByConditionFields.length) {
13826 if (orderByComparator.isAscending() ^ previous) {
13827 query.append(WHERE_GREATER_THAN_HAS_NEXT);
13828 }
13829 else {
13830 query.append(WHERE_LESSER_THAN_HAS_NEXT);
13831 }
13832 }
13833 else {
13834 if (orderByComparator.isAscending() ^ previous) {
13835 query.append(WHERE_GREATER_THAN);
13836 }
13837 else {
13838 query.append(WHERE_LESSER_THAN);
13839 }
13840 }
13841 }
13842
13843 query.append(ORDER_BY_CLAUSE);
13844
13845 String[] orderByFields = orderByComparator.getOrderByFields();
13846
13847 for (int i = 0; i < orderByFields.length; i++) {
13848 query.append(_ORDER_BY_ENTITY_ALIAS);
13849 query.append(orderByFields[i]);
13850
13851 if ((i + 1) < orderByFields.length) {
13852 if (orderByComparator.isAscending() ^ previous) {
13853 query.append(ORDER_BY_ASC_HAS_NEXT);
13854 }
13855 else {
13856 query.append(ORDER_BY_DESC_HAS_NEXT);
13857 }
13858 }
13859 else {
13860 if (orderByComparator.isAscending() ^ previous) {
13861 query.append(ORDER_BY_ASC);
13862 }
13863 else {
13864 query.append(ORDER_BY_DESC);
13865 }
13866 }
13867 }
13868 }
13869 else {
13870 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13871 }
13872
13873 String sql = query.toString();
13874
13875 Query q = session.createQuery(sql);
13876
13877 q.setFirstResult(0);
13878 q.setMaxResults(2);
13879
13880 QueryPos qPos = QueryPos.getInstance(q);
13881
13882 qPos.add(groupId);
13883
13884 if (bindDisplayDate) {
13885 qPos.add(CalendarUtil.getTimestamp(displayDate));
13886 }
13887
13888 qPos.add(status);
13889
13890 if (orderByComparator != null) {
13891 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13892
13893 for (Object value : values) {
13894 qPos.add(value);
13895 }
13896 }
13897
13898 List<BlogsEntry> list = q.list();
13899
13900 if (list.size() == 2) {
13901 return list.get(1);
13902 }
13903 else {
13904 return null;
13905 }
13906 }
13907
13908
13917 public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13918 Date displayDate, int status) throws SystemException {
13919 return filterFindByG_LtD_NotS(groupId, displayDate, status,
13920 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13921 }
13922
13923
13938 public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13939 Date displayDate, int status, int start, int end)
13940 throws SystemException {
13941 return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
13942 null);
13943 }
13944
13945
13961 public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13962 Date displayDate, int status, int start, int end,
13963 OrderByComparator orderByComparator) throws SystemException {
13964 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13965 return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13966 orderByComparator);
13967 }
13968
13969 StringBundler query = null;
13970
13971 if (orderByComparator != null) {
13972 query = new StringBundler(5 +
13973 (orderByComparator.getOrderByFields().length * 3));
13974 }
13975 else {
13976 query = new StringBundler(5);
13977 }
13978
13979 if (getDB().isSupportsInlineDistinct()) {
13980 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13981 }
13982 else {
13983 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13984 }
13985
13986 query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13987
13988 boolean bindDisplayDate = false;
13989
13990 if (displayDate == null) {
13991 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13992 }
13993 else {
13994 bindDisplayDate = true;
13995
13996 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13997 }
13998
13999 query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14000
14001 if (!getDB().isSupportsInlineDistinct()) {
14002 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14003 }
14004
14005 if (orderByComparator != null) {
14006 if (getDB().isSupportsInlineDistinct()) {
14007 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14008 orderByComparator, true);
14009 }
14010 else {
14011 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14012 orderByComparator, true);
14013 }
14014 }
14015 else {
14016 if (getDB().isSupportsInlineDistinct()) {
14017 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14018 }
14019 else {
14020 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14021 }
14022 }
14023
14024 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14025 BlogsEntry.class.getName(),
14026 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14027
14028 Session session = null;
14029
14030 try {
14031 session = openSession();
14032
14033 SQLQuery q = session.createSQLQuery(sql);
14034
14035 if (getDB().isSupportsInlineDistinct()) {
14036 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14037 }
14038 else {
14039 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14040 }
14041
14042 QueryPos qPos = QueryPos.getInstance(q);
14043
14044 qPos.add(groupId);
14045
14046 if (bindDisplayDate) {
14047 qPos.add(CalendarUtil.getTimestamp(displayDate));
14048 }
14049
14050 qPos.add(status);
14051
14052 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
14053 }
14054 catch (Exception e) {
14055 throw processException(e);
14056 }
14057 finally {
14058 closeSession(session);
14059 }
14060 }
14061
14062
14074 public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
14075 long groupId, Date displayDate, int status,
14076 OrderByComparator orderByComparator)
14077 throws NoSuchEntryException, SystemException {
14078 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14079 return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
14080 status, orderByComparator);
14081 }
14082
14083 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14084
14085 Session session = null;
14086
14087 try {
14088 session = openSession();
14089
14090 BlogsEntry[] array = new BlogsEntryImpl[3];
14091
14092 array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
14093 groupId, displayDate, status, orderByComparator, true);
14094
14095 array[1] = blogsEntry;
14096
14097 array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
14098 groupId, displayDate, status, orderByComparator, false);
14099
14100 return array;
14101 }
14102 catch (Exception e) {
14103 throw processException(e);
14104 }
14105 finally {
14106 closeSession(session);
14107 }
14108 }
14109
14110 protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
14111 BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
14112 OrderByComparator orderByComparator, boolean previous) {
14113 StringBundler query = null;
14114
14115 if (orderByComparator != null) {
14116 query = new StringBundler(6 +
14117 (orderByComparator.getOrderByFields().length * 6));
14118 }
14119 else {
14120 query = new StringBundler(3);
14121 }
14122
14123 if (getDB().isSupportsInlineDistinct()) {
14124 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14125 }
14126 else {
14127 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14128 }
14129
14130 query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14131
14132 boolean bindDisplayDate = false;
14133
14134 if (displayDate == null) {
14135 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14136 }
14137 else {
14138 bindDisplayDate = true;
14139
14140 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14141 }
14142
14143 query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14144
14145 if (!getDB().isSupportsInlineDistinct()) {
14146 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14147 }
14148
14149 if (orderByComparator != null) {
14150 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14151
14152 if (orderByConditionFields.length > 0) {
14153 query.append(WHERE_AND);
14154 }
14155
14156 for (int i = 0; i < orderByConditionFields.length; i++) {
14157 if (getDB().isSupportsInlineDistinct()) {
14158 query.append(_ORDER_BY_ENTITY_ALIAS);
14159 }
14160 else {
14161 query.append(_ORDER_BY_ENTITY_TABLE);
14162 }
14163
14164 query.append(orderByConditionFields[i]);
14165
14166 if ((i + 1) < orderByConditionFields.length) {
14167 if (orderByComparator.isAscending() ^ previous) {
14168 query.append(WHERE_GREATER_THAN_HAS_NEXT);
14169 }
14170 else {
14171 query.append(WHERE_LESSER_THAN_HAS_NEXT);
14172 }
14173 }
14174 else {
14175 if (orderByComparator.isAscending() ^ previous) {
14176 query.append(WHERE_GREATER_THAN);
14177 }
14178 else {
14179 query.append(WHERE_LESSER_THAN);
14180 }
14181 }
14182 }
14183
14184 query.append(ORDER_BY_CLAUSE);
14185
14186 String[] orderByFields = orderByComparator.getOrderByFields();
14187
14188 for (int i = 0; i < orderByFields.length; i++) {
14189 if (getDB().isSupportsInlineDistinct()) {
14190 query.append(_ORDER_BY_ENTITY_ALIAS);
14191 }
14192 else {
14193 query.append(_ORDER_BY_ENTITY_TABLE);
14194 }
14195
14196 query.append(orderByFields[i]);
14197
14198 if ((i + 1) < orderByFields.length) {
14199 if (orderByComparator.isAscending() ^ previous) {
14200 query.append(ORDER_BY_ASC_HAS_NEXT);
14201 }
14202 else {
14203 query.append(ORDER_BY_DESC_HAS_NEXT);
14204 }
14205 }
14206 else {
14207 if (orderByComparator.isAscending() ^ previous) {
14208 query.append(ORDER_BY_ASC);
14209 }
14210 else {
14211 query.append(ORDER_BY_DESC);
14212 }
14213 }
14214 }
14215 }
14216 else {
14217 if (getDB().isSupportsInlineDistinct()) {
14218 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14219 }
14220 else {
14221 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14222 }
14223 }
14224
14225 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14226 BlogsEntry.class.getName(),
14227 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14228
14229 SQLQuery q = session.createSQLQuery(sql);
14230
14231 q.setFirstResult(0);
14232 q.setMaxResults(2);
14233
14234 if (getDB().isSupportsInlineDistinct()) {
14235 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14236 }
14237 else {
14238 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14239 }
14240
14241 QueryPos qPos = QueryPos.getInstance(q);
14242
14243 qPos.add(groupId);
14244
14245 if (bindDisplayDate) {
14246 qPos.add(CalendarUtil.getTimestamp(displayDate));
14247 }
14248
14249 qPos.add(status);
14250
14251 if (orderByComparator != null) {
14252 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14253
14254 for (Object value : values) {
14255 qPos.add(value);
14256 }
14257 }
14258
14259 List<BlogsEntry> list = q.list();
14260
14261 if (list.size() == 2) {
14262 return list.get(1);
14263 }
14264 else {
14265 return null;
14266 }
14267 }
14268
14269
14277 public void removeByG_LtD_NotS(long groupId, Date displayDate, int status)
14278 throws SystemException {
14279 for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
14280 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14281 remove(blogsEntry);
14282 }
14283 }
14284
14285
14294 public int countByG_LtD_NotS(long groupId, Date displayDate, int status)
14295 throws SystemException {
14296 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
14297
14298 Object[] finderArgs = new Object[] { groupId, displayDate, status };
14299
14300 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14301 this);
14302
14303 if (count == null) {
14304 StringBundler query = new StringBundler(4);
14305
14306 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14307
14308 query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14309
14310 boolean bindDisplayDate = false;
14311
14312 if (displayDate == null) {
14313 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14314 }
14315 else {
14316 bindDisplayDate = true;
14317
14318 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14319 }
14320
14321 query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14322
14323 String sql = query.toString();
14324
14325 Session session = null;
14326
14327 try {
14328 session = openSession();
14329
14330 Query q = session.createQuery(sql);
14331
14332 QueryPos qPos = QueryPos.getInstance(q);
14333
14334 qPos.add(groupId);
14335
14336 if (bindDisplayDate) {
14337 qPos.add(CalendarUtil.getTimestamp(displayDate));
14338 }
14339
14340 qPos.add(status);
14341
14342 count = (Long)q.uniqueResult();
14343
14344 FinderCacheUtil.putResult(finderPath, finderArgs, count);
14345 }
14346 catch (Exception e) {
14347 FinderCacheUtil.removeResult(finderPath, finderArgs);
14348
14349 throw processException(e);
14350 }
14351 finally {
14352 closeSession(session);
14353 }
14354 }
14355
14356 return count.intValue();
14357 }
14358
14359
14368 public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
14369 int status) throws SystemException {
14370 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14371 return countByG_LtD_NotS(groupId, displayDate, status);
14372 }
14373
14374 StringBundler query = new StringBundler(4);
14375
14376 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
14377
14378 query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14379
14380 boolean bindDisplayDate = false;
14381
14382 if (displayDate == null) {
14383 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14384 }
14385 else {
14386 bindDisplayDate = true;
14387
14388 query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14389 }
14390
14391 query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14392
14393 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14394 BlogsEntry.class.getName(),
14395 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14396
14397 Session session = null;
14398
14399 try {
14400 session = openSession();
14401
14402 SQLQuery q = session.createSQLQuery(sql);
14403
14404 q.addScalar(COUNT_COLUMN_NAME,
14405 com.liferay.portal.kernel.dao.orm.Type.LONG);
14406
14407 QueryPos qPos = QueryPos.getInstance(q);
14408
14409 qPos.add(groupId);
14410
14411 if (bindDisplayDate) {
14412 qPos.add(CalendarUtil.getTimestamp(displayDate));
14413 }
14414
14415 qPos.add(status);
14416
14417 Long count = (Long)q.uniqueResult();
14418
14419 return count.intValue();
14420 }
14421 catch (Exception e) {
14422 throw processException(e);
14423 }
14424 finally {
14425 closeSession(session);
14426 }
14427 }
14428
14429 private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
14430 private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
14431 private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
14432 private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
14433 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14434 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14435 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
14436 new String[] {
14437 Long.class.getName(), Date.class.getName(),
14438 Integer.class.getName(),
14439
14440 Integer.class.getName(), Integer.class.getName(),
14441 OrderByComparator.class.getName()
14442 });
14443 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14444 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14445 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
14446 new String[] {
14447 Long.class.getName(), Date.class.getName(),
14448 Integer.class.getName()
14449 });
14450
14451
14460 public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14461 int status) throws SystemException {
14462 return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
14463 QueryUtil.ALL_POS, null);
14464 }
14465
14466
14481 public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14482 int status, int start, int end) throws SystemException {
14483 return findByG_LtD_S(groupId, displayDate, status, start, end, null);
14484 }
14485
14486
14502 public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14503 int status, int start, int end, OrderByComparator orderByComparator)
14504 throws SystemException {
14505 boolean pagination = true;
14506 FinderPath finderPath = null;
14507 Object[] finderArgs = null;
14508
14509 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
14510 finderArgs = new Object[] {
14511 groupId, displayDate, status,
14512
14513 start, end, orderByComparator
14514 };
14515
14516 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
14517 finderArgs, this);
14518
14519 if ((list != null) && !list.isEmpty()) {
14520 for (BlogsEntry blogsEntry : list) {
14521 if ((groupId != blogsEntry.getGroupId()) ||
14522 !Validator.equals(displayDate,
14523 blogsEntry.getDisplayDate()) ||
14524 (status != blogsEntry.getStatus())) {
14525 list = null;
14526
14527 break;
14528 }
14529 }
14530 }
14531
14532 if (list == null) {
14533 StringBundler query = null;
14534
14535 if (orderByComparator != null) {
14536 query = new StringBundler(5 +
14537 (orderByComparator.getOrderByFields().length * 3));
14538 }
14539 else {
14540 query = new StringBundler(5);
14541 }
14542
14543 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14544
14545 query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
14546
14547 boolean bindDisplayDate = false;
14548
14549 if (displayDate == null) {
14550 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
14551 }
14552 else {
14553 bindDisplayDate = true;
14554
14555 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
14556 }
14557
14558 query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
14559
14560 if (orderByComparator != null) {
14561 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14562 orderByComparator);
14563 }
14564 else
14565 if (pagination) {
14566 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14567 }
14568
14569 String sql = query.toString();
14570
14571 Session session = null;
14572
14573 try {
14574 session = openSession();
14575
14576 Query q = session.createQuery(sql);
14577
14578 QueryPos qPos = QueryPos.getInstance(q);
14579
14580 qPos.add(groupId);
14581
14582 if (bindDisplayDate) {
14583 qPos.add(CalendarUtil.getTimestamp(displayDate));
14584 }
14585
14586 qPos.add(status);
14587
14588 if (!pagination) {
14589 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14590 start, end, false);
14591
14592 Collections.sort(list);
14593
14594 list = new UnmodifiableList<BlogsEntry>(list);
14595 }
14596 else {
14597 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14598 start, end);
14599 }
14600
14601 cacheResult(list);
14602
14603 FinderCacheUtil.putResult(finderPath, finderArgs, list);
14604 }
14605 catch (Exception e) {
14606 FinderCacheUtil.removeResult(finderPath, finderArgs);
14607
14608 throw processException(e);
14609 }
14610 finally {
14611 closeSession(session);
14612 }
14613 }
14614
14615 return list;
14616 }
14617
14618
14629 public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
14630 int status, OrderByComparator orderByComparator)
14631 throws NoSuchEntryException, SystemException {
14632 BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
14633 status, orderByComparator);
14634
14635 if (blogsEntry != null) {
14636 return blogsEntry;
14637 }
14638
14639 StringBundler msg = new StringBundler(8);
14640
14641 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14642
14643 msg.append("groupId=");
14644 msg.append(groupId);
14645
14646 msg.append(", displayDate=");
14647 msg.append(displayDate);
14648
14649 msg.append(", status=");
14650 msg.append(status);
14651
14652 msg.append(StringPool.CLOSE_CURLY_BRACE);
14653
14654 throw new NoSuchEntryException(msg.toString());
14655 }
14656
14657
14667 public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
14668 int status, OrderByComparator orderByComparator)
14669 throws SystemException {
14670 List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
14671 1, orderByComparator);
14672
14673 if (!list.isEmpty()) {
14674 return list.get(0);
14675 }
14676
14677 return null;
14678 }
14679
14680
14691 public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
14692 int status, OrderByComparator orderByComparator)
14693 throws NoSuchEntryException, SystemException {
14694 BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
14695 status, orderByComparator);
14696
14697 if (blogsEntry != null) {
14698 return blogsEntry;
14699 }
14700
14701 StringBundler msg = new StringBundler(8);
14702
14703 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14704
14705 msg.append("groupId=");
14706 msg.append(groupId);
14707
14708 msg.append(", displayDate=");
14709 msg.append(displayDate);
14710
14711 msg.append(", status=");
14712 msg.append(status);
14713
14714 msg.append(StringPool.CLOSE_CURLY_BRACE);
14715
14716 throw new NoSuchEntryException(msg.toString());
14717 }
14718
14719
14729 public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
14730 int status, OrderByComparator orderByComparator)
14731 throws SystemException {
14732 int count = countByG_LtD_S(groupId, displayDate, status);
14733
14734 List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
14735 count - 1, count, orderByComparator);
14736
14737 if (!list.isEmpty()) {
14738 return list.get(0);
14739 }
14740
14741 return null;
14742 }
14743
14744
14756 public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
14757 Date displayDate, int status, OrderByComparator orderByComparator)
14758 throws NoSuchEntryException, SystemException {
14759 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14760
14761 Session session = null;
14762
14763 try {
14764 session = openSession();
14765
14766 BlogsEntry[] array = new BlogsEntryImpl[3];
14767
14768 array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
14769 displayDate, status, orderByComparator, true);
14770
14771 array[1] = blogsEntry;
14772
14773 array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
14774 displayDate, status, orderByComparator, false);
14775
14776 return array;
14777 }
14778 catch (Exception e) {
14779 throw processException(e);
14780 }
14781 finally {
14782 closeSession(session);
14783 }
14784 }
14785
14786 protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
14787 BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
14788 OrderByComparator orderByComparator, boolean previous) {
14789 StringBundler query = null;
14790
14791 if (orderByComparator != null) {
14792 query = new StringBundler(6 +
14793 (orderByComparator.getOrderByFields().length * 6));
14794 }
14795 else {
14796 query = new StringBundler(3);
14797 }
14798
14799 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14800
14801 query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
14802
14803 boolean bindDisplayDate = false;
14804
14805 if (displayDate == null) {
14806 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
14807 }
14808 else {
14809 bindDisplayDate = true;
14810
14811 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
14812 }
14813
14814 query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
14815
14816 if (orderByComparator != null) {
14817 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14818
14819 if (orderByConditionFields.length > 0) {
14820 query.append(WHERE_AND);
14821 }
14822
14823 for (int i = 0; i < orderByConditionFields.length; i++) {
14824 query.append(_ORDER_BY_ENTITY_ALIAS);
14825 query.append(orderByConditionFields[i]);
14826
14827 if ((i + 1) < orderByConditionFields.length) {
14828 if (orderByComparator.isAscending() ^ previous) {
14829 query.append(WHERE_GREATER_THAN_HAS_NEXT);
14830 }
14831 else {
14832 query.append(WHERE_LESSER_THAN_HAS_NEXT);
14833 }
14834 }
14835 else {
14836 if (orderByComparator.isAscending() ^ previous) {
14837 query.append(WHERE_GREATER_THAN);
14838 }
14839 else {
14840 query.append(WHERE_LESSER_THAN);
14841 }
14842 }
14843 }
14844
14845 query.append(ORDER_BY_CLAUSE);
14846
14847 String[] orderByFields = orderByComparator.getOrderByFields();
14848
14849 for (int i = 0; i < orderByFields.length; i++) {
14850 query.append(_ORDER_BY_ENTITY_ALIAS);
14851 query.append(orderByFields[i]);
14852
14853 if ((i + 1) < orderByFields.length) {
14854 if (orderByComparator.isAscending() ^ previous) {
14855 query.append(ORDER_BY_ASC_HAS_NEXT);
14856 }
14857 else {
14858 query.append(ORDER_BY_DESC_HAS_NEXT);
14859 }
14860 }
14861 else {
14862 if (orderByComparator.isAscending() ^ previous) {
14863 query.append(ORDER_BY_ASC);
14864 }
14865 else {
14866 query.append(ORDER_BY_DESC);
14867 }
14868 }
14869 }
14870 }
14871 else {
14872 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14873 }
14874
14875 String sql = query.toString();
14876
14877 Query q = session.createQuery(sql);
14878
14879 q.setFirstResult(0);
14880 q.setMaxResults(2);
14881
14882 QueryPos qPos = QueryPos.getInstance(q);
14883
14884 qPos.add(groupId);
14885
14886 if (bindDisplayDate) {
14887 qPos.add(CalendarUtil.getTimestamp(displayDate));
14888 }
14889
14890 qPos.add(status);
14891
14892 if (orderByComparator != null) {
14893 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14894
14895 for (Object value : values) {
14896 qPos.add(value);
14897 }
14898 }
14899
14900 List<BlogsEntry> list = q.list();
14901
14902 if (list.size() == 2) {
14903 return list.get(1);
14904 }
14905 else {
14906 return null;
14907 }
14908 }
14909
14910
14919 public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
14920 int status) throws SystemException {
14921 return filterFindByG_LtD_S(groupId, displayDate, status,
14922 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14923 }
14924
14925
14940 public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
14941 int status, int start, int end) throws SystemException {
14942 return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
14943 null);
14944 }
14945
14946
14962 public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
14963 int status, int start, int end, OrderByComparator orderByComparator)
14964 throws SystemException {
14965 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14966 return findByG_LtD_S(groupId, displayDate, status, start, end,
14967 orderByComparator);
14968 }
14969
14970 StringBundler query = null;
14971
14972 if (orderByComparator != null) {
14973 query = new StringBundler(5 +
14974 (orderByComparator.getOrderByFields().length * 3));
14975 }
14976 else {
14977 query = new StringBundler(5);
14978 }
14979
14980 if (getDB().isSupportsInlineDistinct()) {
14981 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14982 }
14983 else {
14984 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14985 }
14986
14987 query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
14988
14989 boolean bindDisplayDate = false;
14990
14991 if (displayDate == null) {
14992 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
14993 }
14994 else {
14995 bindDisplayDate = true;
14996
14997 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
14998 }
14999
15000 query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15001
15002 if (!getDB().isSupportsInlineDistinct()) {
15003 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
15004 }
15005
15006 if (orderByComparator != null) {
15007 if (getDB().isSupportsInlineDistinct()) {
15008 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15009 orderByComparator, true);
15010 }
15011 else {
15012 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15013 orderByComparator, true);
15014 }
15015 }
15016 else {
15017 if (getDB().isSupportsInlineDistinct()) {
15018 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15019 }
15020 else {
15021 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
15022 }
15023 }
15024
15025 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15026 BlogsEntry.class.getName(),
15027 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15028
15029 Session session = null;
15030
15031 try {
15032 session = openSession();
15033
15034 SQLQuery q = session.createSQLQuery(sql);
15035
15036 if (getDB().isSupportsInlineDistinct()) {
15037 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
15038 }
15039 else {
15040 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
15041 }
15042
15043 QueryPos qPos = QueryPos.getInstance(q);
15044
15045 qPos.add(groupId);
15046
15047 if (bindDisplayDate) {
15048 qPos.add(CalendarUtil.getTimestamp(displayDate));
15049 }
15050
15051 qPos.add(status);
15052
15053 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
15054 }
15055 catch (Exception e) {
15056 throw processException(e);
15057 }
15058 finally {
15059 closeSession(session);
15060 }
15061 }
15062
15063
15075 public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
15076 long groupId, Date displayDate, int status,
15077 OrderByComparator orderByComparator)
15078 throws NoSuchEntryException, SystemException {
15079 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15080 return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
15081 status, orderByComparator);
15082 }
15083
15084 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15085
15086 Session session = null;
15087
15088 try {
15089 session = openSession();
15090
15091 BlogsEntry[] array = new BlogsEntryImpl[3];
15092
15093 array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
15094 groupId, displayDate, status, orderByComparator, true);
15095
15096 array[1] = blogsEntry;
15097
15098 array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
15099 groupId, displayDate, status, orderByComparator, false);
15100
15101 return array;
15102 }
15103 catch (Exception e) {
15104 throw processException(e);
15105 }
15106 finally {
15107 closeSession(session);
15108 }
15109 }
15110
15111 protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
15112 BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
15113 OrderByComparator orderByComparator, boolean previous) {
15114 StringBundler query = null;
15115
15116 if (orderByComparator != null) {
15117 query = new StringBundler(6 +
15118 (orderByComparator.getOrderByFields().length * 6));
15119 }
15120 else {
15121 query = new StringBundler(3);
15122 }
15123
15124 if (getDB().isSupportsInlineDistinct()) {
15125 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
15126 }
15127 else {
15128 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
15129 }
15130
15131 query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15132
15133 boolean bindDisplayDate = false;
15134
15135 if (displayDate == null) {
15136 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15137 }
15138 else {
15139 bindDisplayDate = true;
15140
15141 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15142 }
15143
15144 query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15145
15146 if (!getDB().isSupportsInlineDistinct()) {
15147 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
15148 }
15149
15150 if (orderByComparator != null) {
15151 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15152
15153 if (orderByConditionFields.length > 0) {
15154 query.append(WHERE_AND);
15155 }
15156
15157 for (int i = 0; i < orderByConditionFields.length; i++) {
15158 if (getDB().isSupportsInlineDistinct()) {
15159 query.append(_ORDER_BY_ENTITY_ALIAS);
15160 }
15161 else {
15162 query.append(_ORDER_BY_ENTITY_TABLE);
15163 }
15164
15165 query.append(orderByConditionFields[i]);
15166
15167 if ((i + 1) < orderByConditionFields.length) {
15168 if (orderByComparator.isAscending() ^ previous) {
15169 query.append(WHERE_GREATER_THAN_HAS_NEXT);
15170 }
15171 else {
15172 query.append(WHERE_LESSER_THAN_HAS_NEXT);
15173 }
15174 }
15175 else {
15176 if (orderByComparator.isAscending() ^ previous) {
15177 query.append(WHERE_GREATER_THAN);
15178 }
15179 else {
15180 query.append(WHERE_LESSER_THAN);
15181 }
15182 }
15183 }
15184
15185 query.append(ORDER_BY_CLAUSE);
15186
15187 String[] orderByFields = orderByComparator.getOrderByFields();
15188
15189 for (int i = 0; i < orderByFields.length; i++) {
15190 if (getDB().isSupportsInlineDistinct()) {
15191 query.append(_ORDER_BY_ENTITY_ALIAS);
15192 }
15193 else {
15194 query.append(_ORDER_BY_ENTITY_TABLE);
15195 }
15196
15197 query.append(orderByFields[i]);
15198
15199 if ((i + 1) < orderByFields.length) {
15200 if (orderByComparator.isAscending() ^ previous) {
15201 query.append(ORDER_BY_ASC_HAS_NEXT);
15202 }
15203 else {
15204 query.append(ORDER_BY_DESC_HAS_NEXT);
15205 }
15206 }
15207 else {
15208 if (orderByComparator.isAscending() ^ previous) {
15209 query.append(ORDER_BY_ASC);
15210 }
15211 else {
15212 query.append(ORDER_BY_DESC);
15213 }
15214 }
15215 }
15216 }
15217 else {
15218 if (getDB().isSupportsInlineDistinct()) {
15219 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15220 }
15221 else {
15222 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
15223 }
15224 }
15225
15226 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15227 BlogsEntry.class.getName(),
15228 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15229
15230 SQLQuery q = session.createSQLQuery(sql);
15231
15232 q.setFirstResult(0);
15233 q.setMaxResults(2);
15234
15235 if (getDB().isSupportsInlineDistinct()) {
15236 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
15237 }
15238 else {
15239 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
15240 }
15241
15242 QueryPos qPos = QueryPos.getInstance(q);
15243
15244 qPos.add(groupId);
15245
15246 if (bindDisplayDate) {
15247 qPos.add(CalendarUtil.getTimestamp(displayDate));
15248 }
15249
15250 qPos.add(status);
15251
15252 if (orderByComparator != null) {
15253 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15254
15255 for (Object value : values) {
15256 qPos.add(value);
15257 }
15258 }
15259
15260 List<BlogsEntry> list = q.list();
15261
15262 if (list.size() == 2) {
15263 return list.get(1);
15264 }
15265 else {
15266 return null;
15267 }
15268 }
15269
15270
15278 public void removeByG_LtD_S(long groupId, Date displayDate, int status)
15279 throws SystemException {
15280 for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
15281 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15282 remove(blogsEntry);
15283 }
15284 }
15285
15286
15295 public int countByG_LtD_S(long groupId, Date displayDate, int status)
15296 throws SystemException {
15297 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
15298
15299 Object[] finderArgs = new Object[] { groupId, displayDate, status };
15300
15301 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15302 this);
15303
15304 if (count == null) {
15305 StringBundler query = new StringBundler(4);
15306
15307 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15308
15309 query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15310
15311 boolean bindDisplayDate = false;
15312
15313 if (displayDate == null) {
15314 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15315 }
15316 else {
15317 bindDisplayDate = true;
15318
15319 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15320 }
15321
15322 query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15323
15324 String sql = query.toString();
15325
15326 Session session = null;
15327
15328 try {
15329 session = openSession();
15330
15331 Query q = session.createQuery(sql);
15332
15333 QueryPos qPos = QueryPos.getInstance(q);
15334
15335 qPos.add(groupId);
15336
15337 if (bindDisplayDate) {
15338 qPos.add(CalendarUtil.getTimestamp(displayDate));
15339 }
15340
15341 qPos.add(status);
15342
15343 count = (Long)q.uniqueResult();
15344
15345 FinderCacheUtil.putResult(finderPath, finderArgs, count);
15346 }
15347 catch (Exception e) {
15348 FinderCacheUtil.removeResult(finderPath, finderArgs);
15349
15350 throw processException(e);
15351 }
15352 finally {
15353 closeSession(session);
15354 }
15355 }
15356
15357 return count.intValue();
15358 }
15359
15360
15369 public int filterCountByG_LtD_S(long groupId, Date displayDate, int status)
15370 throws SystemException {
15371 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15372 return countByG_LtD_S(groupId, displayDate, status);
15373 }
15374
15375 StringBundler query = new StringBundler(4);
15376
15377 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
15378
15379 query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15380
15381 boolean bindDisplayDate = false;
15382
15383 if (displayDate == null) {
15384 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15385 }
15386 else {
15387 bindDisplayDate = true;
15388
15389 query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15390 }
15391
15392 query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15393
15394 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15395 BlogsEntry.class.getName(),
15396 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15397
15398 Session session = null;
15399
15400 try {
15401 session = openSession();
15402
15403 SQLQuery q = session.createSQLQuery(sql);
15404
15405 q.addScalar(COUNT_COLUMN_NAME,
15406 com.liferay.portal.kernel.dao.orm.Type.LONG);
15407
15408 QueryPos qPos = QueryPos.getInstance(q);
15409
15410 qPos.add(groupId);
15411
15412 if (bindDisplayDate) {
15413 qPos.add(CalendarUtil.getTimestamp(displayDate));
15414 }
15415
15416 qPos.add(status);
15417
15418 Long count = (Long)q.uniqueResult();
15419
15420 return count.intValue();
15421 }
15422 catch (Exception e) {
15423 throw processException(e);
15424 }
15425 finally {
15426 closeSession(session);
15427 }
15428 }
15429
15430 private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
15431 private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
15432 private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15433 private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
15434 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
15435 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15436 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15437 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
15438 new String[] {
15439 Long.class.getName(), Long.class.getName(), Date.class.getName(),
15440 Integer.class.getName(),
15441
15442 Integer.class.getName(), Integer.class.getName(),
15443 OrderByComparator.class.getName()
15444 });
15445 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
15446 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15447 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15448 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
15449 new String[] {
15450 Long.class.getName(), Long.class.getName(), Date.class.getName(),
15451 Integer.class.getName()
15452 });
15453
15454
15464 public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15465 Date displayDate, int status) throws SystemException {
15466 return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
15467 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15468 }
15469
15470
15486 public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15487 Date displayDate, int status, int start, int end)
15488 throws SystemException {
15489 return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
15490 end, null);
15491 }
15492
15493
15510 public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15511 Date displayDate, int status, int start, int end,
15512 OrderByComparator orderByComparator) throws SystemException {
15513 boolean pagination = true;
15514 FinderPath finderPath = null;
15515 Object[] finderArgs = null;
15516
15517 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
15518 finderArgs = new Object[] {
15519 groupId, userId, displayDate, status,
15520
15521 start, end, orderByComparator
15522 };
15523
15524 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
15525 finderArgs, this);
15526
15527 if ((list != null) && !list.isEmpty()) {
15528 for (BlogsEntry blogsEntry : list) {
15529 if ((groupId != blogsEntry.getGroupId()) ||
15530 (userId != blogsEntry.getUserId()) ||
15531 !Validator.equals(displayDate,
15532 blogsEntry.getDisplayDate()) ||
15533 (status != blogsEntry.getStatus())) {
15534 list = null;
15535
15536 break;
15537 }
15538 }
15539 }
15540
15541 if (list == null) {
15542 StringBundler query = null;
15543
15544 if (orderByComparator != null) {
15545 query = new StringBundler(6 +
15546 (orderByComparator.getOrderByFields().length * 3));
15547 }
15548 else {
15549 query = new StringBundler(6);
15550 }
15551
15552 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15553
15554 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
15555
15556 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
15557
15558 boolean bindDisplayDate = false;
15559
15560 if (displayDate == null) {
15561 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
15562 }
15563 else {
15564 bindDisplayDate = true;
15565
15566 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
15567 }
15568
15569 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
15570
15571 if (orderByComparator != null) {
15572 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15573 orderByComparator);
15574 }
15575 else
15576 if (pagination) {
15577 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15578 }
15579
15580 String sql = query.toString();
15581
15582 Session session = null;
15583
15584 try {
15585 session = openSession();
15586
15587 Query q = session.createQuery(sql);
15588
15589 QueryPos qPos = QueryPos.getInstance(q);
15590
15591 qPos.add(groupId);
15592
15593 qPos.add(userId);
15594
15595 if (bindDisplayDate) {
15596 qPos.add(CalendarUtil.getTimestamp(displayDate));
15597 }
15598
15599 qPos.add(status);
15600
15601 if (!pagination) {
15602 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15603 start, end, false);
15604
15605 Collections.sort(list);
15606
15607 list = new UnmodifiableList<BlogsEntry>(list);
15608 }
15609 else {
15610 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15611 start, end);
15612 }
15613
15614 cacheResult(list);
15615
15616 FinderCacheUtil.putResult(finderPath, finderArgs, list);
15617 }
15618 catch (Exception e) {
15619 FinderCacheUtil.removeResult(finderPath, finderArgs);
15620
15621 throw processException(e);
15622 }
15623 finally {
15624 closeSession(session);
15625 }
15626 }
15627
15628 return list;
15629 }
15630
15631
15643 public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
15644 Date displayDate, int status, OrderByComparator orderByComparator)
15645 throws NoSuchEntryException, SystemException {
15646 BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
15647 displayDate, status, orderByComparator);
15648
15649 if (blogsEntry != null) {
15650 return blogsEntry;
15651 }
15652
15653 StringBundler msg = new StringBundler(10);
15654
15655 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15656
15657 msg.append("groupId=");
15658 msg.append(groupId);
15659
15660 msg.append(", userId=");
15661 msg.append(userId);
15662
15663 msg.append(", displayDate=");
15664 msg.append(displayDate);
15665
15666 msg.append(", status=");
15667 msg.append(status);
15668
15669 msg.append(StringPool.CLOSE_CURLY_BRACE);
15670
15671 throw new NoSuchEntryException(msg.toString());
15672 }
15673
15674
15685 public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
15686 Date displayDate, int status, OrderByComparator orderByComparator)
15687 throws SystemException {
15688 List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
15689 displayDate, status, 0, 1, orderByComparator);
15690
15691 if (!list.isEmpty()) {
15692 return list.get(0);
15693 }
15694
15695 return null;
15696 }
15697
15698
15710 public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
15711 Date displayDate, int status, OrderByComparator orderByComparator)
15712 throws NoSuchEntryException, SystemException {
15713 BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
15714 displayDate, status, orderByComparator);
15715
15716 if (blogsEntry != null) {
15717 return blogsEntry;
15718 }
15719
15720 StringBundler msg = new StringBundler(10);
15721
15722 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15723
15724 msg.append("groupId=");
15725 msg.append(groupId);
15726
15727 msg.append(", userId=");
15728 msg.append(userId);
15729
15730 msg.append(", displayDate=");
15731 msg.append(displayDate);
15732
15733 msg.append(", status=");
15734 msg.append(status);
15735
15736 msg.append(StringPool.CLOSE_CURLY_BRACE);
15737
15738 throw new NoSuchEntryException(msg.toString());
15739 }
15740
15741
15752 public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
15753 Date displayDate, int status, OrderByComparator orderByComparator)
15754 throws SystemException {
15755 int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
15756
15757 List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
15758 displayDate, status, count - 1, count, orderByComparator);
15759
15760 if (!list.isEmpty()) {
15761 return list.get(0);
15762 }
15763
15764 return null;
15765 }
15766
15767
15780 public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
15781 long groupId, long userId, Date displayDate, int status,
15782 OrderByComparator orderByComparator)
15783 throws NoSuchEntryException, SystemException {
15784 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15785
15786 Session session = null;
15787
15788 try {
15789 session = openSession();
15790
15791 BlogsEntry[] array = new BlogsEntryImpl[3];
15792
15793 array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
15794 groupId, userId, displayDate, status, orderByComparator,
15795 true);
15796
15797 array[1] = blogsEntry;
15798
15799 array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
15800 groupId, userId, displayDate, status, orderByComparator,
15801 false);
15802
15803 return array;
15804 }
15805 catch (Exception e) {
15806 throw processException(e);
15807 }
15808 finally {
15809 closeSession(session);
15810 }
15811 }
15812
15813 protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
15814 BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
15815 int status, OrderByComparator orderByComparator, boolean previous) {
15816 StringBundler query = null;
15817
15818 if (orderByComparator != null) {
15819 query = new StringBundler(6 +
15820 (orderByComparator.getOrderByFields().length * 6));
15821 }
15822 else {
15823 query = new StringBundler(3);
15824 }
15825
15826 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15827
15828 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
15829
15830 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
15831
15832 boolean bindDisplayDate = false;
15833
15834 if (displayDate == null) {
15835 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
15836 }
15837 else {
15838 bindDisplayDate = true;
15839
15840 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
15841 }
15842
15843 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
15844
15845 if (orderByComparator != null) {
15846 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15847
15848 if (orderByConditionFields.length > 0) {
15849 query.append(WHERE_AND);
15850 }
15851
15852 for (int i = 0; i < orderByConditionFields.length; i++) {
15853 query.append(_ORDER_BY_ENTITY_ALIAS);
15854 query.append(orderByConditionFields[i]);
15855
15856 if ((i + 1) < orderByConditionFields.length) {
15857 if (orderByComparator.isAscending() ^ previous) {
15858 query.append(WHERE_GREATER_THAN_HAS_NEXT);
15859 }
15860 else {
15861 query.append(WHERE_LESSER_THAN_HAS_NEXT);
15862 }
15863 }
15864 else {
15865 if (orderByComparator.isAscending() ^ previous) {
15866 query.append(WHERE_GREATER_THAN);
15867 }
15868 else {
15869 query.append(WHERE_LESSER_THAN);
15870 }
15871 }
15872 }
15873
15874 query.append(ORDER_BY_CLAUSE);
15875
15876 String[] orderByFields = orderByComparator.getOrderByFields();
15877
15878 for (int i = 0; i < orderByFields.length; i++) {
15879 query.append(_ORDER_BY_ENTITY_ALIAS);
15880 query.append(orderByFields[i]);
15881
15882 if ((i + 1) < orderByFields.length) {
15883 if (orderByComparator.isAscending() ^ previous) {
15884 query.append(ORDER_BY_ASC_HAS_NEXT);
15885 }
15886 else {
15887 query.append(ORDER_BY_DESC_HAS_NEXT);
15888 }
15889 }
15890 else {
15891 if (orderByComparator.isAscending() ^ previous) {
15892 query.append(ORDER_BY_ASC);
15893 }
15894 else {
15895 query.append(ORDER_BY_DESC);
15896 }
15897 }
15898 }
15899 }
15900 else {
15901 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15902 }
15903
15904 String sql = query.toString();
15905
15906 Query q = session.createQuery(sql);
15907
15908 q.setFirstResult(0);
15909 q.setMaxResults(2);
15910
15911 QueryPos qPos = QueryPos.getInstance(q);
15912
15913 qPos.add(groupId);
15914
15915 qPos.add(userId);
15916
15917 if (bindDisplayDate) {
15918 qPos.add(CalendarUtil.getTimestamp(displayDate));
15919 }
15920
15921 qPos.add(status);
15922
15923 if (orderByComparator != null) {
15924 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15925
15926 for (Object value : values) {
15927 qPos.add(value);
15928 }
15929 }
15930
15931 List<BlogsEntry> list = q.list();
15932
15933 if (list.size() == 2) {
15934 return list.get(1);
15935 }
15936 else {
15937 return null;
15938 }
15939 }
15940
15941
15951 public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
15952 Date displayDate, int status) throws SystemException {
15953 return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
15954 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15955 }
15956
15957
15973 public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
15974 Date displayDate, int status, int start, int end)
15975 throws SystemException {
15976 return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
15977 start, end, null);
15978 }
15979
15980
15997 public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
15998 Date displayDate, int status, int start, int end,
15999 OrderByComparator orderByComparator) throws SystemException {
16000 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16001 return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
16002 start, end, orderByComparator);
16003 }
16004
16005 StringBundler query = null;
16006
16007 if (orderByComparator != null) {
16008 query = new StringBundler(6 +
16009 (orderByComparator.getOrderByFields().length * 3));
16010 }
16011 else {
16012 query = new StringBundler(6);
16013 }
16014
16015 if (getDB().isSupportsInlineDistinct()) {
16016 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16017 }
16018 else {
16019 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16020 }
16021
16022 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16023
16024 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16025
16026 boolean bindDisplayDate = false;
16027
16028 if (displayDate == null) {
16029 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16030 }
16031 else {
16032 bindDisplayDate = true;
16033
16034 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16035 }
16036
16037 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16038
16039 if (!getDB().isSupportsInlineDistinct()) {
16040 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16041 }
16042
16043 if (orderByComparator != null) {
16044 if (getDB().isSupportsInlineDistinct()) {
16045 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16046 orderByComparator, true);
16047 }
16048 else {
16049 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16050 orderByComparator, true);
16051 }
16052 }
16053 else {
16054 if (getDB().isSupportsInlineDistinct()) {
16055 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16056 }
16057 else {
16058 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16059 }
16060 }
16061
16062 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16063 BlogsEntry.class.getName(),
16064 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16065
16066 Session session = null;
16067
16068 try {
16069 session = openSession();
16070
16071 SQLQuery q = session.createSQLQuery(sql);
16072
16073 if (getDB().isSupportsInlineDistinct()) {
16074 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16075 }
16076 else {
16077 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16078 }
16079
16080 QueryPos qPos = QueryPos.getInstance(q);
16081
16082 qPos.add(groupId);
16083
16084 qPos.add(userId);
16085
16086 if (bindDisplayDate) {
16087 qPos.add(CalendarUtil.getTimestamp(displayDate));
16088 }
16089
16090 qPos.add(status);
16091
16092 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
16093 }
16094 catch (Exception e) {
16095 throw processException(e);
16096 }
16097 finally {
16098 closeSession(session);
16099 }
16100 }
16101
16102
16115 public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
16116 long groupId, long userId, Date displayDate, int status,
16117 OrderByComparator orderByComparator)
16118 throws NoSuchEntryException, SystemException {
16119 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16120 return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
16121 displayDate, status, orderByComparator);
16122 }
16123
16124 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16125
16126 Session session = null;
16127
16128 try {
16129 session = openSession();
16130
16131 BlogsEntry[] array = new BlogsEntryImpl[3];
16132
16133 array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16134 groupId, userId, displayDate, status, orderByComparator,
16135 true);
16136
16137 array[1] = blogsEntry;
16138
16139 array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16140 groupId, userId, displayDate, status, orderByComparator,
16141 false);
16142
16143 return array;
16144 }
16145 catch (Exception e) {
16146 throw processException(e);
16147 }
16148 finally {
16149 closeSession(session);
16150 }
16151 }
16152
16153 protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
16154 BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16155 int status, OrderByComparator orderByComparator, boolean previous) {
16156 StringBundler query = null;
16157
16158 if (orderByComparator != null) {
16159 query = new StringBundler(6 +
16160 (orderByComparator.getOrderByFields().length * 6));
16161 }
16162 else {
16163 query = new StringBundler(3);
16164 }
16165
16166 if (getDB().isSupportsInlineDistinct()) {
16167 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16168 }
16169 else {
16170 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16171 }
16172
16173 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16174
16175 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16176
16177 boolean bindDisplayDate = false;
16178
16179 if (displayDate == null) {
16180 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16181 }
16182 else {
16183 bindDisplayDate = true;
16184
16185 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16186 }
16187
16188 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16189
16190 if (!getDB().isSupportsInlineDistinct()) {
16191 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16192 }
16193
16194 if (orderByComparator != null) {
16195 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16196
16197 if (orderByConditionFields.length > 0) {
16198 query.append(WHERE_AND);
16199 }
16200
16201 for (int i = 0; i < orderByConditionFields.length; i++) {
16202 if (getDB().isSupportsInlineDistinct()) {
16203 query.append(_ORDER_BY_ENTITY_ALIAS);
16204 }
16205 else {
16206 query.append(_ORDER_BY_ENTITY_TABLE);
16207 }
16208
16209 query.append(orderByConditionFields[i]);
16210
16211 if ((i + 1) < orderByConditionFields.length) {
16212 if (orderByComparator.isAscending() ^ previous) {
16213 query.append(WHERE_GREATER_THAN_HAS_NEXT);
16214 }
16215 else {
16216 query.append(WHERE_LESSER_THAN_HAS_NEXT);
16217 }
16218 }
16219 else {
16220 if (orderByComparator.isAscending() ^ previous) {
16221 query.append(WHERE_GREATER_THAN);
16222 }
16223 else {
16224 query.append(WHERE_LESSER_THAN);
16225 }
16226 }
16227 }
16228
16229 query.append(ORDER_BY_CLAUSE);
16230
16231 String[] orderByFields = orderByComparator.getOrderByFields();
16232
16233 for (int i = 0; i < orderByFields.length; i++) {
16234 if (getDB().isSupportsInlineDistinct()) {
16235 query.append(_ORDER_BY_ENTITY_ALIAS);
16236 }
16237 else {
16238 query.append(_ORDER_BY_ENTITY_TABLE);
16239 }
16240
16241 query.append(orderByFields[i]);
16242
16243 if ((i + 1) < orderByFields.length) {
16244 if (orderByComparator.isAscending() ^ previous) {
16245 query.append(ORDER_BY_ASC_HAS_NEXT);
16246 }
16247 else {
16248 query.append(ORDER_BY_DESC_HAS_NEXT);
16249 }
16250 }
16251 else {
16252 if (orderByComparator.isAscending() ^ previous) {
16253 query.append(ORDER_BY_ASC);
16254 }
16255 else {
16256 query.append(ORDER_BY_DESC);
16257 }
16258 }
16259 }
16260 }
16261 else {
16262 if (getDB().isSupportsInlineDistinct()) {
16263 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16264 }
16265 else {
16266 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16267 }
16268 }
16269
16270 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16271 BlogsEntry.class.getName(),
16272 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16273
16274 SQLQuery q = session.createSQLQuery(sql);
16275
16276 q.setFirstResult(0);
16277 q.setMaxResults(2);
16278
16279 if (getDB().isSupportsInlineDistinct()) {
16280 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16281 }
16282 else {
16283 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16284 }
16285
16286 QueryPos qPos = QueryPos.getInstance(q);
16287
16288 qPos.add(groupId);
16289
16290 qPos.add(userId);
16291
16292 if (bindDisplayDate) {
16293 qPos.add(CalendarUtil.getTimestamp(displayDate));
16294 }
16295
16296 qPos.add(status);
16297
16298 if (orderByComparator != null) {
16299 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16300
16301 for (Object value : values) {
16302 qPos.add(value);
16303 }
16304 }
16305
16306 List<BlogsEntry> list = q.list();
16307
16308 if (list.size() == 2) {
16309 return list.get(1);
16310 }
16311 else {
16312 return null;
16313 }
16314 }
16315
16316
16325 public void removeByG_U_LtD_NotS(long groupId, long userId,
16326 Date displayDate, int status) throws SystemException {
16327 for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
16328 displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16329 remove(blogsEntry);
16330 }
16331 }
16332
16333
16343 public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
16344 int status) throws SystemException {
16345 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
16346
16347 Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
16348
16349 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16350 this);
16351
16352 if (count == null) {
16353 StringBundler query = new StringBundler(5);
16354
16355 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16356
16357 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16358
16359 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16360
16361 boolean bindDisplayDate = false;
16362
16363 if (displayDate == null) {
16364 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16365 }
16366 else {
16367 bindDisplayDate = true;
16368
16369 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16370 }
16371
16372 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16373
16374 String sql = query.toString();
16375
16376 Session session = null;
16377
16378 try {
16379 session = openSession();
16380
16381 Query q = session.createQuery(sql);
16382
16383 QueryPos qPos = QueryPos.getInstance(q);
16384
16385 qPos.add(groupId);
16386
16387 qPos.add(userId);
16388
16389 if (bindDisplayDate) {
16390 qPos.add(CalendarUtil.getTimestamp(displayDate));
16391 }
16392
16393 qPos.add(status);
16394
16395 count = (Long)q.uniqueResult();
16396
16397 FinderCacheUtil.putResult(finderPath, finderArgs, count);
16398 }
16399 catch (Exception e) {
16400 FinderCacheUtil.removeResult(finderPath, finderArgs);
16401
16402 throw processException(e);
16403 }
16404 finally {
16405 closeSession(session);
16406 }
16407 }
16408
16409 return count.intValue();
16410 }
16411
16412
16422 public int filterCountByG_U_LtD_NotS(long groupId, long userId,
16423 Date displayDate, int status) throws SystemException {
16424 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16425 return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
16426 }
16427
16428 StringBundler query = new StringBundler(5);
16429
16430 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
16431
16432 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16433
16434 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16435
16436 boolean bindDisplayDate = false;
16437
16438 if (displayDate == null) {
16439 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16440 }
16441 else {
16442 bindDisplayDate = true;
16443
16444 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16445 }
16446
16447 query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16448
16449 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16450 BlogsEntry.class.getName(),
16451 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16452
16453 Session session = null;
16454
16455 try {
16456 session = openSession();
16457
16458 SQLQuery q = session.createSQLQuery(sql);
16459
16460 q.addScalar(COUNT_COLUMN_NAME,
16461 com.liferay.portal.kernel.dao.orm.Type.LONG);
16462
16463 QueryPos qPos = QueryPos.getInstance(q);
16464
16465 qPos.add(groupId);
16466
16467 qPos.add(userId);
16468
16469 if (bindDisplayDate) {
16470 qPos.add(CalendarUtil.getTimestamp(displayDate));
16471 }
16472
16473 qPos.add(status);
16474
16475 Long count = (Long)q.uniqueResult();
16476
16477 return count.intValue();
16478 }
16479 catch (Exception e) {
16480 throw processException(e);
16481 }
16482 finally {
16483 closeSession(session);
16484 }
16485 }
16486
16487 private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
16488 private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
16489 private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
16490 private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
16491 private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
16492 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
16493 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16494 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
16495 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
16496 new String[] {
16497 Long.class.getName(), Long.class.getName(), Date.class.getName(),
16498 Integer.class.getName(),
16499
16500 Integer.class.getName(), Integer.class.getName(),
16501 OrderByComparator.class.getName()
16502 });
16503 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
16504 new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16505 BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16506 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
16507 new String[] {
16508 Long.class.getName(), Long.class.getName(), Date.class.getName(),
16509 Integer.class.getName()
16510 });
16511
16512
16522 public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16523 Date displayDate, int status) throws SystemException {
16524 return findByG_U_LtD_S(groupId, userId, displayDate, status,
16525 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16526 }
16527
16528
16544 public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16545 Date displayDate, int status, int start, int end)
16546 throws SystemException {
16547 return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16548 end, null);
16549 }
16550
16551
16568 public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16569 Date displayDate, int status, int start, int end,
16570 OrderByComparator orderByComparator) throws SystemException {
16571 boolean pagination = true;
16572 FinderPath finderPath = null;
16573 Object[] finderArgs = null;
16574
16575 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
16576 finderArgs = new Object[] {
16577 groupId, userId, displayDate, status,
16578
16579 start, end, orderByComparator
16580 };
16581
16582 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
16583 finderArgs, this);
16584
16585 if ((list != null) && !list.isEmpty()) {
16586 for (BlogsEntry blogsEntry : list) {
16587 if ((groupId != blogsEntry.getGroupId()) ||
16588 (userId != blogsEntry.getUserId()) ||
16589 !Validator.equals(displayDate,
16590 blogsEntry.getDisplayDate()) ||
16591 (status != blogsEntry.getStatus())) {
16592 list = null;
16593
16594 break;
16595 }
16596 }
16597 }
16598
16599 if (list == null) {
16600 StringBundler query = null;
16601
16602 if (orderByComparator != null) {
16603 query = new StringBundler(6 +
16604 (orderByComparator.getOrderByFields().length * 3));
16605 }
16606 else {
16607 query = new StringBundler(6);
16608 }
16609
16610 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16611
16612 query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16613
16614 query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16615
16616 boolean bindDisplayDate = false;
16617
16618 if (displayDate == null) {
16619 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16620 }
16621 else {
16622 bindDisplayDate = true;
16623
16624 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16625 }
16626
16627 query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16628
16629 if (orderByComparator != null) {
16630 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16631 orderByComparator);
16632 }
16633 else
16634 if (pagination) {
16635 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16636 }
16637
16638 String sql = query.toString();
16639
16640 Session session = null;
16641
16642 try {
16643 session = openSession();
16644
16645 Query q = session.createQuery(sql);
16646
16647 QueryPos qPos = QueryPos.getInstance(q);
16648
16649 qPos.add(groupId);
16650
16651 qPos.add(userId);
16652
16653 if (bindDisplayDate) {
16654 qPos.add(CalendarUtil.getTimestamp(displayDate));
16655 }
16656
16657 qPos.add(status);
16658
16659 if (!pagination) {
16660 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16661 start, end, false);
16662
16663 Collections.sort(list);
16664
16665 list = new UnmodifiableList<BlogsEntry>(list);
16666 }
16667 else {
16668 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16669 start, end);
16670 }
16671
16672 cacheResult(list);
16673
16674 FinderCacheUtil.putResult(finderPath, finderArgs, list);
16675 }
16676 catch (Exception e) {
16677 FinderCacheUtil.removeResult(finderPath, finderArgs);
16678
16679 throw processException(e);
16680 }
16681 finally {
16682 closeSession(session);
16683 }
16684 }
16685
16686 return list;
16687 }
16688
16689
16701 public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
16702 Date displayDate, int status, OrderByComparator orderByComparator)
16703 throws NoSuchEntryException, SystemException {
16704 BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
16705 displayDate, status, orderByComparator);
16706
16707 if (blogsEntry != null) {
16708 return blogsEntry;
16709 }
16710
16711 StringBundler msg = new StringBundler(10);
16712
16713 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16714
16715 msg.append("groupId=");
16716 msg.append(groupId);
16717
16718 msg.append(", userId=");
16719 msg.append(userId);
16720
16721 msg.append(", displayDate=");
16722 msg.append(displayDate);
16723
16724 msg.append(", status=");
16725 msg.append(status);
16726
16727 msg.append(StringPool.CLOSE_CURLY_BRACE);
16728
16729 throw new NoSuchEntryException(msg.toString());
16730 }
16731
16732
16743 public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
16744 Date displayDate, int status, OrderByComparator orderByComparator)
16745 throws SystemException {
16746 List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16747 status, 0, 1, orderByComparator);
16748
16749 if (!list.isEmpty()) {
16750 return list.get(0);
16751 }
16752
16753 return null;
16754 }
16755
16756
16768 public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
16769 Date displayDate, int status, OrderByComparator orderByComparator)
16770 throws NoSuchEntryException, SystemException {
16771 BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
16772 displayDate, status, orderByComparator);
16773
16774 if (blogsEntry != null) {
16775 return blogsEntry;
16776 }
16777
16778 StringBundler msg = new StringBundler(10);
16779
16780 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16781
16782 msg.append("groupId=");
16783 msg.append(groupId);
16784
16785 msg.append(", userId=");
16786 msg.append(userId);
16787
16788 msg.append(", displayDate=");
16789 msg.append(displayDate);
16790
16791 msg.append(", status=");
16792 msg.append(status);
16793
16794 msg.append(StringPool.CLOSE_CURLY_BRACE);
16795
16796 throw new NoSuchEntryException(msg.toString());
16797 }
16798
16799
16810 public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
16811 Date displayDate, int status, OrderByComparator orderByComparator)
16812 throws SystemException {
16813 int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
16814
16815 List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16816 status, count - 1, count, orderByComparator);
16817
16818 if (!list.isEmpty()) {
16819 return list.get(0);
16820 }
16821
16822 return null;
16823 }
16824
16825
16838 public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
16839 long userId, Date displayDate, int status,
16840 OrderByComparator orderByComparator)
16841 throws NoSuchEntryException, SystemException {
16842 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16843
16844 Session session = null;
16845
16846 try {
16847 session = openSession();
16848
16849 BlogsEntry[] array = new BlogsEntryImpl[3];
16850
16851 array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16852 userId, displayDate, status, orderByComparator, true);
16853
16854 array[1] = blogsEntry;
16855
16856 array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16857 userId, displayDate, status, orderByComparator, false);
16858
16859 return array;
16860 }
16861 catch (Exception e) {
16862 throw processException(e);
16863 }
16864 finally {
16865 closeSession(session);
16866 }
16867 }
16868
16869 protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
16870 BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16871 int status, OrderByComparator orderByComparator, boolean previous) {
16872 StringBundler query = null;
16873
16874 if (orderByComparator != null) {
16875 query = new StringBundler(6 +
16876 (orderByComparator.getOrderByFields().length * 6));
16877 }
16878 else {
16879 query = new StringBundler(3);
16880 }
16881
16882 query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16883
16884 query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16885
16886 query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16887
16888 boolean bindDisplayDate = false;
16889
16890 if (displayDate == null) {
16891 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16892 }
16893 else {
16894 bindDisplayDate = true;
16895
16896 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16897 }
16898
16899 query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16900
16901 if (orderByComparator != null) {
16902 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16903
16904 if (orderByConditionFields.length > 0) {
16905 query.append(WHERE_AND);
16906 }
16907
16908 for (int i = 0; i < orderByConditionFields.length; i++) {
16909 query.append(_ORDER_BY_ENTITY_ALIAS);
16910 query.append(orderByConditionFields[i]);
16911
16912 if ((i + 1) < orderByConditionFields.length) {
16913 if (orderByComparator.isAscending() ^ previous) {
16914 query.append(WHERE_GREATER_THAN_HAS_NEXT);
16915 }
16916 else {
16917 query.append(WHERE_LESSER_THAN_HAS_NEXT);
16918 }
16919 }
16920 else {
16921 if (orderByComparator.isAscending() ^ previous) {
16922 query.append(WHERE_GREATER_THAN);
16923 }
16924 else {
16925 query.append(WHERE_LESSER_THAN);
16926 }
16927 }
16928 }
16929
16930 query.append(ORDER_BY_CLAUSE);
16931
16932 String[] orderByFields = orderByComparator.getOrderByFields();
16933
16934 for (int i = 0; i < orderByFields.length; i++) {
16935 query.append(_ORDER_BY_ENTITY_ALIAS);
16936 query.append(orderByFields[i]);
16937
16938 if ((i + 1) < orderByFields.length) {
16939 if (orderByComparator.isAscending() ^ previous) {
16940 query.append(ORDER_BY_ASC_HAS_NEXT);
16941 }
16942 else {
16943 query.append(ORDER_BY_DESC_HAS_NEXT);
16944 }
16945 }
16946 else {
16947 if (orderByComparator.isAscending() ^ previous) {
16948 query.append(ORDER_BY_ASC);
16949 }
16950 else {
16951 query.append(ORDER_BY_DESC);
16952 }
16953 }
16954 }
16955 }
16956 else {
16957 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16958 }
16959
16960 String sql = query.toString();
16961
16962 Query q = session.createQuery(sql);
16963
16964 q.setFirstResult(0);
16965 q.setMaxResults(2);
16966
16967 QueryPos qPos = QueryPos.getInstance(q);
16968
16969 qPos.add(groupId);
16970
16971 qPos.add(userId);
16972
16973 if (bindDisplayDate) {
16974 qPos.add(CalendarUtil.getTimestamp(displayDate));
16975 }
16976
16977 qPos.add(status);
16978
16979 if (orderByComparator != null) {
16980 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16981
16982 for (Object value : values) {
16983 qPos.add(value);
16984 }
16985 }
16986
16987 List<BlogsEntry> list = q.list();
16988
16989 if (list.size() == 2) {
16990 return list.get(1);
16991 }
16992 else {
16993 return null;
16994 }
16995 }
16996
16997
17007 public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17008 Date displayDate, int status) throws SystemException {
17009 return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17010 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17011 }
17012
17013
17029 public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17030 Date displayDate, int status, int start, int end)
17031 throws SystemException {
17032 return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17033 start, end, null);
17034 }
17035
17036
17053 public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17054 Date displayDate, int status, int start, int end,
17055 OrderByComparator orderByComparator) throws SystemException {
17056 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17057 return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
17058 end, orderByComparator);
17059 }
17060
17061 StringBundler query = null;
17062
17063 if (orderByComparator != null) {
17064 query = new StringBundler(6 +
17065 (orderByComparator.getOrderByFields().length * 3));
17066 }
17067 else {
17068 query = new StringBundler(6);
17069 }
17070
17071 if (getDB().isSupportsInlineDistinct()) {
17072 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17073 }
17074 else {
17075 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17076 }
17077
17078 query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17079
17080 query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17081
17082 boolean bindDisplayDate = false;
17083
17084 if (displayDate == null) {
17085 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17086 }
17087 else {
17088 bindDisplayDate = true;
17089
17090 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17091 }
17092
17093 query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17094
17095 if (!getDB().isSupportsInlineDistinct()) {
17096 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17097 }
17098
17099 if (orderByComparator != null) {
17100 if (getDB().isSupportsInlineDistinct()) {
17101 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17102 orderByComparator, true);
17103 }
17104 else {
17105 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17106 orderByComparator, true);
17107 }
17108 }
17109 else {
17110 if (getDB().isSupportsInlineDistinct()) {
17111 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17112 }
17113 else {
17114 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17115 }
17116 }
17117
17118 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17119 BlogsEntry.class.getName(),
17120 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17121
17122 Session session = null;
17123
17124 try {
17125 session = openSession();
17126
17127 SQLQuery q = session.createSQLQuery(sql);
17128
17129 if (getDB().isSupportsInlineDistinct()) {
17130 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17131 }
17132 else {
17133 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17134 }
17135
17136 QueryPos qPos = QueryPos.getInstance(q);
17137
17138 qPos.add(groupId);
17139
17140 qPos.add(userId);
17141
17142 if (bindDisplayDate) {
17143 qPos.add(CalendarUtil.getTimestamp(displayDate));
17144 }
17145
17146 qPos.add(status);
17147
17148 return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17149 }
17150 catch (Exception e) {
17151 throw processException(e);
17152 }
17153 finally {
17154 closeSession(session);
17155 }
17156 }
17157
17158
17171 public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
17172 long groupId, long userId, Date displayDate, int status,
17173 OrderByComparator orderByComparator)
17174 throws NoSuchEntryException, SystemException {
17175 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17176 return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
17177 displayDate, status, orderByComparator);
17178 }
17179
17180 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17181
17182 Session session = null;
17183
17184 try {
17185 session = openSession();
17186
17187 BlogsEntry[] array = new BlogsEntryImpl[3];
17188
17189 array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17190 groupId, userId, displayDate, status, orderByComparator,
17191 true);
17192
17193 array[1] = blogsEntry;
17194
17195 array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17196 groupId, userId, displayDate, status, orderByComparator,
17197 false);
17198
17199 return array;
17200 }
17201 catch (Exception e) {
17202 throw processException(e);
17203 }
17204 finally {
17205 closeSession(session);
17206 }
17207 }
17208
17209 protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
17210 BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17211 int status, OrderByComparator orderByComparator, boolean previous) {
17212 StringBundler query = null;
17213
17214 if (orderByComparator != null) {
17215 query = new StringBundler(6 +
17216 (orderByComparator.getOrderByFields().length * 6));
17217 }
17218 else {
17219 query = new StringBundler(3);
17220 }
17221
17222 if (getDB().isSupportsInlineDistinct()) {
17223 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17224 }
17225 else {
17226 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17227 }
17228
17229 query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17230
17231 query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17232
17233 boolean bindDisplayDate = false;
17234
17235 if (displayDate == null) {
17236 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17237 }
17238 else {
17239 bindDisplayDate = true;
17240
17241 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17242 }
17243
17244 query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17245
17246 if (!getDB().isSupportsInlineDistinct()) {
17247 query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17248 }
17249
17250 if (orderByComparator != null) {
17251 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17252
17253 if (orderByConditionFields.length > 0) {
17254 query.append(WHERE_AND);
17255 }
17256
17257 for (int i = 0; i < orderByConditionFields.length; i++) {
17258 if (getDB().isSupportsInlineDistinct()) {
17259 query.append(_ORDER_BY_ENTITY_ALIAS);
17260 }
17261 else {
17262 query.append(_ORDER_BY_ENTITY_TABLE);
17263 }
17264
17265 query.append(orderByConditionFields[i]);
17266
17267 if ((i + 1) < orderByConditionFields.length) {
17268 if (orderByComparator.isAscending() ^ previous) {
17269 query.append(WHERE_GREATER_THAN_HAS_NEXT);
17270 }
17271 else {
17272 query.append(WHERE_LESSER_THAN_HAS_NEXT);
17273 }
17274 }
17275 else {
17276 if (orderByComparator.isAscending() ^ previous) {
17277 query.append(WHERE_GREATER_THAN);
17278 }
17279 else {
17280 query.append(WHERE_LESSER_THAN);
17281 }
17282 }
17283 }
17284
17285 query.append(ORDER_BY_CLAUSE);
17286
17287 String[] orderByFields = orderByComparator.getOrderByFields();
17288
17289 for (int i = 0; i < orderByFields.length; i++) {
17290 if (getDB().isSupportsInlineDistinct()) {
17291 query.append(_ORDER_BY_ENTITY_ALIAS);
17292 }
17293 else {
17294 query.append(_ORDER_BY_ENTITY_TABLE);
17295 }
17296
17297 query.append(orderByFields[i]);
17298
17299 if ((i + 1) < orderByFields.length) {
17300 if (orderByComparator.isAscending() ^ previous) {
17301 query.append(ORDER_BY_ASC_HAS_NEXT);
17302 }
17303 else {
17304 query.append(ORDER_BY_DESC_HAS_NEXT);
17305 }
17306 }
17307 else {
17308 if (orderByComparator.isAscending() ^ previous) {
17309 query.append(ORDER_BY_ASC);
17310 }
17311 else {
17312 query.append(ORDER_BY_DESC);
17313 }
17314 }
17315 }
17316 }
17317 else {
17318 if (getDB().isSupportsInlineDistinct()) {
17319 query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17320 }
17321 else {
17322 query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17323 }
17324 }
17325
17326 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17327 BlogsEntry.class.getName(),
17328 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17329
17330 SQLQuery q = session.createSQLQuery(sql);
17331
17332 q.setFirstResult(0);
17333 q.setMaxResults(2);
17334
17335 if (getDB().isSupportsInlineDistinct()) {
17336 q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17337 }
17338 else {
17339 q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17340 }
17341
17342 QueryPos qPos = QueryPos.getInstance(q);
17343
17344 qPos.add(groupId);
17345
17346 qPos.add(userId);
17347
17348 if (bindDisplayDate) {
17349 qPos.add(CalendarUtil.getTimestamp(displayDate));
17350 }
17351
17352 qPos.add(status);
17353
17354 if (orderByComparator != null) {
17355 Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17356
17357 for (Object value : values) {
17358 qPos.add(value);
17359 }
17360 }
17361
17362 List<BlogsEntry> list = q.list();
17363
17364 if (list.size() == 2) {
17365 return list.get(1);
17366 }
17367 else {
17368 return null;
17369 }
17370 }
17371
17372
17381 public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
17382 int status) throws SystemException {
17383 for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
17384 displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17385 remove(blogsEntry);
17386 }
17387 }
17388
17389
17399 public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
17400 int status) throws SystemException {
17401 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
17402
17403 Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17404
17405 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17406 this);
17407
17408 if (count == null) {
17409 StringBundler query = new StringBundler(5);
17410
17411 query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17412
17413 query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17414
17415 query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17416
17417 boolean bindDisplayDate = false;
17418
17419 if (displayDate == null) {
17420 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17421 }
17422 else {
17423 bindDisplayDate = true;
17424
17425 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17426 }
17427
17428 query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17429
17430 String sql = query.toString();
17431
17432 Session session = null;
17433
17434 try {
17435 session = openSession();
17436
17437 Query q = session.createQuery(sql);
17438
17439 QueryPos qPos = QueryPos.getInstance(q);
17440
17441 qPos.add(groupId);
17442
17443 qPos.add(userId);
17444
17445 if (bindDisplayDate) {
17446 qPos.add(CalendarUtil.getTimestamp(displayDate));
17447 }
17448
17449 qPos.add(status);
17450
17451 count = (Long)q.uniqueResult();
17452
17453 FinderCacheUtil.putResult(finderPath, finderArgs, count);
17454 }
17455 catch (Exception e) {
17456 FinderCacheUtil.removeResult(finderPath, finderArgs);
17457
17458 throw processException(e);
17459 }
17460 finally {
17461 closeSession(session);
17462 }
17463 }
17464
17465 return count.intValue();
17466 }
17467
17468
17478 public int filterCountByG_U_LtD_S(long groupId, long userId,
17479 Date displayDate, int status) throws SystemException {
17480 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17481 return countByG_U_LtD_S(groupId, userId, displayDate, status);
17482 }
17483
17484 StringBundler query = new StringBundler(5);
17485
17486 query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17487
17488 query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17489
17490 query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17491
17492 boolean bindDisplayDate = false;
17493
17494 if (displayDate == null) {
17495 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17496 }
17497 else {
17498 bindDisplayDate = true;
17499
17500 query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17501 }
17502
17503 query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17504
17505 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17506 BlogsEntry.class.getName(),
17507 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17508
17509 Session session = null;
17510
17511 try {
17512 session = openSession();
17513
17514 SQLQuery q = session.createSQLQuery(sql);
17515
17516 q.addScalar(COUNT_COLUMN_NAME,
17517 com.liferay.portal.kernel.dao.orm.Type.LONG);
17518
17519 QueryPos qPos = QueryPos.getInstance(q);
17520
17521 qPos.add(groupId);
17522
17523 qPos.add(userId);
17524
17525 if (bindDisplayDate) {
17526 qPos.add(CalendarUtil.getTimestamp(displayDate));
17527 }
17528
17529 qPos.add(status);
17530
17531 Long count = (Long)q.uniqueResult();
17532
17533 return count.intValue();
17534 }
17535 catch (Exception e) {
17536 throw processException(e);
17537 }
17538 finally {
17539 closeSession(session);
17540 }
17541 }
17542
17543 private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17544 private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
17545 private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
17546 private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17547 private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
17548
17549
17554 public void cacheResult(BlogsEntry blogsEntry) {
17555 EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17556 BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
17557
17558 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
17559 new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
17560 blogsEntry);
17561
17562 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
17563 new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
17564 blogsEntry);
17565
17566 blogsEntry.resetOriginalValues();
17567 }
17568
17569
17574 public void cacheResult(List<BlogsEntry> blogsEntries) {
17575 for (BlogsEntry blogsEntry : blogsEntries) {
17576 if (EntityCacheUtil.getResult(
17577 BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17578 BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
17579 cacheResult(blogsEntry);
17580 }
17581 else {
17582 blogsEntry.resetOriginalValues();
17583 }
17584 }
17585 }
17586
17587
17594 @Override
17595 public void clearCache() {
17596 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
17597 CacheRegistryUtil.clear(BlogsEntryImpl.class.getName());
17598 }
17599
17600 EntityCacheUtil.clearCache(BlogsEntryImpl.class.getName());
17601
17602 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
17603 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17604 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17605 }
17606
17607
17614 @Override
17615 public void clearCache(BlogsEntry blogsEntry) {
17616 EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17617 BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
17618
17619 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17620 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17621
17622 clearUniqueFindersCache(blogsEntry);
17623 }
17624
17625 @Override
17626 public void clearCache(List<BlogsEntry> blogsEntries) {
17627 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17628 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17629
17630 for (BlogsEntry blogsEntry : blogsEntries) {
17631 EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17632 BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
17633
17634 clearUniqueFindersCache(blogsEntry);
17635 }
17636 }
17637
17638 protected void cacheUniqueFindersCache(BlogsEntry blogsEntry) {
17639 if (blogsEntry.isNew()) {
17640 Object[] args = new Object[] {
17641 blogsEntry.getUuid(), blogsEntry.getGroupId()
17642 };
17643
17644 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
17645 Long.valueOf(1));
17646 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
17647 blogsEntry);
17648
17649 args = new Object[] {
17650 blogsEntry.getGroupId(), blogsEntry.getUrlTitle()
17651 };
17652
17653 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
17654 Long.valueOf(1));
17655 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
17656 blogsEntry);
17657 }
17658 else {
17659 BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17660
17661 if ((blogsEntryModelImpl.getColumnBitmask() &
17662 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
17663 Object[] args = new Object[] {
17664 blogsEntry.getUuid(), blogsEntry.getGroupId()
17665 };
17666
17667 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
17668 Long.valueOf(1));
17669 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
17670 blogsEntry);
17671 }
17672
17673 if ((blogsEntryModelImpl.getColumnBitmask() &
17674 FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
17675 Object[] args = new Object[] {
17676 blogsEntry.getGroupId(), blogsEntry.getUrlTitle()
17677 };
17678
17679 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
17680 Long.valueOf(1));
17681 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
17682 blogsEntry);
17683 }
17684 }
17685 }
17686
17687 protected void clearUniqueFindersCache(BlogsEntry blogsEntry) {
17688 BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17689
17690 Object[] args = new Object[] {
17691 blogsEntry.getUuid(), blogsEntry.getGroupId()
17692 };
17693
17694 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
17695 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
17696
17697 if ((blogsEntryModelImpl.getColumnBitmask() &
17698 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
17699 args = new Object[] {
17700 blogsEntryModelImpl.getOriginalUuid(),
17701 blogsEntryModelImpl.getOriginalGroupId()
17702 };
17703
17704 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
17705 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
17706 }
17707
17708 args = new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() };
17709
17710 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
17711 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
17712
17713 if ((blogsEntryModelImpl.getColumnBitmask() &
17714 FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
17715 args = new Object[] {
17716 blogsEntryModelImpl.getOriginalGroupId(),
17717 blogsEntryModelImpl.getOriginalUrlTitle()
17718 };
17719
17720 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
17721 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
17722 }
17723 }
17724
17725
17731 public BlogsEntry create(long entryId) {
17732 BlogsEntry blogsEntry = new BlogsEntryImpl();
17733
17734 blogsEntry.setNew(true);
17735 blogsEntry.setPrimaryKey(entryId);
17736
17737 String uuid = PortalUUIDUtil.generate();
17738
17739 blogsEntry.setUuid(uuid);
17740
17741 return blogsEntry;
17742 }
17743
17744
17752 public BlogsEntry remove(long entryId)
17753 throws NoSuchEntryException, SystemException {
17754 return remove((Serializable)entryId);
17755 }
17756
17757
17765 @Override
17766 public BlogsEntry remove(Serializable primaryKey)
17767 throws NoSuchEntryException, SystemException {
17768 Session session = null;
17769
17770 try {
17771 session = openSession();
17772
17773 BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
17774 primaryKey);
17775
17776 if (blogsEntry == null) {
17777 if (_log.isWarnEnabled()) {
17778 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
17779 }
17780
17781 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
17782 primaryKey);
17783 }
17784
17785 return remove(blogsEntry);
17786 }
17787 catch (NoSuchEntryException nsee) {
17788 throw nsee;
17789 }
17790 catch (Exception e) {
17791 throw processException(e);
17792 }
17793 finally {
17794 closeSession(session);
17795 }
17796 }
17797
17798 @Override
17799 protected BlogsEntry removeImpl(BlogsEntry blogsEntry)
17800 throws SystemException {
17801 blogsEntry = toUnwrappedModel(blogsEntry);
17802
17803 Session session = null;
17804
17805 try {
17806 session = openSession();
17807
17808 if (!session.contains(blogsEntry)) {
17809 blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
17810 blogsEntry.getPrimaryKeyObj());
17811 }
17812
17813 if (blogsEntry != null) {
17814 session.delete(blogsEntry);
17815 }
17816 }
17817 catch (Exception e) {
17818 throw processException(e);
17819 }
17820 finally {
17821 closeSession(session);
17822 }
17823
17824 if (blogsEntry != null) {
17825 clearCache(blogsEntry);
17826 }
17827
17828 return blogsEntry;
17829 }
17830
17831 @Override
17832 public BlogsEntry updateImpl(
17833 com.liferay.portlet.blogs.model.BlogsEntry blogsEntry)
17834 throws SystemException {
17835 blogsEntry = toUnwrappedModel(blogsEntry);
17836
17837 boolean isNew = blogsEntry.isNew();
17838
17839 BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17840
17841 if (Validator.isNull(blogsEntry.getUuid())) {
17842 String uuid = PortalUUIDUtil.generate();
17843
17844 blogsEntry.setUuid(uuid);
17845 }
17846
17847 long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
17848
17849 if (userId > 0) {
17850 long companyId = blogsEntry.getCompanyId();
17851
17852 long groupId = blogsEntry.getGroupId();
17853
17854 long entryId = 0;
17855
17856 if (!isNew) {
17857 entryId = blogsEntry.getPrimaryKey();
17858 }
17859
17860 try {
17861 blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
17862 userId,
17863 com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
17864 entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
17865 blogsEntry.getTitle(), null));
17866
17867 blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
17868 groupId, userId,
17869 com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
17870 entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
17871 blogsEntry.getContent(), null));
17872 }
17873 catch (SanitizerException se) {
17874 throw new SystemException(se);
17875 }
17876 }
17877
17878 Session session = null;
17879
17880 try {
17881 session = openSession();
17882
17883 if (blogsEntry.isNew()) {
17884 session.save(blogsEntry);
17885
17886 blogsEntry.setNew(false);
17887 }
17888 else {
17889 session.merge(blogsEntry);
17890 }
17891 }
17892 catch (Exception e) {
17893 throw processException(e);
17894 }
17895 finally {
17896 closeSession(session);
17897 }
17898
17899 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17900
17901 if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
17902 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17903 }
17904
17905 else {
17906 if ((blogsEntryModelImpl.getColumnBitmask() &
17907 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
17908 Object[] args = new Object[] {
17909 blogsEntryModelImpl.getOriginalUuid()
17910 };
17911
17912 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
17913 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
17914 args);
17915
17916 args = new Object[] { blogsEntryModelImpl.getUuid() };
17917
17918 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
17919 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
17920 args);
17921 }
17922
17923 if ((blogsEntryModelImpl.getColumnBitmask() &
17924 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
17925 Object[] args = new Object[] {
17926 blogsEntryModelImpl.getOriginalUuid(),
17927 blogsEntryModelImpl.getOriginalCompanyId()
17928 };
17929
17930 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
17931 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
17932 args);
17933
17934 args = new Object[] {
17935 blogsEntryModelImpl.getUuid(),
17936 blogsEntryModelImpl.getCompanyId()
17937 };
17938
17939 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
17940 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
17941 args);
17942 }
17943
17944 if ((blogsEntryModelImpl.getColumnBitmask() &
17945 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
17946 Object[] args = new Object[] {
17947 blogsEntryModelImpl.getOriginalGroupId()
17948 };
17949
17950 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
17951 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
17952 args);
17953
17954 args = new Object[] { blogsEntryModelImpl.getGroupId() };
17955
17956 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
17957 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
17958 args);
17959 }
17960
17961 if ((blogsEntryModelImpl.getColumnBitmask() &
17962 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
17963 Object[] args = new Object[] {
17964 blogsEntryModelImpl.getOriginalCompanyId()
17965 };
17966
17967 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
17968 args);
17969 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
17970 args);
17971
17972 args = new Object[] { blogsEntryModelImpl.getCompanyId() };
17973
17974 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
17975 args);
17976 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
17977 args);
17978 }
17979
17980 if ((blogsEntryModelImpl.getColumnBitmask() &
17981 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
17982 Object[] args = new Object[] {
17983 blogsEntryModelImpl.getOriginalCompanyId(),
17984 blogsEntryModelImpl.getOriginalUserId()
17985 };
17986
17987 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
17988 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
17989 args);
17990
17991 args = new Object[] {
17992 blogsEntryModelImpl.getCompanyId(),
17993 blogsEntryModelImpl.getUserId()
17994 };
17995
17996 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
17997 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
17998 args);
17999 }
18000
18001 if ((blogsEntryModelImpl.getColumnBitmask() &
18002 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
18003 Object[] args = new Object[] {
18004 blogsEntryModelImpl.getOriginalCompanyId(),
18005 blogsEntryModelImpl.getOriginalStatus()
18006 };
18007
18008 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18009 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18010 args);
18011
18012 args = new Object[] {
18013 blogsEntryModelImpl.getCompanyId(),
18014 blogsEntryModelImpl.getStatus()
18015 };
18016
18017 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18018 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18019 args);
18020 }
18021
18022 if ((blogsEntryModelImpl.getColumnBitmask() &
18023 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
18024 Object[] args = new Object[] {
18025 blogsEntryModelImpl.getOriginalGroupId(),
18026 blogsEntryModelImpl.getOriginalStatus()
18027 };
18028
18029 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18030 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18031 args);
18032
18033 args = new Object[] {
18034 blogsEntryModelImpl.getGroupId(),
18035 blogsEntryModelImpl.getStatus()
18036 };
18037
18038 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18039 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18040 args);
18041 }
18042
18043 if ((blogsEntryModelImpl.getColumnBitmask() &
18044 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
18045 Object[] args = new Object[] {
18046 blogsEntryModelImpl.getOriginalCompanyId(),
18047 blogsEntryModelImpl.getOriginalUserId(),
18048 blogsEntryModelImpl.getOriginalStatus()
18049 };
18050
18051 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18052 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18053 args);
18054
18055 args = new Object[] {
18056 blogsEntryModelImpl.getCompanyId(),
18057 blogsEntryModelImpl.getUserId(),
18058 blogsEntryModelImpl.getStatus()
18059 };
18060
18061 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18062 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18063 args);
18064 }
18065
18066 if ((blogsEntryModelImpl.getColumnBitmask() &
18067 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
18068 Object[] args = new Object[] {
18069 blogsEntryModelImpl.getOriginalGroupId(),
18070 blogsEntryModelImpl.getOriginalUserId(),
18071 blogsEntryModelImpl.getOriginalStatus()
18072 };
18073
18074 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18075 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18076 args);
18077
18078 args = new Object[] {
18079 blogsEntryModelImpl.getGroupId(),
18080 blogsEntryModelImpl.getUserId(),
18081 blogsEntryModelImpl.getStatus()
18082 };
18083
18084 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18085 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18086 args);
18087 }
18088 }
18089
18090 EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18091 BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
18092
18093 clearUniqueFindersCache(blogsEntry);
18094 cacheUniqueFindersCache(blogsEntry);
18095
18096 return blogsEntry;
18097 }
18098
18099 protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
18100 if (blogsEntry instanceof BlogsEntryImpl) {
18101 return blogsEntry;
18102 }
18103
18104 BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
18105
18106 blogsEntryImpl.setNew(blogsEntry.isNew());
18107 blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
18108
18109 blogsEntryImpl.setUuid(blogsEntry.getUuid());
18110 blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
18111 blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
18112 blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
18113 blogsEntryImpl.setUserId(blogsEntry.getUserId());
18114 blogsEntryImpl.setUserName(blogsEntry.getUserName());
18115 blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
18116 blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
18117 blogsEntryImpl.setTitle(blogsEntry.getTitle());
18118 blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
18119 blogsEntryImpl.setDescription(blogsEntry.getDescription());
18120 blogsEntryImpl.setContent(blogsEntry.getContent());
18121 blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
18122 blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
18123 blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
18124 blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
18125 blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
18126 blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
18127 blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
18128 blogsEntryImpl.setStatus(blogsEntry.getStatus());
18129 blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
18130 blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
18131 blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
18132
18133 return blogsEntryImpl;
18134 }
18135
18136
18144 @Override
18145 public BlogsEntry findByPrimaryKey(Serializable primaryKey)
18146 throws NoSuchEntryException, SystemException {
18147 BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18148
18149 if (blogsEntry == null) {
18150 if (_log.isWarnEnabled()) {
18151 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18152 }
18153
18154 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18155 primaryKey);
18156 }
18157
18158 return blogsEntry;
18159 }
18160
18161
18169 public BlogsEntry findByPrimaryKey(long entryId)
18170 throws NoSuchEntryException, SystemException {
18171 return findByPrimaryKey((Serializable)entryId);
18172 }
18173
18174
18181 @Override
18182 public BlogsEntry fetchByPrimaryKey(Serializable primaryKey)
18183 throws SystemException {
18184 BlogsEntry blogsEntry = (BlogsEntry)EntityCacheUtil.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18185 BlogsEntryImpl.class, primaryKey);
18186
18187 if (blogsEntry == _nullBlogsEntry) {
18188 return null;
18189 }
18190
18191 if (blogsEntry == null) {
18192 Session session = null;
18193
18194 try {
18195 session = openSession();
18196
18197 blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18198 primaryKey);
18199
18200 if (blogsEntry != null) {
18201 cacheResult(blogsEntry);
18202 }
18203 else {
18204 EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18205 BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18206 }
18207 }
18208 catch (Exception e) {
18209 EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18210 BlogsEntryImpl.class, primaryKey);
18211
18212 throw processException(e);
18213 }
18214 finally {
18215 closeSession(session);
18216 }
18217 }
18218
18219 return blogsEntry;
18220 }
18221
18222
18229 public BlogsEntry fetchByPrimaryKey(long entryId) throws SystemException {
18230 return fetchByPrimaryKey((Serializable)entryId);
18231 }
18232
18233
18239 public List<BlogsEntry> findAll() throws SystemException {
18240 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18241 }
18242
18243
18255 public List<BlogsEntry> findAll(int start, int end)
18256 throws SystemException {
18257 return findAll(start, end, null);
18258 }
18259
18260
18273 public List<BlogsEntry> findAll(int start, int end,
18274 OrderByComparator orderByComparator) throws SystemException {
18275 boolean pagination = true;
18276 FinderPath finderPath = null;
18277 Object[] finderArgs = null;
18278
18279 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18280 (orderByComparator == null)) {
18281 pagination = false;
18282 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
18283 finderArgs = FINDER_ARGS_EMPTY;
18284 }
18285 else {
18286 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
18287 finderArgs = new Object[] { start, end, orderByComparator };
18288 }
18289
18290 List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
18291 finderArgs, this);
18292
18293 if (list == null) {
18294 StringBundler query = null;
18295 String sql = null;
18296
18297 if (orderByComparator != null) {
18298 query = new StringBundler(2 +
18299 (orderByComparator.getOrderByFields().length * 3));
18300
18301 query.append(_SQL_SELECT_BLOGSENTRY);
18302
18303 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18304 orderByComparator);
18305
18306 sql = query.toString();
18307 }
18308 else {
18309 sql = _SQL_SELECT_BLOGSENTRY;
18310
18311 if (pagination) {
18312 sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
18313 }
18314 }
18315
18316 Session session = null;
18317
18318 try {
18319 session = openSession();
18320
18321 Query q = session.createQuery(sql);
18322
18323 if (!pagination) {
18324 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18325 start, end, false);
18326
18327 Collections.sort(list);
18328
18329 list = new UnmodifiableList<BlogsEntry>(list);
18330 }
18331 else {
18332 list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18333 start, end);
18334 }
18335
18336 cacheResult(list);
18337
18338 FinderCacheUtil.putResult(finderPath, finderArgs, list);
18339 }
18340 catch (Exception e) {
18341 FinderCacheUtil.removeResult(finderPath, finderArgs);
18342
18343 throw processException(e);
18344 }
18345 finally {
18346 closeSession(session);
18347 }
18348 }
18349
18350 return list;
18351 }
18352
18353
18358 public void removeAll() throws SystemException {
18359 for (BlogsEntry blogsEntry : findAll()) {
18360 remove(blogsEntry);
18361 }
18362 }
18363
18364
18370 public int countAll() throws SystemException {
18371 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
18372 FINDER_ARGS_EMPTY, this);
18373
18374 if (count == null) {
18375 Session session = null;
18376
18377 try {
18378 session = openSession();
18379
18380 Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
18381
18382 count = (Long)q.uniqueResult();
18383
18384 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
18385 FINDER_ARGS_EMPTY, count);
18386 }
18387 catch (Exception e) {
18388 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
18389 FINDER_ARGS_EMPTY);
18390
18391 throw processException(e);
18392 }
18393 finally {
18394 closeSession(session);
18395 }
18396 }
18397
18398 return count.intValue();
18399 }
18400
18401 @Override
18402 protected Set<String> getBadColumnNames() {
18403 return _badColumnNames;
18404 }
18405
18406
18409 public void afterPropertiesSet() {
18410 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
18411 com.liferay.portal.util.PropsUtil.get(
18412 "value.object.listener.com.liferay.portlet.blogs.model.BlogsEntry")));
18413
18414 if (listenerClassNames.length > 0) {
18415 try {
18416 List<ModelListener<BlogsEntry>> listenersList = new ArrayList<ModelListener<BlogsEntry>>();
18417
18418 for (String listenerClassName : listenerClassNames) {
18419 listenersList.add((ModelListener<BlogsEntry>)InstanceFactory.newInstance(
18420 getClassLoader(), listenerClassName));
18421 }
18422
18423 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
18424 }
18425 catch (Exception e) {
18426 _log.error(e);
18427 }
18428 }
18429 }
18430
18431 public void destroy() {
18432 EntityCacheUtil.removeCache(BlogsEntryImpl.class.getName());
18433 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
18434 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18435 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18436 }
18437
18438 private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
18439 private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
18440 private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
18441 private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
18442 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
18443 private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
18444 private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
18445 "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
18446 private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
18447 ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
18448 private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
18449 private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
18450 private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
18451 private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
18452 private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
18453 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
18454 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
18455 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
18456 private static Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
18457 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
18458 "uuid"
18459 });
18460 private static BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
18461 @Override
18462 public Object clone() {
18463 return this;
18464 }
18465
18466 @Override
18467 public CacheModel<BlogsEntry> toCacheModel() {
18468 return _nullBlogsEntryCacheModel;
18469 }
18470 };
18471
18472 private static CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
18473 public BlogsEntry toEntityModel() {
18474 return _nullBlogsEntry;
18475 }
18476 };
18477 }