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