001
014
015 package com.liferay.portlet.journal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.GetterUtil;
030 import com.liferay.portal.kernel.util.InstanceFactory;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.StringUtil;
035 import com.liferay.portal.kernel.util.UnmodifiableList;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
040
041 import com.liferay.portlet.journal.NoSuchContentSearchException;
042 import com.liferay.portlet.journal.model.JournalContentSearch;
043 import com.liferay.portlet.journal.model.impl.JournalContentSearchImpl;
044 import com.liferay.portlet.journal.model.impl.JournalContentSearchModelImpl;
045
046 import java.io.Serializable;
047
048 import java.util.ArrayList;
049 import java.util.Collections;
050 import java.util.List;
051
052
064 public class JournalContentSearchPersistenceImpl extends BasePersistenceImpl<JournalContentSearch>
065 implements JournalContentSearchPersistence {
066
071 public static final String FINDER_CLASS_NAME_ENTITY = JournalContentSearchImpl.class.getName();
072 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List1";
074 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List2";
076 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
077 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
078 JournalContentSearchImpl.class,
079 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
080 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
081 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
082 JournalContentSearchImpl.class,
083 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
084 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
085 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PORTLETID =
088 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
089 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
090 JournalContentSearchImpl.class,
091 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByPortletId",
092 new String[] {
093 String.class.getName(),
094
095 Integer.class.getName(), Integer.class.getName(),
096 OrderByComparator.class.getName()
097 });
098 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID =
099 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
100 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
101 JournalContentSearchImpl.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPortletId",
103 new String[] { String.class.getName() },
104 JournalContentSearchModelImpl.PORTLETID_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_PORTLETID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
106 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPortletId",
108 new String[] { String.class.getName() });
109
110
117 public List<JournalContentSearch> findByPortletId(String portletId)
118 throws SystemException {
119 return findByPortletId(portletId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
120 null);
121 }
122
123
136 public List<JournalContentSearch> findByPortletId(String portletId,
137 int start, int end) throws SystemException {
138 return findByPortletId(portletId, start, end, null);
139 }
140
141
155 public List<JournalContentSearch> findByPortletId(String portletId,
156 int start, int end, OrderByComparator orderByComparator)
157 throws SystemException {
158 boolean pagination = true;
159 FinderPath finderPath = null;
160 Object[] finderArgs = null;
161
162 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
163 (orderByComparator == null)) {
164 pagination = false;
165 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID;
166 finderArgs = new Object[] { portletId };
167 }
168 else {
169 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PORTLETID;
170 finderArgs = new Object[] { portletId, start, end, orderByComparator };
171 }
172
173 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
174 finderArgs, this);
175
176 if ((list != null) && !list.isEmpty()) {
177 for (JournalContentSearch journalContentSearch : list) {
178 if (!Validator.equals(portletId,
179 journalContentSearch.getPortletId())) {
180 list = null;
181
182 break;
183 }
184 }
185 }
186
187 if (list == null) {
188 StringBundler query = null;
189
190 if (orderByComparator != null) {
191 query = new StringBundler(3 +
192 (orderByComparator.getOrderByFields().length * 3));
193 }
194 else {
195 query = new StringBundler(3);
196 }
197
198 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
199
200 if (portletId == null) {
201 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
202 }
203 else {
204 if (portletId.equals(StringPool.BLANK)) {
205 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
206 }
207 else {
208 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
209 }
210 }
211
212 if (orderByComparator != null) {
213 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
214 orderByComparator);
215 }
216 else
217 if (pagination) {
218 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
219 }
220
221 String sql = query.toString();
222
223 Session session = null;
224
225 try {
226 session = openSession();
227
228 Query q = session.createQuery(sql);
229
230 QueryPos qPos = QueryPos.getInstance(q);
231
232 if (portletId != null) {
233 qPos.add(portletId);
234 }
235
236 if (!pagination) {
237 list = (List<JournalContentSearch>)QueryUtil.list(q,
238 getDialect(), start, end, false);
239
240 Collections.sort(list);
241
242 list = new UnmodifiableList<JournalContentSearch>(list);
243 }
244 else {
245 list = (List<JournalContentSearch>)QueryUtil.list(q,
246 getDialect(), start, end);
247 }
248
249 cacheResult(list);
250
251 FinderCacheUtil.putResult(finderPath, finderArgs, list);
252 }
253 catch (Exception e) {
254 FinderCacheUtil.removeResult(finderPath, finderArgs);
255
256 throw processException(e);
257 }
258 finally {
259 closeSession(session);
260 }
261 }
262
263 return list;
264 }
265
266
275 public JournalContentSearch findByPortletId_First(String portletId,
276 OrderByComparator orderByComparator)
277 throws NoSuchContentSearchException, SystemException {
278 JournalContentSearch journalContentSearch = fetchByPortletId_First(portletId,
279 orderByComparator);
280
281 if (journalContentSearch != null) {
282 return journalContentSearch;
283 }
284
285 StringBundler msg = new StringBundler(4);
286
287 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
288
289 msg.append("portletId=");
290 msg.append(portletId);
291
292 msg.append(StringPool.CLOSE_CURLY_BRACE);
293
294 throw new NoSuchContentSearchException(msg.toString());
295 }
296
297
305 public JournalContentSearch fetchByPortletId_First(String portletId,
306 OrderByComparator orderByComparator) throws SystemException {
307 List<JournalContentSearch> list = findByPortletId(portletId, 0, 1,
308 orderByComparator);
309
310 if (!list.isEmpty()) {
311 return list.get(0);
312 }
313
314 return null;
315 }
316
317
326 public JournalContentSearch findByPortletId_Last(String portletId,
327 OrderByComparator orderByComparator)
328 throws NoSuchContentSearchException, SystemException {
329 JournalContentSearch journalContentSearch = fetchByPortletId_Last(portletId,
330 orderByComparator);
331
332 if (journalContentSearch != null) {
333 return journalContentSearch;
334 }
335
336 StringBundler msg = new StringBundler(4);
337
338 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
339
340 msg.append("portletId=");
341 msg.append(portletId);
342
343 msg.append(StringPool.CLOSE_CURLY_BRACE);
344
345 throw new NoSuchContentSearchException(msg.toString());
346 }
347
348
356 public JournalContentSearch fetchByPortletId_Last(String portletId,
357 OrderByComparator orderByComparator) throws SystemException {
358 int count = countByPortletId(portletId);
359
360 List<JournalContentSearch> list = findByPortletId(portletId, count - 1,
361 count, orderByComparator);
362
363 if (!list.isEmpty()) {
364 return list.get(0);
365 }
366
367 return null;
368 }
369
370
380 public JournalContentSearch[] findByPortletId_PrevAndNext(
381 long contentSearchId, String portletId,
382 OrderByComparator orderByComparator)
383 throws NoSuchContentSearchException, SystemException {
384 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
385
386 Session session = null;
387
388 try {
389 session = openSession();
390
391 JournalContentSearch[] array = new JournalContentSearchImpl[3];
392
393 array[0] = getByPortletId_PrevAndNext(session,
394 journalContentSearch, portletId, orderByComparator, true);
395
396 array[1] = journalContentSearch;
397
398 array[2] = getByPortletId_PrevAndNext(session,
399 journalContentSearch, portletId, orderByComparator, false);
400
401 return array;
402 }
403 catch (Exception e) {
404 throw processException(e);
405 }
406 finally {
407 closeSession(session);
408 }
409 }
410
411 protected JournalContentSearch getByPortletId_PrevAndNext(Session session,
412 JournalContentSearch journalContentSearch, String portletId,
413 OrderByComparator orderByComparator, boolean previous) {
414 StringBundler query = null;
415
416 if (orderByComparator != null) {
417 query = new StringBundler(6 +
418 (orderByComparator.getOrderByFields().length * 6));
419 }
420 else {
421 query = new StringBundler(3);
422 }
423
424 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
425
426 if (portletId == null) {
427 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
428 }
429 else {
430 if (portletId.equals(StringPool.BLANK)) {
431 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
432 }
433 else {
434 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
435 }
436 }
437
438 if (orderByComparator != null) {
439 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
440
441 if (orderByConditionFields.length > 0) {
442 query.append(WHERE_AND);
443 }
444
445 for (int i = 0; i < orderByConditionFields.length; i++) {
446 query.append(_ORDER_BY_ENTITY_ALIAS);
447 query.append(orderByConditionFields[i]);
448
449 if ((i + 1) < orderByConditionFields.length) {
450 if (orderByComparator.isAscending() ^ previous) {
451 query.append(WHERE_GREATER_THAN_HAS_NEXT);
452 }
453 else {
454 query.append(WHERE_LESSER_THAN_HAS_NEXT);
455 }
456 }
457 else {
458 if (orderByComparator.isAscending() ^ previous) {
459 query.append(WHERE_GREATER_THAN);
460 }
461 else {
462 query.append(WHERE_LESSER_THAN);
463 }
464 }
465 }
466
467 query.append(ORDER_BY_CLAUSE);
468
469 String[] orderByFields = orderByComparator.getOrderByFields();
470
471 for (int i = 0; i < orderByFields.length; i++) {
472 query.append(_ORDER_BY_ENTITY_ALIAS);
473 query.append(orderByFields[i]);
474
475 if ((i + 1) < orderByFields.length) {
476 if (orderByComparator.isAscending() ^ previous) {
477 query.append(ORDER_BY_ASC_HAS_NEXT);
478 }
479 else {
480 query.append(ORDER_BY_DESC_HAS_NEXT);
481 }
482 }
483 else {
484 if (orderByComparator.isAscending() ^ previous) {
485 query.append(ORDER_BY_ASC);
486 }
487 else {
488 query.append(ORDER_BY_DESC);
489 }
490 }
491 }
492 }
493 else {
494 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
495 }
496
497 String sql = query.toString();
498
499 Query q = session.createQuery(sql);
500
501 q.setFirstResult(0);
502 q.setMaxResults(2);
503
504 QueryPos qPos = QueryPos.getInstance(q);
505
506 if (portletId != null) {
507 qPos.add(portletId);
508 }
509
510 if (orderByComparator != null) {
511 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
512
513 for (Object value : values) {
514 qPos.add(value);
515 }
516 }
517
518 List<JournalContentSearch> list = q.list();
519
520 if (list.size() == 2) {
521 return list.get(1);
522 }
523 else {
524 return null;
525 }
526 }
527
528
534 public void removeByPortletId(String portletId) throws SystemException {
535 for (JournalContentSearch journalContentSearch : findByPortletId(
536 portletId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
537 remove(journalContentSearch);
538 }
539 }
540
541
548 public int countByPortletId(String portletId) throws SystemException {
549 FinderPath finderPath = FINDER_PATH_COUNT_BY_PORTLETID;
550
551 Object[] finderArgs = new Object[] { portletId };
552
553 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
554 this);
555
556 if (count == null) {
557 StringBundler query = new StringBundler(2);
558
559 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
560
561 if (portletId == null) {
562 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
563 }
564 else {
565 if (portletId.equals(StringPool.BLANK)) {
566 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
567 }
568 else {
569 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
570 }
571 }
572
573 String sql = query.toString();
574
575 Session session = null;
576
577 try {
578 session = openSession();
579
580 Query q = session.createQuery(sql);
581
582 QueryPos qPos = QueryPos.getInstance(q);
583
584 if (portletId != null) {
585 qPos.add(portletId);
586 }
587
588 count = (Long)q.uniqueResult();
589
590 FinderCacheUtil.putResult(finderPath, finderArgs, count);
591 }
592 catch (Exception e) {
593 FinderCacheUtil.removeResult(finderPath, finderArgs);
594
595 throw processException(e);
596 }
597 finally {
598 closeSession(session);
599 }
600 }
601
602 return count.intValue();
603 }
604
605 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
606 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_2 = "journalContentSearch.portletId = ?";
607 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?)";
608 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ARTICLEID =
609 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
610 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
611 JournalContentSearchImpl.class,
612 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByArticleId",
613 new String[] {
614 String.class.getName(),
615
616 Integer.class.getName(), Integer.class.getName(),
617 OrderByComparator.class.getName()
618 });
619 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID =
620 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
621 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
622 JournalContentSearchImpl.class,
623 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByArticleId",
624 new String[] { String.class.getName() },
625 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
626 public static final FinderPath FINDER_PATH_COUNT_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
627 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
628 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByArticleId",
629 new String[] { String.class.getName() });
630
631
638 public List<JournalContentSearch> findByArticleId(String articleId)
639 throws SystemException {
640 return findByArticleId(articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
641 null);
642 }
643
644
657 public List<JournalContentSearch> findByArticleId(String articleId,
658 int start, int end) throws SystemException {
659 return findByArticleId(articleId, start, end, null);
660 }
661
662
676 public List<JournalContentSearch> findByArticleId(String articleId,
677 int start, int end, OrderByComparator orderByComparator)
678 throws SystemException {
679 boolean pagination = true;
680 FinderPath finderPath = null;
681 Object[] finderArgs = null;
682
683 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
684 (orderByComparator == null)) {
685 pagination = false;
686 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID;
687 finderArgs = new Object[] { articleId };
688 }
689 else {
690 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ARTICLEID;
691 finderArgs = new Object[] { articleId, start, end, orderByComparator };
692 }
693
694 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
695 finderArgs, this);
696
697 if ((list != null) && !list.isEmpty()) {
698 for (JournalContentSearch journalContentSearch : list) {
699 if (!Validator.equals(articleId,
700 journalContentSearch.getArticleId())) {
701 list = null;
702
703 break;
704 }
705 }
706 }
707
708 if (list == null) {
709 StringBundler query = null;
710
711 if (orderByComparator != null) {
712 query = new StringBundler(3 +
713 (orderByComparator.getOrderByFields().length * 3));
714 }
715 else {
716 query = new StringBundler(3);
717 }
718
719 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
720
721 if (articleId == null) {
722 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
723 }
724 else {
725 if (articleId.equals(StringPool.BLANK)) {
726 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
727 }
728 else {
729 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
730 }
731 }
732
733 if (orderByComparator != null) {
734 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
735 orderByComparator);
736 }
737 else
738 if (pagination) {
739 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
740 }
741
742 String sql = query.toString();
743
744 Session session = null;
745
746 try {
747 session = openSession();
748
749 Query q = session.createQuery(sql);
750
751 QueryPos qPos = QueryPos.getInstance(q);
752
753 if (articleId != null) {
754 qPos.add(articleId);
755 }
756
757 if (!pagination) {
758 list = (List<JournalContentSearch>)QueryUtil.list(q,
759 getDialect(), start, end, false);
760
761 Collections.sort(list);
762
763 list = new UnmodifiableList<JournalContentSearch>(list);
764 }
765 else {
766 list = (List<JournalContentSearch>)QueryUtil.list(q,
767 getDialect(), start, end);
768 }
769
770 cacheResult(list);
771
772 FinderCacheUtil.putResult(finderPath, finderArgs, list);
773 }
774 catch (Exception e) {
775 FinderCacheUtil.removeResult(finderPath, finderArgs);
776
777 throw processException(e);
778 }
779 finally {
780 closeSession(session);
781 }
782 }
783
784 return list;
785 }
786
787
796 public JournalContentSearch findByArticleId_First(String articleId,
797 OrderByComparator orderByComparator)
798 throws NoSuchContentSearchException, SystemException {
799 JournalContentSearch journalContentSearch = fetchByArticleId_First(articleId,
800 orderByComparator);
801
802 if (journalContentSearch != null) {
803 return journalContentSearch;
804 }
805
806 StringBundler msg = new StringBundler(4);
807
808 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
809
810 msg.append("articleId=");
811 msg.append(articleId);
812
813 msg.append(StringPool.CLOSE_CURLY_BRACE);
814
815 throw new NoSuchContentSearchException(msg.toString());
816 }
817
818
826 public JournalContentSearch fetchByArticleId_First(String articleId,
827 OrderByComparator orderByComparator) throws SystemException {
828 List<JournalContentSearch> list = findByArticleId(articleId, 0, 1,
829 orderByComparator);
830
831 if (!list.isEmpty()) {
832 return list.get(0);
833 }
834
835 return null;
836 }
837
838
847 public JournalContentSearch findByArticleId_Last(String articleId,
848 OrderByComparator orderByComparator)
849 throws NoSuchContentSearchException, SystemException {
850 JournalContentSearch journalContentSearch = fetchByArticleId_Last(articleId,
851 orderByComparator);
852
853 if (journalContentSearch != null) {
854 return journalContentSearch;
855 }
856
857 StringBundler msg = new StringBundler(4);
858
859 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
860
861 msg.append("articleId=");
862 msg.append(articleId);
863
864 msg.append(StringPool.CLOSE_CURLY_BRACE);
865
866 throw new NoSuchContentSearchException(msg.toString());
867 }
868
869
877 public JournalContentSearch fetchByArticleId_Last(String articleId,
878 OrderByComparator orderByComparator) throws SystemException {
879 int count = countByArticleId(articleId);
880
881 List<JournalContentSearch> list = findByArticleId(articleId, count - 1,
882 count, orderByComparator);
883
884 if (!list.isEmpty()) {
885 return list.get(0);
886 }
887
888 return null;
889 }
890
891
901 public JournalContentSearch[] findByArticleId_PrevAndNext(
902 long contentSearchId, String articleId,
903 OrderByComparator orderByComparator)
904 throws NoSuchContentSearchException, SystemException {
905 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
906
907 Session session = null;
908
909 try {
910 session = openSession();
911
912 JournalContentSearch[] array = new JournalContentSearchImpl[3];
913
914 array[0] = getByArticleId_PrevAndNext(session,
915 journalContentSearch, articleId, orderByComparator, true);
916
917 array[1] = journalContentSearch;
918
919 array[2] = getByArticleId_PrevAndNext(session,
920 journalContentSearch, articleId, orderByComparator, false);
921
922 return array;
923 }
924 catch (Exception e) {
925 throw processException(e);
926 }
927 finally {
928 closeSession(session);
929 }
930 }
931
932 protected JournalContentSearch getByArticleId_PrevAndNext(Session session,
933 JournalContentSearch journalContentSearch, String articleId,
934 OrderByComparator orderByComparator, boolean previous) {
935 StringBundler query = null;
936
937 if (orderByComparator != null) {
938 query = new StringBundler(6 +
939 (orderByComparator.getOrderByFields().length * 6));
940 }
941 else {
942 query = new StringBundler(3);
943 }
944
945 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
946
947 if (articleId == null) {
948 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
949 }
950 else {
951 if (articleId.equals(StringPool.BLANK)) {
952 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
953 }
954 else {
955 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
956 }
957 }
958
959 if (orderByComparator != null) {
960 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
961
962 if (orderByConditionFields.length > 0) {
963 query.append(WHERE_AND);
964 }
965
966 for (int i = 0; i < orderByConditionFields.length; i++) {
967 query.append(_ORDER_BY_ENTITY_ALIAS);
968 query.append(orderByConditionFields[i]);
969
970 if ((i + 1) < orderByConditionFields.length) {
971 if (orderByComparator.isAscending() ^ previous) {
972 query.append(WHERE_GREATER_THAN_HAS_NEXT);
973 }
974 else {
975 query.append(WHERE_LESSER_THAN_HAS_NEXT);
976 }
977 }
978 else {
979 if (orderByComparator.isAscending() ^ previous) {
980 query.append(WHERE_GREATER_THAN);
981 }
982 else {
983 query.append(WHERE_LESSER_THAN);
984 }
985 }
986 }
987
988 query.append(ORDER_BY_CLAUSE);
989
990 String[] orderByFields = orderByComparator.getOrderByFields();
991
992 for (int i = 0; i < orderByFields.length; i++) {
993 query.append(_ORDER_BY_ENTITY_ALIAS);
994 query.append(orderByFields[i]);
995
996 if ((i + 1) < orderByFields.length) {
997 if (orderByComparator.isAscending() ^ previous) {
998 query.append(ORDER_BY_ASC_HAS_NEXT);
999 }
1000 else {
1001 query.append(ORDER_BY_DESC_HAS_NEXT);
1002 }
1003 }
1004 else {
1005 if (orderByComparator.isAscending() ^ previous) {
1006 query.append(ORDER_BY_ASC);
1007 }
1008 else {
1009 query.append(ORDER_BY_DESC);
1010 }
1011 }
1012 }
1013 }
1014 else {
1015 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1016 }
1017
1018 String sql = query.toString();
1019
1020 Query q = session.createQuery(sql);
1021
1022 q.setFirstResult(0);
1023 q.setMaxResults(2);
1024
1025 QueryPos qPos = QueryPos.getInstance(q);
1026
1027 if (articleId != null) {
1028 qPos.add(articleId);
1029 }
1030
1031 if (orderByComparator != null) {
1032 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
1033
1034 for (Object value : values) {
1035 qPos.add(value);
1036 }
1037 }
1038
1039 List<JournalContentSearch> list = q.list();
1040
1041 if (list.size() == 2) {
1042 return list.get(1);
1043 }
1044 else {
1045 return null;
1046 }
1047 }
1048
1049
1055 public void removeByArticleId(String articleId) throws SystemException {
1056 for (JournalContentSearch journalContentSearch : findByArticleId(
1057 articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1058 remove(journalContentSearch);
1059 }
1060 }
1061
1062
1069 public int countByArticleId(String articleId) throws SystemException {
1070 FinderPath finderPath = FINDER_PATH_COUNT_BY_ARTICLEID;
1071
1072 Object[] finderArgs = new Object[] { articleId };
1073
1074 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1075 this);
1076
1077 if (count == null) {
1078 StringBundler query = new StringBundler(2);
1079
1080 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
1081
1082 if (articleId == null) {
1083 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
1084 }
1085 else {
1086 if (articleId.equals(StringPool.BLANK)) {
1087 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
1088 }
1089 else {
1090 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
1091 }
1092 }
1093
1094 String sql = query.toString();
1095
1096 Session session = null;
1097
1098 try {
1099 session = openSession();
1100
1101 Query q = session.createQuery(sql);
1102
1103 QueryPos qPos = QueryPos.getInstance(q);
1104
1105 if (articleId != null) {
1106 qPos.add(articleId);
1107 }
1108
1109 count = (Long)q.uniqueResult();
1110
1111 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1112 }
1113 catch (Exception e) {
1114 FinderCacheUtil.removeResult(finderPath, finderArgs);
1115
1116 throw processException(e);
1117 }
1118 finally {
1119 closeSession(session);
1120 }
1121 }
1122
1123 return count.intValue();
1124 }
1125
1126 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
1127 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_2 = "journalContentSearch.articleId = ?";
1128 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
1129 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1130 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1131 JournalContentSearchImpl.class,
1132 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
1133 new String[] {
1134 Long.class.getName(), Boolean.class.getName(),
1135
1136 Integer.class.getName(), Integer.class.getName(),
1137 OrderByComparator.class.getName()
1138 });
1139 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1140 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1141 JournalContentSearchImpl.class,
1142 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
1143 new String[] { Long.class.getName(), Boolean.class.getName() },
1144 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
1145 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK);
1146 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1147 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
1148 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
1149 new String[] { Long.class.getName(), Boolean.class.getName() });
1150
1151
1159 public List<JournalContentSearch> findByG_P(long groupId,
1160 boolean privateLayout) throws SystemException {
1161 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1162 QueryUtil.ALL_POS, null);
1163 }
1164
1165
1179 public List<JournalContentSearch> findByG_P(long groupId,
1180 boolean privateLayout, int start, int end) throws SystemException {
1181 return findByG_P(groupId, privateLayout, start, end, null);
1182 }
1183
1184
1199 public List<JournalContentSearch> findByG_P(long groupId,
1200 boolean privateLayout, int start, int end,
1201 OrderByComparator orderByComparator) throws SystemException {
1202 boolean pagination = true;
1203 FinderPath finderPath = null;
1204 Object[] finderArgs = null;
1205
1206 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1207 (orderByComparator == null)) {
1208 pagination = false;
1209 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1210 finderArgs = new Object[] { groupId, privateLayout };
1211 }
1212 else {
1213 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1214 finderArgs = new Object[] {
1215 groupId, privateLayout,
1216
1217 start, end, orderByComparator
1218 };
1219 }
1220
1221 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
1222 finderArgs, this);
1223
1224 if ((list != null) && !list.isEmpty()) {
1225 for (JournalContentSearch journalContentSearch : list) {
1226 if ((groupId != journalContentSearch.getGroupId()) ||
1227 (privateLayout != journalContentSearch.getPrivateLayout())) {
1228 list = null;
1229
1230 break;
1231 }
1232 }
1233 }
1234
1235 if (list == null) {
1236 StringBundler query = null;
1237
1238 if (orderByComparator != null) {
1239 query = new StringBundler(4 +
1240 (orderByComparator.getOrderByFields().length * 3));
1241 }
1242 else {
1243 query = new StringBundler(4);
1244 }
1245
1246 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1247
1248 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1249
1250 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1251
1252 if (orderByComparator != null) {
1253 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1254 orderByComparator);
1255 }
1256 else
1257 if (pagination) {
1258 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1259 }
1260
1261 String sql = query.toString();
1262
1263 Session session = null;
1264
1265 try {
1266 session = openSession();
1267
1268 Query q = session.createQuery(sql);
1269
1270 QueryPos qPos = QueryPos.getInstance(q);
1271
1272 qPos.add(groupId);
1273
1274 qPos.add(privateLayout);
1275
1276 if (!pagination) {
1277 list = (List<JournalContentSearch>)QueryUtil.list(q,
1278 getDialect(), start, end, false);
1279
1280 Collections.sort(list);
1281
1282 list = new UnmodifiableList<JournalContentSearch>(list);
1283 }
1284 else {
1285 list = (List<JournalContentSearch>)QueryUtil.list(q,
1286 getDialect(), start, end);
1287 }
1288
1289 cacheResult(list);
1290
1291 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1292 }
1293 catch (Exception e) {
1294 FinderCacheUtil.removeResult(finderPath, finderArgs);
1295
1296 throw processException(e);
1297 }
1298 finally {
1299 closeSession(session);
1300 }
1301 }
1302
1303 return list;
1304 }
1305
1306
1316 public JournalContentSearch findByG_P_First(long groupId,
1317 boolean privateLayout, OrderByComparator orderByComparator)
1318 throws NoSuchContentSearchException, SystemException {
1319 JournalContentSearch journalContentSearch = fetchByG_P_First(groupId,
1320 privateLayout, orderByComparator);
1321
1322 if (journalContentSearch != null) {
1323 return journalContentSearch;
1324 }
1325
1326 StringBundler msg = new StringBundler(6);
1327
1328 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1329
1330 msg.append("groupId=");
1331 msg.append(groupId);
1332
1333 msg.append(", privateLayout=");
1334 msg.append(privateLayout);
1335
1336 msg.append(StringPool.CLOSE_CURLY_BRACE);
1337
1338 throw new NoSuchContentSearchException(msg.toString());
1339 }
1340
1341
1350 public JournalContentSearch fetchByG_P_First(long groupId,
1351 boolean privateLayout, OrderByComparator orderByComparator)
1352 throws SystemException {
1353 List<JournalContentSearch> list = findByG_P(groupId, privateLayout, 0,
1354 1, orderByComparator);
1355
1356 if (!list.isEmpty()) {
1357 return list.get(0);
1358 }
1359
1360 return null;
1361 }
1362
1363
1373 public JournalContentSearch findByG_P_Last(long groupId,
1374 boolean privateLayout, OrderByComparator orderByComparator)
1375 throws NoSuchContentSearchException, SystemException {
1376 JournalContentSearch journalContentSearch = fetchByG_P_Last(groupId,
1377 privateLayout, orderByComparator);
1378
1379 if (journalContentSearch != null) {
1380 return journalContentSearch;
1381 }
1382
1383 StringBundler msg = new StringBundler(6);
1384
1385 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1386
1387 msg.append("groupId=");
1388 msg.append(groupId);
1389
1390 msg.append(", privateLayout=");
1391 msg.append(privateLayout);
1392
1393 msg.append(StringPool.CLOSE_CURLY_BRACE);
1394
1395 throw new NoSuchContentSearchException(msg.toString());
1396 }
1397
1398
1407 public JournalContentSearch fetchByG_P_Last(long groupId,
1408 boolean privateLayout, OrderByComparator orderByComparator)
1409 throws SystemException {
1410 int count = countByG_P(groupId, privateLayout);
1411
1412 List<JournalContentSearch> list = findByG_P(groupId, privateLayout,
1413 count - 1, count, orderByComparator);
1414
1415 if (!list.isEmpty()) {
1416 return list.get(0);
1417 }
1418
1419 return null;
1420 }
1421
1422
1433 public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
1434 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1435 throws NoSuchContentSearchException, SystemException {
1436 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1437
1438 Session session = null;
1439
1440 try {
1441 session = openSession();
1442
1443 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1444
1445 array[0] = getByG_P_PrevAndNext(session, journalContentSearch,
1446 groupId, privateLayout, orderByComparator, true);
1447
1448 array[1] = journalContentSearch;
1449
1450 array[2] = getByG_P_PrevAndNext(session, journalContentSearch,
1451 groupId, privateLayout, orderByComparator, false);
1452
1453 return array;
1454 }
1455 catch (Exception e) {
1456 throw processException(e);
1457 }
1458 finally {
1459 closeSession(session);
1460 }
1461 }
1462
1463 protected JournalContentSearch getByG_P_PrevAndNext(Session session,
1464 JournalContentSearch journalContentSearch, long groupId,
1465 boolean privateLayout, OrderByComparator orderByComparator,
1466 boolean previous) {
1467 StringBundler query = null;
1468
1469 if (orderByComparator != null) {
1470 query = new StringBundler(6 +
1471 (orderByComparator.getOrderByFields().length * 6));
1472 }
1473 else {
1474 query = new StringBundler(3);
1475 }
1476
1477 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1478
1479 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1480
1481 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1482
1483 if (orderByComparator != null) {
1484 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1485
1486 if (orderByConditionFields.length > 0) {
1487 query.append(WHERE_AND);
1488 }
1489
1490 for (int i = 0; i < orderByConditionFields.length; i++) {
1491 query.append(_ORDER_BY_ENTITY_ALIAS);
1492 query.append(orderByConditionFields[i]);
1493
1494 if ((i + 1) < orderByConditionFields.length) {
1495 if (orderByComparator.isAscending() ^ previous) {
1496 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1497 }
1498 else {
1499 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1500 }
1501 }
1502 else {
1503 if (orderByComparator.isAscending() ^ previous) {
1504 query.append(WHERE_GREATER_THAN);
1505 }
1506 else {
1507 query.append(WHERE_LESSER_THAN);
1508 }
1509 }
1510 }
1511
1512 query.append(ORDER_BY_CLAUSE);
1513
1514 String[] orderByFields = orderByComparator.getOrderByFields();
1515
1516 for (int i = 0; i < orderByFields.length; i++) {
1517 query.append(_ORDER_BY_ENTITY_ALIAS);
1518 query.append(orderByFields[i]);
1519
1520 if ((i + 1) < orderByFields.length) {
1521 if (orderByComparator.isAscending() ^ previous) {
1522 query.append(ORDER_BY_ASC_HAS_NEXT);
1523 }
1524 else {
1525 query.append(ORDER_BY_DESC_HAS_NEXT);
1526 }
1527 }
1528 else {
1529 if (orderByComparator.isAscending() ^ previous) {
1530 query.append(ORDER_BY_ASC);
1531 }
1532 else {
1533 query.append(ORDER_BY_DESC);
1534 }
1535 }
1536 }
1537 }
1538 else {
1539 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1540 }
1541
1542 String sql = query.toString();
1543
1544 Query q = session.createQuery(sql);
1545
1546 q.setFirstResult(0);
1547 q.setMaxResults(2);
1548
1549 QueryPos qPos = QueryPos.getInstance(q);
1550
1551 qPos.add(groupId);
1552
1553 qPos.add(privateLayout);
1554
1555 if (orderByComparator != null) {
1556 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
1557
1558 for (Object value : values) {
1559 qPos.add(value);
1560 }
1561 }
1562
1563 List<JournalContentSearch> list = q.list();
1564
1565 if (list.size() == 2) {
1566 return list.get(1);
1567 }
1568 else {
1569 return null;
1570 }
1571 }
1572
1573
1580 public void removeByG_P(long groupId, boolean privateLayout)
1581 throws SystemException {
1582 for (JournalContentSearch journalContentSearch : findByG_P(groupId,
1583 privateLayout, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1584 remove(journalContentSearch);
1585 }
1586 }
1587
1588
1596 public int countByG_P(long groupId, boolean privateLayout)
1597 throws SystemException {
1598 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P;
1599
1600 Object[] finderArgs = new Object[] { groupId, privateLayout };
1601
1602 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1603 this);
1604
1605 if (count == null) {
1606 StringBundler query = new StringBundler(3);
1607
1608 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
1609
1610 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1611
1612 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1613
1614 String sql = query.toString();
1615
1616 Session session = null;
1617
1618 try {
1619 session = openSession();
1620
1621 Query q = session.createQuery(sql);
1622
1623 QueryPos qPos = QueryPos.getInstance(q);
1624
1625 qPos.add(groupId);
1626
1627 qPos.add(privateLayout);
1628
1629 count = (Long)q.uniqueResult();
1630
1631 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1632 }
1633 catch (Exception e) {
1634 FinderCacheUtil.removeResult(finderPath, finderArgs);
1635
1636 throw processException(e);
1637 }
1638 finally {
1639 closeSession(session);
1640 }
1641 }
1642
1643 return count.intValue();
1644 }
1645
1646 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
1647 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ?";
1648 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1649 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1650 JournalContentSearchImpl.class,
1651 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_A",
1652 new String[] {
1653 Long.class.getName(), String.class.getName(),
1654
1655 Integer.class.getName(), Integer.class.getName(),
1656 OrderByComparator.class.getName()
1657 });
1658 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1659 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1660 JournalContentSearchImpl.class,
1661 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
1662 new String[] { Long.class.getName(), String.class.getName() },
1663 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
1664 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
1665 public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1666 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
1667 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
1668 new String[] { Long.class.getName(), String.class.getName() });
1669
1670
1678 public List<JournalContentSearch> findByG_A(long groupId, String articleId)
1679 throws SystemException {
1680 return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
1681 QueryUtil.ALL_POS, null);
1682 }
1683
1684
1698 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1699 int start, int end) throws SystemException {
1700 return findByG_A(groupId, articleId, start, end, null);
1701 }
1702
1703
1718 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1719 int start, int end, OrderByComparator orderByComparator)
1720 throws SystemException {
1721 boolean pagination = true;
1722 FinderPath finderPath = null;
1723 Object[] finderArgs = null;
1724
1725 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1726 (orderByComparator == null)) {
1727 pagination = false;
1728 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
1729 finderArgs = new Object[] { groupId, articleId };
1730 }
1731 else {
1732 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
1733 finderArgs = new Object[] {
1734 groupId, articleId,
1735
1736 start, end, orderByComparator
1737 };
1738 }
1739
1740 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
1741 finderArgs, this);
1742
1743 if ((list != null) && !list.isEmpty()) {
1744 for (JournalContentSearch journalContentSearch : list) {
1745 if ((groupId != journalContentSearch.getGroupId()) ||
1746 !Validator.equals(articleId,
1747 journalContentSearch.getArticleId())) {
1748 list = null;
1749
1750 break;
1751 }
1752 }
1753 }
1754
1755 if (list == null) {
1756 StringBundler query = null;
1757
1758 if (orderByComparator != null) {
1759 query = new StringBundler(4 +
1760 (orderByComparator.getOrderByFields().length * 3));
1761 }
1762 else {
1763 query = new StringBundler(4);
1764 }
1765
1766 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1767
1768 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1769
1770 if (articleId == null) {
1771 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1772 }
1773 else {
1774 if (articleId.equals(StringPool.BLANK)) {
1775 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1776 }
1777 else {
1778 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1779 }
1780 }
1781
1782 if (orderByComparator != null) {
1783 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1784 orderByComparator);
1785 }
1786 else
1787 if (pagination) {
1788 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1789 }
1790
1791 String sql = query.toString();
1792
1793 Session session = null;
1794
1795 try {
1796 session = openSession();
1797
1798 Query q = session.createQuery(sql);
1799
1800 QueryPos qPos = QueryPos.getInstance(q);
1801
1802 qPos.add(groupId);
1803
1804 if (articleId != null) {
1805 qPos.add(articleId);
1806 }
1807
1808 if (!pagination) {
1809 list = (List<JournalContentSearch>)QueryUtil.list(q,
1810 getDialect(), start, end, false);
1811
1812 Collections.sort(list);
1813
1814 list = new UnmodifiableList<JournalContentSearch>(list);
1815 }
1816 else {
1817 list = (List<JournalContentSearch>)QueryUtil.list(q,
1818 getDialect(), start, end);
1819 }
1820
1821 cacheResult(list);
1822
1823 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1824 }
1825 catch (Exception e) {
1826 FinderCacheUtil.removeResult(finderPath, finderArgs);
1827
1828 throw processException(e);
1829 }
1830 finally {
1831 closeSession(session);
1832 }
1833 }
1834
1835 return list;
1836 }
1837
1838
1848 public JournalContentSearch findByG_A_First(long groupId, String articleId,
1849 OrderByComparator orderByComparator)
1850 throws NoSuchContentSearchException, SystemException {
1851 JournalContentSearch journalContentSearch = fetchByG_A_First(groupId,
1852 articleId, orderByComparator);
1853
1854 if (journalContentSearch != null) {
1855 return journalContentSearch;
1856 }
1857
1858 StringBundler msg = new StringBundler(6);
1859
1860 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1861
1862 msg.append("groupId=");
1863 msg.append(groupId);
1864
1865 msg.append(", articleId=");
1866 msg.append(articleId);
1867
1868 msg.append(StringPool.CLOSE_CURLY_BRACE);
1869
1870 throw new NoSuchContentSearchException(msg.toString());
1871 }
1872
1873
1882 public JournalContentSearch fetchByG_A_First(long groupId,
1883 String articleId, OrderByComparator orderByComparator)
1884 throws SystemException {
1885 List<JournalContentSearch> list = findByG_A(groupId, articleId, 0, 1,
1886 orderByComparator);
1887
1888 if (!list.isEmpty()) {
1889 return list.get(0);
1890 }
1891
1892 return null;
1893 }
1894
1895
1905 public JournalContentSearch findByG_A_Last(long groupId, String articleId,
1906 OrderByComparator orderByComparator)
1907 throws NoSuchContentSearchException, SystemException {
1908 JournalContentSearch journalContentSearch = fetchByG_A_Last(groupId,
1909 articleId, orderByComparator);
1910
1911 if (journalContentSearch != null) {
1912 return journalContentSearch;
1913 }
1914
1915 StringBundler msg = new StringBundler(6);
1916
1917 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1918
1919 msg.append("groupId=");
1920 msg.append(groupId);
1921
1922 msg.append(", articleId=");
1923 msg.append(articleId);
1924
1925 msg.append(StringPool.CLOSE_CURLY_BRACE);
1926
1927 throw new NoSuchContentSearchException(msg.toString());
1928 }
1929
1930
1939 public JournalContentSearch fetchByG_A_Last(long groupId, String articleId,
1940 OrderByComparator orderByComparator) throws SystemException {
1941 int count = countByG_A(groupId, articleId);
1942
1943 List<JournalContentSearch> list = findByG_A(groupId, articleId,
1944 count - 1, count, orderByComparator);
1945
1946 if (!list.isEmpty()) {
1947 return list.get(0);
1948 }
1949
1950 return null;
1951 }
1952
1953
1964 public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
1965 long groupId, String articleId, OrderByComparator orderByComparator)
1966 throws NoSuchContentSearchException, SystemException {
1967 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1968
1969 Session session = null;
1970
1971 try {
1972 session = openSession();
1973
1974 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1975
1976 array[0] = getByG_A_PrevAndNext(session, journalContentSearch,
1977 groupId, articleId, orderByComparator, true);
1978
1979 array[1] = journalContentSearch;
1980
1981 array[2] = getByG_A_PrevAndNext(session, journalContentSearch,
1982 groupId, articleId, orderByComparator, false);
1983
1984 return array;
1985 }
1986 catch (Exception e) {
1987 throw processException(e);
1988 }
1989 finally {
1990 closeSession(session);
1991 }
1992 }
1993
1994 protected JournalContentSearch getByG_A_PrevAndNext(Session session,
1995 JournalContentSearch journalContentSearch, long groupId,
1996 String articleId, OrderByComparator orderByComparator, boolean previous) {
1997 StringBundler query = null;
1998
1999 if (orderByComparator != null) {
2000 query = new StringBundler(6 +
2001 (orderByComparator.getOrderByFields().length * 6));
2002 }
2003 else {
2004 query = new StringBundler(3);
2005 }
2006
2007 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2008
2009 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2010
2011 if (articleId == null) {
2012 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2013 }
2014 else {
2015 if (articleId.equals(StringPool.BLANK)) {
2016 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2017 }
2018 else {
2019 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2020 }
2021 }
2022
2023 if (orderByComparator != null) {
2024 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2025
2026 if (orderByConditionFields.length > 0) {
2027 query.append(WHERE_AND);
2028 }
2029
2030 for (int i = 0; i < orderByConditionFields.length; i++) {
2031 query.append(_ORDER_BY_ENTITY_ALIAS);
2032 query.append(orderByConditionFields[i]);
2033
2034 if ((i + 1) < orderByConditionFields.length) {
2035 if (orderByComparator.isAscending() ^ previous) {
2036 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2037 }
2038 else {
2039 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2040 }
2041 }
2042 else {
2043 if (orderByComparator.isAscending() ^ previous) {
2044 query.append(WHERE_GREATER_THAN);
2045 }
2046 else {
2047 query.append(WHERE_LESSER_THAN);
2048 }
2049 }
2050 }
2051
2052 query.append(ORDER_BY_CLAUSE);
2053
2054 String[] orderByFields = orderByComparator.getOrderByFields();
2055
2056 for (int i = 0; i < orderByFields.length; i++) {
2057 query.append(_ORDER_BY_ENTITY_ALIAS);
2058 query.append(orderByFields[i]);
2059
2060 if ((i + 1) < orderByFields.length) {
2061 if (orderByComparator.isAscending() ^ previous) {
2062 query.append(ORDER_BY_ASC_HAS_NEXT);
2063 }
2064 else {
2065 query.append(ORDER_BY_DESC_HAS_NEXT);
2066 }
2067 }
2068 else {
2069 if (orderByComparator.isAscending() ^ previous) {
2070 query.append(ORDER_BY_ASC);
2071 }
2072 else {
2073 query.append(ORDER_BY_DESC);
2074 }
2075 }
2076 }
2077 }
2078 else {
2079 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2080 }
2081
2082 String sql = query.toString();
2083
2084 Query q = session.createQuery(sql);
2085
2086 q.setFirstResult(0);
2087 q.setMaxResults(2);
2088
2089 QueryPos qPos = QueryPos.getInstance(q);
2090
2091 qPos.add(groupId);
2092
2093 if (articleId != null) {
2094 qPos.add(articleId);
2095 }
2096
2097 if (orderByComparator != null) {
2098 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2099
2100 for (Object value : values) {
2101 qPos.add(value);
2102 }
2103 }
2104
2105 List<JournalContentSearch> list = q.list();
2106
2107 if (list.size() == 2) {
2108 return list.get(1);
2109 }
2110 else {
2111 return null;
2112 }
2113 }
2114
2115
2122 public void removeByG_A(long groupId, String articleId)
2123 throws SystemException {
2124 for (JournalContentSearch journalContentSearch : findByG_A(groupId,
2125 articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2126 remove(journalContentSearch);
2127 }
2128 }
2129
2130
2138 public int countByG_A(long groupId, String articleId)
2139 throws SystemException {
2140 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
2141
2142 Object[] finderArgs = new Object[] { groupId, articleId };
2143
2144 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2145 this);
2146
2147 if (count == null) {
2148 StringBundler query = new StringBundler(3);
2149
2150 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2151
2152 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2153
2154 if (articleId == null) {
2155 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2156 }
2157 else {
2158 if (articleId.equals(StringPool.BLANK)) {
2159 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2160 }
2161 else {
2162 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2163 }
2164 }
2165
2166 String sql = query.toString();
2167
2168 Session session = null;
2169
2170 try {
2171 session = openSession();
2172
2173 Query q = session.createQuery(sql);
2174
2175 QueryPos qPos = QueryPos.getInstance(q);
2176
2177 qPos.add(groupId);
2178
2179 if (articleId != null) {
2180 qPos.add(articleId);
2181 }
2182
2183 count = (Long)q.uniqueResult();
2184
2185 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2186 }
2187 catch (Exception e) {
2188 FinderCacheUtil.removeResult(finderPath, finderArgs);
2189
2190 throw processException(e);
2191 }
2192 finally {
2193 closeSession(session);
2194 }
2195 }
2196
2197 return count.intValue();
2198 }
2199
2200 private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
2201 private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
2202 private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
2203 private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
2204 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2205 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2206 JournalContentSearchImpl.class,
2207 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_L",
2208 new String[] {
2209 Long.class.getName(), Boolean.class.getName(),
2210 Long.class.getName(),
2211
2212 Integer.class.getName(), Integer.class.getName(),
2213 OrderByComparator.class.getName()
2214 });
2215 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2216 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2217 JournalContentSearchImpl.class,
2218 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_L",
2219 new String[] {
2220 Long.class.getName(), Boolean.class.getName(),
2221 Long.class.getName()
2222 },
2223 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
2224 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
2225 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK);
2226 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2227 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
2228 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L",
2229 new String[] {
2230 Long.class.getName(), Boolean.class.getName(),
2231 Long.class.getName()
2232 });
2233
2234
2243 public List<JournalContentSearch> findByG_P_L(long groupId,
2244 boolean privateLayout, long layoutId) throws SystemException {
2245 return findByG_P_L(groupId, privateLayout, layoutId, QueryUtil.ALL_POS,
2246 QueryUtil.ALL_POS, null);
2247 }
2248
2249
2264 public List<JournalContentSearch> findByG_P_L(long groupId,
2265 boolean privateLayout, long layoutId, int start, int end)
2266 throws SystemException {
2267 return findByG_P_L(groupId, privateLayout, layoutId, start, end, null);
2268 }
2269
2270
2286 public List<JournalContentSearch> findByG_P_L(long groupId,
2287 boolean privateLayout, long layoutId, int start, int end,
2288 OrderByComparator orderByComparator) throws SystemException {
2289 boolean pagination = true;
2290 FinderPath finderPath = null;
2291 Object[] finderArgs = null;
2292
2293 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2294 (orderByComparator == null)) {
2295 pagination = false;
2296 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L;
2297 finderArgs = new Object[] { groupId, privateLayout, layoutId };
2298 }
2299 else {
2300 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L;
2301 finderArgs = new Object[] {
2302 groupId, privateLayout, layoutId,
2303
2304 start, end, orderByComparator
2305 };
2306 }
2307
2308 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
2309 finderArgs, this);
2310
2311 if ((list != null) && !list.isEmpty()) {
2312 for (JournalContentSearch journalContentSearch : list) {
2313 if ((groupId != journalContentSearch.getGroupId()) ||
2314 (privateLayout != journalContentSearch.getPrivateLayout()) ||
2315 (layoutId != journalContentSearch.getLayoutId())) {
2316 list = null;
2317
2318 break;
2319 }
2320 }
2321 }
2322
2323 if (list == null) {
2324 StringBundler query = null;
2325
2326 if (orderByComparator != null) {
2327 query = new StringBundler(5 +
2328 (orderByComparator.getOrderByFields().length * 3));
2329 }
2330 else {
2331 query = new StringBundler(5);
2332 }
2333
2334 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2335
2336 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2337
2338 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2339
2340 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2341
2342 if (orderByComparator != null) {
2343 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2344 orderByComparator);
2345 }
2346 else
2347 if (pagination) {
2348 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2349 }
2350
2351 String sql = query.toString();
2352
2353 Session session = null;
2354
2355 try {
2356 session = openSession();
2357
2358 Query q = session.createQuery(sql);
2359
2360 QueryPos qPos = QueryPos.getInstance(q);
2361
2362 qPos.add(groupId);
2363
2364 qPos.add(privateLayout);
2365
2366 qPos.add(layoutId);
2367
2368 if (!pagination) {
2369 list = (List<JournalContentSearch>)QueryUtil.list(q,
2370 getDialect(), start, end, false);
2371
2372 Collections.sort(list);
2373
2374 list = new UnmodifiableList<JournalContentSearch>(list);
2375 }
2376 else {
2377 list = (List<JournalContentSearch>)QueryUtil.list(q,
2378 getDialect(), start, end);
2379 }
2380
2381 cacheResult(list);
2382
2383 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2384 }
2385 catch (Exception e) {
2386 FinderCacheUtil.removeResult(finderPath, finderArgs);
2387
2388 throw processException(e);
2389 }
2390 finally {
2391 closeSession(session);
2392 }
2393 }
2394
2395 return list;
2396 }
2397
2398
2409 public JournalContentSearch findByG_P_L_First(long groupId,
2410 boolean privateLayout, long layoutId,
2411 OrderByComparator orderByComparator)
2412 throws NoSuchContentSearchException, SystemException {
2413 JournalContentSearch journalContentSearch = fetchByG_P_L_First(groupId,
2414 privateLayout, layoutId, orderByComparator);
2415
2416 if (journalContentSearch != null) {
2417 return journalContentSearch;
2418 }
2419
2420 StringBundler msg = new StringBundler(8);
2421
2422 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2423
2424 msg.append("groupId=");
2425 msg.append(groupId);
2426
2427 msg.append(", privateLayout=");
2428 msg.append(privateLayout);
2429
2430 msg.append(", layoutId=");
2431 msg.append(layoutId);
2432
2433 msg.append(StringPool.CLOSE_CURLY_BRACE);
2434
2435 throw new NoSuchContentSearchException(msg.toString());
2436 }
2437
2438
2448 public JournalContentSearch fetchByG_P_L_First(long groupId,
2449 boolean privateLayout, long layoutId,
2450 OrderByComparator orderByComparator) throws SystemException {
2451 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
2452 layoutId, 0, 1, orderByComparator);
2453
2454 if (!list.isEmpty()) {
2455 return list.get(0);
2456 }
2457
2458 return null;
2459 }
2460
2461
2472 public JournalContentSearch findByG_P_L_Last(long groupId,
2473 boolean privateLayout, long layoutId,
2474 OrderByComparator orderByComparator)
2475 throws NoSuchContentSearchException, SystemException {
2476 JournalContentSearch journalContentSearch = fetchByG_P_L_Last(groupId,
2477 privateLayout, layoutId, orderByComparator);
2478
2479 if (journalContentSearch != null) {
2480 return journalContentSearch;
2481 }
2482
2483 StringBundler msg = new StringBundler(8);
2484
2485 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2486
2487 msg.append("groupId=");
2488 msg.append(groupId);
2489
2490 msg.append(", privateLayout=");
2491 msg.append(privateLayout);
2492
2493 msg.append(", layoutId=");
2494 msg.append(layoutId);
2495
2496 msg.append(StringPool.CLOSE_CURLY_BRACE);
2497
2498 throw new NoSuchContentSearchException(msg.toString());
2499 }
2500
2501
2511 public JournalContentSearch fetchByG_P_L_Last(long groupId,
2512 boolean privateLayout, long layoutId,
2513 OrderByComparator orderByComparator) throws SystemException {
2514 int count = countByG_P_L(groupId, privateLayout, layoutId);
2515
2516 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
2517 layoutId, count - 1, count, orderByComparator);
2518
2519 if (!list.isEmpty()) {
2520 return list.get(0);
2521 }
2522
2523 return null;
2524 }
2525
2526
2538 public JournalContentSearch[] findByG_P_L_PrevAndNext(
2539 long contentSearchId, long groupId, boolean privateLayout,
2540 long layoutId, OrderByComparator orderByComparator)
2541 throws NoSuchContentSearchException, SystemException {
2542 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2543
2544 Session session = null;
2545
2546 try {
2547 session = openSession();
2548
2549 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2550
2551 array[0] = getByG_P_L_PrevAndNext(session, journalContentSearch,
2552 groupId, privateLayout, layoutId, orderByComparator, true);
2553
2554 array[1] = journalContentSearch;
2555
2556 array[2] = getByG_P_L_PrevAndNext(session, journalContentSearch,
2557 groupId, privateLayout, layoutId, orderByComparator, false);
2558
2559 return array;
2560 }
2561 catch (Exception e) {
2562 throw processException(e);
2563 }
2564 finally {
2565 closeSession(session);
2566 }
2567 }
2568
2569 protected JournalContentSearch getByG_P_L_PrevAndNext(Session session,
2570 JournalContentSearch journalContentSearch, long groupId,
2571 boolean privateLayout, long layoutId,
2572 OrderByComparator orderByComparator, boolean previous) {
2573 StringBundler query = null;
2574
2575 if (orderByComparator != null) {
2576 query = new StringBundler(6 +
2577 (orderByComparator.getOrderByFields().length * 6));
2578 }
2579 else {
2580 query = new StringBundler(3);
2581 }
2582
2583 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2584
2585 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2586
2587 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2588
2589 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2590
2591 if (orderByComparator != null) {
2592 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2593
2594 if (orderByConditionFields.length > 0) {
2595 query.append(WHERE_AND);
2596 }
2597
2598 for (int i = 0; i < orderByConditionFields.length; i++) {
2599 query.append(_ORDER_BY_ENTITY_ALIAS);
2600 query.append(orderByConditionFields[i]);
2601
2602 if ((i + 1) < orderByConditionFields.length) {
2603 if (orderByComparator.isAscending() ^ previous) {
2604 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2605 }
2606 else {
2607 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2608 }
2609 }
2610 else {
2611 if (orderByComparator.isAscending() ^ previous) {
2612 query.append(WHERE_GREATER_THAN);
2613 }
2614 else {
2615 query.append(WHERE_LESSER_THAN);
2616 }
2617 }
2618 }
2619
2620 query.append(ORDER_BY_CLAUSE);
2621
2622 String[] orderByFields = orderByComparator.getOrderByFields();
2623
2624 for (int i = 0; i < orderByFields.length; i++) {
2625 query.append(_ORDER_BY_ENTITY_ALIAS);
2626 query.append(orderByFields[i]);
2627
2628 if ((i + 1) < orderByFields.length) {
2629 if (orderByComparator.isAscending() ^ previous) {
2630 query.append(ORDER_BY_ASC_HAS_NEXT);
2631 }
2632 else {
2633 query.append(ORDER_BY_DESC_HAS_NEXT);
2634 }
2635 }
2636 else {
2637 if (orderByComparator.isAscending() ^ previous) {
2638 query.append(ORDER_BY_ASC);
2639 }
2640 else {
2641 query.append(ORDER_BY_DESC);
2642 }
2643 }
2644 }
2645 }
2646 else {
2647 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2648 }
2649
2650 String sql = query.toString();
2651
2652 Query q = session.createQuery(sql);
2653
2654 q.setFirstResult(0);
2655 q.setMaxResults(2);
2656
2657 QueryPos qPos = QueryPos.getInstance(q);
2658
2659 qPos.add(groupId);
2660
2661 qPos.add(privateLayout);
2662
2663 qPos.add(layoutId);
2664
2665 if (orderByComparator != null) {
2666 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2667
2668 for (Object value : values) {
2669 qPos.add(value);
2670 }
2671 }
2672
2673 List<JournalContentSearch> list = q.list();
2674
2675 if (list.size() == 2) {
2676 return list.get(1);
2677 }
2678 else {
2679 return null;
2680 }
2681 }
2682
2683
2691 public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId)
2692 throws SystemException {
2693 for (JournalContentSearch journalContentSearch : findByG_P_L(groupId,
2694 privateLayout, layoutId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2695 null)) {
2696 remove(journalContentSearch);
2697 }
2698 }
2699
2700
2709 public int countByG_P_L(long groupId, boolean privateLayout, long layoutId)
2710 throws SystemException {
2711 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_L;
2712
2713 Object[] finderArgs = new Object[] { groupId, privateLayout, layoutId };
2714
2715 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2716 this);
2717
2718 if (count == null) {
2719 StringBundler query = new StringBundler(4);
2720
2721 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2722
2723 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2724
2725 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2726
2727 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2728
2729 String sql = query.toString();
2730
2731 Session session = null;
2732
2733 try {
2734 session = openSession();
2735
2736 Query q = session.createQuery(sql);
2737
2738 QueryPos qPos = QueryPos.getInstance(q);
2739
2740 qPos.add(groupId);
2741
2742 qPos.add(privateLayout);
2743
2744 qPos.add(layoutId);
2745
2746 count = (Long)q.uniqueResult();
2747
2748 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2749 }
2750 catch (Exception e) {
2751 FinderCacheUtil.removeResult(finderPath, finderArgs);
2752
2753 throw processException(e);
2754 }
2755 finally {
2756 closeSession(session);
2757 }
2758 }
2759
2760 return count.intValue();
2761 }
2762
2763 private static final String _FINDER_COLUMN_G_P_L_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
2764 private static final String _FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
2765 private static final String _FINDER_COLUMN_G_P_L_LAYOUTID_2 = "journalContentSearch.layoutId = ?";
2766 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2767 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2768 JournalContentSearchImpl.class,
2769 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_A",
2770 new String[] {
2771 Long.class.getName(), Boolean.class.getName(),
2772 String.class.getName(),
2773
2774 Integer.class.getName(), Integer.class.getName(),
2775 OrderByComparator.class.getName()
2776 });
2777 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2778 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2779 JournalContentSearchImpl.class,
2780 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_A",
2781 new String[] {
2782 Long.class.getName(), Boolean.class.getName(),
2783 String.class.getName()
2784 },
2785 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
2786 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
2787 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
2788 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2789 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
2790 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_A",
2791 new String[] {
2792 Long.class.getName(), Boolean.class.getName(),
2793 String.class.getName()
2794 });
2795
2796
2805 public List<JournalContentSearch> findByG_P_A(long groupId,
2806 boolean privateLayout, String articleId) throws SystemException {
2807 return findByG_P_A(groupId, privateLayout, articleId,
2808 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2809 }
2810
2811
2826 public List<JournalContentSearch> findByG_P_A(long groupId,
2827 boolean privateLayout, String articleId, int start, int end)
2828 throws SystemException {
2829 return findByG_P_A(groupId, privateLayout, articleId, start, end, null);
2830 }
2831
2832
2848 public List<JournalContentSearch> findByG_P_A(long groupId,
2849 boolean privateLayout, String articleId, int start, int end,
2850 OrderByComparator orderByComparator) throws SystemException {
2851 boolean pagination = true;
2852 FinderPath finderPath = null;
2853 Object[] finderArgs = null;
2854
2855 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2856 (orderByComparator == null)) {
2857 pagination = false;
2858 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A;
2859 finderArgs = new Object[] { groupId, privateLayout, articleId };
2860 }
2861 else {
2862 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_A;
2863 finderArgs = new Object[] {
2864 groupId, privateLayout, articleId,
2865
2866 start, end, orderByComparator
2867 };
2868 }
2869
2870 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
2871 finderArgs, this);
2872
2873 if ((list != null) && !list.isEmpty()) {
2874 for (JournalContentSearch journalContentSearch : list) {
2875 if ((groupId != journalContentSearch.getGroupId()) ||
2876 (privateLayout != journalContentSearch.getPrivateLayout()) ||
2877 !Validator.equals(articleId,
2878 journalContentSearch.getArticleId())) {
2879 list = null;
2880
2881 break;
2882 }
2883 }
2884 }
2885
2886 if (list == null) {
2887 StringBundler query = null;
2888
2889 if (orderByComparator != null) {
2890 query = new StringBundler(5 +
2891 (orderByComparator.getOrderByFields().length * 3));
2892 }
2893 else {
2894 query = new StringBundler(5);
2895 }
2896
2897 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2898
2899 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2900
2901 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2902
2903 if (articleId == null) {
2904 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2905 }
2906 else {
2907 if (articleId.equals(StringPool.BLANK)) {
2908 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2909 }
2910 else {
2911 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2912 }
2913 }
2914
2915 if (orderByComparator != null) {
2916 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2917 orderByComparator);
2918 }
2919 else
2920 if (pagination) {
2921 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2922 }
2923
2924 String sql = query.toString();
2925
2926 Session session = null;
2927
2928 try {
2929 session = openSession();
2930
2931 Query q = session.createQuery(sql);
2932
2933 QueryPos qPos = QueryPos.getInstance(q);
2934
2935 qPos.add(groupId);
2936
2937 qPos.add(privateLayout);
2938
2939 if (articleId != null) {
2940 qPos.add(articleId);
2941 }
2942
2943 if (!pagination) {
2944 list = (List<JournalContentSearch>)QueryUtil.list(q,
2945 getDialect(), start, end, false);
2946
2947 Collections.sort(list);
2948
2949 list = new UnmodifiableList<JournalContentSearch>(list);
2950 }
2951 else {
2952 list = (List<JournalContentSearch>)QueryUtil.list(q,
2953 getDialect(), start, end);
2954 }
2955
2956 cacheResult(list);
2957
2958 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2959 }
2960 catch (Exception e) {
2961 FinderCacheUtil.removeResult(finderPath, finderArgs);
2962
2963 throw processException(e);
2964 }
2965 finally {
2966 closeSession(session);
2967 }
2968 }
2969
2970 return list;
2971 }
2972
2973
2984 public JournalContentSearch findByG_P_A_First(long groupId,
2985 boolean privateLayout, String articleId,
2986 OrderByComparator orderByComparator)
2987 throws NoSuchContentSearchException, SystemException {
2988 JournalContentSearch journalContentSearch = fetchByG_P_A_First(groupId,
2989 privateLayout, articleId, orderByComparator);
2990
2991 if (journalContentSearch != null) {
2992 return journalContentSearch;
2993 }
2994
2995 StringBundler msg = new StringBundler(8);
2996
2997 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2998
2999 msg.append("groupId=");
3000 msg.append(groupId);
3001
3002 msg.append(", privateLayout=");
3003 msg.append(privateLayout);
3004
3005 msg.append(", articleId=");
3006 msg.append(articleId);
3007
3008 msg.append(StringPool.CLOSE_CURLY_BRACE);
3009
3010 throw new NoSuchContentSearchException(msg.toString());
3011 }
3012
3013
3023 public JournalContentSearch fetchByG_P_A_First(long groupId,
3024 boolean privateLayout, String articleId,
3025 OrderByComparator orderByComparator) throws SystemException {
3026 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
3027 articleId, 0, 1, orderByComparator);
3028
3029 if (!list.isEmpty()) {
3030 return list.get(0);
3031 }
3032
3033 return null;
3034 }
3035
3036
3047 public JournalContentSearch findByG_P_A_Last(long groupId,
3048 boolean privateLayout, String articleId,
3049 OrderByComparator orderByComparator)
3050 throws NoSuchContentSearchException, SystemException {
3051 JournalContentSearch journalContentSearch = fetchByG_P_A_Last(groupId,
3052 privateLayout, articleId, orderByComparator);
3053
3054 if (journalContentSearch != null) {
3055 return journalContentSearch;
3056 }
3057
3058 StringBundler msg = new StringBundler(8);
3059
3060 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3061
3062 msg.append("groupId=");
3063 msg.append(groupId);
3064
3065 msg.append(", privateLayout=");
3066 msg.append(privateLayout);
3067
3068 msg.append(", articleId=");
3069 msg.append(articleId);
3070
3071 msg.append(StringPool.CLOSE_CURLY_BRACE);
3072
3073 throw new NoSuchContentSearchException(msg.toString());
3074 }
3075
3076
3086 public JournalContentSearch fetchByG_P_A_Last(long groupId,
3087 boolean privateLayout, String articleId,
3088 OrderByComparator orderByComparator) throws SystemException {
3089 int count = countByG_P_A(groupId, privateLayout, articleId);
3090
3091 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
3092 articleId, count - 1, count, orderByComparator);
3093
3094 if (!list.isEmpty()) {
3095 return list.get(0);
3096 }
3097
3098 return null;
3099 }
3100
3101
3113 public JournalContentSearch[] findByG_P_A_PrevAndNext(
3114 long contentSearchId, long groupId, boolean privateLayout,
3115 String articleId, OrderByComparator orderByComparator)
3116 throws NoSuchContentSearchException, SystemException {
3117 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
3118
3119 Session session = null;
3120
3121 try {
3122 session = openSession();
3123
3124 JournalContentSearch[] array = new JournalContentSearchImpl[3];
3125
3126 array[0] = getByG_P_A_PrevAndNext(session, journalContentSearch,
3127 groupId, privateLayout, articleId, orderByComparator, true);
3128
3129 array[1] = journalContentSearch;
3130
3131 array[2] = getByG_P_A_PrevAndNext(session, journalContentSearch,
3132 groupId, privateLayout, articleId, orderByComparator, false);
3133
3134 return array;
3135 }
3136 catch (Exception e) {
3137 throw processException(e);
3138 }
3139 finally {
3140 closeSession(session);
3141 }
3142 }
3143
3144 protected JournalContentSearch getByG_P_A_PrevAndNext(Session session,
3145 JournalContentSearch journalContentSearch, long groupId,
3146 boolean privateLayout, String articleId,
3147 OrderByComparator orderByComparator, boolean previous) {
3148 StringBundler query = null;
3149
3150 if (orderByComparator != null) {
3151 query = new StringBundler(6 +
3152 (orderByComparator.getOrderByFields().length * 6));
3153 }
3154 else {
3155 query = new StringBundler(3);
3156 }
3157
3158 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3159
3160 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
3161
3162 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
3163
3164 if (articleId == null) {
3165 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
3166 }
3167 else {
3168 if (articleId.equals(StringPool.BLANK)) {
3169 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
3170 }
3171 else {
3172 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
3173 }
3174 }
3175
3176 if (orderByComparator != null) {
3177 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3178
3179 if (orderByConditionFields.length > 0) {
3180 query.append(WHERE_AND);
3181 }
3182
3183 for (int i = 0; i < orderByConditionFields.length; i++) {
3184 query.append(_ORDER_BY_ENTITY_ALIAS);
3185 query.append(orderByConditionFields[i]);
3186
3187 if ((i + 1) < orderByConditionFields.length) {
3188 if (orderByComparator.isAscending() ^ previous) {
3189 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3190 }
3191 else {
3192 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3193 }
3194 }
3195 else {
3196 if (orderByComparator.isAscending() ^ previous) {
3197 query.append(WHERE_GREATER_THAN);
3198 }
3199 else {
3200 query.append(WHERE_LESSER_THAN);
3201 }
3202 }
3203 }
3204
3205 query.append(ORDER_BY_CLAUSE);
3206
3207 String[] orderByFields = orderByComparator.getOrderByFields();
3208
3209 for (int i = 0; i < orderByFields.length; i++) {
3210 query.append(_ORDER_BY_ENTITY_ALIAS);
3211 query.append(orderByFields[i]);
3212
3213 if ((i + 1) < orderByFields.length) {
3214 if (orderByComparator.isAscending() ^ previous) {
3215 query.append(ORDER_BY_ASC_HAS_NEXT);
3216 }
3217 else {
3218 query.append(ORDER_BY_DESC_HAS_NEXT);
3219 }
3220 }
3221 else {
3222 if (orderByComparator.isAscending() ^ previous) {
3223 query.append(ORDER_BY_ASC);
3224 }
3225 else {
3226 query.append(ORDER_BY_DESC);
3227 }
3228 }
3229 }
3230 }
3231 else {
3232 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
3233 }
3234
3235 String sql = query.toString();
3236
3237 Query q = session.createQuery(sql);
3238
3239 q.setFirstResult(0);
3240 q.setMaxResults(2);
3241
3242 QueryPos qPos = QueryPos.getInstance(q);
3243
3244 qPos.add(groupId);
3245
3246 qPos.add(privateLayout);
3247
3248 if (articleId != null) {
3249 qPos.add(articleId);
3250 }
3251
3252 if (orderByComparator != null) {
3253 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
3254
3255 for (Object value : values) {
3256 qPos.add(value);
3257 }
3258 }
3259
3260 List<JournalContentSearch> list = q.list();
3261
3262 if (list.size() == 2) {
3263 return list.get(1);
3264 }
3265 else {
3266 return null;
3267 }
3268 }
3269
3270
3278 public void removeByG_P_A(long groupId, boolean privateLayout,
3279 String articleId) throws SystemException {
3280 for (JournalContentSearch journalContentSearch : findByG_P_A(groupId,
3281 privateLayout, articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3282 null)) {
3283 remove(journalContentSearch);
3284 }
3285 }
3286
3287
3296 public int countByG_P_A(long groupId, boolean privateLayout,
3297 String articleId) throws SystemException {
3298 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_A;
3299
3300 Object[] finderArgs = new Object[] { groupId, privateLayout, articleId };
3301
3302 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3303 this);
3304
3305 if (count == null) {
3306 StringBundler query = new StringBundler(4);
3307
3308 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3309
3310 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
3311
3312 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
3313
3314 if (articleId == null) {
3315 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
3316 }
3317 else {
3318 if (articleId.equals(StringPool.BLANK)) {
3319 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
3320 }
3321 else {
3322 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
3323 }
3324 }
3325
3326 String sql = query.toString();
3327
3328 Session session = null;
3329
3330 try {
3331 session = openSession();
3332
3333 Query q = session.createQuery(sql);
3334
3335 QueryPos qPos = QueryPos.getInstance(q);
3336
3337 qPos.add(groupId);
3338
3339 qPos.add(privateLayout);
3340
3341 if (articleId != null) {
3342 qPos.add(articleId);
3343 }
3344
3345 count = (Long)q.uniqueResult();
3346
3347 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3348 }
3349 catch (Exception e) {
3350 FinderCacheUtil.removeResult(finderPath, finderArgs);
3351
3352 throw processException(e);
3353 }
3354 finally {
3355 closeSession(session);
3356 }
3357 }
3358
3359 return count.intValue();
3360 }
3361
3362 private static final String _FINDER_COLUMN_G_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3363 private static final String _FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3364 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3365 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3366 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3367 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
3368 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
3369 JournalContentSearchImpl.class,
3370 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_L_P",
3371 new String[] {
3372 Long.class.getName(), Boolean.class.getName(),
3373 Long.class.getName(), String.class.getName(),
3374
3375 Integer.class.getName(), Integer.class.getName(),
3376 OrderByComparator.class.getName()
3377 });
3378 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P =
3379 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
3380 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
3381 JournalContentSearchImpl.class,
3382 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_L_P",
3383 new String[] {
3384 Long.class.getName(), Boolean.class.getName(),
3385 Long.class.getName(), String.class.getName()
3386 },
3387 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
3388 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
3389 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK |
3390 JournalContentSearchModelImpl.PORTLETID_COLUMN_BITMASK);
3391 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
3392 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
3393 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L_P",
3394 new String[] {
3395 Long.class.getName(), Boolean.class.getName(),
3396 Long.class.getName(), String.class.getName()
3397 });
3398
3399
3409 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3410 boolean privateLayout, long layoutId, String portletId)
3411 throws SystemException {
3412 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
3413 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3414 }
3415
3416
3432 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3433 boolean privateLayout, long layoutId, String portletId, int start,
3434 int end) throws SystemException {
3435 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
3436 start, end, null);
3437 }
3438
3439
3456 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3457 boolean privateLayout, long layoutId, String portletId, int start,
3458 int end, OrderByComparator orderByComparator) throws SystemException {
3459 boolean pagination = true;
3460 FinderPath finderPath = null;
3461 Object[] finderArgs = null;
3462
3463 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3464 (orderByComparator == null)) {
3465 pagination = false;
3466 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P;
3467 finderArgs = new Object[] {
3468 groupId, privateLayout, layoutId, portletId
3469 };
3470 }
3471 else {
3472 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L_P;
3473 finderArgs = new Object[] {
3474 groupId, privateLayout, layoutId, portletId,
3475
3476 start, end, orderByComparator
3477 };
3478 }
3479
3480 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
3481 finderArgs, this);
3482
3483 if ((list != null) && !list.isEmpty()) {
3484 for (JournalContentSearch journalContentSearch : list) {
3485 if ((groupId != journalContentSearch.getGroupId()) ||
3486 (privateLayout != journalContentSearch.getPrivateLayout()) ||
3487 (layoutId != journalContentSearch.getLayoutId()) ||
3488 !Validator.equals(portletId,
3489 journalContentSearch.getPortletId())) {
3490 list = null;
3491
3492 break;
3493 }
3494 }
3495 }
3496
3497 if (list == null) {
3498 StringBundler query = null;
3499
3500 if (orderByComparator != null) {
3501 query = new StringBundler(6 +
3502 (orderByComparator.getOrderByFields().length * 3));
3503 }
3504 else {
3505 query = new StringBundler(6);
3506 }
3507
3508 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3509
3510 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3511
3512 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3513
3514 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3515
3516 if (portletId == null) {
3517 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3518 }
3519 else {
3520 if (portletId.equals(StringPool.BLANK)) {
3521 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3522 }
3523 else {
3524 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3525 }
3526 }
3527
3528 if (orderByComparator != null) {
3529 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3530 orderByComparator);
3531 }
3532 else
3533 if (pagination) {
3534 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
3535 }
3536
3537 String sql = query.toString();
3538
3539 Session session = null;
3540
3541 try {
3542 session = openSession();
3543
3544 Query q = session.createQuery(sql);
3545
3546 QueryPos qPos = QueryPos.getInstance(q);
3547
3548 qPos.add(groupId);
3549
3550 qPos.add(privateLayout);
3551
3552 qPos.add(layoutId);
3553
3554 if (portletId != null) {
3555 qPos.add(portletId);
3556 }
3557
3558 if (!pagination) {
3559 list = (List<JournalContentSearch>)QueryUtil.list(q,
3560 getDialect(), start, end, false);
3561
3562 Collections.sort(list);
3563
3564 list = new UnmodifiableList<JournalContentSearch>(list);
3565 }
3566 else {
3567 list = (List<JournalContentSearch>)QueryUtil.list(q,
3568 getDialect(), start, end);
3569 }
3570
3571 cacheResult(list);
3572
3573 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3574 }
3575 catch (Exception e) {
3576 FinderCacheUtil.removeResult(finderPath, finderArgs);
3577
3578 throw processException(e);
3579 }
3580 finally {
3581 closeSession(session);
3582 }
3583 }
3584
3585 return list;
3586 }
3587
3588
3600 public JournalContentSearch findByG_P_L_P_First(long groupId,
3601 boolean privateLayout, long layoutId, String portletId,
3602 OrderByComparator orderByComparator)
3603 throws NoSuchContentSearchException, SystemException {
3604 JournalContentSearch journalContentSearch = fetchByG_P_L_P_First(groupId,
3605 privateLayout, layoutId, portletId, orderByComparator);
3606
3607 if (journalContentSearch != null) {
3608 return journalContentSearch;
3609 }
3610
3611 StringBundler msg = new StringBundler(10);
3612
3613 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3614
3615 msg.append("groupId=");
3616 msg.append(groupId);
3617
3618 msg.append(", privateLayout=");
3619 msg.append(privateLayout);
3620
3621 msg.append(", layoutId=");
3622 msg.append(layoutId);
3623
3624 msg.append(", portletId=");
3625 msg.append(portletId);
3626
3627 msg.append(StringPool.CLOSE_CURLY_BRACE);
3628
3629 throw new NoSuchContentSearchException(msg.toString());
3630 }
3631
3632
3643 public JournalContentSearch fetchByG_P_L_P_First(long groupId,
3644 boolean privateLayout, long layoutId, String portletId,
3645 OrderByComparator orderByComparator) throws SystemException {
3646 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
3647 layoutId, portletId, 0, 1, orderByComparator);
3648
3649 if (!list.isEmpty()) {
3650 return list.get(0);
3651 }
3652
3653 return null;
3654 }
3655
3656
3668 public JournalContentSearch findByG_P_L_P_Last(long groupId,
3669 boolean privateLayout, long layoutId, String portletId,
3670 OrderByComparator orderByComparator)
3671 throws NoSuchContentSearchException, SystemException {
3672 JournalContentSearch journalContentSearch = fetchByG_P_L_P_Last(groupId,
3673 privateLayout, layoutId, portletId, orderByComparator);
3674
3675 if (journalContentSearch != null) {
3676 return journalContentSearch;
3677 }
3678
3679 StringBundler msg = new StringBundler(10);
3680
3681 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3682
3683 msg.append("groupId=");
3684 msg.append(groupId);
3685
3686 msg.append(", privateLayout=");
3687 msg.append(privateLayout);
3688
3689 msg.append(", layoutId=");
3690 msg.append(layoutId);
3691
3692 msg.append(", portletId=");
3693 msg.append(portletId);
3694
3695 msg.append(StringPool.CLOSE_CURLY_BRACE);
3696
3697 throw new NoSuchContentSearchException(msg.toString());
3698 }
3699
3700
3711 public JournalContentSearch fetchByG_P_L_P_Last(long groupId,
3712 boolean privateLayout, long layoutId, String portletId,
3713 OrderByComparator orderByComparator) throws SystemException {
3714 int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
3715
3716 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
3717 layoutId, portletId, count - 1, count, orderByComparator);
3718
3719 if (!list.isEmpty()) {
3720 return list.get(0);
3721 }
3722
3723 return null;
3724 }
3725
3726
3739 public JournalContentSearch[] findByG_P_L_P_PrevAndNext(
3740 long contentSearchId, long groupId, boolean privateLayout,
3741 long layoutId, String portletId, OrderByComparator orderByComparator)
3742 throws NoSuchContentSearchException, SystemException {
3743 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
3744
3745 Session session = null;
3746
3747 try {
3748 session = openSession();
3749
3750 JournalContentSearch[] array = new JournalContentSearchImpl[3];
3751
3752 array[0] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
3753 groupId, privateLayout, layoutId, portletId,
3754 orderByComparator, true);
3755
3756 array[1] = journalContentSearch;
3757
3758 array[2] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
3759 groupId, privateLayout, layoutId, portletId,
3760 orderByComparator, false);
3761
3762 return array;
3763 }
3764 catch (Exception e) {
3765 throw processException(e);
3766 }
3767 finally {
3768 closeSession(session);
3769 }
3770 }
3771
3772 protected JournalContentSearch getByG_P_L_P_PrevAndNext(Session session,
3773 JournalContentSearch journalContentSearch, long groupId,
3774 boolean privateLayout, long layoutId, String portletId,
3775 OrderByComparator orderByComparator, boolean previous) {
3776 StringBundler query = null;
3777
3778 if (orderByComparator != null) {
3779 query = new StringBundler(6 +
3780 (orderByComparator.getOrderByFields().length * 6));
3781 }
3782 else {
3783 query = new StringBundler(3);
3784 }
3785
3786 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3787
3788 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3789
3790 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3791
3792 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3793
3794 if (portletId == null) {
3795 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3796 }
3797 else {
3798 if (portletId.equals(StringPool.BLANK)) {
3799 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3800 }
3801 else {
3802 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3803 }
3804 }
3805
3806 if (orderByComparator != null) {
3807 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3808
3809 if (orderByConditionFields.length > 0) {
3810 query.append(WHERE_AND);
3811 }
3812
3813 for (int i = 0; i < orderByConditionFields.length; i++) {
3814 query.append(_ORDER_BY_ENTITY_ALIAS);
3815 query.append(orderByConditionFields[i]);
3816
3817 if ((i + 1) < orderByConditionFields.length) {
3818 if (orderByComparator.isAscending() ^ previous) {
3819 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3820 }
3821 else {
3822 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3823 }
3824 }
3825 else {
3826 if (orderByComparator.isAscending() ^ previous) {
3827 query.append(WHERE_GREATER_THAN);
3828 }
3829 else {
3830 query.append(WHERE_LESSER_THAN);
3831 }
3832 }
3833 }
3834
3835 query.append(ORDER_BY_CLAUSE);
3836
3837 String[] orderByFields = orderByComparator.getOrderByFields();
3838
3839 for (int i = 0; i < orderByFields.length; i++) {
3840 query.append(_ORDER_BY_ENTITY_ALIAS);
3841 query.append(orderByFields[i]);
3842
3843 if ((i + 1) < orderByFields.length) {
3844 if (orderByComparator.isAscending() ^ previous) {
3845 query.append(ORDER_BY_ASC_HAS_NEXT);
3846 }
3847 else {
3848 query.append(ORDER_BY_DESC_HAS_NEXT);
3849 }
3850 }
3851 else {
3852 if (orderByComparator.isAscending() ^ previous) {
3853 query.append(ORDER_BY_ASC);
3854 }
3855 else {
3856 query.append(ORDER_BY_DESC);
3857 }
3858 }
3859 }
3860 }
3861 else {
3862 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
3863 }
3864
3865 String sql = query.toString();
3866
3867 Query q = session.createQuery(sql);
3868
3869 q.setFirstResult(0);
3870 q.setMaxResults(2);
3871
3872 QueryPos qPos = QueryPos.getInstance(q);
3873
3874 qPos.add(groupId);
3875
3876 qPos.add(privateLayout);
3877
3878 qPos.add(layoutId);
3879
3880 if (portletId != null) {
3881 qPos.add(portletId);
3882 }
3883
3884 if (orderByComparator != null) {
3885 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
3886
3887 for (Object value : values) {
3888 qPos.add(value);
3889 }
3890 }
3891
3892 List<JournalContentSearch> list = q.list();
3893
3894 if (list.size() == 2) {
3895 return list.get(1);
3896 }
3897 else {
3898 return null;
3899 }
3900 }
3901
3902
3911 public void removeByG_P_L_P(long groupId, boolean privateLayout,
3912 long layoutId, String portletId) throws SystemException {
3913 for (JournalContentSearch journalContentSearch : findByG_P_L_P(
3914 groupId, privateLayout, layoutId, portletId, QueryUtil.ALL_POS,
3915 QueryUtil.ALL_POS, null)) {
3916 remove(journalContentSearch);
3917 }
3918 }
3919
3920
3930 public int countByG_P_L_P(long groupId, boolean privateLayout,
3931 long layoutId, String portletId) throws SystemException {
3932 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_L_P;
3933
3934 Object[] finderArgs = new Object[] {
3935 groupId, privateLayout, layoutId, portletId
3936 };
3937
3938 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3939 this);
3940
3941 if (count == null) {
3942 StringBundler query = new StringBundler(5);
3943
3944 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3945
3946 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3947
3948 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3949
3950 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3951
3952 if (portletId == null) {
3953 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3954 }
3955 else {
3956 if (portletId.equals(StringPool.BLANK)) {
3957 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3958 }
3959 else {
3960 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3961 }
3962 }
3963
3964 String sql = query.toString();
3965
3966 Session session = null;
3967
3968 try {
3969 session = openSession();
3970
3971 Query q = session.createQuery(sql);
3972
3973 QueryPos qPos = QueryPos.getInstance(q);
3974
3975 qPos.add(groupId);
3976
3977 qPos.add(privateLayout);
3978
3979 qPos.add(layoutId);
3980
3981 if (portletId != null) {
3982 qPos.add(portletId);
3983 }
3984
3985 count = (Long)q.uniqueResult();
3986
3987 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3988 }
3989 catch (Exception e) {
3990 FinderCacheUtil.removeResult(finderPath, finderArgs);
3991
3992 throw processException(e);
3993 }
3994 finally {
3995 closeSession(session);
3996 }
3997 }
3998
3999 return count.intValue();
4000 }
4001
4002 private static final String _FINDER_COLUMN_G_P_L_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4003 private static final String _FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4004 private static final String _FINDER_COLUMN_G_P_L_P_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
4005 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
4006 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_2 = "journalContentSearch.portletId = ?";
4007 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?)";
4008 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4009 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
4010 JournalContentSearchImpl.class, FINDER_CLASS_NAME_ENTITY,
4011 "fetchByG_P_L_P_A",
4012 new String[] {
4013 Long.class.getName(), Boolean.class.getName(),
4014 Long.class.getName(), String.class.getName(),
4015 String.class.getName()
4016 },
4017 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
4018 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
4019 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK |
4020 JournalContentSearchModelImpl.PORTLETID_COLUMN_BITMASK |
4021 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
4022 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4023 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
4024 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L_P_A",
4025 new String[] {
4026 Long.class.getName(), Boolean.class.getName(),
4027 Long.class.getName(), String.class.getName(),
4028 String.class.getName()
4029 });
4030
4031
4043 public JournalContentSearch findByG_P_L_P_A(long groupId,
4044 boolean privateLayout, long layoutId, String portletId, String articleId)
4045 throws NoSuchContentSearchException, SystemException {
4046 JournalContentSearch journalContentSearch = fetchByG_P_L_P_A(groupId,
4047 privateLayout, layoutId, portletId, articleId);
4048
4049 if (journalContentSearch == null) {
4050 StringBundler msg = new StringBundler(12);
4051
4052 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4053
4054 msg.append("groupId=");
4055 msg.append(groupId);
4056
4057 msg.append(", privateLayout=");
4058 msg.append(privateLayout);
4059
4060 msg.append(", layoutId=");
4061 msg.append(layoutId);
4062
4063 msg.append(", portletId=");
4064 msg.append(portletId);
4065
4066 msg.append(", articleId=");
4067 msg.append(articleId);
4068
4069 msg.append(StringPool.CLOSE_CURLY_BRACE);
4070
4071 if (_log.isWarnEnabled()) {
4072 _log.warn(msg.toString());
4073 }
4074
4075 throw new NoSuchContentSearchException(msg.toString());
4076 }
4077
4078 return journalContentSearch;
4079 }
4080
4081
4092 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
4093 boolean privateLayout, long layoutId, String portletId, String articleId)
4094 throws SystemException {
4095 return fetchByG_P_L_P_A(groupId, privateLayout, layoutId, portletId,
4096 articleId, true);
4097 }
4098
4099
4111 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
4112 boolean privateLayout, long layoutId, String portletId,
4113 String articleId, boolean retrieveFromCache) throws SystemException {
4114 Object[] finderArgs = new Object[] {
4115 groupId, privateLayout, layoutId, portletId, articleId
4116 };
4117
4118 Object result = null;
4119
4120 if (retrieveFromCache) {
4121 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4122 finderArgs, this);
4123 }
4124
4125 if (result instanceof JournalContentSearch) {
4126 JournalContentSearch journalContentSearch = (JournalContentSearch)result;
4127
4128 if ((groupId != journalContentSearch.getGroupId()) ||
4129 (privateLayout != journalContentSearch.getPrivateLayout()) ||
4130 (layoutId != journalContentSearch.getLayoutId()) ||
4131 !Validator.equals(portletId,
4132 journalContentSearch.getPortletId()) ||
4133 !Validator.equals(articleId,
4134 journalContentSearch.getArticleId())) {
4135 result = null;
4136 }
4137 }
4138
4139 if (result == null) {
4140 StringBundler query = new StringBundler(7);
4141
4142 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
4143
4144 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
4145
4146 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
4147
4148 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
4149
4150 if (portletId == null) {
4151 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
4152 }
4153 else {
4154 if (portletId.equals(StringPool.BLANK)) {
4155 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
4156 }
4157 else {
4158 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
4159 }
4160 }
4161
4162 if (articleId == null) {
4163 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
4164 }
4165 else {
4166 if (articleId.equals(StringPool.BLANK)) {
4167 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
4168 }
4169 else {
4170 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
4171 }
4172 }
4173
4174 String sql = query.toString();
4175
4176 Session session = null;
4177
4178 try {
4179 session = openSession();
4180
4181 Query q = session.createQuery(sql);
4182
4183 QueryPos qPos = QueryPos.getInstance(q);
4184
4185 qPos.add(groupId);
4186
4187 qPos.add(privateLayout);
4188
4189 qPos.add(layoutId);
4190
4191 if (portletId != null) {
4192 qPos.add(portletId);
4193 }
4194
4195 if (articleId != null) {
4196 qPos.add(articleId);
4197 }
4198
4199 List<JournalContentSearch> list = q.list();
4200
4201 if (list.isEmpty()) {
4202 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4203 finderArgs, list);
4204 }
4205 else {
4206 JournalContentSearch journalContentSearch = list.get(0);
4207
4208 result = journalContentSearch;
4209
4210 cacheResult(journalContentSearch);
4211
4212 if ((journalContentSearch.getGroupId() != groupId) ||
4213 (journalContentSearch.getPrivateLayout() != privateLayout) ||
4214 (journalContentSearch.getLayoutId() != layoutId) ||
4215 (journalContentSearch.getPortletId() == null) ||
4216 !journalContentSearch.getPortletId()
4217 .equals(portletId) ||
4218 (journalContentSearch.getArticleId() == null) ||
4219 !journalContentSearch.getArticleId()
4220 .equals(articleId)) {
4221 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4222 finderArgs, journalContentSearch);
4223 }
4224 }
4225 }
4226 catch (Exception e) {
4227 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4228 finderArgs);
4229
4230 throw processException(e);
4231 }
4232 finally {
4233 closeSession(session);
4234 }
4235 }
4236
4237 if (result instanceof List<?>) {
4238 return null;
4239 }
4240 else {
4241 return (JournalContentSearch)result;
4242 }
4243 }
4244
4245
4256 public JournalContentSearch removeByG_P_L_P_A(long groupId,
4257 boolean privateLayout, long layoutId, String portletId, String articleId)
4258 throws NoSuchContentSearchException, SystemException {
4259 JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
4260 privateLayout, layoutId, portletId, articleId);
4261
4262 return remove(journalContentSearch);
4263 }
4264
4265
4276 public int countByG_P_L_P_A(long groupId, boolean privateLayout,
4277 long layoutId, String portletId, String articleId)
4278 throws SystemException {
4279 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_L_P_A;
4280
4281 Object[] finderArgs = new Object[] {
4282 groupId, privateLayout, layoutId, portletId, articleId
4283 };
4284
4285 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4286 this);
4287
4288 if (count == null) {
4289 StringBundler query = new StringBundler(6);
4290
4291 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4292
4293 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
4294
4295 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
4296
4297 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
4298
4299 if (portletId == null) {
4300 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
4301 }
4302 else {
4303 if (portletId.equals(StringPool.BLANK)) {
4304 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
4305 }
4306 else {
4307 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
4308 }
4309 }
4310
4311 if (articleId == null) {
4312 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
4313 }
4314 else {
4315 if (articleId.equals(StringPool.BLANK)) {
4316 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
4317 }
4318 else {
4319 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
4320 }
4321 }
4322
4323 String sql = query.toString();
4324
4325 Session session = null;
4326
4327 try {
4328 session = openSession();
4329
4330 Query q = session.createQuery(sql);
4331
4332 QueryPos qPos = QueryPos.getInstance(q);
4333
4334 qPos.add(groupId);
4335
4336 qPos.add(privateLayout);
4337
4338 qPos.add(layoutId);
4339
4340 if (portletId != null) {
4341 qPos.add(portletId);
4342 }
4343
4344 if (articleId != null) {
4345 qPos.add(articleId);
4346 }
4347
4348 count = (Long)q.uniqueResult();
4349
4350 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4351 }
4352 catch (Exception e) {
4353 FinderCacheUtil.removeResult(finderPath, finderArgs);
4354
4355 throw processException(e);
4356 }
4357 finally {
4358 closeSession(session);
4359 }
4360 }
4361
4362 return count.intValue();
4363 }
4364
4365 private static final String _FINDER_COLUMN_G_P_L_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4366 private static final String _FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4367 private static final String _FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
4368 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_1 = "journalContentSearch.portletId IS NULL AND ";
4369 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_2 = "journalContentSearch.portletId = ? AND ";
4370 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?) AND ";
4371 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4372 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4373 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
4374
4375
4380 public void cacheResult(JournalContentSearch journalContentSearch) {
4381 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4382 JournalContentSearchImpl.class,
4383 journalContentSearch.getPrimaryKey(), journalContentSearch);
4384
4385 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4386 new Object[] {
4387 Long.valueOf(journalContentSearch.getGroupId()),
4388 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
4389 Long.valueOf(journalContentSearch.getLayoutId()),
4390
4391 journalContentSearch.getPortletId(),
4392
4393 journalContentSearch.getArticleId()
4394 }, journalContentSearch);
4395
4396 journalContentSearch.resetOriginalValues();
4397 }
4398
4399
4404 public void cacheResult(List<JournalContentSearch> journalContentSearchs) {
4405 for (JournalContentSearch journalContentSearch : journalContentSearchs) {
4406 if (EntityCacheUtil.getResult(
4407 JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4408 JournalContentSearchImpl.class,
4409 journalContentSearch.getPrimaryKey()) == null) {
4410 cacheResult(journalContentSearch);
4411 }
4412 else {
4413 journalContentSearch.resetOriginalValues();
4414 }
4415 }
4416 }
4417
4418
4425 @Override
4426 public void clearCache() {
4427 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
4428 CacheRegistryUtil.clear(JournalContentSearchImpl.class.getName());
4429 }
4430
4431 EntityCacheUtil.clearCache(JournalContentSearchImpl.class.getName());
4432
4433 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4434 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4435 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4436 }
4437
4438
4445 @Override
4446 public void clearCache(JournalContentSearch journalContentSearch) {
4447 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4448 JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
4449
4450 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4451 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4452
4453 clearUniqueFindersCache(journalContentSearch);
4454 }
4455
4456 @Override
4457 public void clearCache(List<JournalContentSearch> journalContentSearchs) {
4458 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4459 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4460
4461 for (JournalContentSearch journalContentSearch : journalContentSearchs) {
4462 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4463 JournalContentSearchImpl.class,
4464 journalContentSearch.getPrimaryKey());
4465
4466 clearUniqueFindersCache(journalContentSearch);
4467 }
4468 }
4469
4470 protected void cacheUniqueFindersCache(
4471 JournalContentSearch journalContentSearch) {
4472 if (journalContentSearch.isNew()) {
4473 Object[] args = new Object[] {
4474 Long.valueOf(journalContentSearch.getGroupId()),
4475 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
4476 Long.valueOf(journalContentSearch.getLayoutId()),
4477
4478 journalContentSearch.getPortletId(),
4479
4480 journalContentSearch.getArticleId()
4481 };
4482
4483 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args,
4484 Long.valueOf(1));
4485 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args,
4486 journalContentSearch);
4487 }
4488 else {
4489 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
4490
4491 if ((journalContentSearchModelImpl.getColumnBitmask() &
4492 FINDER_PATH_FETCH_BY_G_P_L_P_A.getColumnBitmask()) != 0) {
4493 Object[] args = new Object[] {
4494 Long.valueOf(journalContentSearch.getGroupId()),
4495 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
4496 Long.valueOf(journalContentSearch.getLayoutId()),
4497
4498 journalContentSearch.getPortletId(),
4499
4500 journalContentSearch.getArticleId()
4501 };
4502
4503 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args,
4504 Long.valueOf(1));
4505 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args,
4506 journalContentSearch);
4507 }
4508 }
4509 }
4510
4511 protected void clearUniqueFindersCache(
4512 JournalContentSearch journalContentSearch) {
4513 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
4514
4515 Object[] args = new Object[] {
4516 Long.valueOf(journalContentSearch.getGroupId()),
4517 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
4518 Long.valueOf(journalContentSearch.getLayoutId()),
4519
4520 journalContentSearch.getPortletId(),
4521
4522 journalContentSearch.getArticleId()
4523 };
4524
4525 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args);
4526 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args);
4527
4528 if ((journalContentSearchModelImpl.getColumnBitmask() &
4529 FINDER_PATH_FETCH_BY_G_P_L_P_A.getColumnBitmask()) != 0) {
4530 args = new Object[] {
4531 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
4532 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
4533 Long.valueOf(journalContentSearchModelImpl.getOriginalLayoutId()),
4534
4535 journalContentSearchModelImpl.getOriginalPortletId(),
4536
4537 journalContentSearchModelImpl.getOriginalArticleId()
4538 };
4539
4540 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args);
4541 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args);
4542 }
4543 }
4544
4545
4551 public JournalContentSearch create(long contentSearchId) {
4552 JournalContentSearch journalContentSearch = new JournalContentSearchImpl();
4553
4554 journalContentSearch.setNew(true);
4555 journalContentSearch.setPrimaryKey(contentSearchId);
4556
4557 return journalContentSearch;
4558 }
4559
4560
4568 public JournalContentSearch remove(long contentSearchId)
4569 throws NoSuchContentSearchException, SystemException {
4570 return remove(Long.valueOf(contentSearchId));
4571 }
4572
4573
4581 @Override
4582 public JournalContentSearch remove(Serializable primaryKey)
4583 throws NoSuchContentSearchException, SystemException {
4584 Session session = null;
4585
4586 try {
4587 session = openSession();
4588
4589 JournalContentSearch journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
4590 primaryKey);
4591
4592 if (journalContentSearch == null) {
4593 if (_log.isWarnEnabled()) {
4594 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4595 }
4596
4597 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4598 primaryKey);
4599 }
4600
4601 return remove(journalContentSearch);
4602 }
4603 catch (NoSuchContentSearchException nsee) {
4604 throw nsee;
4605 }
4606 catch (Exception e) {
4607 throw processException(e);
4608 }
4609 finally {
4610 closeSession(session);
4611 }
4612 }
4613
4614 @Override
4615 protected JournalContentSearch removeImpl(
4616 JournalContentSearch journalContentSearch) throws SystemException {
4617 journalContentSearch = toUnwrappedModel(journalContentSearch);
4618
4619 Session session = null;
4620
4621 try {
4622 session = openSession();
4623
4624 if (!session.contains(journalContentSearch)) {
4625 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
4626 journalContentSearch.getPrimaryKeyObj());
4627 }
4628
4629 if (journalContentSearch != null) {
4630 session.delete(journalContentSearch);
4631 }
4632 }
4633 catch (Exception e) {
4634 throw processException(e);
4635 }
4636 finally {
4637 closeSession(session);
4638 }
4639
4640 if (journalContentSearch != null) {
4641 clearCache(journalContentSearch);
4642 }
4643
4644 return journalContentSearch;
4645 }
4646
4647 @Override
4648 public JournalContentSearch updateImpl(
4649 com.liferay.portlet.journal.model.JournalContentSearch journalContentSearch)
4650 throws SystemException {
4651 journalContentSearch = toUnwrappedModel(journalContentSearch);
4652
4653 boolean isNew = journalContentSearch.isNew();
4654
4655 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
4656
4657 Session session = null;
4658
4659 try {
4660 session = openSession();
4661
4662 if (journalContentSearch.isNew()) {
4663 session.save(journalContentSearch);
4664
4665 journalContentSearch.setNew(false);
4666 }
4667 else {
4668 session.merge(journalContentSearch);
4669 }
4670 }
4671 catch (Exception e) {
4672 throw processException(e);
4673 }
4674 finally {
4675 closeSession(session);
4676 }
4677
4678 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4679
4680 if (isNew || !JournalContentSearchModelImpl.COLUMN_BITMASK_ENABLED) {
4681 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4682 }
4683
4684 else {
4685 if ((journalContentSearchModelImpl.getColumnBitmask() &
4686 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID.getColumnBitmask()) != 0) {
4687 Object[] args = new Object[] {
4688 journalContentSearchModelImpl.getOriginalPortletId()
4689 };
4690
4691 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTLETID,
4692 args);
4693 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID,
4694 args);
4695
4696 args = new Object[] { journalContentSearchModelImpl.getPortletId() };
4697
4698 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTLETID,
4699 args);
4700 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID,
4701 args);
4702 }
4703
4704 if ((journalContentSearchModelImpl.getColumnBitmask() &
4705 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID.getColumnBitmask()) != 0) {
4706 Object[] args = new Object[] {
4707 journalContentSearchModelImpl.getOriginalArticleId()
4708 };
4709
4710 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ARTICLEID,
4711 args);
4712 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID,
4713 args);
4714
4715 args = new Object[] { journalContentSearchModelImpl.getArticleId() };
4716
4717 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ARTICLEID,
4718 args);
4719 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID,
4720 args);
4721 }
4722
4723 if ((journalContentSearchModelImpl.getColumnBitmask() &
4724 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
4725 Object[] args = new Object[] {
4726 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
4727 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout())
4728 };
4729
4730 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
4731 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
4732 args);
4733
4734 args = new Object[] {
4735 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
4736 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout())
4737 };
4738
4739 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
4740 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
4741 args);
4742 }
4743
4744 if ((journalContentSearchModelImpl.getColumnBitmask() &
4745 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
4746 Object[] args = new Object[] {
4747 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
4748
4749 journalContentSearchModelImpl.getOriginalArticleId()
4750 };
4751
4752 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
4753 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
4754 args);
4755
4756 args = new Object[] {
4757 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
4758
4759 journalContentSearchModelImpl.getArticleId()
4760 };
4761
4762 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
4763 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
4764 args);
4765 }
4766
4767 if ((journalContentSearchModelImpl.getColumnBitmask() &
4768 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L.getColumnBitmask()) != 0) {
4769 Object[] args = new Object[] {
4770 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
4771 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
4772 Long.valueOf(journalContentSearchModelImpl.getOriginalLayoutId())
4773 };
4774
4775 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L, args);
4776 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L,
4777 args);
4778
4779 args = new Object[] {
4780 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
4781 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout()),
4782 Long.valueOf(journalContentSearchModelImpl.getLayoutId())
4783 };
4784
4785 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L, args);
4786 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L,
4787 args);
4788 }
4789
4790 if ((journalContentSearchModelImpl.getColumnBitmask() &
4791 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A.getColumnBitmask()) != 0) {
4792 Object[] args = new Object[] {
4793 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
4794 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
4795
4796 journalContentSearchModelImpl.getOriginalArticleId()
4797 };
4798
4799 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_A, args);
4800 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A,
4801 args);
4802
4803 args = new Object[] {
4804 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
4805 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout()),
4806
4807 journalContentSearchModelImpl.getArticleId()
4808 };
4809
4810 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_A, args);
4811 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A,
4812 args);
4813 }
4814
4815 if ((journalContentSearchModelImpl.getColumnBitmask() &
4816 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P.getColumnBitmask()) != 0) {
4817 Object[] args = new Object[] {
4818 Long.valueOf(journalContentSearchModelImpl.getOriginalGroupId()),
4819 Boolean.valueOf(journalContentSearchModelImpl.getOriginalPrivateLayout()),
4820 Long.valueOf(journalContentSearchModelImpl.getOriginalLayoutId()),
4821
4822 journalContentSearchModelImpl.getOriginalPortletId()
4823 };
4824
4825 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P, args);
4826 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P,
4827 args);
4828
4829 args = new Object[] {
4830 Long.valueOf(journalContentSearchModelImpl.getGroupId()),
4831 Boolean.valueOf(journalContentSearchModelImpl.getPrivateLayout()),
4832 Long.valueOf(journalContentSearchModelImpl.getLayoutId()),
4833
4834 journalContentSearchModelImpl.getPortletId()
4835 };
4836
4837 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P, args);
4838 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P,
4839 args);
4840 }
4841 }
4842
4843 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4844 JournalContentSearchImpl.class,
4845 journalContentSearch.getPrimaryKey(), journalContentSearch);
4846
4847 clearUniqueFindersCache(journalContentSearch);
4848 cacheUniqueFindersCache(journalContentSearch);
4849
4850 return journalContentSearch;
4851 }
4852
4853 protected JournalContentSearch toUnwrappedModel(
4854 JournalContentSearch journalContentSearch) {
4855 if (journalContentSearch instanceof JournalContentSearchImpl) {
4856 return journalContentSearch;
4857 }
4858
4859 JournalContentSearchImpl journalContentSearchImpl = new JournalContentSearchImpl();
4860
4861 journalContentSearchImpl.setNew(journalContentSearch.isNew());
4862 journalContentSearchImpl.setPrimaryKey(journalContentSearch.getPrimaryKey());
4863
4864 journalContentSearchImpl.setContentSearchId(journalContentSearch.getContentSearchId());
4865 journalContentSearchImpl.setGroupId(journalContentSearch.getGroupId());
4866 journalContentSearchImpl.setCompanyId(journalContentSearch.getCompanyId());
4867 journalContentSearchImpl.setPrivateLayout(journalContentSearch.isPrivateLayout());
4868 journalContentSearchImpl.setLayoutId(journalContentSearch.getLayoutId());
4869 journalContentSearchImpl.setPortletId(journalContentSearch.getPortletId());
4870 journalContentSearchImpl.setArticleId(journalContentSearch.getArticleId());
4871
4872 return journalContentSearchImpl;
4873 }
4874
4875
4883 @Override
4884 public JournalContentSearch findByPrimaryKey(Serializable primaryKey)
4885 throws NoSuchModelException, SystemException {
4886 return findByPrimaryKey(((Long)primaryKey).longValue());
4887 }
4888
4889
4897 public JournalContentSearch findByPrimaryKey(long contentSearchId)
4898 throws NoSuchContentSearchException, SystemException {
4899 JournalContentSearch journalContentSearch = fetchByPrimaryKey(contentSearchId);
4900
4901 if (journalContentSearch == null) {
4902 if (_log.isWarnEnabled()) {
4903 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contentSearchId);
4904 }
4905
4906 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4907 contentSearchId);
4908 }
4909
4910 return journalContentSearch;
4911 }
4912
4913
4920 @Override
4921 public JournalContentSearch fetchByPrimaryKey(Serializable primaryKey)
4922 throws SystemException {
4923 return fetchByPrimaryKey(((Long)primaryKey).longValue());
4924 }
4925
4926
4933 public JournalContentSearch fetchByPrimaryKey(long contentSearchId)
4934 throws SystemException {
4935 JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4936 JournalContentSearchImpl.class, contentSearchId);
4937
4938 if (journalContentSearch == _nullJournalContentSearch) {
4939 return null;
4940 }
4941
4942 if (journalContentSearch == null) {
4943 Session session = null;
4944
4945 try {
4946 session = openSession();
4947
4948 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
4949 Long.valueOf(contentSearchId));
4950
4951 if (journalContentSearch != null) {
4952 cacheResult(journalContentSearch);
4953 }
4954 else {
4955 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4956 JournalContentSearchImpl.class, contentSearchId,
4957 _nullJournalContentSearch);
4958 }
4959 }
4960 catch (Exception e) {
4961 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4962 JournalContentSearchImpl.class, contentSearchId);
4963
4964 throw processException(e);
4965 }
4966 finally {
4967 closeSession(session);
4968 }
4969 }
4970
4971 return journalContentSearch;
4972 }
4973
4974
4980 public List<JournalContentSearch> findAll() throws SystemException {
4981 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4982 }
4983
4984
4996 public List<JournalContentSearch> findAll(int start, int end)
4997 throws SystemException {
4998 return findAll(start, end, null);
4999 }
5000
5001
5014 public List<JournalContentSearch> findAll(int start, int end,
5015 OrderByComparator orderByComparator) throws SystemException {
5016 boolean pagination = true;
5017 FinderPath finderPath = null;
5018 Object[] finderArgs = null;
5019
5020 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5021 (orderByComparator == null)) {
5022 pagination = false;
5023 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5024 finderArgs = FINDER_ARGS_EMPTY;
5025 }
5026 else {
5027 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5028 finderArgs = new Object[] { start, end, orderByComparator };
5029 }
5030
5031 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
5032 finderArgs, this);
5033
5034 if (list == null) {
5035 StringBundler query = null;
5036 String sql = null;
5037
5038 if (orderByComparator != null) {
5039 query = new StringBundler(2 +
5040 (orderByComparator.getOrderByFields().length * 3));
5041
5042 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH);
5043
5044 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5045 orderByComparator);
5046
5047 sql = query.toString();
5048 }
5049 else {
5050 sql = _SQL_SELECT_JOURNALCONTENTSEARCH;
5051
5052 if (pagination) {
5053 sql = sql.concat(JournalContentSearchModelImpl.ORDER_BY_JPQL);
5054 }
5055 }
5056
5057 Session session = null;
5058
5059 try {
5060 session = openSession();
5061
5062 Query q = session.createQuery(sql);
5063
5064 if (!pagination) {
5065 list = (List<JournalContentSearch>)QueryUtil.list(q,
5066 getDialect(), start, end, false);
5067
5068 Collections.sort(list);
5069
5070 list = new UnmodifiableList<JournalContentSearch>(list);
5071 }
5072 else {
5073 list = (List<JournalContentSearch>)QueryUtil.list(q,
5074 getDialect(), start, end);
5075 }
5076
5077 cacheResult(list);
5078
5079 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5080 }
5081 catch (Exception e) {
5082 FinderCacheUtil.removeResult(finderPath, finderArgs);
5083
5084 throw processException(e);
5085 }
5086 finally {
5087 closeSession(session);
5088 }
5089 }
5090
5091 return list;
5092 }
5093
5094
5099 public void removeAll() throws SystemException {
5100 for (JournalContentSearch journalContentSearch : findAll()) {
5101 remove(journalContentSearch);
5102 }
5103 }
5104
5105
5111 public int countAll() throws SystemException {
5112 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5113 FINDER_ARGS_EMPTY, this);
5114
5115 if (count == null) {
5116 Session session = null;
5117
5118 try {
5119 session = openSession();
5120
5121 Query q = session.createQuery(_SQL_COUNT_JOURNALCONTENTSEARCH);
5122
5123 count = (Long)q.uniqueResult();
5124
5125 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5126 FINDER_ARGS_EMPTY, count);
5127 }
5128 catch (Exception e) {
5129 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5130 FINDER_ARGS_EMPTY);
5131
5132 throw processException(e);
5133 }
5134 finally {
5135 closeSession(session);
5136 }
5137 }
5138
5139 return count.intValue();
5140 }
5141
5142
5145 public void afterPropertiesSet() {
5146 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5147 com.liferay.portal.util.PropsUtil.get(
5148 "value.object.listener.com.liferay.portlet.journal.model.JournalContentSearch")));
5149
5150 if (listenerClassNames.length > 0) {
5151 try {
5152 List<ModelListener<JournalContentSearch>> listenersList = new ArrayList<ModelListener<JournalContentSearch>>();
5153
5154 for (String listenerClassName : listenerClassNames) {
5155 listenersList.add((ModelListener<JournalContentSearch>)InstanceFactory.newInstance(
5156 listenerClassName));
5157 }
5158
5159 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5160 }
5161 catch (Exception e) {
5162 _log.error(e);
5163 }
5164 }
5165 }
5166
5167 public void destroy() {
5168 EntityCacheUtil.removeCache(JournalContentSearchImpl.class.getName());
5169 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5170 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5171 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5172 }
5173
5174 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch";
5175 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE ";
5176 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch";
5177 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH_WHERE = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch WHERE ";
5178 private static final String _ORDER_BY_ENTITY_ALIAS = "journalContentSearch.";
5179 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalContentSearch exists with the primary key ";
5180 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalContentSearch exists with the key {";
5181 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5182 private static Log _log = LogFactoryUtil.getLog(JournalContentSearchPersistenceImpl.class);
5183 private static JournalContentSearch _nullJournalContentSearch = new JournalContentSearchImpl() {
5184 @Override
5185 public Object clone() {
5186 return this;
5187 }
5188
5189 @Override
5190 public CacheModel<JournalContentSearch> toCacheModel() {
5191 return _nullJournalContentSearchCacheModel;
5192 }
5193 };
5194
5195 private static CacheModel<JournalContentSearch> _nullJournalContentSearchCacheModel =
5196 new CacheModel<JournalContentSearch>() {
5197 public JournalContentSearch toEntityModel() {
5198 return _nullJournalContentSearch;
5199 }
5200 };
5201 }