001
014
015 package com.liferay.portlet.journal.service.persistence;
016
017 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderPath;
021 import com.liferay.portal.kernel.dao.orm.Query;
022 import com.liferay.portal.kernel.dao.orm.QueryPos;
023 import com.liferay.portal.kernel.dao.orm.QueryUtil;
024 import com.liferay.portal.kernel.dao.orm.Session;
025 import com.liferay.portal.kernel.exception.SystemException;
026 import com.liferay.portal.kernel.log.Log;
027 import com.liferay.portal.kernel.log.LogFactoryUtil;
028 import com.liferay.portal.kernel.util.GetterUtil;
029 import com.liferay.portal.kernel.util.InstanceFactory;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.StringBundler;
032 import com.liferay.portal.kernel.util.StringPool;
033 import com.liferay.portal.kernel.util.StringUtil;
034 import com.liferay.portal.kernel.util.UnmodifiableList;
035 import com.liferay.portal.kernel.util.Validator;
036 import com.liferay.portal.model.CacheModel;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
039
040 import com.liferay.portlet.journal.NoSuchContentSearchException;
041 import com.liferay.portlet.journal.model.JournalContentSearch;
042 import com.liferay.portlet.journal.model.impl.JournalContentSearchImpl;
043 import com.liferay.portlet.journal.model.impl.JournalContentSearchModelImpl;
044 import com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence;
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 @Override
118 public List<JournalContentSearch> findByPortletId(String portletId)
119 throws SystemException {
120 return findByPortletId(portletId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
121 null);
122 }
123
124
137 @Override
138 public List<JournalContentSearch> findByPortletId(String portletId,
139 int start, int end) throws SystemException {
140 return findByPortletId(portletId, start, end, null);
141 }
142
143
157 @Override
158 public List<JournalContentSearch> findByPortletId(String portletId,
159 int start, int end, OrderByComparator orderByComparator)
160 throws SystemException {
161 boolean pagination = true;
162 FinderPath finderPath = null;
163 Object[] finderArgs = null;
164
165 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
166 (orderByComparator == null)) {
167 pagination = false;
168 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID;
169 finderArgs = new Object[] { portletId };
170 }
171 else {
172 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PORTLETID;
173 finderArgs = new Object[] { portletId, start, end, orderByComparator };
174 }
175
176 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
177 finderArgs, this);
178
179 if ((list != null) && !list.isEmpty()) {
180 for (JournalContentSearch journalContentSearch : list) {
181 if (!Validator.equals(portletId,
182 journalContentSearch.getPortletId())) {
183 list = null;
184
185 break;
186 }
187 }
188 }
189
190 if (list == null) {
191 StringBundler query = null;
192
193 if (orderByComparator != null) {
194 query = new StringBundler(3 +
195 (orderByComparator.getOrderByFields().length * 3));
196 }
197 else {
198 query = new StringBundler(3);
199 }
200
201 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
202
203 boolean bindPortletId = false;
204
205 if (portletId == null) {
206 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
207 }
208 else if (portletId.equals(StringPool.BLANK)) {
209 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
210 }
211 else {
212 bindPortletId = true;
213
214 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
215 }
216
217 if (orderByComparator != null) {
218 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
219 orderByComparator);
220 }
221 else
222 if (pagination) {
223 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
224 }
225
226 String sql = query.toString();
227
228 Session session = null;
229
230 try {
231 session = openSession();
232
233 Query q = session.createQuery(sql);
234
235 QueryPos qPos = QueryPos.getInstance(q);
236
237 if (bindPortletId) {
238 qPos.add(portletId);
239 }
240
241 if (!pagination) {
242 list = (List<JournalContentSearch>)QueryUtil.list(q,
243 getDialect(), start, end, false);
244
245 Collections.sort(list);
246
247 list = new UnmodifiableList<JournalContentSearch>(list);
248 }
249 else {
250 list = (List<JournalContentSearch>)QueryUtil.list(q,
251 getDialect(), start, end);
252 }
253
254 cacheResult(list);
255
256 FinderCacheUtil.putResult(finderPath, finderArgs, list);
257 }
258 catch (Exception e) {
259 FinderCacheUtil.removeResult(finderPath, finderArgs);
260
261 throw processException(e);
262 }
263 finally {
264 closeSession(session);
265 }
266 }
267
268 return list;
269 }
270
271
280 @Override
281 public JournalContentSearch findByPortletId_First(String portletId,
282 OrderByComparator orderByComparator)
283 throws NoSuchContentSearchException, SystemException {
284 JournalContentSearch journalContentSearch = fetchByPortletId_First(portletId,
285 orderByComparator);
286
287 if (journalContentSearch != null) {
288 return journalContentSearch;
289 }
290
291 StringBundler msg = new StringBundler(4);
292
293 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
294
295 msg.append("portletId=");
296 msg.append(portletId);
297
298 msg.append(StringPool.CLOSE_CURLY_BRACE);
299
300 throw new NoSuchContentSearchException(msg.toString());
301 }
302
303
311 @Override
312 public JournalContentSearch fetchByPortletId_First(String portletId,
313 OrderByComparator orderByComparator) throws SystemException {
314 List<JournalContentSearch> list = findByPortletId(portletId, 0, 1,
315 orderByComparator);
316
317 if (!list.isEmpty()) {
318 return list.get(0);
319 }
320
321 return null;
322 }
323
324
333 @Override
334 public JournalContentSearch findByPortletId_Last(String portletId,
335 OrderByComparator orderByComparator)
336 throws NoSuchContentSearchException, SystemException {
337 JournalContentSearch journalContentSearch = fetchByPortletId_Last(portletId,
338 orderByComparator);
339
340 if (journalContentSearch != null) {
341 return journalContentSearch;
342 }
343
344 StringBundler msg = new StringBundler(4);
345
346 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
347
348 msg.append("portletId=");
349 msg.append(portletId);
350
351 msg.append(StringPool.CLOSE_CURLY_BRACE);
352
353 throw new NoSuchContentSearchException(msg.toString());
354 }
355
356
364 @Override
365 public JournalContentSearch fetchByPortletId_Last(String portletId,
366 OrderByComparator orderByComparator) throws SystemException {
367 int count = countByPortletId(portletId);
368
369 if (count == 0) {
370 return null;
371 }
372
373 List<JournalContentSearch> list = findByPortletId(portletId, count - 1,
374 count, orderByComparator);
375
376 if (!list.isEmpty()) {
377 return list.get(0);
378 }
379
380 return null;
381 }
382
383
393 @Override
394 public JournalContentSearch[] findByPortletId_PrevAndNext(
395 long contentSearchId, String portletId,
396 OrderByComparator orderByComparator)
397 throws NoSuchContentSearchException, SystemException {
398 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
399
400 Session session = null;
401
402 try {
403 session = openSession();
404
405 JournalContentSearch[] array = new JournalContentSearchImpl[3];
406
407 array[0] = getByPortletId_PrevAndNext(session,
408 journalContentSearch, portletId, orderByComparator, true);
409
410 array[1] = journalContentSearch;
411
412 array[2] = getByPortletId_PrevAndNext(session,
413 journalContentSearch, portletId, orderByComparator, false);
414
415 return array;
416 }
417 catch (Exception e) {
418 throw processException(e);
419 }
420 finally {
421 closeSession(session);
422 }
423 }
424
425 protected JournalContentSearch getByPortletId_PrevAndNext(Session session,
426 JournalContentSearch journalContentSearch, String portletId,
427 OrderByComparator orderByComparator, boolean previous) {
428 StringBundler query = null;
429
430 if (orderByComparator != null) {
431 query = new StringBundler(6 +
432 (orderByComparator.getOrderByFields().length * 6));
433 }
434 else {
435 query = new StringBundler(3);
436 }
437
438 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
439
440 boolean bindPortletId = false;
441
442 if (portletId == null) {
443 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
444 }
445 else if (portletId.equals(StringPool.BLANK)) {
446 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
447 }
448 else {
449 bindPortletId = true;
450
451 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
452 }
453
454 if (orderByComparator != null) {
455 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
456
457 if (orderByConditionFields.length > 0) {
458 query.append(WHERE_AND);
459 }
460
461 for (int i = 0; i < orderByConditionFields.length; i++) {
462 query.append(_ORDER_BY_ENTITY_ALIAS);
463 query.append(orderByConditionFields[i]);
464
465 if ((i + 1) < orderByConditionFields.length) {
466 if (orderByComparator.isAscending() ^ previous) {
467 query.append(WHERE_GREATER_THAN_HAS_NEXT);
468 }
469 else {
470 query.append(WHERE_LESSER_THAN_HAS_NEXT);
471 }
472 }
473 else {
474 if (orderByComparator.isAscending() ^ previous) {
475 query.append(WHERE_GREATER_THAN);
476 }
477 else {
478 query.append(WHERE_LESSER_THAN);
479 }
480 }
481 }
482
483 query.append(ORDER_BY_CLAUSE);
484
485 String[] orderByFields = orderByComparator.getOrderByFields();
486
487 for (int i = 0; i < orderByFields.length; i++) {
488 query.append(_ORDER_BY_ENTITY_ALIAS);
489 query.append(orderByFields[i]);
490
491 if ((i + 1) < orderByFields.length) {
492 if (orderByComparator.isAscending() ^ previous) {
493 query.append(ORDER_BY_ASC_HAS_NEXT);
494 }
495 else {
496 query.append(ORDER_BY_DESC_HAS_NEXT);
497 }
498 }
499 else {
500 if (orderByComparator.isAscending() ^ previous) {
501 query.append(ORDER_BY_ASC);
502 }
503 else {
504 query.append(ORDER_BY_DESC);
505 }
506 }
507 }
508 }
509 else {
510 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
511 }
512
513 String sql = query.toString();
514
515 Query q = session.createQuery(sql);
516
517 q.setFirstResult(0);
518 q.setMaxResults(2);
519
520 QueryPos qPos = QueryPos.getInstance(q);
521
522 if (bindPortletId) {
523 qPos.add(portletId);
524 }
525
526 if (orderByComparator != null) {
527 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
528
529 for (Object value : values) {
530 qPos.add(value);
531 }
532 }
533
534 List<JournalContentSearch> list = q.list();
535
536 if (list.size() == 2) {
537 return list.get(1);
538 }
539 else {
540 return null;
541 }
542 }
543
544
550 @Override
551 public void removeByPortletId(String portletId) throws SystemException {
552 for (JournalContentSearch journalContentSearch : findByPortletId(
553 portletId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
554 remove(journalContentSearch);
555 }
556 }
557
558
565 @Override
566 public int countByPortletId(String portletId) throws SystemException {
567 FinderPath finderPath = FINDER_PATH_COUNT_BY_PORTLETID;
568
569 Object[] finderArgs = new Object[] { portletId };
570
571 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
572 this);
573
574 if (count == null) {
575 StringBundler query = new StringBundler(2);
576
577 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
578
579 boolean bindPortletId = false;
580
581 if (portletId == null) {
582 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
583 }
584 else if (portletId.equals(StringPool.BLANK)) {
585 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
586 }
587 else {
588 bindPortletId = true;
589
590 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
591 }
592
593 String sql = query.toString();
594
595 Session session = null;
596
597 try {
598 session = openSession();
599
600 Query q = session.createQuery(sql);
601
602 QueryPos qPos = QueryPos.getInstance(q);
603
604 if (bindPortletId) {
605 qPos.add(portletId);
606 }
607
608 count = (Long)q.uniqueResult();
609
610 FinderCacheUtil.putResult(finderPath, finderArgs, count);
611 }
612 catch (Exception e) {
613 FinderCacheUtil.removeResult(finderPath, finderArgs);
614
615 throw processException(e);
616 }
617 finally {
618 closeSession(session);
619 }
620 }
621
622 return count.intValue();
623 }
624
625 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
626 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_2 = "journalContentSearch.portletId = ?";
627 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = '')";
628 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ARTICLEID =
629 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
630 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
631 JournalContentSearchImpl.class,
632 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByArticleId",
633 new String[] {
634 String.class.getName(),
635
636 Integer.class.getName(), Integer.class.getName(),
637 OrderByComparator.class.getName()
638 });
639 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID =
640 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
641 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
642 JournalContentSearchImpl.class,
643 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByArticleId",
644 new String[] { String.class.getName() },
645 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
646 public static final FinderPath FINDER_PATH_COUNT_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
647 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
648 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByArticleId",
649 new String[] { String.class.getName() });
650
651
658 @Override
659 public List<JournalContentSearch> findByArticleId(String articleId)
660 throws SystemException {
661 return findByArticleId(articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
662 null);
663 }
664
665
678 @Override
679 public List<JournalContentSearch> findByArticleId(String articleId,
680 int start, int end) throws SystemException {
681 return findByArticleId(articleId, start, end, null);
682 }
683
684
698 @Override
699 public List<JournalContentSearch> findByArticleId(String articleId,
700 int start, int end, OrderByComparator orderByComparator)
701 throws SystemException {
702 boolean pagination = true;
703 FinderPath finderPath = null;
704 Object[] finderArgs = null;
705
706 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
707 (orderByComparator == null)) {
708 pagination = false;
709 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID;
710 finderArgs = new Object[] { articleId };
711 }
712 else {
713 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ARTICLEID;
714 finderArgs = new Object[] { articleId, start, end, orderByComparator };
715 }
716
717 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
718 finderArgs, this);
719
720 if ((list != null) && !list.isEmpty()) {
721 for (JournalContentSearch journalContentSearch : list) {
722 if (!Validator.equals(articleId,
723 journalContentSearch.getArticleId())) {
724 list = null;
725
726 break;
727 }
728 }
729 }
730
731 if (list == null) {
732 StringBundler query = null;
733
734 if (orderByComparator != null) {
735 query = new StringBundler(3 +
736 (orderByComparator.getOrderByFields().length * 3));
737 }
738 else {
739 query = new StringBundler(3);
740 }
741
742 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
743
744 boolean bindArticleId = false;
745
746 if (articleId == null) {
747 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
748 }
749 else if (articleId.equals(StringPool.BLANK)) {
750 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
751 }
752 else {
753 bindArticleId = true;
754
755 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
756 }
757
758 if (orderByComparator != null) {
759 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
760 orderByComparator);
761 }
762 else
763 if (pagination) {
764 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
765 }
766
767 String sql = query.toString();
768
769 Session session = null;
770
771 try {
772 session = openSession();
773
774 Query q = session.createQuery(sql);
775
776 QueryPos qPos = QueryPos.getInstance(q);
777
778 if (bindArticleId) {
779 qPos.add(articleId);
780 }
781
782 if (!pagination) {
783 list = (List<JournalContentSearch>)QueryUtil.list(q,
784 getDialect(), start, end, false);
785
786 Collections.sort(list);
787
788 list = new UnmodifiableList<JournalContentSearch>(list);
789 }
790 else {
791 list = (List<JournalContentSearch>)QueryUtil.list(q,
792 getDialect(), start, end);
793 }
794
795 cacheResult(list);
796
797 FinderCacheUtil.putResult(finderPath, finderArgs, list);
798 }
799 catch (Exception e) {
800 FinderCacheUtil.removeResult(finderPath, finderArgs);
801
802 throw processException(e);
803 }
804 finally {
805 closeSession(session);
806 }
807 }
808
809 return list;
810 }
811
812
821 @Override
822 public JournalContentSearch findByArticleId_First(String articleId,
823 OrderByComparator orderByComparator)
824 throws NoSuchContentSearchException, SystemException {
825 JournalContentSearch journalContentSearch = fetchByArticleId_First(articleId,
826 orderByComparator);
827
828 if (journalContentSearch != null) {
829 return journalContentSearch;
830 }
831
832 StringBundler msg = new StringBundler(4);
833
834 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
835
836 msg.append("articleId=");
837 msg.append(articleId);
838
839 msg.append(StringPool.CLOSE_CURLY_BRACE);
840
841 throw new NoSuchContentSearchException(msg.toString());
842 }
843
844
852 @Override
853 public JournalContentSearch fetchByArticleId_First(String articleId,
854 OrderByComparator orderByComparator) throws SystemException {
855 List<JournalContentSearch> list = findByArticleId(articleId, 0, 1,
856 orderByComparator);
857
858 if (!list.isEmpty()) {
859 return list.get(0);
860 }
861
862 return null;
863 }
864
865
874 @Override
875 public JournalContentSearch findByArticleId_Last(String articleId,
876 OrderByComparator orderByComparator)
877 throws NoSuchContentSearchException, SystemException {
878 JournalContentSearch journalContentSearch = fetchByArticleId_Last(articleId,
879 orderByComparator);
880
881 if (journalContentSearch != null) {
882 return journalContentSearch;
883 }
884
885 StringBundler msg = new StringBundler(4);
886
887 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
888
889 msg.append("articleId=");
890 msg.append(articleId);
891
892 msg.append(StringPool.CLOSE_CURLY_BRACE);
893
894 throw new NoSuchContentSearchException(msg.toString());
895 }
896
897
905 @Override
906 public JournalContentSearch fetchByArticleId_Last(String articleId,
907 OrderByComparator orderByComparator) throws SystemException {
908 int count = countByArticleId(articleId);
909
910 if (count == 0) {
911 return null;
912 }
913
914 List<JournalContentSearch> list = findByArticleId(articleId, count - 1,
915 count, orderByComparator);
916
917 if (!list.isEmpty()) {
918 return list.get(0);
919 }
920
921 return null;
922 }
923
924
934 @Override
935 public JournalContentSearch[] findByArticleId_PrevAndNext(
936 long contentSearchId, String articleId,
937 OrderByComparator orderByComparator)
938 throws NoSuchContentSearchException, SystemException {
939 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
940
941 Session session = null;
942
943 try {
944 session = openSession();
945
946 JournalContentSearch[] array = new JournalContentSearchImpl[3];
947
948 array[0] = getByArticleId_PrevAndNext(session,
949 journalContentSearch, articleId, orderByComparator, true);
950
951 array[1] = journalContentSearch;
952
953 array[2] = getByArticleId_PrevAndNext(session,
954 journalContentSearch, articleId, orderByComparator, false);
955
956 return array;
957 }
958 catch (Exception e) {
959 throw processException(e);
960 }
961 finally {
962 closeSession(session);
963 }
964 }
965
966 protected JournalContentSearch getByArticleId_PrevAndNext(Session session,
967 JournalContentSearch journalContentSearch, String articleId,
968 OrderByComparator orderByComparator, boolean previous) {
969 StringBundler query = null;
970
971 if (orderByComparator != null) {
972 query = new StringBundler(6 +
973 (orderByComparator.getOrderByFields().length * 6));
974 }
975 else {
976 query = new StringBundler(3);
977 }
978
979 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
980
981 boolean bindArticleId = false;
982
983 if (articleId == null) {
984 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
985 }
986 else if (articleId.equals(StringPool.BLANK)) {
987 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
988 }
989 else {
990 bindArticleId = true;
991
992 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
993 }
994
995 if (orderByComparator != null) {
996 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
997
998 if (orderByConditionFields.length > 0) {
999 query.append(WHERE_AND);
1000 }
1001
1002 for (int i = 0; i < orderByConditionFields.length; i++) {
1003 query.append(_ORDER_BY_ENTITY_ALIAS);
1004 query.append(orderByConditionFields[i]);
1005
1006 if ((i + 1) < orderByConditionFields.length) {
1007 if (orderByComparator.isAscending() ^ previous) {
1008 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1009 }
1010 else {
1011 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1012 }
1013 }
1014 else {
1015 if (orderByComparator.isAscending() ^ previous) {
1016 query.append(WHERE_GREATER_THAN);
1017 }
1018 else {
1019 query.append(WHERE_LESSER_THAN);
1020 }
1021 }
1022 }
1023
1024 query.append(ORDER_BY_CLAUSE);
1025
1026 String[] orderByFields = orderByComparator.getOrderByFields();
1027
1028 for (int i = 0; i < orderByFields.length; i++) {
1029 query.append(_ORDER_BY_ENTITY_ALIAS);
1030 query.append(orderByFields[i]);
1031
1032 if ((i + 1) < orderByFields.length) {
1033 if (orderByComparator.isAscending() ^ previous) {
1034 query.append(ORDER_BY_ASC_HAS_NEXT);
1035 }
1036 else {
1037 query.append(ORDER_BY_DESC_HAS_NEXT);
1038 }
1039 }
1040 else {
1041 if (orderByComparator.isAscending() ^ previous) {
1042 query.append(ORDER_BY_ASC);
1043 }
1044 else {
1045 query.append(ORDER_BY_DESC);
1046 }
1047 }
1048 }
1049 }
1050 else {
1051 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1052 }
1053
1054 String sql = query.toString();
1055
1056 Query q = session.createQuery(sql);
1057
1058 q.setFirstResult(0);
1059 q.setMaxResults(2);
1060
1061 QueryPos qPos = QueryPos.getInstance(q);
1062
1063 if (bindArticleId) {
1064 qPos.add(articleId);
1065 }
1066
1067 if (orderByComparator != null) {
1068 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
1069
1070 for (Object value : values) {
1071 qPos.add(value);
1072 }
1073 }
1074
1075 List<JournalContentSearch> list = q.list();
1076
1077 if (list.size() == 2) {
1078 return list.get(1);
1079 }
1080 else {
1081 return null;
1082 }
1083 }
1084
1085
1091 @Override
1092 public void removeByArticleId(String articleId) throws SystemException {
1093 for (JournalContentSearch journalContentSearch : findByArticleId(
1094 articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1095 remove(journalContentSearch);
1096 }
1097 }
1098
1099
1106 @Override
1107 public int countByArticleId(String articleId) throws SystemException {
1108 FinderPath finderPath = FINDER_PATH_COUNT_BY_ARTICLEID;
1109
1110 Object[] finderArgs = new Object[] { articleId };
1111
1112 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1113 this);
1114
1115 if (count == null) {
1116 StringBundler query = new StringBundler(2);
1117
1118 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
1119
1120 boolean bindArticleId = false;
1121
1122 if (articleId == null) {
1123 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
1124 }
1125 else if (articleId.equals(StringPool.BLANK)) {
1126 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
1127 }
1128 else {
1129 bindArticleId = true;
1130
1131 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
1132 }
1133
1134 String sql = query.toString();
1135
1136 Session session = null;
1137
1138 try {
1139 session = openSession();
1140
1141 Query q = session.createQuery(sql);
1142
1143 QueryPos qPos = QueryPos.getInstance(q);
1144
1145 if (bindArticleId) {
1146 qPos.add(articleId);
1147 }
1148
1149 count = (Long)q.uniqueResult();
1150
1151 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1152 }
1153 catch (Exception e) {
1154 FinderCacheUtil.removeResult(finderPath, finderArgs);
1155
1156 throw processException(e);
1157 }
1158 finally {
1159 closeSession(session);
1160 }
1161 }
1162
1163 return count.intValue();
1164 }
1165
1166 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
1167 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_2 = "journalContentSearch.articleId = ?";
1168 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = '')";
1169 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1170 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1171 JournalContentSearchImpl.class,
1172 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
1173 new String[] {
1174 Long.class.getName(), Boolean.class.getName(),
1175
1176 Integer.class.getName(), Integer.class.getName(),
1177 OrderByComparator.class.getName()
1178 });
1179 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1180 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1181 JournalContentSearchImpl.class,
1182 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
1183 new String[] { Long.class.getName(), Boolean.class.getName() },
1184 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
1185 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK);
1186 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1187 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
1188 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
1189 new String[] { Long.class.getName(), Boolean.class.getName() });
1190
1191
1199 @Override
1200 public List<JournalContentSearch> findByG_P(long groupId,
1201 boolean privateLayout) throws SystemException {
1202 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1203 QueryUtil.ALL_POS, null);
1204 }
1205
1206
1220 @Override
1221 public List<JournalContentSearch> findByG_P(long groupId,
1222 boolean privateLayout, int start, int end) throws SystemException {
1223 return findByG_P(groupId, privateLayout, start, end, null);
1224 }
1225
1226
1241 @Override
1242 public List<JournalContentSearch> findByG_P(long groupId,
1243 boolean privateLayout, int start, int end,
1244 OrderByComparator orderByComparator) throws SystemException {
1245 boolean pagination = true;
1246 FinderPath finderPath = null;
1247 Object[] finderArgs = null;
1248
1249 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1250 (orderByComparator == null)) {
1251 pagination = false;
1252 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1253 finderArgs = new Object[] { groupId, privateLayout };
1254 }
1255 else {
1256 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1257 finderArgs = new Object[] {
1258 groupId, privateLayout,
1259
1260 start, end, orderByComparator
1261 };
1262 }
1263
1264 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
1265 finderArgs, this);
1266
1267 if ((list != null) && !list.isEmpty()) {
1268 for (JournalContentSearch journalContentSearch : list) {
1269 if ((groupId != journalContentSearch.getGroupId()) ||
1270 (privateLayout != journalContentSearch.getPrivateLayout())) {
1271 list = null;
1272
1273 break;
1274 }
1275 }
1276 }
1277
1278 if (list == null) {
1279 StringBundler query = null;
1280
1281 if (orderByComparator != null) {
1282 query = new StringBundler(4 +
1283 (orderByComparator.getOrderByFields().length * 3));
1284 }
1285 else {
1286 query = new StringBundler(4);
1287 }
1288
1289 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1290
1291 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1292
1293 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1294
1295 if (orderByComparator != null) {
1296 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1297 orderByComparator);
1298 }
1299 else
1300 if (pagination) {
1301 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1302 }
1303
1304 String sql = query.toString();
1305
1306 Session session = null;
1307
1308 try {
1309 session = openSession();
1310
1311 Query q = session.createQuery(sql);
1312
1313 QueryPos qPos = QueryPos.getInstance(q);
1314
1315 qPos.add(groupId);
1316
1317 qPos.add(privateLayout);
1318
1319 if (!pagination) {
1320 list = (List<JournalContentSearch>)QueryUtil.list(q,
1321 getDialect(), start, end, false);
1322
1323 Collections.sort(list);
1324
1325 list = new UnmodifiableList<JournalContentSearch>(list);
1326 }
1327 else {
1328 list = (List<JournalContentSearch>)QueryUtil.list(q,
1329 getDialect(), start, end);
1330 }
1331
1332 cacheResult(list);
1333
1334 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1335 }
1336 catch (Exception e) {
1337 FinderCacheUtil.removeResult(finderPath, finderArgs);
1338
1339 throw processException(e);
1340 }
1341 finally {
1342 closeSession(session);
1343 }
1344 }
1345
1346 return list;
1347 }
1348
1349
1359 @Override
1360 public JournalContentSearch findByG_P_First(long groupId,
1361 boolean privateLayout, OrderByComparator orderByComparator)
1362 throws NoSuchContentSearchException, SystemException {
1363 JournalContentSearch journalContentSearch = fetchByG_P_First(groupId,
1364 privateLayout, orderByComparator);
1365
1366 if (journalContentSearch != null) {
1367 return journalContentSearch;
1368 }
1369
1370 StringBundler msg = new StringBundler(6);
1371
1372 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1373
1374 msg.append("groupId=");
1375 msg.append(groupId);
1376
1377 msg.append(", privateLayout=");
1378 msg.append(privateLayout);
1379
1380 msg.append(StringPool.CLOSE_CURLY_BRACE);
1381
1382 throw new NoSuchContentSearchException(msg.toString());
1383 }
1384
1385
1394 @Override
1395 public JournalContentSearch fetchByG_P_First(long groupId,
1396 boolean privateLayout, OrderByComparator orderByComparator)
1397 throws SystemException {
1398 List<JournalContentSearch> list = findByG_P(groupId, privateLayout, 0,
1399 1, orderByComparator);
1400
1401 if (!list.isEmpty()) {
1402 return list.get(0);
1403 }
1404
1405 return null;
1406 }
1407
1408
1418 @Override
1419 public JournalContentSearch findByG_P_Last(long groupId,
1420 boolean privateLayout, OrderByComparator orderByComparator)
1421 throws NoSuchContentSearchException, SystemException {
1422 JournalContentSearch journalContentSearch = fetchByG_P_Last(groupId,
1423 privateLayout, orderByComparator);
1424
1425 if (journalContentSearch != null) {
1426 return journalContentSearch;
1427 }
1428
1429 StringBundler msg = new StringBundler(6);
1430
1431 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1432
1433 msg.append("groupId=");
1434 msg.append(groupId);
1435
1436 msg.append(", privateLayout=");
1437 msg.append(privateLayout);
1438
1439 msg.append(StringPool.CLOSE_CURLY_BRACE);
1440
1441 throw new NoSuchContentSearchException(msg.toString());
1442 }
1443
1444
1453 @Override
1454 public JournalContentSearch fetchByG_P_Last(long groupId,
1455 boolean privateLayout, OrderByComparator orderByComparator)
1456 throws SystemException {
1457 int count = countByG_P(groupId, privateLayout);
1458
1459 if (count == 0) {
1460 return null;
1461 }
1462
1463 List<JournalContentSearch> list = findByG_P(groupId, privateLayout,
1464 count - 1, count, orderByComparator);
1465
1466 if (!list.isEmpty()) {
1467 return list.get(0);
1468 }
1469
1470 return null;
1471 }
1472
1473
1484 @Override
1485 public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
1486 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1487 throws NoSuchContentSearchException, SystemException {
1488 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1489
1490 Session session = null;
1491
1492 try {
1493 session = openSession();
1494
1495 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1496
1497 array[0] = getByG_P_PrevAndNext(session, journalContentSearch,
1498 groupId, privateLayout, orderByComparator, true);
1499
1500 array[1] = journalContentSearch;
1501
1502 array[2] = getByG_P_PrevAndNext(session, journalContentSearch,
1503 groupId, privateLayout, orderByComparator, false);
1504
1505 return array;
1506 }
1507 catch (Exception e) {
1508 throw processException(e);
1509 }
1510 finally {
1511 closeSession(session);
1512 }
1513 }
1514
1515 protected JournalContentSearch getByG_P_PrevAndNext(Session session,
1516 JournalContentSearch journalContentSearch, long groupId,
1517 boolean privateLayout, OrderByComparator orderByComparator,
1518 boolean previous) {
1519 StringBundler query = null;
1520
1521 if (orderByComparator != null) {
1522 query = new StringBundler(6 +
1523 (orderByComparator.getOrderByFields().length * 6));
1524 }
1525 else {
1526 query = new StringBundler(3);
1527 }
1528
1529 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1530
1531 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1532
1533 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1534
1535 if (orderByComparator != null) {
1536 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1537
1538 if (orderByConditionFields.length > 0) {
1539 query.append(WHERE_AND);
1540 }
1541
1542 for (int i = 0; i < orderByConditionFields.length; i++) {
1543 query.append(_ORDER_BY_ENTITY_ALIAS);
1544 query.append(orderByConditionFields[i]);
1545
1546 if ((i + 1) < orderByConditionFields.length) {
1547 if (orderByComparator.isAscending() ^ previous) {
1548 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1549 }
1550 else {
1551 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1552 }
1553 }
1554 else {
1555 if (orderByComparator.isAscending() ^ previous) {
1556 query.append(WHERE_GREATER_THAN);
1557 }
1558 else {
1559 query.append(WHERE_LESSER_THAN);
1560 }
1561 }
1562 }
1563
1564 query.append(ORDER_BY_CLAUSE);
1565
1566 String[] orderByFields = orderByComparator.getOrderByFields();
1567
1568 for (int i = 0; i < orderByFields.length; i++) {
1569 query.append(_ORDER_BY_ENTITY_ALIAS);
1570 query.append(orderByFields[i]);
1571
1572 if ((i + 1) < orderByFields.length) {
1573 if (orderByComparator.isAscending() ^ previous) {
1574 query.append(ORDER_BY_ASC_HAS_NEXT);
1575 }
1576 else {
1577 query.append(ORDER_BY_DESC_HAS_NEXT);
1578 }
1579 }
1580 else {
1581 if (orderByComparator.isAscending() ^ previous) {
1582 query.append(ORDER_BY_ASC);
1583 }
1584 else {
1585 query.append(ORDER_BY_DESC);
1586 }
1587 }
1588 }
1589 }
1590 else {
1591 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1592 }
1593
1594 String sql = query.toString();
1595
1596 Query q = session.createQuery(sql);
1597
1598 q.setFirstResult(0);
1599 q.setMaxResults(2);
1600
1601 QueryPos qPos = QueryPos.getInstance(q);
1602
1603 qPos.add(groupId);
1604
1605 qPos.add(privateLayout);
1606
1607 if (orderByComparator != null) {
1608 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
1609
1610 for (Object value : values) {
1611 qPos.add(value);
1612 }
1613 }
1614
1615 List<JournalContentSearch> list = q.list();
1616
1617 if (list.size() == 2) {
1618 return list.get(1);
1619 }
1620 else {
1621 return null;
1622 }
1623 }
1624
1625
1632 @Override
1633 public void removeByG_P(long groupId, boolean privateLayout)
1634 throws SystemException {
1635 for (JournalContentSearch journalContentSearch : findByG_P(groupId,
1636 privateLayout, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1637 remove(journalContentSearch);
1638 }
1639 }
1640
1641
1649 @Override
1650 public int countByG_P(long groupId, boolean privateLayout)
1651 throws SystemException {
1652 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P;
1653
1654 Object[] finderArgs = new Object[] { groupId, privateLayout };
1655
1656 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1657 this);
1658
1659 if (count == null) {
1660 StringBundler query = new StringBundler(3);
1661
1662 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
1663
1664 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1665
1666 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1667
1668 String sql = query.toString();
1669
1670 Session session = null;
1671
1672 try {
1673 session = openSession();
1674
1675 Query q = session.createQuery(sql);
1676
1677 QueryPos qPos = QueryPos.getInstance(q);
1678
1679 qPos.add(groupId);
1680
1681 qPos.add(privateLayout);
1682
1683 count = (Long)q.uniqueResult();
1684
1685 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1686 }
1687 catch (Exception e) {
1688 FinderCacheUtil.removeResult(finderPath, finderArgs);
1689
1690 throw processException(e);
1691 }
1692 finally {
1693 closeSession(session);
1694 }
1695 }
1696
1697 return count.intValue();
1698 }
1699
1700 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
1701 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ?";
1702 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1703 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1704 JournalContentSearchImpl.class,
1705 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_A",
1706 new String[] {
1707 Long.class.getName(), String.class.getName(),
1708
1709 Integer.class.getName(), Integer.class.getName(),
1710 OrderByComparator.class.getName()
1711 });
1712 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1713 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1714 JournalContentSearchImpl.class,
1715 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
1716 new String[] { Long.class.getName(), String.class.getName() },
1717 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
1718 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
1719 public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1720 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
1721 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
1722 new String[] { Long.class.getName(), String.class.getName() });
1723
1724
1732 @Override
1733 public List<JournalContentSearch> findByG_A(long groupId, String articleId)
1734 throws SystemException {
1735 return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
1736 QueryUtil.ALL_POS, null);
1737 }
1738
1739
1753 @Override
1754 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1755 int start, int end) throws SystemException {
1756 return findByG_A(groupId, articleId, start, end, null);
1757 }
1758
1759
1774 @Override
1775 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1776 int start, int end, OrderByComparator orderByComparator)
1777 throws SystemException {
1778 boolean pagination = true;
1779 FinderPath finderPath = null;
1780 Object[] finderArgs = null;
1781
1782 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1783 (orderByComparator == null)) {
1784 pagination = false;
1785 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
1786 finderArgs = new Object[] { groupId, articleId };
1787 }
1788 else {
1789 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
1790 finderArgs = new Object[] {
1791 groupId, articleId,
1792
1793 start, end, orderByComparator
1794 };
1795 }
1796
1797 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
1798 finderArgs, this);
1799
1800 if ((list != null) && !list.isEmpty()) {
1801 for (JournalContentSearch journalContentSearch : list) {
1802 if ((groupId != journalContentSearch.getGroupId()) ||
1803 !Validator.equals(articleId,
1804 journalContentSearch.getArticleId())) {
1805 list = null;
1806
1807 break;
1808 }
1809 }
1810 }
1811
1812 if (list == null) {
1813 StringBundler query = null;
1814
1815 if (orderByComparator != null) {
1816 query = new StringBundler(4 +
1817 (orderByComparator.getOrderByFields().length * 3));
1818 }
1819 else {
1820 query = new StringBundler(4);
1821 }
1822
1823 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1824
1825 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1826
1827 boolean bindArticleId = false;
1828
1829 if (articleId == null) {
1830 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1831 }
1832 else if (articleId.equals(StringPool.BLANK)) {
1833 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1834 }
1835 else {
1836 bindArticleId = true;
1837
1838 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1839 }
1840
1841 if (orderByComparator != null) {
1842 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1843 orderByComparator);
1844 }
1845 else
1846 if (pagination) {
1847 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1848 }
1849
1850 String sql = query.toString();
1851
1852 Session session = null;
1853
1854 try {
1855 session = openSession();
1856
1857 Query q = session.createQuery(sql);
1858
1859 QueryPos qPos = QueryPos.getInstance(q);
1860
1861 qPos.add(groupId);
1862
1863 if (bindArticleId) {
1864 qPos.add(articleId);
1865 }
1866
1867 if (!pagination) {
1868 list = (List<JournalContentSearch>)QueryUtil.list(q,
1869 getDialect(), start, end, false);
1870
1871 Collections.sort(list);
1872
1873 list = new UnmodifiableList<JournalContentSearch>(list);
1874 }
1875 else {
1876 list = (List<JournalContentSearch>)QueryUtil.list(q,
1877 getDialect(), start, end);
1878 }
1879
1880 cacheResult(list);
1881
1882 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1883 }
1884 catch (Exception e) {
1885 FinderCacheUtil.removeResult(finderPath, finderArgs);
1886
1887 throw processException(e);
1888 }
1889 finally {
1890 closeSession(session);
1891 }
1892 }
1893
1894 return list;
1895 }
1896
1897
1907 @Override
1908 public JournalContentSearch findByG_A_First(long groupId, String articleId,
1909 OrderByComparator orderByComparator)
1910 throws NoSuchContentSearchException, SystemException {
1911 JournalContentSearch journalContentSearch = fetchByG_A_First(groupId,
1912 articleId, orderByComparator);
1913
1914 if (journalContentSearch != null) {
1915 return journalContentSearch;
1916 }
1917
1918 StringBundler msg = new StringBundler(6);
1919
1920 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1921
1922 msg.append("groupId=");
1923 msg.append(groupId);
1924
1925 msg.append(", articleId=");
1926 msg.append(articleId);
1927
1928 msg.append(StringPool.CLOSE_CURLY_BRACE);
1929
1930 throw new NoSuchContentSearchException(msg.toString());
1931 }
1932
1933
1942 @Override
1943 public JournalContentSearch fetchByG_A_First(long groupId,
1944 String articleId, OrderByComparator orderByComparator)
1945 throws SystemException {
1946 List<JournalContentSearch> list = findByG_A(groupId, articleId, 0, 1,
1947 orderByComparator);
1948
1949 if (!list.isEmpty()) {
1950 return list.get(0);
1951 }
1952
1953 return null;
1954 }
1955
1956
1966 @Override
1967 public JournalContentSearch findByG_A_Last(long groupId, String articleId,
1968 OrderByComparator orderByComparator)
1969 throws NoSuchContentSearchException, SystemException {
1970 JournalContentSearch journalContentSearch = fetchByG_A_Last(groupId,
1971 articleId, orderByComparator);
1972
1973 if (journalContentSearch != null) {
1974 return journalContentSearch;
1975 }
1976
1977 StringBundler msg = new StringBundler(6);
1978
1979 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1980
1981 msg.append("groupId=");
1982 msg.append(groupId);
1983
1984 msg.append(", articleId=");
1985 msg.append(articleId);
1986
1987 msg.append(StringPool.CLOSE_CURLY_BRACE);
1988
1989 throw new NoSuchContentSearchException(msg.toString());
1990 }
1991
1992
2001 @Override
2002 public JournalContentSearch fetchByG_A_Last(long groupId, String articleId,
2003 OrderByComparator orderByComparator) throws SystemException {
2004 int count = countByG_A(groupId, articleId);
2005
2006 if (count == 0) {
2007 return null;
2008 }
2009
2010 List<JournalContentSearch> list = findByG_A(groupId, articleId,
2011 count - 1, count, orderByComparator);
2012
2013 if (!list.isEmpty()) {
2014 return list.get(0);
2015 }
2016
2017 return null;
2018 }
2019
2020
2031 @Override
2032 public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
2033 long groupId, String articleId, OrderByComparator orderByComparator)
2034 throws NoSuchContentSearchException, SystemException {
2035 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2036
2037 Session session = null;
2038
2039 try {
2040 session = openSession();
2041
2042 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2043
2044 array[0] = getByG_A_PrevAndNext(session, journalContentSearch,
2045 groupId, articleId, orderByComparator, true);
2046
2047 array[1] = journalContentSearch;
2048
2049 array[2] = getByG_A_PrevAndNext(session, journalContentSearch,
2050 groupId, articleId, orderByComparator, false);
2051
2052 return array;
2053 }
2054 catch (Exception e) {
2055 throw processException(e);
2056 }
2057 finally {
2058 closeSession(session);
2059 }
2060 }
2061
2062 protected JournalContentSearch getByG_A_PrevAndNext(Session session,
2063 JournalContentSearch journalContentSearch, long groupId,
2064 String articleId, OrderByComparator orderByComparator, boolean previous) {
2065 StringBundler query = null;
2066
2067 if (orderByComparator != null) {
2068 query = new StringBundler(6 +
2069 (orderByComparator.getOrderByFields().length * 6));
2070 }
2071 else {
2072 query = new StringBundler(3);
2073 }
2074
2075 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2076
2077 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2078
2079 boolean bindArticleId = false;
2080
2081 if (articleId == null) {
2082 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2083 }
2084 else if (articleId.equals(StringPool.BLANK)) {
2085 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2086 }
2087 else {
2088 bindArticleId = true;
2089
2090 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2091 }
2092
2093 if (orderByComparator != null) {
2094 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2095
2096 if (orderByConditionFields.length > 0) {
2097 query.append(WHERE_AND);
2098 }
2099
2100 for (int i = 0; i < orderByConditionFields.length; i++) {
2101 query.append(_ORDER_BY_ENTITY_ALIAS);
2102 query.append(orderByConditionFields[i]);
2103
2104 if ((i + 1) < orderByConditionFields.length) {
2105 if (orderByComparator.isAscending() ^ previous) {
2106 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2107 }
2108 else {
2109 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2110 }
2111 }
2112 else {
2113 if (orderByComparator.isAscending() ^ previous) {
2114 query.append(WHERE_GREATER_THAN);
2115 }
2116 else {
2117 query.append(WHERE_LESSER_THAN);
2118 }
2119 }
2120 }
2121
2122 query.append(ORDER_BY_CLAUSE);
2123
2124 String[] orderByFields = orderByComparator.getOrderByFields();
2125
2126 for (int i = 0; i < orderByFields.length; i++) {
2127 query.append(_ORDER_BY_ENTITY_ALIAS);
2128 query.append(orderByFields[i]);
2129
2130 if ((i + 1) < orderByFields.length) {
2131 if (orderByComparator.isAscending() ^ previous) {
2132 query.append(ORDER_BY_ASC_HAS_NEXT);
2133 }
2134 else {
2135 query.append(ORDER_BY_DESC_HAS_NEXT);
2136 }
2137 }
2138 else {
2139 if (orderByComparator.isAscending() ^ previous) {
2140 query.append(ORDER_BY_ASC);
2141 }
2142 else {
2143 query.append(ORDER_BY_DESC);
2144 }
2145 }
2146 }
2147 }
2148 else {
2149 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2150 }
2151
2152 String sql = query.toString();
2153
2154 Query q = session.createQuery(sql);
2155
2156 q.setFirstResult(0);
2157 q.setMaxResults(2);
2158
2159 QueryPos qPos = QueryPos.getInstance(q);
2160
2161 qPos.add(groupId);
2162
2163 if (bindArticleId) {
2164 qPos.add(articleId);
2165 }
2166
2167 if (orderByComparator != null) {
2168 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2169
2170 for (Object value : values) {
2171 qPos.add(value);
2172 }
2173 }
2174
2175 List<JournalContentSearch> list = q.list();
2176
2177 if (list.size() == 2) {
2178 return list.get(1);
2179 }
2180 else {
2181 return null;
2182 }
2183 }
2184
2185
2192 @Override
2193 public void removeByG_A(long groupId, String articleId)
2194 throws SystemException {
2195 for (JournalContentSearch journalContentSearch : findByG_A(groupId,
2196 articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2197 remove(journalContentSearch);
2198 }
2199 }
2200
2201
2209 @Override
2210 public int countByG_A(long groupId, String articleId)
2211 throws SystemException {
2212 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
2213
2214 Object[] finderArgs = new Object[] { groupId, articleId };
2215
2216 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2217 this);
2218
2219 if (count == null) {
2220 StringBundler query = new StringBundler(3);
2221
2222 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2223
2224 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2225
2226 boolean bindArticleId = false;
2227
2228 if (articleId == null) {
2229 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2230 }
2231 else if (articleId.equals(StringPool.BLANK)) {
2232 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2233 }
2234 else {
2235 bindArticleId = true;
2236
2237 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2238 }
2239
2240 String sql = query.toString();
2241
2242 Session session = null;
2243
2244 try {
2245 session = openSession();
2246
2247 Query q = session.createQuery(sql);
2248
2249 QueryPos qPos = QueryPos.getInstance(q);
2250
2251 qPos.add(groupId);
2252
2253 if (bindArticleId) {
2254 qPos.add(articleId);
2255 }
2256
2257 count = (Long)q.uniqueResult();
2258
2259 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2260 }
2261 catch (Exception e) {
2262 FinderCacheUtil.removeResult(finderPath, finderArgs);
2263
2264 throw processException(e);
2265 }
2266 finally {
2267 closeSession(session);
2268 }
2269 }
2270
2271 return count.intValue();
2272 }
2273
2274 private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
2275 private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
2276 private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
2277 private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = '')";
2278 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2279 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2280 JournalContentSearchImpl.class,
2281 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_L",
2282 new String[] {
2283 Long.class.getName(), Boolean.class.getName(),
2284 Long.class.getName(),
2285
2286 Integer.class.getName(), Integer.class.getName(),
2287 OrderByComparator.class.getName()
2288 });
2289 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2290 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2291 JournalContentSearchImpl.class,
2292 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_L",
2293 new String[] {
2294 Long.class.getName(), Boolean.class.getName(),
2295 Long.class.getName()
2296 },
2297 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
2298 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
2299 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK);
2300 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2301 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
2302 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L",
2303 new String[] {
2304 Long.class.getName(), Boolean.class.getName(),
2305 Long.class.getName()
2306 });
2307
2308
2317 @Override
2318 public List<JournalContentSearch> findByG_P_L(long groupId,
2319 boolean privateLayout, long layoutId) throws SystemException {
2320 return findByG_P_L(groupId, privateLayout, layoutId, QueryUtil.ALL_POS,
2321 QueryUtil.ALL_POS, null);
2322 }
2323
2324
2339 @Override
2340 public List<JournalContentSearch> findByG_P_L(long groupId,
2341 boolean privateLayout, long layoutId, int start, int end)
2342 throws SystemException {
2343 return findByG_P_L(groupId, privateLayout, layoutId, start, end, null);
2344 }
2345
2346
2362 @Override
2363 public List<JournalContentSearch> findByG_P_L(long groupId,
2364 boolean privateLayout, long layoutId, int start, int end,
2365 OrderByComparator orderByComparator) throws SystemException {
2366 boolean pagination = true;
2367 FinderPath finderPath = null;
2368 Object[] finderArgs = null;
2369
2370 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2371 (orderByComparator == null)) {
2372 pagination = false;
2373 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L;
2374 finderArgs = new Object[] { groupId, privateLayout, layoutId };
2375 }
2376 else {
2377 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L;
2378 finderArgs = new Object[] {
2379 groupId, privateLayout, layoutId,
2380
2381 start, end, orderByComparator
2382 };
2383 }
2384
2385 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
2386 finderArgs, this);
2387
2388 if ((list != null) && !list.isEmpty()) {
2389 for (JournalContentSearch journalContentSearch : list) {
2390 if ((groupId != journalContentSearch.getGroupId()) ||
2391 (privateLayout != journalContentSearch.getPrivateLayout()) ||
2392 (layoutId != journalContentSearch.getLayoutId())) {
2393 list = null;
2394
2395 break;
2396 }
2397 }
2398 }
2399
2400 if (list == null) {
2401 StringBundler query = null;
2402
2403 if (orderByComparator != null) {
2404 query = new StringBundler(5 +
2405 (orderByComparator.getOrderByFields().length * 3));
2406 }
2407 else {
2408 query = new StringBundler(5);
2409 }
2410
2411 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2412
2413 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2414
2415 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2416
2417 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2418
2419 if (orderByComparator != null) {
2420 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2421 orderByComparator);
2422 }
2423 else
2424 if (pagination) {
2425 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2426 }
2427
2428 String sql = query.toString();
2429
2430 Session session = null;
2431
2432 try {
2433 session = openSession();
2434
2435 Query q = session.createQuery(sql);
2436
2437 QueryPos qPos = QueryPos.getInstance(q);
2438
2439 qPos.add(groupId);
2440
2441 qPos.add(privateLayout);
2442
2443 qPos.add(layoutId);
2444
2445 if (!pagination) {
2446 list = (List<JournalContentSearch>)QueryUtil.list(q,
2447 getDialect(), start, end, false);
2448
2449 Collections.sort(list);
2450
2451 list = new UnmodifiableList<JournalContentSearch>(list);
2452 }
2453 else {
2454 list = (List<JournalContentSearch>)QueryUtil.list(q,
2455 getDialect(), start, end);
2456 }
2457
2458 cacheResult(list);
2459
2460 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2461 }
2462 catch (Exception e) {
2463 FinderCacheUtil.removeResult(finderPath, finderArgs);
2464
2465 throw processException(e);
2466 }
2467 finally {
2468 closeSession(session);
2469 }
2470 }
2471
2472 return list;
2473 }
2474
2475
2486 @Override
2487 public JournalContentSearch findByG_P_L_First(long groupId,
2488 boolean privateLayout, long layoutId,
2489 OrderByComparator orderByComparator)
2490 throws NoSuchContentSearchException, SystemException {
2491 JournalContentSearch journalContentSearch = fetchByG_P_L_First(groupId,
2492 privateLayout, layoutId, orderByComparator);
2493
2494 if (journalContentSearch != null) {
2495 return journalContentSearch;
2496 }
2497
2498 StringBundler msg = new StringBundler(8);
2499
2500 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2501
2502 msg.append("groupId=");
2503 msg.append(groupId);
2504
2505 msg.append(", privateLayout=");
2506 msg.append(privateLayout);
2507
2508 msg.append(", layoutId=");
2509 msg.append(layoutId);
2510
2511 msg.append(StringPool.CLOSE_CURLY_BRACE);
2512
2513 throw new NoSuchContentSearchException(msg.toString());
2514 }
2515
2516
2526 @Override
2527 public JournalContentSearch fetchByG_P_L_First(long groupId,
2528 boolean privateLayout, long layoutId,
2529 OrderByComparator orderByComparator) throws SystemException {
2530 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
2531 layoutId, 0, 1, orderByComparator);
2532
2533 if (!list.isEmpty()) {
2534 return list.get(0);
2535 }
2536
2537 return null;
2538 }
2539
2540
2551 @Override
2552 public JournalContentSearch findByG_P_L_Last(long groupId,
2553 boolean privateLayout, long layoutId,
2554 OrderByComparator orderByComparator)
2555 throws NoSuchContentSearchException, SystemException {
2556 JournalContentSearch journalContentSearch = fetchByG_P_L_Last(groupId,
2557 privateLayout, layoutId, orderByComparator);
2558
2559 if (journalContentSearch != null) {
2560 return journalContentSearch;
2561 }
2562
2563 StringBundler msg = new StringBundler(8);
2564
2565 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2566
2567 msg.append("groupId=");
2568 msg.append(groupId);
2569
2570 msg.append(", privateLayout=");
2571 msg.append(privateLayout);
2572
2573 msg.append(", layoutId=");
2574 msg.append(layoutId);
2575
2576 msg.append(StringPool.CLOSE_CURLY_BRACE);
2577
2578 throw new NoSuchContentSearchException(msg.toString());
2579 }
2580
2581
2591 @Override
2592 public JournalContentSearch fetchByG_P_L_Last(long groupId,
2593 boolean privateLayout, long layoutId,
2594 OrderByComparator orderByComparator) throws SystemException {
2595 int count = countByG_P_L(groupId, privateLayout, layoutId);
2596
2597 if (count == 0) {
2598 return null;
2599 }
2600
2601 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
2602 layoutId, count - 1, count, orderByComparator);
2603
2604 if (!list.isEmpty()) {
2605 return list.get(0);
2606 }
2607
2608 return null;
2609 }
2610
2611
2623 @Override
2624 public JournalContentSearch[] findByG_P_L_PrevAndNext(
2625 long contentSearchId, long groupId, boolean privateLayout,
2626 long layoutId, OrderByComparator orderByComparator)
2627 throws NoSuchContentSearchException, SystemException {
2628 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2629
2630 Session session = null;
2631
2632 try {
2633 session = openSession();
2634
2635 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2636
2637 array[0] = getByG_P_L_PrevAndNext(session, journalContentSearch,
2638 groupId, privateLayout, layoutId, orderByComparator, true);
2639
2640 array[1] = journalContentSearch;
2641
2642 array[2] = getByG_P_L_PrevAndNext(session, journalContentSearch,
2643 groupId, privateLayout, layoutId, orderByComparator, false);
2644
2645 return array;
2646 }
2647 catch (Exception e) {
2648 throw processException(e);
2649 }
2650 finally {
2651 closeSession(session);
2652 }
2653 }
2654
2655 protected JournalContentSearch getByG_P_L_PrevAndNext(Session session,
2656 JournalContentSearch journalContentSearch, long groupId,
2657 boolean privateLayout, long layoutId,
2658 OrderByComparator orderByComparator, boolean previous) {
2659 StringBundler query = null;
2660
2661 if (orderByComparator != null) {
2662 query = new StringBundler(6 +
2663 (orderByComparator.getOrderByFields().length * 6));
2664 }
2665 else {
2666 query = new StringBundler(3);
2667 }
2668
2669 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2670
2671 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2672
2673 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2674
2675 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2676
2677 if (orderByComparator != null) {
2678 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2679
2680 if (orderByConditionFields.length > 0) {
2681 query.append(WHERE_AND);
2682 }
2683
2684 for (int i = 0; i < orderByConditionFields.length; i++) {
2685 query.append(_ORDER_BY_ENTITY_ALIAS);
2686 query.append(orderByConditionFields[i]);
2687
2688 if ((i + 1) < orderByConditionFields.length) {
2689 if (orderByComparator.isAscending() ^ previous) {
2690 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2691 }
2692 else {
2693 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2694 }
2695 }
2696 else {
2697 if (orderByComparator.isAscending() ^ previous) {
2698 query.append(WHERE_GREATER_THAN);
2699 }
2700 else {
2701 query.append(WHERE_LESSER_THAN);
2702 }
2703 }
2704 }
2705
2706 query.append(ORDER_BY_CLAUSE);
2707
2708 String[] orderByFields = orderByComparator.getOrderByFields();
2709
2710 for (int i = 0; i < orderByFields.length; i++) {
2711 query.append(_ORDER_BY_ENTITY_ALIAS);
2712 query.append(orderByFields[i]);
2713
2714 if ((i + 1) < orderByFields.length) {
2715 if (orderByComparator.isAscending() ^ previous) {
2716 query.append(ORDER_BY_ASC_HAS_NEXT);
2717 }
2718 else {
2719 query.append(ORDER_BY_DESC_HAS_NEXT);
2720 }
2721 }
2722 else {
2723 if (orderByComparator.isAscending() ^ previous) {
2724 query.append(ORDER_BY_ASC);
2725 }
2726 else {
2727 query.append(ORDER_BY_DESC);
2728 }
2729 }
2730 }
2731 }
2732 else {
2733 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2734 }
2735
2736 String sql = query.toString();
2737
2738 Query q = session.createQuery(sql);
2739
2740 q.setFirstResult(0);
2741 q.setMaxResults(2);
2742
2743 QueryPos qPos = QueryPos.getInstance(q);
2744
2745 qPos.add(groupId);
2746
2747 qPos.add(privateLayout);
2748
2749 qPos.add(layoutId);
2750
2751 if (orderByComparator != null) {
2752 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2753
2754 for (Object value : values) {
2755 qPos.add(value);
2756 }
2757 }
2758
2759 List<JournalContentSearch> list = q.list();
2760
2761 if (list.size() == 2) {
2762 return list.get(1);
2763 }
2764 else {
2765 return null;
2766 }
2767 }
2768
2769
2777 @Override
2778 public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId)
2779 throws SystemException {
2780 for (JournalContentSearch journalContentSearch : findByG_P_L(groupId,
2781 privateLayout, layoutId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2782 null)) {
2783 remove(journalContentSearch);
2784 }
2785 }
2786
2787
2796 @Override
2797 public int countByG_P_L(long groupId, boolean privateLayout, long layoutId)
2798 throws SystemException {
2799 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_L;
2800
2801 Object[] finderArgs = new Object[] { groupId, privateLayout, layoutId };
2802
2803 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2804 this);
2805
2806 if (count == null) {
2807 StringBundler query = new StringBundler(4);
2808
2809 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2810
2811 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2812
2813 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2814
2815 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2816
2817 String sql = query.toString();
2818
2819 Session session = null;
2820
2821 try {
2822 session = openSession();
2823
2824 Query q = session.createQuery(sql);
2825
2826 QueryPos qPos = QueryPos.getInstance(q);
2827
2828 qPos.add(groupId);
2829
2830 qPos.add(privateLayout);
2831
2832 qPos.add(layoutId);
2833
2834 count = (Long)q.uniqueResult();
2835
2836 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2837 }
2838 catch (Exception e) {
2839 FinderCacheUtil.removeResult(finderPath, finderArgs);
2840
2841 throw processException(e);
2842 }
2843 finally {
2844 closeSession(session);
2845 }
2846 }
2847
2848 return count.intValue();
2849 }
2850
2851 private static final String _FINDER_COLUMN_G_P_L_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
2852 private static final String _FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
2853 private static final String _FINDER_COLUMN_G_P_L_LAYOUTID_2 = "journalContentSearch.layoutId = ?";
2854 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2855 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2856 JournalContentSearchImpl.class,
2857 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_A",
2858 new String[] {
2859 Long.class.getName(), Boolean.class.getName(),
2860 String.class.getName(),
2861
2862 Integer.class.getName(), Integer.class.getName(),
2863 OrderByComparator.class.getName()
2864 });
2865 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2866 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2867 JournalContentSearchImpl.class,
2868 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_A",
2869 new String[] {
2870 Long.class.getName(), Boolean.class.getName(),
2871 String.class.getName()
2872 },
2873 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
2874 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
2875 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
2876 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2877 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
2878 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_A",
2879 new String[] {
2880 Long.class.getName(), Boolean.class.getName(),
2881 String.class.getName()
2882 });
2883
2884
2893 @Override
2894 public List<JournalContentSearch> findByG_P_A(long groupId,
2895 boolean privateLayout, String articleId) throws SystemException {
2896 return findByG_P_A(groupId, privateLayout, articleId,
2897 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2898 }
2899
2900
2915 @Override
2916 public List<JournalContentSearch> findByG_P_A(long groupId,
2917 boolean privateLayout, String articleId, int start, int end)
2918 throws SystemException {
2919 return findByG_P_A(groupId, privateLayout, articleId, start, end, null);
2920 }
2921
2922
2938 @Override
2939 public List<JournalContentSearch> findByG_P_A(long groupId,
2940 boolean privateLayout, String articleId, int start, int end,
2941 OrderByComparator orderByComparator) throws SystemException {
2942 boolean pagination = true;
2943 FinderPath finderPath = null;
2944 Object[] finderArgs = null;
2945
2946 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2947 (orderByComparator == null)) {
2948 pagination = false;
2949 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A;
2950 finderArgs = new Object[] { groupId, privateLayout, articleId };
2951 }
2952 else {
2953 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_A;
2954 finderArgs = new Object[] {
2955 groupId, privateLayout, articleId,
2956
2957 start, end, orderByComparator
2958 };
2959 }
2960
2961 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
2962 finderArgs, this);
2963
2964 if ((list != null) && !list.isEmpty()) {
2965 for (JournalContentSearch journalContentSearch : list) {
2966 if ((groupId != journalContentSearch.getGroupId()) ||
2967 (privateLayout != journalContentSearch.getPrivateLayout()) ||
2968 !Validator.equals(articleId,
2969 journalContentSearch.getArticleId())) {
2970 list = null;
2971
2972 break;
2973 }
2974 }
2975 }
2976
2977 if (list == null) {
2978 StringBundler query = null;
2979
2980 if (orderByComparator != null) {
2981 query = new StringBundler(5 +
2982 (orderByComparator.getOrderByFields().length * 3));
2983 }
2984 else {
2985 query = new StringBundler(5);
2986 }
2987
2988 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2989
2990 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2991
2992 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2993
2994 boolean bindArticleId = false;
2995
2996 if (articleId == null) {
2997 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2998 }
2999 else if (articleId.equals(StringPool.BLANK)) {
3000 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
3001 }
3002 else {
3003 bindArticleId = true;
3004
3005 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
3006 }
3007
3008 if (orderByComparator != null) {
3009 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3010 orderByComparator);
3011 }
3012 else
3013 if (pagination) {
3014 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
3015 }
3016
3017 String sql = query.toString();
3018
3019 Session session = null;
3020
3021 try {
3022 session = openSession();
3023
3024 Query q = session.createQuery(sql);
3025
3026 QueryPos qPos = QueryPos.getInstance(q);
3027
3028 qPos.add(groupId);
3029
3030 qPos.add(privateLayout);
3031
3032 if (bindArticleId) {
3033 qPos.add(articleId);
3034 }
3035
3036 if (!pagination) {
3037 list = (List<JournalContentSearch>)QueryUtil.list(q,
3038 getDialect(), start, end, false);
3039
3040 Collections.sort(list);
3041
3042 list = new UnmodifiableList<JournalContentSearch>(list);
3043 }
3044 else {
3045 list = (List<JournalContentSearch>)QueryUtil.list(q,
3046 getDialect(), start, end);
3047 }
3048
3049 cacheResult(list);
3050
3051 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3052 }
3053 catch (Exception e) {
3054 FinderCacheUtil.removeResult(finderPath, finderArgs);
3055
3056 throw processException(e);
3057 }
3058 finally {
3059 closeSession(session);
3060 }
3061 }
3062
3063 return list;
3064 }
3065
3066
3077 @Override
3078 public JournalContentSearch findByG_P_A_First(long groupId,
3079 boolean privateLayout, String articleId,
3080 OrderByComparator orderByComparator)
3081 throws NoSuchContentSearchException, SystemException {
3082 JournalContentSearch journalContentSearch = fetchByG_P_A_First(groupId,
3083 privateLayout, articleId, orderByComparator);
3084
3085 if (journalContentSearch != null) {
3086 return journalContentSearch;
3087 }
3088
3089 StringBundler msg = new StringBundler(8);
3090
3091 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3092
3093 msg.append("groupId=");
3094 msg.append(groupId);
3095
3096 msg.append(", privateLayout=");
3097 msg.append(privateLayout);
3098
3099 msg.append(", articleId=");
3100 msg.append(articleId);
3101
3102 msg.append(StringPool.CLOSE_CURLY_BRACE);
3103
3104 throw new NoSuchContentSearchException(msg.toString());
3105 }
3106
3107
3117 @Override
3118 public JournalContentSearch fetchByG_P_A_First(long groupId,
3119 boolean privateLayout, String articleId,
3120 OrderByComparator orderByComparator) throws SystemException {
3121 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
3122 articleId, 0, 1, orderByComparator);
3123
3124 if (!list.isEmpty()) {
3125 return list.get(0);
3126 }
3127
3128 return null;
3129 }
3130
3131
3142 @Override
3143 public JournalContentSearch findByG_P_A_Last(long groupId,
3144 boolean privateLayout, String articleId,
3145 OrderByComparator orderByComparator)
3146 throws NoSuchContentSearchException, SystemException {
3147 JournalContentSearch journalContentSearch = fetchByG_P_A_Last(groupId,
3148 privateLayout, articleId, orderByComparator);
3149
3150 if (journalContentSearch != null) {
3151 return journalContentSearch;
3152 }
3153
3154 StringBundler msg = new StringBundler(8);
3155
3156 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3157
3158 msg.append("groupId=");
3159 msg.append(groupId);
3160
3161 msg.append(", privateLayout=");
3162 msg.append(privateLayout);
3163
3164 msg.append(", articleId=");
3165 msg.append(articleId);
3166
3167 msg.append(StringPool.CLOSE_CURLY_BRACE);
3168
3169 throw new NoSuchContentSearchException(msg.toString());
3170 }
3171
3172
3182 @Override
3183 public JournalContentSearch fetchByG_P_A_Last(long groupId,
3184 boolean privateLayout, String articleId,
3185 OrderByComparator orderByComparator) throws SystemException {
3186 int count = countByG_P_A(groupId, privateLayout, articleId);
3187
3188 if (count == 0) {
3189 return null;
3190 }
3191
3192 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
3193 articleId, count - 1, count, orderByComparator);
3194
3195 if (!list.isEmpty()) {
3196 return list.get(0);
3197 }
3198
3199 return null;
3200 }
3201
3202
3214 @Override
3215 public JournalContentSearch[] findByG_P_A_PrevAndNext(
3216 long contentSearchId, long groupId, boolean privateLayout,
3217 String articleId, OrderByComparator orderByComparator)
3218 throws NoSuchContentSearchException, SystemException {
3219 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
3220
3221 Session session = null;
3222
3223 try {
3224 session = openSession();
3225
3226 JournalContentSearch[] array = new JournalContentSearchImpl[3];
3227
3228 array[0] = getByG_P_A_PrevAndNext(session, journalContentSearch,
3229 groupId, privateLayout, articleId, orderByComparator, true);
3230
3231 array[1] = journalContentSearch;
3232
3233 array[2] = getByG_P_A_PrevAndNext(session, journalContentSearch,
3234 groupId, privateLayout, articleId, orderByComparator, false);
3235
3236 return array;
3237 }
3238 catch (Exception e) {
3239 throw processException(e);
3240 }
3241 finally {
3242 closeSession(session);
3243 }
3244 }
3245
3246 protected JournalContentSearch getByG_P_A_PrevAndNext(Session session,
3247 JournalContentSearch journalContentSearch, long groupId,
3248 boolean privateLayout, String articleId,
3249 OrderByComparator orderByComparator, boolean previous) {
3250 StringBundler query = null;
3251
3252 if (orderByComparator != null) {
3253 query = new StringBundler(6 +
3254 (orderByComparator.getOrderByFields().length * 6));
3255 }
3256 else {
3257 query = new StringBundler(3);
3258 }
3259
3260 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3261
3262 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
3263
3264 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
3265
3266 boolean bindArticleId = false;
3267
3268 if (articleId == null) {
3269 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
3270 }
3271 else if (articleId.equals(StringPool.BLANK)) {
3272 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
3273 }
3274 else {
3275 bindArticleId = true;
3276
3277 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
3278 }
3279
3280 if (orderByComparator != null) {
3281 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3282
3283 if (orderByConditionFields.length > 0) {
3284 query.append(WHERE_AND);
3285 }
3286
3287 for (int i = 0; i < orderByConditionFields.length; i++) {
3288 query.append(_ORDER_BY_ENTITY_ALIAS);
3289 query.append(orderByConditionFields[i]);
3290
3291 if ((i + 1) < orderByConditionFields.length) {
3292 if (orderByComparator.isAscending() ^ previous) {
3293 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3294 }
3295 else {
3296 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3297 }
3298 }
3299 else {
3300 if (orderByComparator.isAscending() ^ previous) {
3301 query.append(WHERE_GREATER_THAN);
3302 }
3303 else {
3304 query.append(WHERE_LESSER_THAN);
3305 }
3306 }
3307 }
3308
3309 query.append(ORDER_BY_CLAUSE);
3310
3311 String[] orderByFields = orderByComparator.getOrderByFields();
3312
3313 for (int i = 0; i < orderByFields.length; i++) {
3314 query.append(_ORDER_BY_ENTITY_ALIAS);
3315 query.append(orderByFields[i]);
3316
3317 if ((i + 1) < orderByFields.length) {
3318 if (orderByComparator.isAscending() ^ previous) {
3319 query.append(ORDER_BY_ASC_HAS_NEXT);
3320 }
3321 else {
3322 query.append(ORDER_BY_DESC_HAS_NEXT);
3323 }
3324 }
3325 else {
3326 if (orderByComparator.isAscending() ^ previous) {
3327 query.append(ORDER_BY_ASC);
3328 }
3329 else {
3330 query.append(ORDER_BY_DESC);
3331 }
3332 }
3333 }
3334 }
3335 else {
3336 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
3337 }
3338
3339 String sql = query.toString();
3340
3341 Query q = session.createQuery(sql);
3342
3343 q.setFirstResult(0);
3344 q.setMaxResults(2);
3345
3346 QueryPos qPos = QueryPos.getInstance(q);
3347
3348 qPos.add(groupId);
3349
3350 qPos.add(privateLayout);
3351
3352 if (bindArticleId) {
3353 qPos.add(articleId);
3354 }
3355
3356 if (orderByComparator != null) {
3357 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
3358
3359 for (Object value : values) {
3360 qPos.add(value);
3361 }
3362 }
3363
3364 List<JournalContentSearch> list = q.list();
3365
3366 if (list.size() == 2) {
3367 return list.get(1);
3368 }
3369 else {
3370 return null;
3371 }
3372 }
3373
3374
3382 @Override
3383 public void removeByG_P_A(long groupId, boolean privateLayout,
3384 String articleId) throws SystemException {
3385 for (JournalContentSearch journalContentSearch : findByG_P_A(groupId,
3386 privateLayout, articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3387 null)) {
3388 remove(journalContentSearch);
3389 }
3390 }
3391
3392
3401 @Override
3402 public int countByG_P_A(long groupId, boolean privateLayout,
3403 String articleId) throws SystemException {
3404 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_A;
3405
3406 Object[] finderArgs = new Object[] { groupId, privateLayout, articleId };
3407
3408 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3409 this);
3410
3411 if (count == null) {
3412 StringBundler query = new StringBundler(4);
3413
3414 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3415
3416 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
3417
3418 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
3419
3420 boolean bindArticleId = false;
3421
3422 if (articleId == null) {
3423 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
3424 }
3425 else if (articleId.equals(StringPool.BLANK)) {
3426 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
3427 }
3428 else {
3429 bindArticleId = true;
3430
3431 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
3432 }
3433
3434 String sql = query.toString();
3435
3436 Session session = null;
3437
3438 try {
3439 session = openSession();
3440
3441 Query q = session.createQuery(sql);
3442
3443 QueryPos qPos = QueryPos.getInstance(q);
3444
3445 qPos.add(groupId);
3446
3447 qPos.add(privateLayout);
3448
3449 if (bindArticleId) {
3450 qPos.add(articleId);
3451 }
3452
3453 count = (Long)q.uniqueResult();
3454
3455 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3456 }
3457 catch (Exception e) {
3458 FinderCacheUtil.removeResult(finderPath, finderArgs);
3459
3460 throw processException(e);
3461 }
3462 finally {
3463 closeSession(session);
3464 }
3465 }
3466
3467 return count.intValue();
3468 }
3469
3470 private static final String _FINDER_COLUMN_G_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3471 private static final String _FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3472 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3473 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3474 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = '')";
3475 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
3476 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
3477 JournalContentSearchImpl.class,
3478 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_L_P",
3479 new String[] {
3480 Long.class.getName(), Boolean.class.getName(),
3481 Long.class.getName(), String.class.getName(),
3482
3483 Integer.class.getName(), Integer.class.getName(),
3484 OrderByComparator.class.getName()
3485 });
3486 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P =
3487 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
3488 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
3489 JournalContentSearchImpl.class,
3490 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_L_P",
3491 new String[] {
3492 Long.class.getName(), Boolean.class.getName(),
3493 Long.class.getName(), String.class.getName()
3494 },
3495 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
3496 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
3497 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK |
3498 JournalContentSearchModelImpl.PORTLETID_COLUMN_BITMASK);
3499 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
3500 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
3501 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L_P",
3502 new String[] {
3503 Long.class.getName(), Boolean.class.getName(),
3504 Long.class.getName(), String.class.getName()
3505 });
3506
3507
3517 @Override
3518 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3519 boolean privateLayout, long layoutId, String portletId)
3520 throws SystemException {
3521 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
3522 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3523 }
3524
3525
3541 @Override
3542 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3543 boolean privateLayout, long layoutId, String portletId, int start,
3544 int end) throws SystemException {
3545 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
3546 start, end, null);
3547 }
3548
3549
3566 @Override
3567 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3568 boolean privateLayout, long layoutId, String portletId, int start,
3569 int end, OrderByComparator orderByComparator) throws SystemException {
3570 boolean pagination = true;
3571 FinderPath finderPath = null;
3572 Object[] finderArgs = null;
3573
3574 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3575 (orderByComparator == null)) {
3576 pagination = false;
3577 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P;
3578 finderArgs = new Object[] {
3579 groupId, privateLayout, layoutId, portletId
3580 };
3581 }
3582 else {
3583 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L_P;
3584 finderArgs = new Object[] {
3585 groupId, privateLayout, layoutId, portletId,
3586
3587 start, end, orderByComparator
3588 };
3589 }
3590
3591 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
3592 finderArgs, this);
3593
3594 if ((list != null) && !list.isEmpty()) {
3595 for (JournalContentSearch journalContentSearch : list) {
3596 if ((groupId != journalContentSearch.getGroupId()) ||
3597 (privateLayout != journalContentSearch.getPrivateLayout()) ||
3598 (layoutId != journalContentSearch.getLayoutId()) ||
3599 !Validator.equals(portletId,
3600 journalContentSearch.getPortletId())) {
3601 list = null;
3602
3603 break;
3604 }
3605 }
3606 }
3607
3608 if (list == null) {
3609 StringBundler query = null;
3610
3611 if (orderByComparator != null) {
3612 query = new StringBundler(6 +
3613 (orderByComparator.getOrderByFields().length * 3));
3614 }
3615 else {
3616 query = new StringBundler(6);
3617 }
3618
3619 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3620
3621 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3622
3623 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3624
3625 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3626
3627 boolean bindPortletId = false;
3628
3629 if (portletId == null) {
3630 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3631 }
3632 else if (portletId.equals(StringPool.BLANK)) {
3633 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3634 }
3635 else {
3636 bindPortletId = true;
3637
3638 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3639 }
3640
3641 if (orderByComparator != null) {
3642 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3643 orderByComparator);
3644 }
3645 else
3646 if (pagination) {
3647 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
3648 }
3649
3650 String sql = query.toString();
3651
3652 Session session = null;
3653
3654 try {
3655 session = openSession();
3656
3657 Query q = session.createQuery(sql);
3658
3659 QueryPos qPos = QueryPos.getInstance(q);
3660
3661 qPos.add(groupId);
3662
3663 qPos.add(privateLayout);
3664
3665 qPos.add(layoutId);
3666
3667 if (bindPortletId) {
3668 qPos.add(portletId);
3669 }
3670
3671 if (!pagination) {
3672 list = (List<JournalContentSearch>)QueryUtil.list(q,
3673 getDialect(), start, end, false);
3674
3675 Collections.sort(list);
3676
3677 list = new UnmodifiableList<JournalContentSearch>(list);
3678 }
3679 else {
3680 list = (List<JournalContentSearch>)QueryUtil.list(q,
3681 getDialect(), start, end);
3682 }
3683
3684 cacheResult(list);
3685
3686 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3687 }
3688 catch (Exception e) {
3689 FinderCacheUtil.removeResult(finderPath, finderArgs);
3690
3691 throw processException(e);
3692 }
3693 finally {
3694 closeSession(session);
3695 }
3696 }
3697
3698 return list;
3699 }
3700
3701
3713 @Override
3714 public JournalContentSearch findByG_P_L_P_First(long groupId,
3715 boolean privateLayout, long layoutId, String portletId,
3716 OrderByComparator orderByComparator)
3717 throws NoSuchContentSearchException, SystemException {
3718 JournalContentSearch journalContentSearch = fetchByG_P_L_P_First(groupId,
3719 privateLayout, layoutId, portletId, orderByComparator);
3720
3721 if (journalContentSearch != null) {
3722 return journalContentSearch;
3723 }
3724
3725 StringBundler msg = new StringBundler(10);
3726
3727 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3728
3729 msg.append("groupId=");
3730 msg.append(groupId);
3731
3732 msg.append(", privateLayout=");
3733 msg.append(privateLayout);
3734
3735 msg.append(", layoutId=");
3736 msg.append(layoutId);
3737
3738 msg.append(", portletId=");
3739 msg.append(portletId);
3740
3741 msg.append(StringPool.CLOSE_CURLY_BRACE);
3742
3743 throw new NoSuchContentSearchException(msg.toString());
3744 }
3745
3746
3757 @Override
3758 public JournalContentSearch fetchByG_P_L_P_First(long groupId,
3759 boolean privateLayout, long layoutId, String portletId,
3760 OrderByComparator orderByComparator) throws SystemException {
3761 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
3762 layoutId, portletId, 0, 1, orderByComparator);
3763
3764 if (!list.isEmpty()) {
3765 return list.get(0);
3766 }
3767
3768 return null;
3769 }
3770
3771
3783 @Override
3784 public JournalContentSearch findByG_P_L_P_Last(long groupId,
3785 boolean privateLayout, long layoutId, String portletId,
3786 OrderByComparator orderByComparator)
3787 throws NoSuchContentSearchException, SystemException {
3788 JournalContentSearch journalContentSearch = fetchByG_P_L_P_Last(groupId,
3789 privateLayout, layoutId, portletId, orderByComparator);
3790
3791 if (journalContentSearch != null) {
3792 return journalContentSearch;
3793 }
3794
3795 StringBundler msg = new StringBundler(10);
3796
3797 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3798
3799 msg.append("groupId=");
3800 msg.append(groupId);
3801
3802 msg.append(", privateLayout=");
3803 msg.append(privateLayout);
3804
3805 msg.append(", layoutId=");
3806 msg.append(layoutId);
3807
3808 msg.append(", portletId=");
3809 msg.append(portletId);
3810
3811 msg.append(StringPool.CLOSE_CURLY_BRACE);
3812
3813 throw new NoSuchContentSearchException(msg.toString());
3814 }
3815
3816
3827 @Override
3828 public JournalContentSearch fetchByG_P_L_P_Last(long groupId,
3829 boolean privateLayout, long layoutId, String portletId,
3830 OrderByComparator orderByComparator) throws SystemException {
3831 int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
3832
3833 if (count == 0) {
3834 return null;
3835 }
3836
3837 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
3838 layoutId, portletId, count - 1, count, orderByComparator);
3839
3840 if (!list.isEmpty()) {
3841 return list.get(0);
3842 }
3843
3844 return null;
3845 }
3846
3847
3860 @Override
3861 public JournalContentSearch[] findByG_P_L_P_PrevAndNext(
3862 long contentSearchId, long groupId, boolean privateLayout,
3863 long layoutId, String portletId, OrderByComparator orderByComparator)
3864 throws NoSuchContentSearchException, SystemException {
3865 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
3866
3867 Session session = null;
3868
3869 try {
3870 session = openSession();
3871
3872 JournalContentSearch[] array = new JournalContentSearchImpl[3];
3873
3874 array[0] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
3875 groupId, privateLayout, layoutId, portletId,
3876 orderByComparator, true);
3877
3878 array[1] = journalContentSearch;
3879
3880 array[2] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
3881 groupId, privateLayout, layoutId, portletId,
3882 orderByComparator, false);
3883
3884 return array;
3885 }
3886 catch (Exception e) {
3887 throw processException(e);
3888 }
3889 finally {
3890 closeSession(session);
3891 }
3892 }
3893
3894 protected JournalContentSearch getByG_P_L_P_PrevAndNext(Session session,
3895 JournalContentSearch journalContentSearch, long groupId,
3896 boolean privateLayout, long layoutId, String portletId,
3897 OrderByComparator orderByComparator, boolean previous) {
3898 StringBundler query = null;
3899
3900 if (orderByComparator != null) {
3901 query = new StringBundler(6 +
3902 (orderByComparator.getOrderByFields().length * 6));
3903 }
3904 else {
3905 query = new StringBundler(3);
3906 }
3907
3908 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3909
3910 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3911
3912 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3913
3914 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3915
3916 boolean bindPortletId = false;
3917
3918 if (portletId == null) {
3919 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3920 }
3921 else if (portletId.equals(StringPool.BLANK)) {
3922 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3923 }
3924 else {
3925 bindPortletId = true;
3926
3927 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3928 }
3929
3930 if (orderByComparator != null) {
3931 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3932
3933 if (orderByConditionFields.length > 0) {
3934 query.append(WHERE_AND);
3935 }
3936
3937 for (int i = 0; i < orderByConditionFields.length; i++) {
3938 query.append(_ORDER_BY_ENTITY_ALIAS);
3939 query.append(orderByConditionFields[i]);
3940
3941 if ((i + 1) < orderByConditionFields.length) {
3942 if (orderByComparator.isAscending() ^ previous) {
3943 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3944 }
3945 else {
3946 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3947 }
3948 }
3949 else {
3950 if (orderByComparator.isAscending() ^ previous) {
3951 query.append(WHERE_GREATER_THAN);
3952 }
3953 else {
3954 query.append(WHERE_LESSER_THAN);
3955 }
3956 }
3957 }
3958
3959 query.append(ORDER_BY_CLAUSE);
3960
3961 String[] orderByFields = orderByComparator.getOrderByFields();
3962
3963 for (int i = 0; i < orderByFields.length; i++) {
3964 query.append(_ORDER_BY_ENTITY_ALIAS);
3965 query.append(orderByFields[i]);
3966
3967 if ((i + 1) < orderByFields.length) {
3968 if (orderByComparator.isAscending() ^ previous) {
3969 query.append(ORDER_BY_ASC_HAS_NEXT);
3970 }
3971 else {
3972 query.append(ORDER_BY_DESC_HAS_NEXT);
3973 }
3974 }
3975 else {
3976 if (orderByComparator.isAscending() ^ previous) {
3977 query.append(ORDER_BY_ASC);
3978 }
3979 else {
3980 query.append(ORDER_BY_DESC);
3981 }
3982 }
3983 }
3984 }
3985 else {
3986 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
3987 }
3988
3989 String sql = query.toString();
3990
3991 Query q = session.createQuery(sql);
3992
3993 q.setFirstResult(0);
3994 q.setMaxResults(2);
3995
3996 QueryPos qPos = QueryPos.getInstance(q);
3997
3998 qPos.add(groupId);
3999
4000 qPos.add(privateLayout);
4001
4002 qPos.add(layoutId);
4003
4004 if (bindPortletId) {
4005 qPos.add(portletId);
4006 }
4007
4008 if (orderByComparator != null) {
4009 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
4010
4011 for (Object value : values) {
4012 qPos.add(value);
4013 }
4014 }
4015
4016 List<JournalContentSearch> list = q.list();
4017
4018 if (list.size() == 2) {
4019 return list.get(1);
4020 }
4021 else {
4022 return null;
4023 }
4024 }
4025
4026
4035 @Override
4036 public void removeByG_P_L_P(long groupId, boolean privateLayout,
4037 long layoutId, String portletId) throws SystemException {
4038 for (JournalContentSearch journalContentSearch : findByG_P_L_P(
4039 groupId, privateLayout, layoutId, portletId, QueryUtil.ALL_POS,
4040 QueryUtil.ALL_POS, null)) {
4041 remove(journalContentSearch);
4042 }
4043 }
4044
4045
4055 @Override
4056 public int countByG_P_L_P(long groupId, boolean privateLayout,
4057 long layoutId, String portletId) throws SystemException {
4058 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_L_P;
4059
4060 Object[] finderArgs = new Object[] {
4061 groupId, privateLayout, layoutId, portletId
4062 };
4063
4064 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4065 this);
4066
4067 if (count == null) {
4068 StringBundler query = new StringBundler(5);
4069
4070 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4071
4072 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
4073
4074 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
4075
4076 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
4077
4078 boolean bindPortletId = false;
4079
4080 if (portletId == null) {
4081 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
4082 }
4083 else if (portletId.equals(StringPool.BLANK)) {
4084 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
4085 }
4086 else {
4087 bindPortletId = true;
4088
4089 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
4090 }
4091
4092 String sql = query.toString();
4093
4094 Session session = null;
4095
4096 try {
4097 session = openSession();
4098
4099 Query q = session.createQuery(sql);
4100
4101 QueryPos qPos = QueryPos.getInstance(q);
4102
4103 qPos.add(groupId);
4104
4105 qPos.add(privateLayout);
4106
4107 qPos.add(layoutId);
4108
4109 if (bindPortletId) {
4110 qPos.add(portletId);
4111 }
4112
4113 count = (Long)q.uniqueResult();
4114
4115 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4116 }
4117 catch (Exception e) {
4118 FinderCacheUtil.removeResult(finderPath, finderArgs);
4119
4120 throw processException(e);
4121 }
4122 finally {
4123 closeSession(session);
4124 }
4125 }
4126
4127 return count.intValue();
4128 }
4129
4130 private static final String _FINDER_COLUMN_G_P_L_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4131 private static final String _FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4132 private static final String _FINDER_COLUMN_G_P_L_P_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
4133 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
4134 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_2 = "journalContentSearch.portletId = ?";
4135 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = '')";
4136 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4137 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
4138 JournalContentSearchImpl.class, FINDER_CLASS_NAME_ENTITY,
4139 "fetchByG_P_L_P_A",
4140 new String[] {
4141 Long.class.getName(), Boolean.class.getName(),
4142 Long.class.getName(), String.class.getName(),
4143 String.class.getName()
4144 },
4145 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
4146 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
4147 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK |
4148 JournalContentSearchModelImpl.PORTLETID_COLUMN_BITMASK |
4149 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
4150 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4151 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
4152 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L_P_A",
4153 new String[] {
4154 Long.class.getName(), Boolean.class.getName(),
4155 Long.class.getName(), String.class.getName(),
4156 String.class.getName()
4157 });
4158
4159
4171 @Override
4172 public JournalContentSearch findByG_P_L_P_A(long groupId,
4173 boolean privateLayout, long layoutId, String portletId, String articleId)
4174 throws NoSuchContentSearchException, SystemException {
4175 JournalContentSearch journalContentSearch = fetchByG_P_L_P_A(groupId,
4176 privateLayout, layoutId, portletId, articleId);
4177
4178 if (journalContentSearch == null) {
4179 StringBundler msg = new StringBundler(12);
4180
4181 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4182
4183 msg.append("groupId=");
4184 msg.append(groupId);
4185
4186 msg.append(", privateLayout=");
4187 msg.append(privateLayout);
4188
4189 msg.append(", layoutId=");
4190 msg.append(layoutId);
4191
4192 msg.append(", portletId=");
4193 msg.append(portletId);
4194
4195 msg.append(", articleId=");
4196 msg.append(articleId);
4197
4198 msg.append(StringPool.CLOSE_CURLY_BRACE);
4199
4200 if (_log.isWarnEnabled()) {
4201 _log.warn(msg.toString());
4202 }
4203
4204 throw new NoSuchContentSearchException(msg.toString());
4205 }
4206
4207 return journalContentSearch;
4208 }
4209
4210
4221 @Override
4222 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
4223 boolean privateLayout, long layoutId, String portletId, String articleId)
4224 throws SystemException {
4225 return fetchByG_P_L_P_A(groupId, privateLayout, layoutId, portletId,
4226 articleId, true);
4227 }
4228
4229
4241 @Override
4242 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
4243 boolean privateLayout, long layoutId, String portletId,
4244 String articleId, boolean retrieveFromCache) throws SystemException {
4245 Object[] finderArgs = new Object[] {
4246 groupId, privateLayout, layoutId, portletId, articleId
4247 };
4248
4249 Object result = null;
4250
4251 if (retrieveFromCache) {
4252 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4253 finderArgs, this);
4254 }
4255
4256 if (result instanceof JournalContentSearch) {
4257 JournalContentSearch journalContentSearch = (JournalContentSearch)result;
4258
4259 if ((groupId != journalContentSearch.getGroupId()) ||
4260 (privateLayout != journalContentSearch.getPrivateLayout()) ||
4261 (layoutId != journalContentSearch.getLayoutId()) ||
4262 !Validator.equals(portletId,
4263 journalContentSearch.getPortletId()) ||
4264 !Validator.equals(articleId,
4265 journalContentSearch.getArticleId())) {
4266 result = null;
4267 }
4268 }
4269
4270 if (result == null) {
4271 StringBundler query = new StringBundler(7);
4272
4273 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
4274
4275 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
4276
4277 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
4278
4279 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
4280
4281 boolean bindPortletId = false;
4282
4283 if (portletId == null) {
4284 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
4285 }
4286 else if (portletId.equals(StringPool.BLANK)) {
4287 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
4288 }
4289 else {
4290 bindPortletId = true;
4291
4292 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
4293 }
4294
4295 boolean bindArticleId = false;
4296
4297 if (articleId == null) {
4298 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
4299 }
4300 else if (articleId.equals(StringPool.BLANK)) {
4301 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
4302 }
4303 else {
4304 bindArticleId = true;
4305
4306 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
4307 }
4308
4309 String sql = query.toString();
4310
4311 Session session = null;
4312
4313 try {
4314 session = openSession();
4315
4316 Query q = session.createQuery(sql);
4317
4318 QueryPos qPos = QueryPos.getInstance(q);
4319
4320 qPos.add(groupId);
4321
4322 qPos.add(privateLayout);
4323
4324 qPos.add(layoutId);
4325
4326 if (bindPortletId) {
4327 qPos.add(portletId);
4328 }
4329
4330 if (bindArticleId) {
4331 qPos.add(articleId);
4332 }
4333
4334 List<JournalContentSearch> list = q.list();
4335
4336 if (list.isEmpty()) {
4337 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4338 finderArgs, list);
4339 }
4340 else {
4341 JournalContentSearch journalContentSearch = list.get(0);
4342
4343 result = journalContentSearch;
4344
4345 cacheResult(journalContentSearch);
4346
4347 if ((journalContentSearch.getGroupId() != groupId) ||
4348 (journalContentSearch.getPrivateLayout() != privateLayout) ||
4349 (journalContentSearch.getLayoutId() != layoutId) ||
4350 (journalContentSearch.getPortletId() == null) ||
4351 !journalContentSearch.getPortletId()
4352 .equals(portletId) ||
4353 (journalContentSearch.getArticleId() == null) ||
4354 !journalContentSearch.getArticleId()
4355 .equals(articleId)) {
4356 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4357 finderArgs, journalContentSearch);
4358 }
4359 }
4360 }
4361 catch (Exception e) {
4362 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4363 finderArgs);
4364
4365 throw processException(e);
4366 }
4367 finally {
4368 closeSession(session);
4369 }
4370 }
4371
4372 if (result instanceof List<?>) {
4373 return null;
4374 }
4375 else {
4376 return (JournalContentSearch)result;
4377 }
4378 }
4379
4380
4391 @Override
4392 public JournalContentSearch removeByG_P_L_P_A(long groupId,
4393 boolean privateLayout, long layoutId, String portletId, String articleId)
4394 throws NoSuchContentSearchException, SystemException {
4395 JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
4396 privateLayout, layoutId, portletId, articleId);
4397
4398 return remove(journalContentSearch);
4399 }
4400
4401
4412 @Override
4413 public int countByG_P_L_P_A(long groupId, boolean privateLayout,
4414 long layoutId, String portletId, String articleId)
4415 throws SystemException {
4416 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_L_P_A;
4417
4418 Object[] finderArgs = new Object[] {
4419 groupId, privateLayout, layoutId, portletId, articleId
4420 };
4421
4422 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4423 this);
4424
4425 if (count == null) {
4426 StringBundler query = new StringBundler(6);
4427
4428 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4429
4430 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
4431
4432 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
4433
4434 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
4435
4436 boolean bindPortletId = false;
4437
4438 if (portletId == null) {
4439 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
4440 }
4441 else if (portletId.equals(StringPool.BLANK)) {
4442 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
4443 }
4444 else {
4445 bindPortletId = true;
4446
4447 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
4448 }
4449
4450 boolean bindArticleId = false;
4451
4452 if (articleId == null) {
4453 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
4454 }
4455 else if (articleId.equals(StringPool.BLANK)) {
4456 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
4457 }
4458 else {
4459 bindArticleId = true;
4460
4461 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
4462 }
4463
4464 String sql = query.toString();
4465
4466 Session session = null;
4467
4468 try {
4469 session = openSession();
4470
4471 Query q = session.createQuery(sql);
4472
4473 QueryPos qPos = QueryPos.getInstance(q);
4474
4475 qPos.add(groupId);
4476
4477 qPos.add(privateLayout);
4478
4479 qPos.add(layoutId);
4480
4481 if (bindPortletId) {
4482 qPos.add(portletId);
4483 }
4484
4485 if (bindArticleId) {
4486 qPos.add(articleId);
4487 }
4488
4489 count = (Long)q.uniqueResult();
4490
4491 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4492 }
4493 catch (Exception e) {
4494 FinderCacheUtil.removeResult(finderPath, finderArgs);
4495
4496 throw processException(e);
4497 }
4498 finally {
4499 closeSession(session);
4500 }
4501 }
4502
4503 return count.intValue();
4504 }
4505
4506 private static final String _FINDER_COLUMN_G_P_L_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4507 private static final String _FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4508 private static final String _FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
4509 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_1 = "journalContentSearch.portletId IS NULL AND ";
4510 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_2 = "journalContentSearch.portletId = ? AND ";
4511 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = '') AND ";
4512 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4513 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4514 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = '')";
4515
4516 public JournalContentSearchPersistenceImpl() {
4517 setModelClass(JournalContentSearch.class);
4518 }
4519
4520
4525 @Override
4526 public void cacheResult(JournalContentSearch journalContentSearch) {
4527 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4528 JournalContentSearchImpl.class,
4529 journalContentSearch.getPrimaryKey(), journalContentSearch);
4530
4531 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4532 new Object[] {
4533 journalContentSearch.getGroupId(),
4534 journalContentSearch.getPrivateLayout(),
4535 journalContentSearch.getLayoutId(),
4536 journalContentSearch.getPortletId(),
4537 journalContentSearch.getArticleId()
4538 }, journalContentSearch);
4539
4540 journalContentSearch.resetOriginalValues();
4541 }
4542
4543
4548 @Override
4549 public void cacheResult(List<JournalContentSearch> journalContentSearchs) {
4550 for (JournalContentSearch journalContentSearch : journalContentSearchs) {
4551 if (EntityCacheUtil.getResult(
4552 JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4553 JournalContentSearchImpl.class,
4554 journalContentSearch.getPrimaryKey()) == null) {
4555 cacheResult(journalContentSearch);
4556 }
4557 else {
4558 journalContentSearch.resetOriginalValues();
4559 }
4560 }
4561 }
4562
4563
4570 @Override
4571 public void clearCache() {
4572 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
4573 CacheRegistryUtil.clear(JournalContentSearchImpl.class.getName());
4574 }
4575
4576 EntityCacheUtil.clearCache(JournalContentSearchImpl.class.getName());
4577
4578 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4579 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4580 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4581 }
4582
4583
4590 @Override
4591 public void clearCache(JournalContentSearch journalContentSearch) {
4592 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4593 JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
4594
4595 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4596 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4597
4598 clearUniqueFindersCache(journalContentSearch);
4599 }
4600
4601 @Override
4602 public void clearCache(List<JournalContentSearch> journalContentSearchs) {
4603 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4604 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4605
4606 for (JournalContentSearch journalContentSearch : journalContentSearchs) {
4607 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4608 JournalContentSearchImpl.class,
4609 journalContentSearch.getPrimaryKey());
4610
4611 clearUniqueFindersCache(journalContentSearch);
4612 }
4613 }
4614
4615 protected void cacheUniqueFindersCache(
4616 JournalContentSearch journalContentSearch) {
4617 if (journalContentSearch.isNew()) {
4618 Object[] args = new Object[] {
4619 journalContentSearch.getGroupId(),
4620 journalContentSearch.getPrivateLayout(),
4621 journalContentSearch.getLayoutId(),
4622 journalContentSearch.getPortletId(),
4623 journalContentSearch.getArticleId()
4624 };
4625
4626 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args,
4627 Long.valueOf(1));
4628 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args,
4629 journalContentSearch);
4630 }
4631 else {
4632 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
4633
4634 if ((journalContentSearchModelImpl.getColumnBitmask() &
4635 FINDER_PATH_FETCH_BY_G_P_L_P_A.getColumnBitmask()) != 0) {
4636 Object[] args = new Object[] {
4637 journalContentSearch.getGroupId(),
4638 journalContentSearch.getPrivateLayout(),
4639 journalContentSearch.getLayoutId(),
4640 journalContentSearch.getPortletId(),
4641 journalContentSearch.getArticleId()
4642 };
4643
4644 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args,
4645 Long.valueOf(1));
4646 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args,
4647 journalContentSearch);
4648 }
4649 }
4650 }
4651
4652 protected void clearUniqueFindersCache(
4653 JournalContentSearch journalContentSearch) {
4654 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
4655
4656 Object[] args = new Object[] {
4657 journalContentSearch.getGroupId(),
4658 journalContentSearch.getPrivateLayout(),
4659 journalContentSearch.getLayoutId(),
4660 journalContentSearch.getPortletId(),
4661 journalContentSearch.getArticleId()
4662 };
4663
4664 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args);
4665 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args);
4666
4667 if ((journalContentSearchModelImpl.getColumnBitmask() &
4668 FINDER_PATH_FETCH_BY_G_P_L_P_A.getColumnBitmask()) != 0) {
4669 args = new Object[] {
4670 journalContentSearchModelImpl.getOriginalGroupId(),
4671 journalContentSearchModelImpl.getOriginalPrivateLayout(),
4672 journalContentSearchModelImpl.getOriginalLayoutId(),
4673 journalContentSearchModelImpl.getOriginalPortletId(),
4674 journalContentSearchModelImpl.getOriginalArticleId()
4675 };
4676
4677 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args);
4678 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args);
4679 }
4680 }
4681
4682
4688 @Override
4689 public JournalContentSearch create(long contentSearchId) {
4690 JournalContentSearch journalContentSearch = new JournalContentSearchImpl();
4691
4692 journalContentSearch.setNew(true);
4693 journalContentSearch.setPrimaryKey(contentSearchId);
4694
4695 return journalContentSearch;
4696 }
4697
4698
4706 @Override
4707 public JournalContentSearch remove(long contentSearchId)
4708 throws NoSuchContentSearchException, SystemException {
4709 return remove((Serializable)contentSearchId);
4710 }
4711
4712
4720 @Override
4721 public JournalContentSearch remove(Serializable primaryKey)
4722 throws NoSuchContentSearchException, SystemException {
4723 Session session = null;
4724
4725 try {
4726 session = openSession();
4727
4728 JournalContentSearch journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
4729 primaryKey);
4730
4731 if (journalContentSearch == null) {
4732 if (_log.isWarnEnabled()) {
4733 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4734 }
4735
4736 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4737 primaryKey);
4738 }
4739
4740 return remove(journalContentSearch);
4741 }
4742 catch (NoSuchContentSearchException nsee) {
4743 throw nsee;
4744 }
4745 catch (Exception e) {
4746 throw processException(e);
4747 }
4748 finally {
4749 closeSession(session);
4750 }
4751 }
4752
4753 @Override
4754 protected JournalContentSearch removeImpl(
4755 JournalContentSearch journalContentSearch) throws SystemException {
4756 journalContentSearch = toUnwrappedModel(journalContentSearch);
4757
4758 Session session = null;
4759
4760 try {
4761 session = openSession();
4762
4763 if (!session.contains(journalContentSearch)) {
4764 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
4765 journalContentSearch.getPrimaryKeyObj());
4766 }
4767
4768 if (journalContentSearch != null) {
4769 session.delete(journalContentSearch);
4770 }
4771 }
4772 catch (Exception e) {
4773 throw processException(e);
4774 }
4775 finally {
4776 closeSession(session);
4777 }
4778
4779 if (journalContentSearch != null) {
4780 clearCache(journalContentSearch);
4781 }
4782
4783 return journalContentSearch;
4784 }
4785
4786 @Override
4787 public JournalContentSearch updateImpl(
4788 com.liferay.portlet.journal.model.JournalContentSearch journalContentSearch)
4789 throws SystemException {
4790 journalContentSearch = toUnwrappedModel(journalContentSearch);
4791
4792 boolean isNew = journalContentSearch.isNew();
4793
4794 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
4795
4796 Session session = null;
4797
4798 try {
4799 session = openSession();
4800
4801 if (journalContentSearch.isNew()) {
4802 session.save(journalContentSearch);
4803
4804 journalContentSearch.setNew(false);
4805 }
4806 else {
4807 session.merge(journalContentSearch);
4808 }
4809 }
4810 catch (Exception e) {
4811 throw processException(e);
4812 }
4813 finally {
4814 closeSession(session);
4815 }
4816
4817 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4818
4819 if (isNew || !JournalContentSearchModelImpl.COLUMN_BITMASK_ENABLED) {
4820 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4821 }
4822
4823 else {
4824 if ((journalContentSearchModelImpl.getColumnBitmask() &
4825 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID.getColumnBitmask()) != 0) {
4826 Object[] args = new Object[] {
4827 journalContentSearchModelImpl.getOriginalPortletId()
4828 };
4829
4830 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTLETID,
4831 args);
4832 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID,
4833 args);
4834
4835 args = new Object[] { journalContentSearchModelImpl.getPortletId() };
4836
4837 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTLETID,
4838 args);
4839 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID,
4840 args);
4841 }
4842
4843 if ((journalContentSearchModelImpl.getColumnBitmask() &
4844 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID.getColumnBitmask()) != 0) {
4845 Object[] args = new Object[] {
4846 journalContentSearchModelImpl.getOriginalArticleId()
4847 };
4848
4849 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ARTICLEID,
4850 args);
4851 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID,
4852 args);
4853
4854 args = new Object[] { journalContentSearchModelImpl.getArticleId() };
4855
4856 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ARTICLEID,
4857 args);
4858 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID,
4859 args);
4860 }
4861
4862 if ((journalContentSearchModelImpl.getColumnBitmask() &
4863 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
4864 Object[] args = new Object[] {
4865 journalContentSearchModelImpl.getOriginalGroupId(),
4866 journalContentSearchModelImpl.getOriginalPrivateLayout()
4867 };
4868
4869 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
4870 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
4871 args);
4872
4873 args = new Object[] {
4874 journalContentSearchModelImpl.getGroupId(),
4875 journalContentSearchModelImpl.getPrivateLayout()
4876 };
4877
4878 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
4879 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
4880 args);
4881 }
4882
4883 if ((journalContentSearchModelImpl.getColumnBitmask() &
4884 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
4885 Object[] args = new Object[] {
4886 journalContentSearchModelImpl.getOriginalGroupId(),
4887 journalContentSearchModelImpl.getOriginalArticleId()
4888 };
4889
4890 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
4891 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
4892 args);
4893
4894 args = new Object[] {
4895 journalContentSearchModelImpl.getGroupId(),
4896 journalContentSearchModelImpl.getArticleId()
4897 };
4898
4899 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
4900 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
4901 args);
4902 }
4903
4904 if ((journalContentSearchModelImpl.getColumnBitmask() &
4905 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L.getColumnBitmask()) != 0) {
4906 Object[] args = new Object[] {
4907 journalContentSearchModelImpl.getOriginalGroupId(),
4908 journalContentSearchModelImpl.getOriginalPrivateLayout(),
4909 journalContentSearchModelImpl.getOriginalLayoutId()
4910 };
4911
4912 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L, args);
4913 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L,
4914 args);
4915
4916 args = new Object[] {
4917 journalContentSearchModelImpl.getGroupId(),
4918 journalContentSearchModelImpl.getPrivateLayout(),
4919 journalContentSearchModelImpl.getLayoutId()
4920 };
4921
4922 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L, args);
4923 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L,
4924 args);
4925 }
4926
4927 if ((journalContentSearchModelImpl.getColumnBitmask() &
4928 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A.getColumnBitmask()) != 0) {
4929 Object[] args = new Object[] {
4930 journalContentSearchModelImpl.getOriginalGroupId(),
4931 journalContentSearchModelImpl.getOriginalPrivateLayout(),
4932 journalContentSearchModelImpl.getOriginalArticleId()
4933 };
4934
4935 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_A, args);
4936 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A,
4937 args);
4938
4939 args = new Object[] {
4940 journalContentSearchModelImpl.getGroupId(),
4941 journalContentSearchModelImpl.getPrivateLayout(),
4942 journalContentSearchModelImpl.getArticleId()
4943 };
4944
4945 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_A, args);
4946 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A,
4947 args);
4948 }
4949
4950 if ((journalContentSearchModelImpl.getColumnBitmask() &
4951 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P.getColumnBitmask()) != 0) {
4952 Object[] args = new Object[] {
4953 journalContentSearchModelImpl.getOriginalGroupId(),
4954 journalContentSearchModelImpl.getOriginalPrivateLayout(),
4955 journalContentSearchModelImpl.getOriginalLayoutId(),
4956 journalContentSearchModelImpl.getOriginalPortletId()
4957 };
4958
4959 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P, args);
4960 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P,
4961 args);
4962
4963 args = new Object[] {
4964 journalContentSearchModelImpl.getGroupId(),
4965 journalContentSearchModelImpl.getPrivateLayout(),
4966 journalContentSearchModelImpl.getLayoutId(),
4967 journalContentSearchModelImpl.getPortletId()
4968 };
4969
4970 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P, args);
4971 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P,
4972 args);
4973 }
4974 }
4975
4976 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4977 JournalContentSearchImpl.class,
4978 journalContentSearch.getPrimaryKey(), journalContentSearch);
4979
4980 clearUniqueFindersCache(journalContentSearch);
4981 cacheUniqueFindersCache(journalContentSearch);
4982
4983 return journalContentSearch;
4984 }
4985
4986 protected JournalContentSearch toUnwrappedModel(
4987 JournalContentSearch journalContentSearch) {
4988 if (journalContentSearch instanceof JournalContentSearchImpl) {
4989 return journalContentSearch;
4990 }
4991
4992 JournalContentSearchImpl journalContentSearchImpl = new JournalContentSearchImpl();
4993
4994 journalContentSearchImpl.setNew(journalContentSearch.isNew());
4995 journalContentSearchImpl.setPrimaryKey(journalContentSearch.getPrimaryKey());
4996
4997 journalContentSearchImpl.setContentSearchId(journalContentSearch.getContentSearchId());
4998 journalContentSearchImpl.setGroupId(journalContentSearch.getGroupId());
4999 journalContentSearchImpl.setCompanyId(journalContentSearch.getCompanyId());
5000 journalContentSearchImpl.setPrivateLayout(journalContentSearch.isPrivateLayout());
5001 journalContentSearchImpl.setLayoutId(journalContentSearch.getLayoutId());
5002 journalContentSearchImpl.setPortletId(journalContentSearch.getPortletId());
5003 journalContentSearchImpl.setArticleId(journalContentSearch.getArticleId());
5004
5005 return journalContentSearchImpl;
5006 }
5007
5008
5016 @Override
5017 public JournalContentSearch findByPrimaryKey(Serializable primaryKey)
5018 throws NoSuchContentSearchException, SystemException {
5019 JournalContentSearch journalContentSearch = fetchByPrimaryKey(primaryKey);
5020
5021 if (journalContentSearch == null) {
5022 if (_log.isWarnEnabled()) {
5023 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5024 }
5025
5026 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5027 primaryKey);
5028 }
5029
5030 return journalContentSearch;
5031 }
5032
5033
5041 @Override
5042 public JournalContentSearch findByPrimaryKey(long contentSearchId)
5043 throws NoSuchContentSearchException, SystemException {
5044 return findByPrimaryKey((Serializable)contentSearchId);
5045 }
5046
5047
5054 @Override
5055 public JournalContentSearch fetchByPrimaryKey(Serializable primaryKey)
5056 throws SystemException {
5057 JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
5058 JournalContentSearchImpl.class, primaryKey);
5059
5060 if (journalContentSearch == _nullJournalContentSearch) {
5061 return null;
5062 }
5063
5064 if (journalContentSearch == null) {
5065 Session session = null;
5066
5067 try {
5068 session = openSession();
5069
5070 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
5071 primaryKey);
5072
5073 if (journalContentSearch != null) {
5074 cacheResult(journalContentSearch);
5075 }
5076 else {
5077 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
5078 JournalContentSearchImpl.class, primaryKey,
5079 _nullJournalContentSearch);
5080 }
5081 }
5082 catch (Exception e) {
5083 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
5084 JournalContentSearchImpl.class, primaryKey);
5085
5086 throw processException(e);
5087 }
5088 finally {
5089 closeSession(session);
5090 }
5091 }
5092
5093 return journalContentSearch;
5094 }
5095
5096
5103 @Override
5104 public JournalContentSearch fetchByPrimaryKey(long contentSearchId)
5105 throws SystemException {
5106 return fetchByPrimaryKey((Serializable)contentSearchId);
5107 }
5108
5109
5115 @Override
5116 public List<JournalContentSearch> findAll() throws SystemException {
5117 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5118 }
5119
5120
5132 @Override
5133 public List<JournalContentSearch> findAll(int start, int end)
5134 throws SystemException {
5135 return findAll(start, end, null);
5136 }
5137
5138
5151 @Override
5152 public List<JournalContentSearch> findAll(int start, int end,
5153 OrderByComparator orderByComparator) throws SystemException {
5154 boolean pagination = true;
5155 FinderPath finderPath = null;
5156 Object[] finderArgs = null;
5157
5158 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5159 (orderByComparator == null)) {
5160 pagination = false;
5161 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5162 finderArgs = FINDER_ARGS_EMPTY;
5163 }
5164 else {
5165 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5166 finderArgs = new Object[] { start, end, orderByComparator };
5167 }
5168
5169 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
5170 finderArgs, this);
5171
5172 if (list == null) {
5173 StringBundler query = null;
5174 String sql = null;
5175
5176 if (orderByComparator != null) {
5177 query = new StringBundler(2 +
5178 (orderByComparator.getOrderByFields().length * 3));
5179
5180 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH);
5181
5182 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5183 orderByComparator);
5184
5185 sql = query.toString();
5186 }
5187 else {
5188 sql = _SQL_SELECT_JOURNALCONTENTSEARCH;
5189
5190 if (pagination) {
5191 sql = sql.concat(JournalContentSearchModelImpl.ORDER_BY_JPQL);
5192 }
5193 }
5194
5195 Session session = null;
5196
5197 try {
5198 session = openSession();
5199
5200 Query q = session.createQuery(sql);
5201
5202 if (!pagination) {
5203 list = (List<JournalContentSearch>)QueryUtil.list(q,
5204 getDialect(), start, end, false);
5205
5206 Collections.sort(list);
5207
5208 list = new UnmodifiableList<JournalContentSearch>(list);
5209 }
5210 else {
5211 list = (List<JournalContentSearch>)QueryUtil.list(q,
5212 getDialect(), start, end);
5213 }
5214
5215 cacheResult(list);
5216
5217 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5218 }
5219 catch (Exception e) {
5220 FinderCacheUtil.removeResult(finderPath, finderArgs);
5221
5222 throw processException(e);
5223 }
5224 finally {
5225 closeSession(session);
5226 }
5227 }
5228
5229 return list;
5230 }
5231
5232
5237 @Override
5238 public void removeAll() throws SystemException {
5239 for (JournalContentSearch journalContentSearch : findAll()) {
5240 remove(journalContentSearch);
5241 }
5242 }
5243
5244
5250 @Override
5251 public int countAll() throws SystemException {
5252 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5253 FINDER_ARGS_EMPTY, this);
5254
5255 if (count == null) {
5256 Session session = null;
5257
5258 try {
5259 session = openSession();
5260
5261 Query q = session.createQuery(_SQL_COUNT_JOURNALCONTENTSEARCH);
5262
5263 count = (Long)q.uniqueResult();
5264
5265 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5266 FINDER_ARGS_EMPTY, count);
5267 }
5268 catch (Exception e) {
5269 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5270 FINDER_ARGS_EMPTY);
5271
5272 throw processException(e);
5273 }
5274 finally {
5275 closeSession(session);
5276 }
5277 }
5278
5279 return count.intValue();
5280 }
5281
5282
5285 public void afterPropertiesSet() {
5286 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5287 com.liferay.portal.util.PropsUtil.get(
5288 "value.object.listener.com.liferay.portlet.journal.model.JournalContentSearch")));
5289
5290 if (listenerClassNames.length > 0) {
5291 try {
5292 List<ModelListener<JournalContentSearch>> listenersList = new ArrayList<ModelListener<JournalContentSearch>>();
5293
5294 for (String listenerClassName : listenerClassNames) {
5295 listenersList.add((ModelListener<JournalContentSearch>)InstanceFactory.newInstance(
5296 getClassLoader(), listenerClassName));
5297 }
5298
5299 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5300 }
5301 catch (Exception e) {
5302 _log.error(e);
5303 }
5304 }
5305 }
5306
5307 public void destroy() {
5308 EntityCacheUtil.removeCache(JournalContentSearchImpl.class.getName());
5309 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5310 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5311 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5312 }
5313
5314 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch";
5315 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE ";
5316 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch";
5317 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH_WHERE = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch WHERE ";
5318 private static final String _ORDER_BY_ENTITY_ALIAS = "journalContentSearch.";
5319 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalContentSearch exists with the primary key ";
5320 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalContentSearch exists with the key {";
5321 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5322 private static Log _log = LogFactoryUtil.getLog(JournalContentSearchPersistenceImpl.class);
5323 private static JournalContentSearch _nullJournalContentSearch = new JournalContentSearchImpl() {
5324 @Override
5325 public Object clone() {
5326 return this;
5327 }
5328
5329 @Override
5330 public CacheModel<JournalContentSearch> toCacheModel() {
5331 return _nullJournalContentSearchCacheModel;
5332 }
5333 };
5334
5335 private static CacheModel<JournalContentSearch> _nullJournalContentSearchCacheModel =
5336 new CacheModel<JournalContentSearch>() {
5337 @Override
5338 public JournalContentSearch toEntityModel() {
5339 return _nullJournalContentSearch;
5340 }
5341 };
5342 }