001
014
015 package com.liferay.portlet.journal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.log.Log;
027 import com.liferay.portal.kernel.log.LogFactoryUtil;
028 import com.liferay.portal.kernel.util.OrderByComparator;
029 import com.liferay.portal.kernel.util.StringBundler;
030 import com.liferay.portal.kernel.util.StringPool;
031 import com.liferay.portal.kernel.util.Validator;
032 import com.liferay.portal.model.CacheModel;
033 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
034
035 import com.liferay.portlet.journal.NoSuchContentSearchException;
036 import com.liferay.portlet.journal.model.JournalContentSearch;
037 import com.liferay.portlet.journal.model.impl.JournalContentSearchImpl;
038 import com.liferay.portlet.journal.model.impl.JournalContentSearchModelImpl;
039 import com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence;
040
041 import java.io.Serializable;
042
043 import java.util.Collections;
044 import java.util.HashMap;
045 import java.util.HashSet;
046 import java.util.Iterator;
047 import java.util.List;
048 import java.util.Map;
049 import java.util.Set;
050
051
063 @ProviderType
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
116 @Override
117 public List<JournalContentSearch> findByPortletId(String portletId) {
118 return findByPortletId(portletId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
119 null);
120 }
121
122
134 @Override
135 public List<JournalContentSearch> findByPortletId(String portletId,
136 int start, int end) {
137 return findByPortletId(portletId, start, end, null);
138 }
139
140
153 @Override
154 public List<JournalContentSearch> findByPortletId(String portletId,
155 int start, int end,
156 OrderByComparator<JournalContentSearch> orderByComparator) {
157 boolean pagination = true;
158 FinderPath finderPath = null;
159 Object[] finderArgs = null;
160
161 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
162 (orderByComparator == null)) {
163 pagination = false;
164 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID;
165 finderArgs = new Object[] { portletId };
166 }
167 else {
168 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PORTLETID;
169 finderArgs = new Object[] { portletId, start, end, orderByComparator };
170 }
171
172 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
173 finderArgs, this);
174
175 if ((list != null) && !list.isEmpty()) {
176 for (JournalContentSearch journalContentSearch : list) {
177 if (!Validator.equals(portletId,
178 journalContentSearch.getPortletId())) {
179 list = null;
180
181 break;
182 }
183 }
184 }
185
186 if (list == null) {
187 StringBundler query = null;
188
189 if (orderByComparator != null) {
190 query = new StringBundler(3 +
191 (orderByComparator.getOrderByFields().length * 3));
192 }
193 else {
194 query = new StringBundler(3);
195 }
196
197 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
198
199 boolean bindPortletId = false;
200
201 if (portletId == null) {
202 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
203 }
204 else if (portletId.equals(StringPool.BLANK)) {
205 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
206 }
207 else {
208 bindPortletId = true;
209
210 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
211 }
212
213 if (orderByComparator != null) {
214 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
215 orderByComparator);
216 }
217 else
218 if (pagination) {
219 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
220 }
221
222 String sql = query.toString();
223
224 Session session = null;
225
226 try {
227 session = openSession();
228
229 Query q = session.createQuery(sql);
230
231 QueryPos qPos = QueryPos.getInstance(q);
232
233 if (bindPortletId) {
234 qPos.add(portletId);
235 }
236
237 if (!pagination) {
238 list = (List<JournalContentSearch>)QueryUtil.list(q,
239 getDialect(), start, end, false);
240
241 Collections.sort(list);
242
243 list = Collections.unmodifiableList(list);
244 }
245 else {
246 list = (List<JournalContentSearch>)QueryUtil.list(q,
247 getDialect(), start, end);
248 }
249
250 cacheResult(list);
251
252 FinderCacheUtil.putResult(finderPath, finderArgs, list);
253 }
254 catch (Exception e) {
255 FinderCacheUtil.removeResult(finderPath, finderArgs);
256
257 throw processException(e);
258 }
259 finally {
260 closeSession(session);
261 }
262 }
263
264 return list;
265 }
266
267
275 @Override
276 public JournalContentSearch findByPortletId_First(String portletId,
277 OrderByComparator<JournalContentSearch> orderByComparator)
278 throws NoSuchContentSearchException {
279 JournalContentSearch journalContentSearch = fetchByPortletId_First(portletId,
280 orderByComparator);
281
282 if (journalContentSearch != null) {
283 return journalContentSearch;
284 }
285
286 StringBundler msg = new StringBundler(4);
287
288 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
289
290 msg.append("portletId=");
291 msg.append(portletId);
292
293 msg.append(StringPool.CLOSE_CURLY_BRACE);
294
295 throw new NoSuchContentSearchException(msg.toString());
296 }
297
298
305 @Override
306 public JournalContentSearch fetchByPortletId_First(String portletId,
307 OrderByComparator<JournalContentSearch> orderByComparator) {
308 List<JournalContentSearch> list = findByPortletId(portletId, 0, 1,
309 orderByComparator);
310
311 if (!list.isEmpty()) {
312 return list.get(0);
313 }
314
315 return null;
316 }
317
318
326 @Override
327 public JournalContentSearch findByPortletId_Last(String portletId,
328 OrderByComparator<JournalContentSearch> orderByComparator)
329 throws NoSuchContentSearchException {
330 JournalContentSearch journalContentSearch = fetchByPortletId_Last(portletId,
331 orderByComparator);
332
333 if (journalContentSearch != null) {
334 return journalContentSearch;
335 }
336
337 StringBundler msg = new StringBundler(4);
338
339 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
340
341 msg.append("portletId=");
342 msg.append(portletId);
343
344 msg.append(StringPool.CLOSE_CURLY_BRACE);
345
346 throw new NoSuchContentSearchException(msg.toString());
347 }
348
349
356 @Override
357 public JournalContentSearch fetchByPortletId_Last(String portletId,
358 OrderByComparator<JournalContentSearch> orderByComparator) {
359 int count = countByPortletId(portletId);
360
361 if (count == 0) {
362 return null;
363 }
364
365 List<JournalContentSearch> list = findByPortletId(portletId, count - 1,
366 count, orderByComparator);
367
368 if (!list.isEmpty()) {
369 return list.get(0);
370 }
371
372 return null;
373 }
374
375
384 @Override
385 public JournalContentSearch[] findByPortletId_PrevAndNext(
386 long contentSearchId, String portletId,
387 OrderByComparator<JournalContentSearch> orderByComparator)
388 throws NoSuchContentSearchException {
389 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
390
391 Session session = null;
392
393 try {
394 session = openSession();
395
396 JournalContentSearch[] array = new JournalContentSearchImpl[3];
397
398 array[0] = getByPortletId_PrevAndNext(session,
399 journalContentSearch, portletId, orderByComparator, true);
400
401 array[1] = journalContentSearch;
402
403 array[2] = getByPortletId_PrevAndNext(session,
404 journalContentSearch, portletId, orderByComparator, false);
405
406 return array;
407 }
408 catch (Exception e) {
409 throw processException(e);
410 }
411 finally {
412 closeSession(session);
413 }
414 }
415
416 protected JournalContentSearch getByPortletId_PrevAndNext(Session session,
417 JournalContentSearch journalContentSearch, String portletId,
418 OrderByComparator<JournalContentSearch> orderByComparator,
419 boolean previous) {
420 StringBundler query = null;
421
422 if (orderByComparator != null) {
423 query = new StringBundler(6 +
424 (orderByComparator.getOrderByFields().length * 6));
425 }
426 else {
427 query = new StringBundler(3);
428 }
429
430 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
431
432 boolean bindPortletId = false;
433
434 if (portletId == null) {
435 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
436 }
437 else if (portletId.equals(StringPool.BLANK)) {
438 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
439 }
440 else {
441 bindPortletId = true;
442
443 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
444 }
445
446 if (orderByComparator != null) {
447 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
448
449 if (orderByConditionFields.length > 0) {
450 query.append(WHERE_AND);
451 }
452
453 for (int i = 0; i < orderByConditionFields.length; i++) {
454 query.append(_ORDER_BY_ENTITY_ALIAS);
455 query.append(orderByConditionFields[i]);
456
457 if ((i + 1) < orderByConditionFields.length) {
458 if (orderByComparator.isAscending() ^ previous) {
459 query.append(WHERE_GREATER_THAN_HAS_NEXT);
460 }
461 else {
462 query.append(WHERE_LESSER_THAN_HAS_NEXT);
463 }
464 }
465 else {
466 if (orderByComparator.isAscending() ^ previous) {
467 query.append(WHERE_GREATER_THAN);
468 }
469 else {
470 query.append(WHERE_LESSER_THAN);
471 }
472 }
473 }
474
475 query.append(ORDER_BY_CLAUSE);
476
477 String[] orderByFields = orderByComparator.getOrderByFields();
478
479 for (int i = 0; i < orderByFields.length; i++) {
480 query.append(_ORDER_BY_ENTITY_ALIAS);
481 query.append(orderByFields[i]);
482
483 if ((i + 1) < orderByFields.length) {
484 if (orderByComparator.isAscending() ^ previous) {
485 query.append(ORDER_BY_ASC_HAS_NEXT);
486 }
487 else {
488 query.append(ORDER_BY_DESC_HAS_NEXT);
489 }
490 }
491 else {
492 if (orderByComparator.isAscending() ^ previous) {
493 query.append(ORDER_BY_ASC);
494 }
495 else {
496 query.append(ORDER_BY_DESC);
497 }
498 }
499 }
500 }
501 else {
502 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
503 }
504
505 String sql = query.toString();
506
507 Query q = session.createQuery(sql);
508
509 q.setFirstResult(0);
510 q.setMaxResults(2);
511
512 QueryPos qPos = QueryPos.getInstance(q);
513
514 if (bindPortletId) {
515 qPos.add(portletId);
516 }
517
518 if (orderByComparator != null) {
519 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
520
521 for (Object value : values) {
522 qPos.add(value);
523 }
524 }
525
526 List<JournalContentSearch> list = q.list();
527
528 if (list.size() == 2) {
529 return list.get(1);
530 }
531 else {
532 return null;
533 }
534 }
535
536
541 @Override
542 public void removeByPortletId(String portletId) {
543 for (JournalContentSearch journalContentSearch : findByPortletId(
544 portletId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
545 remove(journalContentSearch);
546 }
547 }
548
549
555 @Override
556 public int countByPortletId(String portletId) {
557 FinderPath finderPath = FINDER_PATH_COUNT_BY_PORTLETID;
558
559 Object[] finderArgs = new Object[] { portletId };
560
561 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
562 this);
563
564 if (count == null) {
565 StringBundler query = new StringBundler(2);
566
567 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
568
569 boolean bindPortletId = false;
570
571 if (portletId == null) {
572 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
573 }
574 else if (portletId.equals(StringPool.BLANK)) {
575 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
576 }
577 else {
578 bindPortletId = true;
579
580 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
581 }
582
583 String sql = query.toString();
584
585 Session session = null;
586
587 try {
588 session = openSession();
589
590 Query q = session.createQuery(sql);
591
592 QueryPos qPos = QueryPos.getInstance(q);
593
594 if (bindPortletId) {
595 qPos.add(portletId);
596 }
597
598 count = (Long)q.uniqueResult();
599
600 FinderCacheUtil.putResult(finderPath, finderArgs, count);
601 }
602 catch (Exception e) {
603 FinderCacheUtil.removeResult(finderPath, finderArgs);
604
605 throw processException(e);
606 }
607 finally {
608 closeSession(session);
609 }
610 }
611
612 return count.intValue();
613 }
614
615 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
616 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_2 = "journalContentSearch.portletId = ?";
617 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = '')";
618 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ARTICLEID =
619 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
620 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
621 JournalContentSearchImpl.class,
622 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByArticleId",
623 new String[] {
624 String.class.getName(),
625
626 Integer.class.getName(), Integer.class.getName(),
627 OrderByComparator.class.getName()
628 });
629 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID =
630 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
631 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
632 JournalContentSearchImpl.class,
633 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByArticleId",
634 new String[] { String.class.getName() },
635 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
636 public static final FinderPath FINDER_PATH_COUNT_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
637 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
638 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByArticleId",
639 new String[] { String.class.getName() });
640
641
647 @Override
648 public List<JournalContentSearch> findByArticleId(String articleId) {
649 return findByArticleId(articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
650 null);
651 }
652
653
665 @Override
666 public List<JournalContentSearch> findByArticleId(String articleId,
667 int start, int end) {
668 return findByArticleId(articleId, start, end, null);
669 }
670
671
684 @Override
685 public List<JournalContentSearch> findByArticleId(String articleId,
686 int start, int end,
687 OrderByComparator<JournalContentSearch> orderByComparator) {
688 boolean pagination = true;
689 FinderPath finderPath = null;
690 Object[] finderArgs = null;
691
692 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
693 (orderByComparator == null)) {
694 pagination = false;
695 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID;
696 finderArgs = new Object[] { articleId };
697 }
698 else {
699 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ARTICLEID;
700 finderArgs = new Object[] { articleId, start, end, orderByComparator };
701 }
702
703 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
704 finderArgs, this);
705
706 if ((list != null) && !list.isEmpty()) {
707 for (JournalContentSearch journalContentSearch : list) {
708 if (!Validator.equals(articleId,
709 journalContentSearch.getArticleId())) {
710 list = null;
711
712 break;
713 }
714 }
715 }
716
717 if (list == null) {
718 StringBundler query = null;
719
720 if (orderByComparator != null) {
721 query = new StringBundler(3 +
722 (orderByComparator.getOrderByFields().length * 3));
723 }
724 else {
725 query = new StringBundler(3);
726 }
727
728 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
729
730 boolean bindArticleId = false;
731
732 if (articleId == null) {
733 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
734 }
735 else if (articleId.equals(StringPool.BLANK)) {
736 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
737 }
738 else {
739 bindArticleId = true;
740
741 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
742 }
743
744 if (orderByComparator != null) {
745 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
746 orderByComparator);
747 }
748 else
749 if (pagination) {
750 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
751 }
752
753 String sql = query.toString();
754
755 Session session = null;
756
757 try {
758 session = openSession();
759
760 Query q = session.createQuery(sql);
761
762 QueryPos qPos = QueryPos.getInstance(q);
763
764 if (bindArticleId) {
765 qPos.add(articleId);
766 }
767
768 if (!pagination) {
769 list = (List<JournalContentSearch>)QueryUtil.list(q,
770 getDialect(), start, end, false);
771
772 Collections.sort(list);
773
774 list = Collections.unmodifiableList(list);
775 }
776 else {
777 list = (List<JournalContentSearch>)QueryUtil.list(q,
778 getDialect(), start, end);
779 }
780
781 cacheResult(list);
782
783 FinderCacheUtil.putResult(finderPath, finderArgs, list);
784 }
785 catch (Exception e) {
786 FinderCacheUtil.removeResult(finderPath, finderArgs);
787
788 throw processException(e);
789 }
790 finally {
791 closeSession(session);
792 }
793 }
794
795 return list;
796 }
797
798
806 @Override
807 public JournalContentSearch findByArticleId_First(String articleId,
808 OrderByComparator<JournalContentSearch> orderByComparator)
809 throws NoSuchContentSearchException {
810 JournalContentSearch journalContentSearch = fetchByArticleId_First(articleId,
811 orderByComparator);
812
813 if (journalContentSearch != null) {
814 return journalContentSearch;
815 }
816
817 StringBundler msg = new StringBundler(4);
818
819 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
820
821 msg.append("articleId=");
822 msg.append(articleId);
823
824 msg.append(StringPool.CLOSE_CURLY_BRACE);
825
826 throw new NoSuchContentSearchException(msg.toString());
827 }
828
829
836 @Override
837 public JournalContentSearch fetchByArticleId_First(String articleId,
838 OrderByComparator<JournalContentSearch> orderByComparator) {
839 List<JournalContentSearch> list = findByArticleId(articleId, 0, 1,
840 orderByComparator);
841
842 if (!list.isEmpty()) {
843 return list.get(0);
844 }
845
846 return null;
847 }
848
849
857 @Override
858 public JournalContentSearch findByArticleId_Last(String articleId,
859 OrderByComparator<JournalContentSearch> orderByComparator)
860 throws NoSuchContentSearchException {
861 JournalContentSearch journalContentSearch = fetchByArticleId_Last(articleId,
862 orderByComparator);
863
864 if (journalContentSearch != null) {
865 return journalContentSearch;
866 }
867
868 StringBundler msg = new StringBundler(4);
869
870 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
871
872 msg.append("articleId=");
873 msg.append(articleId);
874
875 msg.append(StringPool.CLOSE_CURLY_BRACE);
876
877 throw new NoSuchContentSearchException(msg.toString());
878 }
879
880
887 @Override
888 public JournalContentSearch fetchByArticleId_Last(String articleId,
889 OrderByComparator<JournalContentSearch> orderByComparator) {
890 int count = countByArticleId(articleId);
891
892 if (count == 0) {
893 return null;
894 }
895
896 List<JournalContentSearch> list = findByArticleId(articleId, count - 1,
897 count, orderByComparator);
898
899 if (!list.isEmpty()) {
900 return list.get(0);
901 }
902
903 return null;
904 }
905
906
915 @Override
916 public JournalContentSearch[] findByArticleId_PrevAndNext(
917 long contentSearchId, String articleId,
918 OrderByComparator<JournalContentSearch> orderByComparator)
919 throws NoSuchContentSearchException {
920 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
921
922 Session session = null;
923
924 try {
925 session = openSession();
926
927 JournalContentSearch[] array = new JournalContentSearchImpl[3];
928
929 array[0] = getByArticleId_PrevAndNext(session,
930 journalContentSearch, articleId, orderByComparator, true);
931
932 array[1] = journalContentSearch;
933
934 array[2] = getByArticleId_PrevAndNext(session,
935 journalContentSearch, articleId, orderByComparator, false);
936
937 return array;
938 }
939 catch (Exception e) {
940 throw processException(e);
941 }
942 finally {
943 closeSession(session);
944 }
945 }
946
947 protected JournalContentSearch getByArticleId_PrevAndNext(Session session,
948 JournalContentSearch journalContentSearch, String articleId,
949 OrderByComparator<JournalContentSearch> orderByComparator,
950 boolean previous) {
951 StringBundler query = null;
952
953 if (orderByComparator != null) {
954 query = new StringBundler(6 +
955 (orderByComparator.getOrderByFields().length * 6));
956 }
957 else {
958 query = new StringBundler(3);
959 }
960
961 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
962
963 boolean bindArticleId = false;
964
965 if (articleId == null) {
966 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
967 }
968 else if (articleId.equals(StringPool.BLANK)) {
969 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
970 }
971 else {
972 bindArticleId = true;
973
974 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
975 }
976
977 if (orderByComparator != null) {
978 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
979
980 if (orderByConditionFields.length > 0) {
981 query.append(WHERE_AND);
982 }
983
984 for (int i = 0; i < orderByConditionFields.length; i++) {
985 query.append(_ORDER_BY_ENTITY_ALIAS);
986 query.append(orderByConditionFields[i]);
987
988 if ((i + 1) < orderByConditionFields.length) {
989 if (orderByComparator.isAscending() ^ previous) {
990 query.append(WHERE_GREATER_THAN_HAS_NEXT);
991 }
992 else {
993 query.append(WHERE_LESSER_THAN_HAS_NEXT);
994 }
995 }
996 else {
997 if (orderByComparator.isAscending() ^ previous) {
998 query.append(WHERE_GREATER_THAN);
999 }
1000 else {
1001 query.append(WHERE_LESSER_THAN);
1002 }
1003 }
1004 }
1005
1006 query.append(ORDER_BY_CLAUSE);
1007
1008 String[] orderByFields = orderByComparator.getOrderByFields();
1009
1010 for (int i = 0; i < orderByFields.length; i++) {
1011 query.append(_ORDER_BY_ENTITY_ALIAS);
1012 query.append(orderByFields[i]);
1013
1014 if ((i + 1) < orderByFields.length) {
1015 if (orderByComparator.isAscending() ^ previous) {
1016 query.append(ORDER_BY_ASC_HAS_NEXT);
1017 }
1018 else {
1019 query.append(ORDER_BY_DESC_HAS_NEXT);
1020 }
1021 }
1022 else {
1023 if (orderByComparator.isAscending() ^ previous) {
1024 query.append(ORDER_BY_ASC);
1025 }
1026 else {
1027 query.append(ORDER_BY_DESC);
1028 }
1029 }
1030 }
1031 }
1032 else {
1033 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1034 }
1035
1036 String sql = query.toString();
1037
1038 Query q = session.createQuery(sql);
1039
1040 q.setFirstResult(0);
1041 q.setMaxResults(2);
1042
1043 QueryPos qPos = QueryPos.getInstance(q);
1044
1045 if (bindArticleId) {
1046 qPos.add(articleId);
1047 }
1048
1049 if (orderByComparator != null) {
1050 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
1051
1052 for (Object value : values) {
1053 qPos.add(value);
1054 }
1055 }
1056
1057 List<JournalContentSearch> list = q.list();
1058
1059 if (list.size() == 2) {
1060 return list.get(1);
1061 }
1062 else {
1063 return null;
1064 }
1065 }
1066
1067
1072 @Override
1073 public void removeByArticleId(String articleId) {
1074 for (JournalContentSearch journalContentSearch : findByArticleId(
1075 articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1076 remove(journalContentSearch);
1077 }
1078 }
1079
1080
1086 @Override
1087 public int countByArticleId(String articleId) {
1088 FinderPath finderPath = FINDER_PATH_COUNT_BY_ARTICLEID;
1089
1090 Object[] finderArgs = new Object[] { articleId };
1091
1092 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1093 this);
1094
1095 if (count == null) {
1096 StringBundler query = new StringBundler(2);
1097
1098 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
1099
1100 boolean bindArticleId = false;
1101
1102 if (articleId == null) {
1103 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
1104 }
1105 else if (articleId.equals(StringPool.BLANK)) {
1106 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
1107 }
1108 else {
1109 bindArticleId = true;
1110
1111 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
1112 }
1113
1114 String sql = query.toString();
1115
1116 Session session = null;
1117
1118 try {
1119 session = openSession();
1120
1121 Query q = session.createQuery(sql);
1122
1123 QueryPos qPos = QueryPos.getInstance(q);
1124
1125 if (bindArticleId) {
1126 qPos.add(articleId);
1127 }
1128
1129 count = (Long)q.uniqueResult();
1130
1131 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1132 }
1133 catch (Exception e) {
1134 FinderCacheUtil.removeResult(finderPath, finderArgs);
1135
1136 throw processException(e);
1137 }
1138 finally {
1139 closeSession(session);
1140 }
1141 }
1142
1143 return count.intValue();
1144 }
1145
1146 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
1147 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_2 = "journalContentSearch.articleId = ?";
1148 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = '')";
1149 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1150 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1151 JournalContentSearchImpl.class,
1152 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
1153 new String[] {
1154 Long.class.getName(), Boolean.class.getName(),
1155
1156 Integer.class.getName(), Integer.class.getName(),
1157 OrderByComparator.class.getName()
1158 });
1159 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1160 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1161 JournalContentSearchImpl.class,
1162 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
1163 new String[] { Long.class.getName(), Boolean.class.getName() },
1164 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
1165 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK);
1166 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1167 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
1168 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
1169 new String[] { Long.class.getName(), Boolean.class.getName() });
1170
1171
1178 @Override
1179 public List<JournalContentSearch> findByG_P(long groupId,
1180 boolean privateLayout) {
1181 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1182 QueryUtil.ALL_POS, null);
1183 }
1184
1185
1198 @Override
1199 public List<JournalContentSearch> findByG_P(long groupId,
1200 boolean privateLayout, int start, int end) {
1201 return findByG_P(groupId, privateLayout, start, end, null);
1202 }
1203
1204
1218 @Override
1219 public List<JournalContentSearch> findByG_P(long groupId,
1220 boolean privateLayout, int start, int end,
1221 OrderByComparator<JournalContentSearch> orderByComparator) {
1222 boolean pagination = true;
1223 FinderPath finderPath = null;
1224 Object[] finderArgs = null;
1225
1226 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1227 (orderByComparator == null)) {
1228 pagination = false;
1229 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1230 finderArgs = new Object[] { groupId, privateLayout };
1231 }
1232 else {
1233 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1234 finderArgs = new Object[] {
1235 groupId, privateLayout,
1236
1237 start, end, orderByComparator
1238 };
1239 }
1240
1241 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
1242 finderArgs, this);
1243
1244 if ((list != null) && !list.isEmpty()) {
1245 for (JournalContentSearch journalContentSearch : list) {
1246 if ((groupId != journalContentSearch.getGroupId()) ||
1247 (privateLayout != journalContentSearch.getPrivateLayout())) {
1248 list = null;
1249
1250 break;
1251 }
1252 }
1253 }
1254
1255 if (list == null) {
1256 StringBundler query = null;
1257
1258 if (orderByComparator != null) {
1259 query = new StringBundler(4 +
1260 (orderByComparator.getOrderByFields().length * 3));
1261 }
1262 else {
1263 query = new StringBundler(4);
1264 }
1265
1266 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1267
1268 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1269
1270 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1271
1272 if (orderByComparator != null) {
1273 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1274 orderByComparator);
1275 }
1276 else
1277 if (pagination) {
1278 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1279 }
1280
1281 String sql = query.toString();
1282
1283 Session session = null;
1284
1285 try {
1286 session = openSession();
1287
1288 Query q = session.createQuery(sql);
1289
1290 QueryPos qPos = QueryPos.getInstance(q);
1291
1292 qPos.add(groupId);
1293
1294 qPos.add(privateLayout);
1295
1296 if (!pagination) {
1297 list = (List<JournalContentSearch>)QueryUtil.list(q,
1298 getDialect(), start, end, false);
1299
1300 Collections.sort(list);
1301
1302 list = Collections.unmodifiableList(list);
1303 }
1304 else {
1305 list = (List<JournalContentSearch>)QueryUtil.list(q,
1306 getDialect(), start, end);
1307 }
1308
1309 cacheResult(list);
1310
1311 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1312 }
1313 catch (Exception e) {
1314 FinderCacheUtil.removeResult(finderPath, finderArgs);
1315
1316 throw processException(e);
1317 }
1318 finally {
1319 closeSession(session);
1320 }
1321 }
1322
1323 return list;
1324 }
1325
1326
1335 @Override
1336 public JournalContentSearch findByG_P_First(long groupId,
1337 boolean privateLayout,
1338 OrderByComparator<JournalContentSearch> orderByComparator)
1339 throws NoSuchContentSearchException {
1340 JournalContentSearch journalContentSearch = fetchByG_P_First(groupId,
1341 privateLayout, orderByComparator);
1342
1343 if (journalContentSearch != null) {
1344 return journalContentSearch;
1345 }
1346
1347 StringBundler msg = new StringBundler(6);
1348
1349 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1350
1351 msg.append("groupId=");
1352 msg.append(groupId);
1353
1354 msg.append(", privateLayout=");
1355 msg.append(privateLayout);
1356
1357 msg.append(StringPool.CLOSE_CURLY_BRACE);
1358
1359 throw new NoSuchContentSearchException(msg.toString());
1360 }
1361
1362
1370 @Override
1371 public JournalContentSearch fetchByG_P_First(long groupId,
1372 boolean privateLayout,
1373 OrderByComparator<JournalContentSearch> orderByComparator) {
1374 List<JournalContentSearch> list = findByG_P(groupId, privateLayout, 0,
1375 1, orderByComparator);
1376
1377 if (!list.isEmpty()) {
1378 return list.get(0);
1379 }
1380
1381 return null;
1382 }
1383
1384
1393 @Override
1394 public JournalContentSearch findByG_P_Last(long groupId,
1395 boolean privateLayout,
1396 OrderByComparator<JournalContentSearch> orderByComparator)
1397 throws NoSuchContentSearchException {
1398 JournalContentSearch journalContentSearch = fetchByG_P_Last(groupId,
1399 privateLayout, orderByComparator);
1400
1401 if (journalContentSearch != null) {
1402 return journalContentSearch;
1403 }
1404
1405 StringBundler msg = new StringBundler(6);
1406
1407 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1408
1409 msg.append("groupId=");
1410 msg.append(groupId);
1411
1412 msg.append(", privateLayout=");
1413 msg.append(privateLayout);
1414
1415 msg.append(StringPool.CLOSE_CURLY_BRACE);
1416
1417 throw new NoSuchContentSearchException(msg.toString());
1418 }
1419
1420
1428 @Override
1429 public JournalContentSearch fetchByG_P_Last(long groupId,
1430 boolean privateLayout,
1431 OrderByComparator<JournalContentSearch> orderByComparator) {
1432 int count = countByG_P(groupId, privateLayout);
1433
1434 if (count == 0) {
1435 return null;
1436 }
1437
1438 List<JournalContentSearch> list = findByG_P(groupId, privateLayout,
1439 count - 1, count, orderByComparator);
1440
1441 if (!list.isEmpty()) {
1442 return list.get(0);
1443 }
1444
1445 return null;
1446 }
1447
1448
1458 @Override
1459 public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
1460 long groupId, boolean privateLayout,
1461 OrderByComparator<JournalContentSearch> orderByComparator)
1462 throws NoSuchContentSearchException {
1463 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1464
1465 Session session = null;
1466
1467 try {
1468 session = openSession();
1469
1470 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1471
1472 array[0] = getByG_P_PrevAndNext(session, journalContentSearch,
1473 groupId, privateLayout, orderByComparator, true);
1474
1475 array[1] = journalContentSearch;
1476
1477 array[2] = getByG_P_PrevAndNext(session, journalContentSearch,
1478 groupId, privateLayout, orderByComparator, false);
1479
1480 return array;
1481 }
1482 catch (Exception e) {
1483 throw processException(e);
1484 }
1485 finally {
1486 closeSession(session);
1487 }
1488 }
1489
1490 protected JournalContentSearch getByG_P_PrevAndNext(Session session,
1491 JournalContentSearch journalContentSearch, long groupId,
1492 boolean privateLayout,
1493 OrderByComparator<JournalContentSearch> orderByComparator,
1494 boolean previous) {
1495 StringBundler query = null;
1496
1497 if (orderByComparator != null) {
1498 query = new StringBundler(6 +
1499 (orderByComparator.getOrderByFields().length * 6));
1500 }
1501 else {
1502 query = new StringBundler(3);
1503 }
1504
1505 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1506
1507 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1508
1509 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1510
1511 if (orderByComparator != null) {
1512 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1513
1514 if (orderByConditionFields.length > 0) {
1515 query.append(WHERE_AND);
1516 }
1517
1518 for (int i = 0; i < orderByConditionFields.length; i++) {
1519 query.append(_ORDER_BY_ENTITY_ALIAS);
1520 query.append(orderByConditionFields[i]);
1521
1522 if ((i + 1) < orderByConditionFields.length) {
1523 if (orderByComparator.isAscending() ^ previous) {
1524 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1525 }
1526 else {
1527 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1528 }
1529 }
1530 else {
1531 if (orderByComparator.isAscending() ^ previous) {
1532 query.append(WHERE_GREATER_THAN);
1533 }
1534 else {
1535 query.append(WHERE_LESSER_THAN);
1536 }
1537 }
1538 }
1539
1540 query.append(ORDER_BY_CLAUSE);
1541
1542 String[] orderByFields = orderByComparator.getOrderByFields();
1543
1544 for (int i = 0; i < orderByFields.length; i++) {
1545 query.append(_ORDER_BY_ENTITY_ALIAS);
1546 query.append(orderByFields[i]);
1547
1548 if ((i + 1) < orderByFields.length) {
1549 if (orderByComparator.isAscending() ^ previous) {
1550 query.append(ORDER_BY_ASC_HAS_NEXT);
1551 }
1552 else {
1553 query.append(ORDER_BY_DESC_HAS_NEXT);
1554 }
1555 }
1556 else {
1557 if (orderByComparator.isAscending() ^ previous) {
1558 query.append(ORDER_BY_ASC);
1559 }
1560 else {
1561 query.append(ORDER_BY_DESC);
1562 }
1563 }
1564 }
1565 }
1566 else {
1567 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1568 }
1569
1570 String sql = query.toString();
1571
1572 Query q = session.createQuery(sql);
1573
1574 q.setFirstResult(0);
1575 q.setMaxResults(2);
1576
1577 QueryPos qPos = QueryPos.getInstance(q);
1578
1579 qPos.add(groupId);
1580
1581 qPos.add(privateLayout);
1582
1583 if (orderByComparator != null) {
1584 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
1585
1586 for (Object value : values) {
1587 qPos.add(value);
1588 }
1589 }
1590
1591 List<JournalContentSearch> list = q.list();
1592
1593 if (list.size() == 2) {
1594 return list.get(1);
1595 }
1596 else {
1597 return null;
1598 }
1599 }
1600
1601
1607 @Override
1608 public void removeByG_P(long groupId, boolean privateLayout) {
1609 for (JournalContentSearch journalContentSearch : findByG_P(groupId,
1610 privateLayout, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1611 remove(journalContentSearch);
1612 }
1613 }
1614
1615
1622 @Override
1623 public int countByG_P(long groupId, boolean privateLayout) {
1624 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P;
1625
1626 Object[] finderArgs = new Object[] { groupId, privateLayout };
1627
1628 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1629 this);
1630
1631 if (count == null) {
1632 StringBundler query = new StringBundler(3);
1633
1634 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
1635
1636 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1637
1638 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1639
1640 String sql = query.toString();
1641
1642 Session session = null;
1643
1644 try {
1645 session = openSession();
1646
1647 Query q = session.createQuery(sql);
1648
1649 QueryPos qPos = QueryPos.getInstance(q);
1650
1651 qPos.add(groupId);
1652
1653 qPos.add(privateLayout);
1654
1655 count = (Long)q.uniqueResult();
1656
1657 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1658 }
1659 catch (Exception e) {
1660 FinderCacheUtil.removeResult(finderPath, finderArgs);
1661
1662 throw processException(e);
1663 }
1664 finally {
1665 closeSession(session);
1666 }
1667 }
1668
1669 return count.intValue();
1670 }
1671
1672 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
1673 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ?";
1674 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1675 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1676 JournalContentSearchImpl.class,
1677 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_A",
1678 new String[] {
1679 Long.class.getName(), String.class.getName(),
1680
1681 Integer.class.getName(), Integer.class.getName(),
1682 OrderByComparator.class.getName()
1683 });
1684 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1685 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
1686 JournalContentSearchImpl.class,
1687 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
1688 new String[] { Long.class.getName(), String.class.getName() },
1689 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
1690 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
1691 public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
1692 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
1693 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
1694 new String[] { Long.class.getName(), String.class.getName() });
1695
1696
1703 @Override
1704 public List<JournalContentSearch> findByG_A(long groupId, String articleId) {
1705 return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
1706 QueryUtil.ALL_POS, null);
1707 }
1708
1709
1722 @Override
1723 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1724 int start, int end) {
1725 return findByG_A(groupId, articleId, start, end, null);
1726 }
1727
1728
1742 @Override
1743 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1744 int start, int end,
1745 OrderByComparator<JournalContentSearch> orderByComparator) {
1746 boolean pagination = true;
1747 FinderPath finderPath = null;
1748 Object[] finderArgs = null;
1749
1750 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1751 (orderByComparator == null)) {
1752 pagination = false;
1753 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
1754 finderArgs = new Object[] { groupId, articleId };
1755 }
1756 else {
1757 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
1758 finderArgs = new Object[] {
1759 groupId, articleId,
1760
1761 start, end, orderByComparator
1762 };
1763 }
1764
1765 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
1766 finderArgs, this);
1767
1768 if ((list != null) && !list.isEmpty()) {
1769 for (JournalContentSearch journalContentSearch : list) {
1770 if ((groupId != journalContentSearch.getGroupId()) ||
1771 !Validator.equals(articleId,
1772 journalContentSearch.getArticleId())) {
1773 list = null;
1774
1775 break;
1776 }
1777 }
1778 }
1779
1780 if (list == null) {
1781 StringBundler query = null;
1782
1783 if (orderByComparator != null) {
1784 query = new StringBundler(4 +
1785 (orderByComparator.getOrderByFields().length * 3));
1786 }
1787 else {
1788 query = new StringBundler(4);
1789 }
1790
1791 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1792
1793 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1794
1795 boolean bindArticleId = false;
1796
1797 if (articleId == null) {
1798 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1799 }
1800 else if (articleId.equals(StringPool.BLANK)) {
1801 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1802 }
1803 else {
1804 bindArticleId = true;
1805
1806 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1807 }
1808
1809 if (orderByComparator != null) {
1810 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1811 orderByComparator);
1812 }
1813 else
1814 if (pagination) {
1815 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
1816 }
1817
1818 String sql = query.toString();
1819
1820 Session session = null;
1821
1822 try {
1823 session = openSession();
1824
1825 Query q = session.createQuery(sql);
1826
1827 QueryPos qPos = QueryPos.getInstance(q);
1828
1829 qPos.add(groupId);
1830
1831 if (bindArticleId) {
1832 qPos.add(articleId);
1833 }
1834
1835 if (!pagination) {
1836 list = (List<JournalContentSearch>)QueryUtil.list(q,
1837 getDialect(), start, end, false);
1838
1839 Collections.sort(list);
1840
1841 list = Collections.unmodifiableList(list);
1842 }
1843 else {
1844 list = (List<JournalContentSearch>)QueryUtil.list(q,
1845 getDialect(), start, end);
1846 }
1847
1848 cacheResult(list);
1849
1850 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1851 }
1852 catch (Exception e) {
1853 FinderCacheUtil.removeResult(finderPath, finderArgs);
1854
1855 throw processException(e);
1856 }
1857 finally {
1858 closeSession(session);
1859 }
1860 }
1861
1862 return list;
1863 }
1864
1865
1874 @Override
1875 public JournalContentSearch findByG_A_First(long groupId, String articleId,
1876 OrderByComparator<JournalContentSearch> orderByComparator)
1877 throws NoSuchContentSearchException {
1878 JournalContentSearch journalContentSearch = fetchByG_A_First(groupId,
1879 articleId, orderByComparator);
1880
1881 if (journalContentSearch != null) {
1882 return journalContentSearch;
1883 }
1884
1885 StringBundler msg = new StringBundler(6);
1886
1887 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1888
1889 msg.append("groupId=");
1890 msg.append(groupId);
1891
1892 msg.append(", articleId=");
1893 msg.append(articleId);
1894
1895 msg.append(StringPool.CLOSE_CURLY_BRACE);
1896
1897 throw new NoSuchContentSearchException(msg.toString());
1898 }
1899
1900
1908 @Override
1909 public JournalContentSearch fetchByG_A_First(long groupId,
1910 String articleId,
1911 OrderByComparator<JournalContentSearch> orderByComparator) {
1912 List<JournalContentSearch> list = findByG_A(groupId, articleId, 0, 1,
1913 orderByComparator);
1914
1915 if (!list.isEmpty()) {
1916 return list.get(0);
1917 }
1918
1919 return null;
1920 }
1921
1922
1931 @Override
1932 public JournalContentSearch findByG_A_Last(long groupId, String articleId,
1933 OrderByComparator<JournalContentSearch> orderByComparator)
1934 throws NoSuchContentSearchException {
1935 JournalContentSearch journalContentSearch = fetchByG_A_Last(groupId,
1936 articleId, orderByComparator);
1937
1938 if (journalContentSearch != null) {
1939 return journalContentSearch;
1940 }
1941
1942 StringBundler msg = new StringBundler(6);
1943
1944 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1945
1946 msg.append("groupId=");
1947 msg.append(groupId);
1948
1949 msg.append(", articleId=");
1950 msg.append(articleId);
1951
1952 msg.append(StringPool.CLOSE_CURLY_BRACE);
1953
1954 throw new NoSuchContentSearchException(msg.toString());
1955 }
1956
1957
1965 @Override
1966 public JournalContentSearch fetchByG_A_Last(long groupId, String articleId,
1967 OrderByComparator<JournalContentSearch> orderByComparator) {
1968 int count = countByG_A(groupId, articleId);
1969
1970 if (count == 0) {
1971 return null;
1972 }
1973
1974 List<JournalContentSearch> list = findByG_A(groupId, articleId,
1975 count - 1, count, orderByComparator);
1976
1977 if (!list.isEmpty()) {
1978 return list.get(0);
1979 }
1980
1981 return null;
1982 }
1983
1984
1994 @Override
1995 public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
1996 long groupId, String articleId,
1997 OrderByComparator<JournalContentSearch> orderByComparator)
1998 throws NoSuchContentSearchException {
1999 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2000
2001 Session session = null;
2002
2003 try {
2004 session = openSession();
2005
2006 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2007
2008 array[0] = getByG_A_PrevAndNext(session, journalContentSearch,
2009 groupId, articleId, orderByComparator, true);
2010
2011 array[1] = journalContentSearch;
2012
2013 array[2] = getByG_A_PrevAndNext(session, journalContentSearch,
2014 groupId, articleId, orderByComparator, false);
2015
2016 return array;
2017 }
2018 catch (Exception e) {
2019 throw processException(e);
2020 }
2021 finally {
2022 closeSession(session);
2023 }
2024 }
2025
2026 protected JournalContentSearch getByG_A_PrevAndNext(Session session,
2027 JournalContentSearch journalContentSearch, long groupId,
2028 String articleId,
2029 OrderByComparator<JournalContentSearch> orderByComparator,
2030 boolean previous) {
2031 StringBundler query = null;
2032
2033 if (orderByComparator != null) {
2034 query = new StringBundler(6 +
2035 (orderByComparator.getOrderByFields().length * 6));
2036 }
2037 else {
2038 query = new StringBundler(3);
2039 }
2040
2041 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2042
2043 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2044
2045 boolean bindArticleId = false;
2046
2047 if (articleId == null) {
2048 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2049 }
2050 else if (articleId.equals(StringPool.BLANK)) {
2051 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2052 }
2053 else {
2054 bindArticleId = true;
2055
2056 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2057 }
2058
2059 if (orderByComparator != null) {
2060 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2061
2062 if (orderByConditionFields.length > 0) {
2063 query.append(WHERE_AND);
2064 }
2065
2066 for (int i = 0; i < orderByConditionFields.length; i++) {
2067 query.append(_ORDER_BY_ENTITY_ALIAS);
2068 query.append(orderByConditionFields[i]);
2069
2070 if ((i + 1) < orderByConditionFields.length) {
2071 if (orderByComparator.isAscending() ^ previous) {
2072 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2073 }
2074 else {
2075 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2076 }
2077 }
2078 else {
2079 if (orderByComparator.isAscending() ^ previous) {
2080 query.append(WHERE_GREATER_THAN);
2081 }
2082 else {
2083 query.append(WHERE_LESSER_THAN);
2084 }
2085 }
2086 }
2087
2088 query.append(ORDER_BY_CLAUSE);
2089
2090 String[] orderByFields = orderByComparator.getOrderByFields();
2091
2092 for (int i = 0; i < orderByFields.length; i++) {
2093 query.append(_ORDER_BY_ENTITY_ALIAS);
2094 query.append(orderByFields[i]);
2095
2096 if ((i + 1) < orderByFields.length) {
2097 if (orderByComparator.isAscending() ^ previous) {
2098 query.append(ORDER_BY_ASC_HAS_NEXT);
2099 }
2100 else {
2101 query.append(ORDER_BY_DESC_HAS_NEXT);
2102 }
2103 }
2104 else {
2105 if (orderByComparator.isAscending() ^ previous) {
2106 query.append(ORDER_BY_ASC);
2107 }
2108 else {
2109 query.append(ORDER_BY_DESC);
2110 }
2111 }
2112 }
2113 }
2114 else {
2115 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2116 }
2117
2118 String sql = query.toString();
2119
2120 Query q = session.createQuery(sql);
2121
2122 q.setFirstResult(0);
2123 q.setMaxResults(2);
2124
2125 QueryPos qPos = QueryPos.getInstance(q);
2126
2127 qPos.add(groupId);
2128
2129 if (bindArticleId) {
2130 qPos.add(articleId);
2131 }
2132
2133 if (orderByComparator != null) {
2134 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2135
2136 for (Object value : values) {
2137 qPos.add(value);
2138 }
2139 }
2140
2141 List<JournalContentSearch> list = q.list();
2142
2143 if (list.size() == 2) {
2144 return list.get(1);
2145 }
2146 else {
2147 return null;
2148 }
2149 }
2150
2151
2157 @Override
2158 public void removeByG_A(long groupId, String articleId) {
2159 for (JournalContentSearch journalContentSearch : findByG_A(groupId,
2160 articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2161 remove(journalContentSearch);
2162 }
2163 }
2164
2165
2172 @Override
2173 public int countByG_A(long groupId, String articleId) {
2174 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
2175
2176 Object[] finderArgs = new Object[] { groupId, articleId };
2177
2178 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2179 this);
2180
2181 if (count == null) {
2182 StringBundler query = new StringBundler(3);
2183
2184 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2185
2186 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2187
2188 boolean bindArticleId = false;
2189
2190 if (articleId == null) {
2191 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2192 }
2193 else if (articleId.equals(StringPool.BLANK)) {
2194 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2195 }
2196 else {
2197 bindArticleId = true;
2198
2199 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2200 }
2201
2202 String sql = query.toString();
2203
2204 Session session = null;
2205
2206 try {
2207 session = openSession();
2208
2209 Query q = session.createQuery(sql);
2210
2211 QueryPos qPos = QueryPos.getInstance(q);
2212
2213 qPos.add(groupId);
2214
2215 if (bindArticleId) {
2216 qPos.add(articleId);
2217 }
2218
2219 count = (Long)q.uniqueResult();
2220
2221 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2222 }
2223 catch (Exception e) {
2224 FinderCacheUtil.removeResult(finderPath, finderArgs);
2225
2226 throw processException(e);
2227 }
2228 finally {
2229 closeSession(session);
2230 }
2231 }
2232
2233 return count.intValue();
2234 }
2235
2236 private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
2237 private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
2238 private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
2239 private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = '')";
2240 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2241 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2242 JournalContentSearchImpl.class,
2243 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_L",
2244 new String[] {
2245 Long.class.getName(), Boolean.class.getName(),
2246 Long.class.getName(),
2247
2248 Integer.class.getName(), Integer.class.getName(),
2249 OrderByComparator.class.getName()
2250 });
2251 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2252 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2253 JournalContentSearchImpl.class,
2254 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_L",
2255 new String[] {
2256 Long.class.getName(), Boolean.class.getName(),
2257 Long.class.getName()
2258 },
2259 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
2260 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
2261 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK);
2262 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2263 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
2264 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L",
2265 new String[] {
2266 Long.class.getName(), Boolean.class.getName(),
2267 Long.class.getName()
2268 });
2269
2270
2278 @Override
2279 public List<JournalContentSearch> findByG_P_L(long groupId,
2280 boolean privateLayout, long layoutId) {
2281 return findByG_P_L(groupId, privateLayout, layoutId, QueryUtil.ALL_POS,
2282 QueryUtil.ALL_POS, null);
2283 }
2284
2285
2299 @Override
2300 public List<JournalContentSearch> findByG_P_L(long groupId,
2301 boolean privateLayout, long layoutId, int start, int end) {
2302 return findByG_P_L(groupId, privateLayout, layoutId, start, end, null);
2303 }
2304
2305
2320 @Override
2321 public List<JournalContentSearch> findByG_P_L(long groupId,
2322 boolean privateLayout, long layoutId, int start, int end,
2323 OrderByComparator<JournalContentSearch> orderByComparator) {
2324 boolean pagination = true;
2325 FinderPath finderPath = null;
2326 Object[] finderArgs = null;
2327
2328 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2329 (orderByComparator == null)) {
2330 pagination = false;
2331 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L;
2332 finderArgs = new Object[] { groupId, privateLayout, layoutId };
2333 }
2334 else {
2335 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L;
2336 finderArgs = new Object[] {
2337 groupId, privateLayout, layoutId,
2338
2339 start, end, orderByComparator
2340 };
2341 }
2342
2343 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
2344 finderArgs, this);
2345
2346 if ((list != null) && !list.isEmpty()) {
2347 for (JournalContentSearch journalContentSearch : list) {
2348 if ((groupId != journalContentSearch.getGroupId()) ||
2349 (privateLayout != journalContentSearch.getPrivateLayout()) ||
2350 (layoutId != journalContentSearch.getLayoutId())) {
2351 list = null;
2352
2353 break;
2354 }
2355 }
2356 }
2357
2358 if (list == null) {
2359 StringBundler query = null;
2360
2361 if (orderByComparator != null) {
2362 query = new StringBundler(5 +
2363 (orderByComparator.getOrderByFields().length * 3));
2364 }
2365 else {
2366 query = new StringBundler(5);
2367 }
2368
2369 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2370
2371 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2372
2373 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2374
2375 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2376
2377 if (orderByComparator != null) {
2378 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2379 orderByComparator);
2380 }
2381 else
2382 if (pagination) {
2383 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2384 }
2385
2386 String sql = query.toString();
2387
2388 Session session = null;
2389
2390 try {
2391 session = openSession();
2392
2393 Query q = session.createQuery(sql);
2394
2395 QueryPos qPos = QueryPos.getInstance(q);
2396
2397 qPos.add(groupId);
2398
2399 qPos.add(privateLayout);
2400
2401 qPos.add(layoutId);
2402
2403 if (!pagination) {
2404 list = (List<JournalContentSearch>)QueryUtil.list(q,
2405 getDialect(), start, end, false);
2406
2407 Collections.sort(list);
2408
2409 list = Collections.unmodifiableList(list);
2410 }
2411 else {
2412 list = (List<JournalContentSearch>)QueryUtil.list(q,
2413 getDialect(), start, end);
2414 }
2415
2416 cacheResult(list);
2417
2418 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2419 }
2420 catch (Exception e) {
2421 FinderCacheUtil.removeResult(finderPath, finderArgs);
2422
2423 throw processException(e);
2424 }
2425 finally {
2426 closeSession(session);
2427 }
2428 }
2429
2430 return list;
2431 }
2432
2433
2443 @Override
2444 public JournalContentSearch findByG_P_L_First(long groupId,
2445 boolean privateLayout, long layoutId,
2446 OrderByComparator<JournalContentSearch> orderByComparator)
2447 throws NoSuchContentSearchException {
2448 JournalContentSearch journalContentSearch = fetchByG_P_L_First(groupId,
2449 privateLayout, layoutId, orderByComparator);
2450
2451 if (journalContentSearch != null) {
2452 return journalContentSearch;
2453 }
2454
2455 StringBundler msg = new StringBundler(8);
2456
2457 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2458
2459 msg.append("groupId=");
2460 msg.append(groupId);
2461
2462 msg.append(", privateLayout=");
2463 msg.append(privateLayout);
2464
2465 msg.append(", layoutId=");
2466 msg.append(layoutId);
2467
2468 msg.append(StringPool.CLOSE_CURLY_BRACE);
2469
2470 throw new NoSuchContentSearchException(msg.toString());
2471 }
2472
2473
2482 @Override
2483 public JournalContentSearch fetchByG_P_L_First(long groupId,
2484 boolean privateLayout, long layoutId,
2485 OrderByComparator<JournalContentSearch> orderByComparator) {
2486 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
2487 layoutId, 0, 1, orderByComparator);
2488
2489 if (!list.isEmpty()) {
2490 return list.get(0);
2491 }
2492
2493 return null;
2494 }
2495
2496
2506 @Override
2507 public JournalContentSearch findByG_P_L_Last(long groupId,
2508 boolean privateLayout, long layoutId,
2509 OrderByComparator<JournalContentSearch> orderByComparator)
2510 throws NoSuchContentSearchException {
2511 JournalContentSearch journalContentSearch = fetchByG_P_L_Last(groupId,
2512 privateLayout, layoutId, orderByComparator);
2513
2514 if (journalContentSearch != null) {
2515 return journalContentSearch;
2516 }
2517
2518 StringBundler msg = new StringBundler(8);
2519
2520 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2521
2522 msg.append("groupId=");
2523 msg.append(groupId);
2524
2525 msg.append(", privateLayout=");
2526 msg.append(privateLayout);
2527
2528 msg.append(", layoutId=");
2529 msg.append(layoutId);
2530
2531 msg.append(StringPool.CLOSE_CURLY_BRACE);
2532
2533 throw new NoSuchContentSearchException(msg.toString());
2534 }
2535
2536
2545 @Override
2546 public JournalContentSearch fetchByG_P_L_Last(long groupId,
2547 boolean privateLayout, long layoutId,
2548 OrderByComparator<JournalContentSearch> orderByComparator) {
2549 int count = countByG_P_L(groupId, privateLayout, layoutId);
2550
2551 if (count == 0) {
2552 return null;
2553 }
2554
2555 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
2556 layoutId, count - 1, count, orderByComparator);
2557
2558 if (!list.isEmpty()) {
2559 return list.get(0);
2560 }
2561
2562 return null;
2563 }
2564
2565
2576 @Override
2577 public JournalContentSearch[] findByG_P_L_PrevAndNext(
2578 long contentSearchId, long groupId, boolean privateLayout,
2579 long layoutId, OrderByComparator<JournalContentSearch> orderByComparator)
2580 throws NoSuchContentSearchException {
2581 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2582
2583 Session session = null;
2584
2585 try {
2586 session = openSession();
2587
2588 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2589
2590 array[0] = getByG_P_L_PrevAndNext(session, journalContentSearch,
2591 groupId, privateLayout, layoutId, orderByComparator, true);
2592
2593 array[1] = journalContentSearch;
2594
2595 array[2] = getByG_P_L_PrevAndNext(session, journalContentSearch,
2596 groupId, privateLayout, layoutId, orderByComparator, false);
2597
2598 return array;
2599 }
2600 catch (Exception e) {
2601 throw processException(e);
2602 }
2603 finally {
2604 closeSession(session);
2605 }
2606 }
2607
2608 protected JournalContentSearch getByG_P_L_PrevAndNext(Session session,
2609 JournalContentSearch journalContentSearch, long groupId,
2610 boolean privateLayout, long layoutId,
2611 OrderByComparator<JournalContentSearch> orderByComparator,
2612 boolean previous) {
2613 StringBundler query = null;
2614
2615 if (orderByComparator != null) {
2616 query = new StringBundler(6 +
2617 (orderByComparator.getOrderByFields().length * 6));
2618 }
2619 else {
2620 query = new StringBundler(3);
2621 }
2622
2623 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2624
2625 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2626
2627 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2628
2629 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2630
2631 if (orderByComparator != null) {
2632 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2633
2634 if (orderByConditionFields.length > 0) {
2635 query.append(WHERE_AND);
2636 }
2637
2638 for (int i = 0; i < orderByConditionFields.length; i++) {
2639 query.append(_ORDER_BY_ENTITY_ALIAS);
2640 query.append(orderByConditionFields[i]);
2641
2642 if ((i + 1) < orderByConditionFields.length) {
2643 if (orderByComparator.isAscending() ^ previous) {
2644 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2645 }
2646 else {
2647 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2648 }
2649 }
2650 else {
2651 if (orderByComparator.isAscending() ^ previous) {
2652 query.append(WHERE_GREATER_THAN);
2653 }
2654 else {
2655 query.append(WHERE_LESSER_THAN);
2656 }
2657 }
2658 }
2659
2660 query.append(ORDER_BY_CLAUSE);
2661
2662 String[] orderByFields = orderByComparator.getOrderByFields();
2663
2664 for (int i = 0; i < orderByFields.length; i++) {
2665 query.append(_ORDER_BY_ENTITY_ALIAS);
2666 query.append(orderByFields[i]);
2667
2668 if ((i + 1) < orderByFields.length) {
2669 if (orderByComparator.isAscending() ^ previous) {
2670 query.append(ORDER_BY_ASC_HAS_NEXT);
2671 }
2672 else {
2673 query.append(ORDER_BY_DESC_HAS_NEXT);
2674 }
2675 }
2676 else {
2677 if (orderByComparator.isAscending() ^ previous) {
2678 query.append(ORDER_BY_ASC);
2679 }
2680 else {
2681 query.append(ORDER_BY_DESC);
2682 }
2683 }
2684 }
2685 }
2686 else {
2687 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2688 }
2689
2690 String sql = query.toString();
2691
2692 Query q = session.createQuery(sql);
2693
2694 q.setFirstResult(0);
2695 q.setMaxResults(2);
2696
2697 QueryPos qPos = QueryPos.getInstance(q);
2698
2699 qPos.add(groupId);
2700
2701 qPos.add(privateLayout);
2702
2703 qPos.add(layoutId);
2704
2705 if (orderByComparator != null) {
2706 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
2707
2708 for (Object value : values) {
2709 qPos.add(value);
2710 }
2711 }
2712
2713 List<JournalContentSearch> list = q.list();
2714
2715 if (list.size() == 2) {
2716 return list.get(1);
2717 }
2718 else {
2719 return null;
2720 }
2721 }
2722
2723
2730 @Override
2731 public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId) {
2732 for (JournalContentSearch journalContentSearch : findByG_P_L(groupId,
2733 privateLayout, layoutId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2734 null)) {
2735 remove(journalContentSearch);
2736 }
2737 }
2738
2739
2747 @Override
2748 public int countByG_P_L(long groupId, boolean privateLayout, long layoutId) {
2749 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_L;
2750
2751 Object[] finderArgs = new Object[] { groupId, privateLayout, layoutId };
2752
2753 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2754 this);
2755
2756 if (count == null) {
2757 StringBundler query = new StringBundler(4);
2758
2759 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2760
2761 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2762
2763 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2764
2765 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2766
2767 String sql = query.toString();
2768
2769 Session session = null;
2770
2771 try {
2772 session = openSession();
2773
2774 Query q = session.createQuery(sql);
2775
2776 QueryPos qPos = QueryPos.getInstance(q);
2777
2778 qPos.add(groupId);
2779
2780 qPos.add(privateLayout);
2781
2782 qPos.add(layoutId);
2783
2784 count = (Long)q.uniqueResult();
2785
2786 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2787 }
2788 catch (Exception e) {
2789 FinderCacheUtil.removeResult(finderPath, finderArgs);
2790
2791 throw processException(e);
2792 }
2793 finally {
2794 closeSession(session);
2795 }
2796 }
2797
2798 return count.intValue();
2799 }
2800
2801 private static final String _FINDER_COLUMN_G_P_L_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
2802 private static final String _FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
2803 private static final String _FINDER_COLUMN_G_P_L_LAYOUTID_2 = "journalContentSearch.layoutId = ?";
2804 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2805 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2806 JournalContentSearchImpl.class,
2807 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_A",
2808 new String[] {
2809 Long.class.getName(), Boolean.class.getName(),
2810 String.class.getName(),
2811
2812 Integer.class.getName(), Integer.class.getName(),
2813 OrderByComparator.class.getName()
2814 });
2815 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2816 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
2817 JournalContentSearchImpl.class,
2818 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_A",
2819 new String[] {
2820 Long.class.getName(), Boolean.class.getName(),
2821 String.class.getName()
2822 },
2823 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
2824 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
2825 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
2826 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
2827 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
2828 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_A",
2829 new String[] {
2830 Long.class.getName(), Boolean.class.getName(),
2831 String.class.getName()
2832 });
2833
2834
2842 @Override
2843 public List<JournalContentSearch> findByG_P_A(long groupId,
2844 boolean privateLayout, String articleId) {
2845 return findByG_P_A(groupId, privateLayout, articleId,
2846 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2847 }
2848
2849
2863 @Override
2864 public List<JournalContentSearch> findByG_P_A(long groupId,
2865 boolean privateLayout, String articleId, int start, int end) {
2866 return findByG_P_A(groupId, privateLayout, articleId, start, end, null);
2867 }
2868
2869
2884 @Override
2885 public List<JournalContentSearch> findByG_P_A(long groupId,
2886 boolean privateLayout, String articleId, int start, int end,
2887 OrderByComparator<JournalContentSearch> orderByComparator) {
2888 boolean pagination = true;
2889 FinderPath finderPath = null;
2890 Object[] finderArgs = null;
2891
2892 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2893 (orderByComparator == null)) {
2894 pagination = false;
2895 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A;
2896 finderArgs = new Object[] { groupId, privateLayout, articleId };
2897 }
2898 else {
2899 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_A;
2900 finderArgs = new Object[] {
2901 groupId, privateLayout, articleId,
2902
2903 start, end, orderByComparator
2904 };
2905 }
2906
2907 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
2908 finderArgs, this);
2909
2910 if ((list != null) && !list.isEmpty()) {
2911 for (JournalContentSearch journalContentSearch : list) {
2912 if ((groupId != journalContentSearch.getGroupId()) ||
2913 (privateLayout != journalContentSearch.getPrivateLayout()) ||
2914 !Validator.equals(articleId,
2915 journalContentSearch.getArticleId())) {
2916 list = null;
2917
2918 break;
2919 }
2920 }
2921 }
2922
2923 if (list == null) {
2924 StringBundler query = null;
2925
2926 if (orderByComparator != null) {
2927 query = new StringBundler(5 +
2928 (orderByComparator.getOrderByFields().length * 3));
2929 }
2930 else {
2931 query = new StringBundler(5);
2932 }
2933
2934 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2935
2936 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2937
2938 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2939
2940 boolean bindArticleId = false;
2941
2942 if (articleId == null) {
2943 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2944 }
2945 else if (articleId.equals(StringPool.BLANK)) {
2946 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2947 }
2948 else {
2949 bindArticleId = true;
2950
2951 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2952 }
2953
2954 if (orderByComparator != null) {
2955 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2956 orderByComparator);
2957 }
2958 else
2959 if (pagination) {
2960 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
2961 }
2962
2963 String sql = query.toString();
2964
2965 Session session = null;
2966
2967 try {
2968 session = openSession();
2969
2970 Query q = session.createQuery(sql);
2971
2972 QueryPos qPos = QueryPos.getInstance(q);
2973
2974 qPos.add(groupId);
2975
2976 qPos.add(privateLayout);
2977
2978 if (bindArticleId) {
2979 qPos.add(articleId);
2980 }
2981
2982 if (!pagination) {
2983 list = (List<JournalContentSearch>)QueryUtil.list(q,
2984 getDialect(), start, end, false);
2985
2986 Collections.sort(list);
2987
2988 list = Collections.unmodifiableList(list);
2989 }
2990 else {
2991 list = (List<JournalContentSearch>)QueryUtil.list(q,
2992 getDialect(), start, end);
2993 }
2994
2995 cacheResult(list);
2996
2997 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2998 }
2999 catch (Exception e) {
3000 FinderCacheUtil.removeResult(finderPath, finderArgs);
3001
3002 throw processException(e);
3003 }
3004 finally {
3005 closeSession(session);
3006 }
3007 }
3008
3009 return list;
3010 }
3011
3012
3022 @Override
3023 public JournalContentSearch findByG_P_A_First(long groupId,
3024 boolean privateLayout, String articleId,
3025 OrderByComparator<JournalContentSearch> orderByComparator)
3026 throws NoSuchContentSearchException {
3027 JournalContentSearch journalContentSearch = fetchByG_P_A_First(groupId,
3028 privateLayout, articleId, orderByComparator);
3029
3030 if (journalContentSearch != null) {
3031 return journalContentSearch;
3032 }
3033
3034 StringBundler msg = new StringBundler(8);
3035
3036 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3037
3038 msg.append("groupId=");
3039 msg.append(groupId);
3040
3041 msg.append(", privateLayout=");
3042 msg.append(privateLayout);
3043
3044 msg.append(", articleId=");
3045 msg.append(articleId);
3046
3047 msg.append(StringPool.CLOSE_CURLY_BRACE);
3048
3049 throw new NoSuchContentSearchException(msg.toString());
3050 }
3051
3052
3061 @Override
3062 public JournalContentSearch fetchByG_P_A_First(long groupId,
3063 boolean privateLayout, String articleId,
3064 OrderByComparator<JournalContentSearch> orderByComparator) {
3065 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
3066 articleId, 0, 1, orderByComparator);
3067
3068 if (!list.isEmpty()) {
3069 return list.get(0);
3070 }
3071
3072 return null;
3073 }
3074
3075
3085 @Override
3086 public JournalContentSearch findByG_P_A_Last(long groupId,
3087 boolean privateLayout, String articleId,
3088 OrderByComparator<JournalContentSearch> orderByComparator)
3089 throws NoSuchContentSearchException {
3090 JournalContentSearch journalContentSearch = fetchByG_P_A_Last(groupId,
3091 privateLayout, articleId, orderByComparator);
3092
3093 if (journalContentSearch != null) {
3094 return journalContentSearch;
3095 }
3096
3097 StringBundler msg = new StringBundler(8);
3098
3099 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3100
3101 msg.append("groupId=");
3102 msg.append(groupId);
3103
3104 msg.append(", privateLayout=");
3105 msg.append(privateLayout);
3106
3107 msg.append(", articleId=");
3108 msg.append(articleId);
3109
3110 msg.append(StringPool.CLOSE_CURLY_BRACE);
3111
3112 throw new NoSuchContentSearchException(msg.toString());
3113 }
3114
3115
3124 @Override
3125 public JournalContentSearch fetchByG_P_A_Last(long groupId,
3126 boolean privateLayout, String articleId,
3127 OrderByComparator<JournalContentSearch> orderByComparator) {
3128 int count = countByG_P_A(groupId, privateLayout, articleId);
3129
3130 if (count == 0) {
3131 return null;
3132 }
3133
3134 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
3135 articleId, count - 1, count, orderByComparator);
3136
3137 if (!list.isEmpty()) {
3138 return list.get(0);
3139 }
3140
3141 return null;
3142 }
3143
3144
3155 @Override
3156 public JournalContentSearch[] findByG_P_A_PrevAndNext(
3157 long contentSearchId, long groupId, boolean privateLayout,
3158 String articleId,
3159 OrderByComparator<JournalContentSearch> orderByComparator)
3160 throws NoSuchContentSearchException {
3161 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
3162
3163 Session session = null;
3164
3165 try {
3166 session = openSession();
3167
3168 JournalContentSearch[] array = new JournalContentSearchImpl[3];
3169
3170 array[0] = getByG_P_A_PrevAndNext(session, journalContentSearch,
3171 groupId, privateLayout, articleId, orderByComparator, true);
3172
3173 array[1] = journalContentSearch;
3174
3175 array[2] = getByG_P_A_PrevAndNext(session, journalContentSearch,
3176 groupId, privateLayout, articleId, orderByComparator, false);
3177
3178 return array;
3179 }
3180 catch (Exception e) {
3181 throw processException(e);
3182 }
3183 finally {
3184 closeSession(session);
3185 }
3186 }
3187
3188 protected JournalContentSearch getByG_P_A_PrevAndNext(Session session,
3189 JournalContentSearch journalContentSearch, long groupId,
3190 boolean privateLayout, String articleId,
3191 OrderByComparator<JournalContentSearch> orderByComparator,
3192 boolean previous) {
3193 StringBundler query = null;
3194
3195 if (orderByComparator != null) {
3196 query = new StringBundler(6 +
3197 (orderByComparator.getOrderByFields().length * 6));
3198 }
3199 else {
3200 query = new StringBundler(3);
3201 }
3202
3203 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3204
3205 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
3206
3207 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
3208
3209 boolean bindArticleId = false;
3210
3211 if (articleId == null) {
3212 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
3213 }
3214 else if (articleId.equals(StringPool.BLANK)) {
3215 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
3216 }
3217 else {
3218 bindArticleId = true;
3219
3220 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
3221 }
3222
3223 if (orderByComparator != null) {
3224 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3225
3226 if (orderByConditionFields.length > 0) {
3227 query.append(WHERE_AND);
3228 }
3229
3230 for (int i = 0; i < orderByConditionFields.length; i++) {
3231 query.append(_ORDER_BY_ENTITY_ALIAS);
3232 query.append(orderByConditionFields[i]);
3233
3234 if ((i + 1) < orderByConditionFields.length) {
3235 if (orderByComparator.isAscending() ^ previous) {
3236 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3237 }
3238 else {
3239 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3240 }
3241 }
3242 else {
3243 if (orderByComparator.isAscending() ^ previous) {
3244 query.append(WHERE_GREATER_THAN);
3245 }
3246 else {
3247 query.append(WHERE_LESSER_THAN);
3248 }
3249 }
3250 }
3251
3252 query.append(ORDER_BY_CLAUSE);
3253
3254 String[] orderByFields = orderByComparator.getOrderByFields();
3255
3256 for (int i = 0; i < orderByFields.length; i++) {
3257 query.append(_ORDER_BY_ENTITY_ALIAS);
3258 query.append(orderByFields[i]);
3259
3260 if ((i + 1) < orderByFields.length) {
3261 if (orderByComparator.isAscending() ^ previous) {
3262 query.append(ORDER_BY_ASC_HAS_NEXT);
3263 }
3264 else {
3265 query.append(ORDER_BY_DESC_HAS_NEXT);
3266 }
3267 }
3268 else {
3269 if (orderByComparator.isAscending() ^ previous) {
3270 query.append(ORDER_BY_ASC);
3271 }
3272 else {
3273 query.append(ORDER_BY_DESC);
3274 }
3275 }
3276 }
3277 }
3278 else {
3279 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
3280 }
3281
3282 String sql = query.toString();
3283
3284 Query q = session.createQuery(sql);
3285
3286 q.setFirstResult(0);
3287 q.setMaxResults(2);
3288
3289 QueryPos qPos = QueryPos.getInstance(q);
3290
3291 qPos.add(groupId);
3292
3293 qPos.add(privateLayout);
3294
3295 if (bindArticleId) {
3296 qPos.add(articleId);
3297 }
3298
3299 if (orderByComparator != null) {
3300 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
3301
3302 for (Object value : values) {
3303 qPos.add(value);
3304 }
3305 }
3306
3307 List<JournalContentSearch> list = q.list();
3308
3309 if (list.size() == 2) {
3310 return list.get(1);
3311 }
3312 else {
3313 return null;
3314 }
3315 }
3316
3317
3324 @Override
3325 public void removeByG_P_A(long groupId, boolean privateLayout,
3326 String articleId) {
3327 for (JournalContentSearch journalContentSearch : findByG_P_A(groupId,
3328 privateLayout, articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3329 null)) {
3330 remove(journalContentSearch);
3331 }
3332 }
3333
3334
3342 @Override
3343 public int countByG_P_A(long groupId, boolean privateLayout,
3344 String articleId) {
3345 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_A;
3346
3347 Object[] finderArgs = new Object[] { groupId, privateLayout, articleId };
3348
3349 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3350 this);
3351
3352 if (count == null) {
3353 StringBundler query = new StringBundler(4);
3354
3355 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3356
3357 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
3358
3359 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
3360
3361 boolean bindArticleId = false;
3362
3363 if (articleId == null) {
3364 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
3365 }
3366 else if (articleId.equals(StringPool.BLANK)) {
3367 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
3368 }
3369 else {
3370 bindArticleId = true;
3371
3372 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
3373 }
3374
3375 String sql = query.toString();
3376
3377 Session session = null;
3378
3379 try {
3380 session = openSession();
3381
3382 Query q = session.createQuery(sql);
3383
3384 QueryPos qPos = QueryPos.getInstance(q);
3385
3386 qPos.add(groupId);
3387
3388 qPos.add(privateLayout);
3389
3390 if (bindArticleId) {
3391 qPos.add(articleId);
3392 }
3393
3394 count = (Long)q.uniqueResult();
3395
3396 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3397 }
3398 catch (Exception e) {
3399 FinderCacheUtil.removeResult(finderPath, finderArgs);
3400
3401 throw processException(e);
3402 }
3403 finally {
3404 closeSession(session);
3405 }
3406 }
3407
3408 return count.intValue();
3409 }
3410
3411 private static final String _FINDER_COLUMN_G_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3412 private static final String _FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3413 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3414 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3415 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = '')";
3416 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
3417 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
3418 JournalContentSearchImpl.class,
3419 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_L_P",
3420 new String[] {
3421 Long.class.getName(), Boolean.class.getName(),
3422 Long.class.getName(), String.class.getName(),
3423
3424 Integer.class.getName(), Integer.class.getName(),
3425 OrderByComparator.class.getName()
3426 });
3427 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P =
3428 new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
3429 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
3430 JournalContentSearchImpl.class,
3431 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_L_P",
3432 new String[] {
3433 Long.class.getName(), Boolean.class.getName(),
3434 Long.class.getName(), String.class.getName()
3435 },
3436 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
3437 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
3438 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK |
3439 JournalContentSearchModelImpl.PORTLETID_COLUMN_BITMASK);
3440 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
3441 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
3442 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L_P",
3443 new String[] {
3444 Long.class.getName(), Boolean.class.getName(),
3445 Long.class.getName(), String.class.getName()
3446 });
3447
3448
3457 @Override
3458 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3459 boolean privateLayout, long layoutId, String portletId) {
3460 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
3461 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3462 }
3463
3464
3479 @Override
3480 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3481 boolean privateLayout, long layoutId, String portletId, int start,
3482 int end) {
3483 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
3484 start, end, null);
3485 }
3486
3487
3503 @Override
3504 public List<JournalContentSearch> findByG_P_L_P(long groupId,
3505 boolean privateLayout, long layoutId, String portletId, int start,
3506 int end, OrderByComparator<JournalContentSearch> orderByComparator) {
3507 boolean pagination = true;
3508 FinderPath finderPath = null;
3509 Object[] finderArgs = null;
3510
3511 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3512 (orderByComparator == null)) {
3513 pagination = false;
3514 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P;
3515 finderArgs = new Object[] {
3516 groupId, privateLayout, layoutId, portletId
3517 };
3518 }
3519 else {
3520 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L_P;
3521 finderArgs = new Object[] {
3522 groupId, privateLayout, layoutId, portletId,
3523
3524 start, end, orderByComparator
3525 };
3526 }
3527
3528 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
3529 finderArgs, this);
3530
3531 if ((list != null) && !list.isEmpty()) {
3532 for (JournalContentSearch journalContentSearch : list) {
3533 if ((groupId != journalContentSearch.getGroupId()) ||
3534 (privateLayout != journalContentSearch.getPrivateLayout()) ||
3535 (layoutId != journalContentSearch.getLayoutId()) ||
3536 !Validator.equals(portletId,
3537 journalContentSearch.getPortletId())) {
3538 list = null;
3539
3540 break;
3541 }
3542 }
3543 }
3544
3545 if (list == null) {
3546 StringBundler query = null;
3547
3548 if (orderByComparator != null) {
3549 query = new StringBundler(6 +
3550 (orderByComparator.getOrderByFields().length * 3));
3551 }
3552 else {
3553 query = new StringBundler(6);
3554 }
3555
3556 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3557
3558 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3559
3560 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3561
3562 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3563
3564 boolean bindPortletId = false;
3565
3566 if (portletId == null) {
3567 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3568 }
3569 else if (portletId.equals(StringPool.BLANK)) {
3570 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3571 }
3572 else {
3573 bindPortletId = true;
3574
3575 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3576 }
3577
3578 if (orderByComparator != null) {
3579 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3580 orderByComparator);
3581 }
3582 else
3583 if (pagination) {
3584 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
3585 }
3586
3587 String sql = query.toString();
3588
3589 Session session = null;
3590
3591 try {
3592 session = openSession();
3593
3594 Query q = session.createQuery(sql);
3595
3596 QueryPos qPos = QueryPos.getInstance(q);
3597
3598 qPos.add(groupId);
3599
3600 qPos.add(privateLayout);
3601
3602 qPos.add(layoutId);
3603
3604 if (bindPortletId) {
3605 qPos.add(portletId);
3606 }
3607
3608 if (!pagination) {
3609 list = (List<JournalContentSearch>)QueryUtil.list(q,
3610 getDialect(), start, end, false);
3611
3612 Collections.sort(list);
3613
3614 list = Collections.unmodifiableList(list);
3615 }
3616 else {
3617 list = (List<JournalContentSearch>)QueryUtil.list(q,
3618 getDialect(), start, end);
3619 }
3620
3621 cacheResult(list);
3622
3623 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3624 }
3625 catch (Exception e) {
3626 FinderCacheUtil.removeResult(finderPath, finderArgs);
3627
3628 throw processException(e);
3629 }
3630 finally {
3631 closeSession(session);
3632 }
3633 }
3634
3635 return list;
3636 }
3637
3638
3649 @Override
3650 public JournalContentSearch findByG_P_L_P_First(long groupId,
3651 boolean privateLayout, long layoutId, String portletId,
3652 OrderByComparator<JournalContentSearch> orderByComparator)
3653 throws NoSuchContentSearchException {
3654 JournalContentSearch journalContentSearch = fetchByG_P_L_P_First(groupId,
3655 privateLayout, layoutId, portletId, orderByComparator);
3656
3657 if (journalContentSearch != null) {
3658 return journalContentSearch;
3659 }
3660
3661 StringBundler msg = new StringBundler(10);
3662
3663 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3664
3665 msg.append("groupId=");
3666 msg.append(groupId);
3667
3668 msg.append(", privateLayout=");
3669 msg.append(privateLayout);
3670
3671 msg.append(", layoutId=");
3672 msg.append(layoutId);
3673
3674 msg.append(", portletId=");
3675 msg.append(portletId);
3676
3677 msg.append(StringPool.CLOSE_CURLY_BRACE);
3678
3679 throw new NoSuchContentSearchException(msg.toString());
3680 }
3681
3682
3692 @Override
3693 public JournalContentSearch fetchByG_P_L_P_First(long groupId,
3694 boolean privateLayout, long layoutId, String portletId,
3695 OrderByComparator<JournalContentSearch> orderByComparator) {
3696 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
3697 layoutId, portletId, 0, 1, orderByComparator);
3698
3699 if (!list.isEmpty()) {
3700 return list.get(0);
3701 }
3702
3703 return null;
3704 }
3705
3706
3717 @Override
3718 public JournalContentSearch findByG_P_L_P_Last(long groupId,
3719 boolean privateLayout, long layoutId, String portletId,
3720 OrderByComparator<JournalContentSearch> orderByComparator)
3721 throws NoSuchContentSearchException {
3722 JournalContentSearch journalContentSearch = fetchByG_P_L_P_Last(groupId,
3723 privateLayout, layoutId, portletId, orderByComparator);
3724
3725 if (journalContentSearch != null) {
3726 return journalContentSearch;
3727 }
3728
3729 StringBundler msg = new StringBundler(10);
3730
3731 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3732
3733 msg.append("groupId=");
3734 msg.append(groupId);
3735
3736 msg.append(", privateLayout=");
3737 msg.append(privateLayout);
3738
3739 msg.append(", layoutId=");
3740 msg.append(layoutId);
3741
3742 msg.append(", portletId=");
3743 msg.append(portletId);
3744
3745 msg.append(StringPool.CLOSE_CURLY_BRACE);
3746
3747 throw new NoSuchContentSearchException(msg.toString());
3748 }
3749
3750
3760 @Override
3761 public JournalContentSearch fetchByG_P_L_P_Last(long groupId,
3762 boolean privateLayout, long layoutId, String portletId,
3763 OrderByComparator<JournalContentSearch> orderByComparator) {
3764 int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
3765
3766 if (count == 0) {
3767 return null;
3768 }
3769
3770 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
3771 layoutId, portletId, count - 1, count, orderByComparator);
3772
3773 if (!list.isEmpty()) {
3774 return list.get(0);
3775 }
3776
3777 return null;
3778 }
3779
3780
3792 @Override
3793 public JournalContentSearch[] findByG_P_L_P_PrevAndNext(
3794 long contentSearchId, long groupId, boolean privateLayout,
3795 long layoutId, String portletId,
3796 OrderByComparator<JournalContentSearch> orderByComparator)
3797 throws NoSuchContentSearchException {
3798 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
3799
3800 Session session = null;
3801
3802 try {
3803 session = openSession();
3804
3805 JournalContentSearch[] array = new JournalContentSearchImpl[3];
3806
3807 array[0] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
3808 groupId, privateLayout, layoutId, portletId,
3809 orderByComparator, true);
3810
3811 array[1] = journalContentSearch;
3812
3813 array[2] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
3814 groupId, privateLayout, layoutId, portletId,
3815 orderByComparator, false);
3816
3817 return array;
3818 }
3819 catch (Exception e) {
3820 throw processException(e);
3821 }
3822 finally {
3823 closeSession(session);
3824 }
3825 }
3826
3827 protected JournalContentSearch getByG_P_L_P_PrevAndNext(Session session,
3828 JournalContentSearch journalContentSearch, long groupId,
3829 boolean privateLayout, long layoutId, String portletId,
3830 OrderByComparator<JournalContentSearch> orderByComparator,
3831 boolean previous) {
3832 StringBundler query = null;
3833
3834 if (orderByComparator != null) {
3835 query = new StringBundler(6 +
3836 (orderByComparator.getOrderByFields().length * 6));
3837 }
3838 else {
3839 query = new StringBundler(3);
3840 }
3841
3842 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
3843
3844 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3845
3846 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3847
3848 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3849
3850 boolean bindPortletId = false;
3851
3852 if (portletId == null) {
3853 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3854 }
3855 else if (portletId.equals(StringPool.BLANK)) {
3856 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3857 }
3858 else {
3859 bindPortletId = true;
3860
3861 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3862 }
3863
3864 if (orderByComparator != null) {
3865 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3866
3867 if (orderByConditionFields.length > 0) {
3868 query.append(WHERE_AND);
3869 }
3870
3871 for (int i = 0; i < orderByConditionFields.length; i++) {
3872 query.append(_ORDER_BY_ENTITY_ALIAS);
3873 query.append(orderByConditionFields[i]);
3874
3875 if ((i + 1) < orderByConditionFields.length) {
3876 if (orderByComparator.isAscending() ^ previous) {
3877 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3878 }
3879 else {
3880 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3881 }
3882 }
3883 else {
3884 if (orderByComparator.isAscending() ^ previous) {
3885 query.append(WHERE_GREATER_THAN);
3886 }
3887 else {
3888 query.append(WHERE_LESSER_THAN);
3889 }
3890 }
3891 }
3892
3893 query.append(ORDER_BY_CLAUSE);
3894
3895 String[] orderByFields = orderByComparator.getOrderByFields();
3896
3897 for (int i = 0; i < orderByFields.length; i++) {
3898 query.append(_ORDER_BY_ENTITY_ALIAS);
3899 query.append(orderByFields[i]);
3900
3901 if ((i + 1) < orderByFields.length) {
3902 if (orderByComparator.isAscending() ^ previous) {
3903 query.append(ORDER_BY_ASC_HAS_NEXT);
3904 }
3905 else {
3906 query.append(ORDER_BY_DESC_HAS_NEXT);
3907 }
3908 }
3909 else {
3910 if (orderByComparator.isAscending() ^ previous) {
3911 query.append(ORDER_BY_ASC);
3912 }
3913 else {
3914 query.append(ORDER_BY_DESC);
3915 }
3916 }
3917 }
3918 }
3919 else {
3920 query.append(JournalContentSearchModelImpl.ORDER_BY_JPQL);
3921 }
3922
3923 String sql = query.toString();
3924
3925 Query q = session.createQuery(sql);
3926
3927 q.setFirstResult(0);
3928 q.setMaxResults(2);
3929
3930 QueryPos qPos = QueryPos.getInstance(q);
3931
3932 qPos.add(groupId);
3933
3934 qPos.add(privateLayout);
3935
3936 qPos.add(layoutId);
3937
3938 if (bindPortletId) {
3939 qPos.add(portletId);
3940 }
3941
3942 if (orderByComparator != null) {
3943 Object[] values = orderByComparator.getOrderByConditionValues(journalContentSearch);
3944
3945 for (Object value : values) {
3946 qPos.add(value);
3947 }
3948 }
3949
3950 List<JournalContentSearch> list = q.list();
3951
3952 if (list.size() == 2) {
3953 return list.get(1);
3954 }
3955 else {
3956 return null;
3957 }
3958 }
3959
3960
3968 @Override
3969 public void removeByG_P_L_P(long groupId, boolean privateLayout,
3970 long layoutId, String portletId) {
3971 for (JournalContentSearch journalContentSearch : findByG_P_L_P(
3972 groupId, privateLayout, layoutId, portletId, QueryUtil.ALL_POS,
3973 QueryUtil.ALL_POS, null)) {
3974 remove(journalContentSearch);
3975 }
3976 }
3977
3978
3987 @Override
3988 public int countByG_P_L_P(long groupId, boolean privateLayout,
3989 long layoutId, String portletId) {
3990 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_L_P;
3991
3992 Object[] finderArgs = new Object[] {
3993 groupId, privateLayout, layoutId, portletId
3994 };
3995
3996 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3997 this);
3998
3999 if (count == null) {
4000 StringBundler query = new StringBundler(5);
4001
4002 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4003
4004 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
4005
4006 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
4007
4008 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
4009
4010 boolean bindPortletId = false;
4011
4012 if (portletId == null) {
4013 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
4014 }
4015 else if (portletId.equals(StringPool.BLANK)) {
4016 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
4017 }
4018 else {
4019 bindPortletId = true;
4020
4021 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
4022 }
4023
4024 String sql = query.toString();
4025
4026 Session session = null;
4027
4028 try {
4029 session = openSession();
4030
4031 Query q = session.createQuery(sql);
4032
4033 QueryPos qPos = QueryPos.getInstance(q);
4034
4035 qPos.add(groupId);
4036
4037 qPos.add(privateLayout);
4038
4039 qPos.add(layoutId);
4040
4041 if (bindPortletId) {
4042 qPos.add(portletId);
4043 }
4044
4045 count = (Long)q.uniqueResult();
4046
4047 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4048 }
4049 catch (Exception e) {
4050 FinderCacheUtil.removeResult(finderPath, finderArgs);
4051
4052 throw processException(e);
4053 }
4054 finally {
4055 closeSession(session);
4056 }
4057 }
4058
4059 return count.intValue();
4060 }
4061
4062 private static final String _FINDER_COLUMN_G_P_L_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4063 private static final String _FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4064 private static final String _FINDER_COLUMN_G_P_L_P_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
4065 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
4066 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_2 = "journalContentSearch.portletId = ?";
4067 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = '')";
4068 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4069 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
4070 JournalContentSearchImpl.class, FINDER_CLASS_NAME_ENTITY,
4071 "fetchByG_P_L_P_A",
4072 new String[] {
4073 Long.class.getName(), Boolean.class.getName(),
4074 Long.class.getName(), String.class.getName(),
4075 String.class.getName()
4076 },
4077 JournalContentSearchModelImpl.GROUPID_COLUMN_BITMASK |
4078 JournalContentSearchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
4079 JournalContentSearchModelImpl.LAYOUTID_COLUMN_BITMASK |
4080 JournalContentSearchModelImpl.PORTLETID_COLUMN_BITMASK |
4081 JournalContentSearchModelImpl.ARTICLEID_COLUMN_BITMASK);
4082 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4083 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED, Long.class,
4084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_L_P_A",
4085 new String[] {
4086 Long.class.getName(), Boolean.class.getName(),
4087 Long.class.getName(), String.class.getName(),
4088 String.class.getName()
4089 });
4090
4091
4102 @Override
4103 public JournalContentSearch findByG_P_L_P_A(long groupId,
4104 boolean privateLayout, long layoutId, String portletId, String articleId)
4105 throws NoSuchContentSearchException {
4106 JournalContentSearch journalContentSearch = fetchByG_P_L_P_A(groupId,
4107 privateLayout, layoutId, portletId, articleId);
4108
4109 if (journalContentSearch == null) {
4110 StringBundler msg = new StringBundler(12);
4111
4112 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4113
4114 msg.append("groupId=");
4115 msg.append(groupId);
4116
4117 msg.append(", privateLayout=");
4118 msg.append(privateLayout);
4119
4120 msg.append(", layoutId=");
4121 msg.append(layoutId);
4122
4123 msg.append(", portletId=");
4124 msg.append(portletId);
4125
4126 msg.append(", articleId=");
4127 msg.append(articleId);
4128
4129 msg.append(StringPool.CLOSE_CURLY_BRACE);
4130
4131 if (_log.isWarnEnabled()) {
4132 _log.warn(msg.toString());
4133 }
4134
4135 throw new NoSuchContentSearchException(msg.toString());
4136 }
4137
4138 return journalContentSearch;
4139 }
4140
4141
4151 @Override
4152 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
4153 boolean privateLayout, long layoutId, String portletId, String articleId) {
4154 return fetchByG_P_L_P_A(groupId, privateLayout, layoutId, portletId,
4155 articleId, true);
4156 }
4157
4158
4169 @Override
4170 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
4171 boolean privateLayout, long layoutId, String portletId,
4172 String articleId, boolean retrieveFromCache) {
4173 Object[] finderArgs = new Object[] {
4174 groupId, privateLayout, layoutId, portletId, articleId
4175 };
4176
4177 Object result = null;
4178
4179 if (retrieveFromCache) {
4180 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4181 finderArgs, this);
4182 }
4183
4184 if (result instanceof JournalContentSearch) {
4185 JournalContentSearch journalContentSearch = (JournalContentSearch)result;
4186
4187 if ((groupId != journalContentSearch.getGroupId()) ||
4188 (privateLayout != journalContentSearch.getPrivateLayout()) ||
4189 (layoutId != journalContentSearch.getLayoutId()) ||
4190 !Validator.equals(portletId,
4191 journalContentSearch.getPortletId()) ||
4192 !Validator.equals(articleId,
4193 journalContentSearch.getArticleId())) {
4194 result = null;
4195 }
4196 }
4197
4198 if (result == null) {
4199 StringBundler query = new StringBundler(7);
4200
4201 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
4202
4203 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
4204
4205 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
4206
4207 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
4208
4209 boolean bindPortletId = false;
4210
4211 if (portletId == null) {
4212 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
4213 }
4214 else if (portletId.equals(StringPool.BLANK)) {
4215 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
4216 }
4217 else {
4218 bindPortletId = true;
4219
4220 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
4221 }
4222
4223 boolean bindArticleId = false;
4224
4225 if (articleId == null) {
4226 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
4227 }
4228 else if (articleId.equals(StringPool.BLANK)) {
4229 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
4230 }
4231 else {
4232 bindArticleId = true;
4233
4234 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
4235 }
4236
4237 String sql = query.toString();
4238
4239 Session session = null;
4240
4241 try {
4242 session = openSession();
4243
4244 Query q = session.createQuery(sql);
4245
4246 QueryPos qPos = QueryPos.getInstance(q);
4247
4248 qPos.add(groupId);
4249
4250 qPos.add(privateLayout);
4251
4252 qPos.add(layoutId);
4253
4254 if (bindPortletId) {
4255 qPos.add(portletId);
4256 }
4257
4258 if (bindArticleId) {
4259 qPos.add(articleId);
4260 }
4261
4262 List<JournalContentSearch> list = q.list();
4263
4264 if (list.isEmpty()) {
4265 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4266 finderArgs, list);
4267 }
4268 else {
4269 JournalContentSearch journalContentSearch = list.get(0);
4270
4271 result = journalContentSearch;
4272
4273 cacheResult(journalContentSearch);
4274
4275 if ((journalContentSearch.getGroupId() != groupId) ||
4276 (journalContentSearch.getPrivateLayout() != privateLayout) ||
4277 (journalContentSearch.getLayoutId() != layoutId) ||
4278 (journalContentSearch.getPortletId() == null) ||
4279 !journalContentSearch.getPortletId()
4280 .equals(portletId) ||
4281 (journalContentSearch.getArticleId() == null) ||
4282 !journalContentSearch.getArticleId()
4283 .equals(articleId)) {
4284 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4285 finderArgs, journalContentSearch);
4286 }
4287 }
4288 }
4289 catch (Exception e) {
4290 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4291 finderArgs);
4292
4293 throw processException(e);
4294 }
4295 finally {
4296 closeSession(session);
4297 }
4298 }
4299
4300 if (result instanceof List<?>) {
4301 return null;
4302 }
4303 else {
4304 return (JournalContentSearch)result;
4305 }
4306 }
4307
4308
4318 @Override
4319 public JournalContentSearch removeByG_P_L_P_A(long groupId,
4320 boolean privateLayout, long layoutId, String portletId, String articleId)
4321 throws NoSuchContentSearchException {
4322 JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
4323 privateLayout, layoutId, portletId, articleId);
4324
4325 return remove(journalContentSearch);
4326 }
4327
4328
4338 @Override
4339 public int countByG_P_L_P_A(long groupId, boolean privateLayout,
4340 long layoutId, String portletId, String articleId) {
4341 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_L_P_A;
4342
4343 Object[] finderArgs = new Object[] {
4344 groupId, privateLayout, layoutId, portletId, articleId
4345 };
4346
4347 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4348 this);
4349
4350 if (count == null) {
4351 StringBundler query = new StringBundler(6);
4352
4353 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
4354
4355 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
4356
4357 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
4358
4359 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
4360
4361 boolean bindPortletId = false;
4362
4363 if (portletId == null) {
4364 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
4365 }
4366 else if (portletId.equals(StringPool.BLANK)) {
4367 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
4368 }
4369 else {
4370 bindPortletId = true;
4371
4372 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
4373 }
4374
4375 boolean bindArticleId = false;
4376
4377 if (articleId == null) {
4378 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
4379 }
4380 else if (articleId.equals(StringPool.BLANK)) {
4381 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
4382 }
4383 else {
4384 bindArticleId = true;
4385
4386 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
4387 }
4388
4389 String sql = query.toString();
4390
4391 Session session = null;
4392
4393 try {
4394 session = openSession();
4395
4396 Query q = session.createQuery(sql);
4397
4398 QueryPos qPos = QueryPos.getInstance(q);
4399
4400 qPos.add(groupId);
4401
4402 qPos.add(privateLayout);
4403
4404 qPos.add(layoutId);
4405
4406 if (bindPortletId) {
4407 qPos.add(portletId);
4408 }
4409
4410 if (bindArticleId) {
4411 qPos.add(articleId);
4412 }
4413
4414 count = (Long)q.uniqueResult();
4415
4416 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4417 }
4418 catch (Exception e) {
4419 FinderCacheUtil.removeResult(finderPath, finderArgs);
4420
4421 throw processException(e);
4422 }
4423 finally {
4424 closeSession(session);
4425 }
4426 }
4427
4428 return count.intValue();
4429 }
4430
4431 private static final String _FINDER_COLUMN_G_P_L_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
4432 private static final String _FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
4433 private static final String _FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
4434 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_1 = "journalContentSearch.portletId IS NULL AND ";
4435 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_2 = "journalContentSearch.portletId = ? AND ";
4436 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = '') AND ";
4437 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
4438 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
4439 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = '')";
4440
4441 public JournalContentSearchPersistenceImpl() {
4442 setModelClass(JournalContentSearch.class);
4443 }
4444
4445
4450 @Override
4451 public void cacheResult(JournalContentSearch journalContentSearch) {
4452 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4453 JournalContentSearchImpl.class,
4454 journalContentSearch.getPrimaryKey(), journalContentSearch);
4455
4456 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
4457 new Object[] {
4458 journalContentSearch.getGroupId(),
4459 journalContentSearch.getPrivateLayout(),
4460 journalContentSearch.getLayoutId(),
4461 journalContentSearch.getPortletId(),
4462 journalContentSearch.getArticleId()
4463 }, journalContentSearch);
4464
4465 journalContentSearch.resetOriginalValues();
4466 }
4467
4468
4473 @Override
4474 public void cacheResult(List<JournalContentSearch> journalContentSearchs) {
4475 for (JournalContentSearch journalContentSearch : journalContentSearchs) {
4476 if (EntityCacheUtil.getResult(
4477 JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4478 JournalContentSearchImpl.class,
4479 journalContentSearch.getPrimaryKey()) == null) {
4480 cacheResult(journalContentSearch);
4481 }
4482 else {
4483 journalContentSearch.resetOriginalValues();
4484 }
4485 }
4486 }
4487
4488
4495 @Override
4496 public void clearCache() {
4497 EntityCacheUtil.clearCache(JournalContentSearchImpl.class);
4498
4499 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4500 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4501 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4502 }
4503
4504
4511 @Override
4512 public void clearCache(JournalContentSearch journalContentSearch) {
4513 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4514 JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
4515
4516 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4517 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4518
4519 clearUniqueFindersCache(journalContentSearch);
4520 }
4521
4522 @Override
4523 public void clearCache(List<JournalContentSearch> journalContentSearchs) {
4524 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4525 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4526
4527 for (JournalContentSearch journalContentSearch : journalContentSearchs) {
4528 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4529 JournalContentSearchImpl.class,
4530 journalContentSearch.getPrimaryKey());
4531
4532 clearUniqueFindersCache(journalContentSearch);
4533 }
4534 }
4535
4536 protected void cacheUniqueFindersCache(
4537 JournalContentSearch journalContentSearch) {
4538 if (journalContentSearch.isNew()) {
4539 Object[] args = new Object[] {
4540 journalContentSearch.getGroupId(),
4541 journalContentSearch.getPrivateLayout(),
4542 journalContentSearch.getLayoutId(),
4543 journalContentSearch.getPortletId(),
4544 journalContentSearch.getArticleId()
4545 };
4546
4547 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args,
4548 Long.valueOf(1));
4549 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args,
4550 journalContentSearch);
4551 }
4552 else {
4553 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
4554
4555 if ((journalContentSearchModelImpl.getColumnBitmask() &
4556 FINDER_PATH_FETCH_BY_G_P_L_P_A.getColumnBitmask()) != 0) {
4557 Object[] args = new Object[] {
4558 journalContentSearch.getGroupId(),
4559 journalContentSearch.getPrivateLayout(),
4560 journalContentSearch.getLayoutId(),
4561 journalContentSearch.getPortletId(),
4562 journalContentSearch.getArticleId()
4563 };
4564
4565 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args,
4566 Long.valueOf(1));
4567 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args,
4568 journalContentSearch);
4569 }
4570 }
4571 }
4572
4573 protected void clearUniqueFindersCache(
4574 JournalContentSearch journalContentSearch) {
4575 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
4576
4577 Object[] args = new Object[] {
4578 journalContentSearch.getGroupId(),
4579 journalContentSearch.getPrivateLayout(),
4580 journalContentSearch.getLayoutId(),
4581 journalContentSearch.getPortletId(),
4582 journalContentSearch.getArticleId()
4583 };
4584
4585 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args);
4586 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args);
4587
4588 if ((journalContentSearchModelImpl.getColumnBitmask() &
4589 FINDER_PATH_FETCH_BY_G_P_L_P_A.getColumnBitmask()) != 0) {
4590 args = new Object[] {
4591 journalContentSearchModelImpl.getOriginalGroupId(),
4592 journalContentSearchModelImpl.getOriginalPrivateLayout(),
4593 journalContentSearchModelImpl.getOriginalLayoutId(),
4594 journalContentSearchModelImpl.getOriginalPortletId(),
4595 journalContentSearchModelImpl.getOriginalArticleId()
4596 };
4597
4598 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P_A, args);
4599 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A, args);
4600 }
4601 }
4602
4603
4609 @Override
4610 public JournalContentSearch create(long contentSearchId) {
4611 JournalContentSearch journalContentSearch = new JournalContentSearchImpl();
4612
4613 journalContentSearch.setNew(true);
4614 journalContentSearch.setPrimaryKey(contentSearchId);
4615
4616 return journalContentSearch;
4617 }
4618
4619
4626 @Override
4627 public JournalContentSearch remove(long contentSearchId)
4628 throws NoSuchContentSearchException {
4629 return remove((Serializable)contentSearchId);
4630 }
4631
4632
4639 @Override
4640 public JournalContentSearch remove(Serializable primaryKey)
4641 throws NoSuchContentSearchException {
4642 Session session = null;
4643
4644 try {
4645 session = openSession();
4646
4647 JournalContentSearch journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
4648 primaryKey);
4649
4650 if (journalContentSearch == null) {
4651 if (_log.isWarnEnabled()) {
4652 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4653 }
4654
4655 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4656 primaryKey);
4657 }
4658
4659 return remove(journalContentSearch);
4660 }
4661 catch (NoSuchContentSearchException nsee) {
4662 throw nsee;
4663 }
4664 catch (Exception e) {
4665 throw processException(e);
4666 }
4667 finally {
4668 closeSession(session);
4669 }
4670 }
4671
4672 @Override
4673 protected JournalContentSearch removeImpl(
4674 JournalContentSearch journalContentSearch) {
4675 journalContentSearch = toUnwrappedModel(journalContentSearch);
4676
4677 Session session = null;
4678
4679 try {
4680 session = openSession();
4681
4682 if (!session.contains(journalContentSearch)) {
4683 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
4684 journalContentSearch.getPrimaryKeyObj());
4685 }
4686
4687 if (journalContentSearch != null) {
4688 session.delete(journalContentSearch);
4689 }
4690 }
4691 catch (Exception e) {
4692 throw processException(e);
4693 }
4694 finally {
4695 closeSession(session);
4696 }
4697
4698 if (journalContentSearch != null) {
4699 clearCache(journalContentSearch);
4700 }
4701
4702 return journalContentSearch;
4703 }
4704
4705 @Override
4706 public JournalContentSearch updateImpl(
4707 JournalContentSearch journalContentSearch) {
4708 journalContentSearch = toUnwrappedModel(journalContentSearch);
4709
4710 boolean isNew = journalContentSearch.isNew();
4711
4712 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
4713
4714 Session session = null;
4715
4716 try {
4717 session = openSession();
4718
4719 if (journalContentSearch.isNew()) {
4720 session.save(journalContentSearch);
4721
4722 journalContentSearch.setNew(false);
4723 }
4724 else {
4725 session.merge(journalContentSearch);
4726 }
4727 }
4728 catch (Exception e) {
4729 throw processException(e);
4730 }
4731 finally {
4732 closeSession(session);
4733 }
4734
4735 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4736
4737 if (isNew || !JournalContentSearchModelImpl.COLUMN_BITMASK_ENABLED) {
4738 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4739 }
4740
4741 else {
4742 if ((journalContentSearchModelImpl.getColumnBitmask() &
4743 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID.getColumnBitmask()) != 0) {
4744 Object[] args = new Object[] {
4745 journalContentSearchModelImpl.getOriginalPortletId()
4746 };
4747
4748 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTLETID,
4749 args);
4750 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID,
4751 args);
4752
4753 args = new Object[] { journalContentSearchModelImpl.getPortletId() };
4754
4755 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTLETID,
4756 args);
4757 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID,
4758 args);
4759 }
4760
4761 if ((journalContentSearchModelImpl.getColumnBitmask() &
4762 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID.getColumnBitmask()) != 0) {
4763 Object[] args = new Object[] {
4764 journalContentSearchModelImpl.getOriginalArticleId()
4765 };
4766
4767 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ARTICLEID,
4768 args);
4769 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID,
4770 args);
4771
4772 args = new Object[] { journalContentSearchModelImpl.getArticleId() };
4773
4774 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ARTICLEID,
4775 args);
4776 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ARTICLEID,
4777 args);
4778 }
4779
4780 if ((journalContentSearchModelImpl.getColumnBitmask() &
4781 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
4782 Object[] args = new Object[] {
4783 journalContentSearchModelImpl.getOriginalGroupId(),
4784 journalContentSearchModelImpl.getOriginalPrivateLayout()
4785 };
4786
4787 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
4788 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
4789 args);
4790
4791 args = new Object[] {
4792 journalContentSearchModelImpl.getGroupId(),
4793 journalContentSearchModelImpl.getPrivateLayout()
4794 };
4795
4796 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
4797 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
4798 args);
4799 }
4800
4801 if ((journalContentSearchModelImpl.getColumnBitmask() &
4802 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
4803 Object[] args = new Object[] {
4804 journalContentSearchModelImpl.getOriginalGroupId(),
4805 journalContentSearchModelImpl.getOriginalArticleId()
4806 };
4807
4808 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
4809 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
4810 args);
4811
4812 args = new Object[] {
4813 journalContentSearchModelImpl.getGroupId(),
4814 journalContentSearchModelImpl.getArticleId()
4815 };
4816
4817 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
4818 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
4819 args);
4820 }
4821
4822 if ((journalContentSearchModelImpl.getColumnBitmask() &
4823 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L.getColumnBitmask()) != 0) {
4824 Object[] args = new Object[] {
4825 journalContentSearchModelImpl.getOriginalGroupId(),
4826 journalContentSearchModelImpl.getOriginalPrivateLayout(),
4827 journalContentSearchModelImpl.getOriginalLayoutId()
4828 };
4829
4830 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L, args);
4831 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L,
4832 args);
4833
4834 args = new Object[] {
4835 journalContentSearchModelImpl.getGroupId(),
4836 journalContentSearchModelImpl.getPrivateLayout(),
4837 journalContentSearchModelImpl.getLayoutId()
4838 };
4839
4840 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L, args);
4841 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L,
4842 args);
4843 }
4844
4845 if ((journalContentSearchModelImpl.getColumnBitmask() &
4846 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A.getColumnBitmask()) != 0) {
4847 Object[] args = new Object[] {
4848 journalContentSearchModelImpl.getOriginalGroupId(),
4849 journalContentSearchModelImpl.getOriginalPrivateLayout(),
4850 journalContentSearchModelImpl.getOriginalArticleId()
4851 };
4852
4853 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_A, args);
4854 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A,
4855 args);
4856
4857 args = new Object[] {
4858 journalContentSearchModelImpl.getGroupId(),
4859 journalContentSearchModelImpl.getPrivateLayout(),
4860 journalContentSearchModelImpl.getArticleId()
4861 };
4862
4863 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_A, args);
4864 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_A,
4865 args);
4866 }
4867
4868 if ((journalContentSearchModelImpl.getColumnBitmask() &
4869 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P.getColumnBitmask()) != 0) {
4870 Object[] args = new Object[] {
4871 journalContentSearchModelImpl.getOriginalGroupId(),
4872 journalContentSearchModelImpl.getOriginalPrivateLayout(),
4873 journalContentSearchModelImpl.getOriginalLayoutId(),
4874 journalContentSearchModelImpl.getOriginalPortletId()
4875 };
4876
4877 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P, args);
4878 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P,
4879 args);
4880
4881 args = new Object[] {
4882 journalContentSearchModelImpl.getGroupId(),
4883 journalContentSearchModelImpl.getPrivateLayout(),
4884 journalContentSearchModelImpl.getLayoutId(),
4885 journalContentSearchModelImpl.getPortletId()
4886 };
4887
4888 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_L_P, args);
4889 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_L_P,
4890 args);
4891 }
4892 }
4893
4894 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4895 JournalContentSearchImpl.class,
4896 journalContentSearch.getPrimaryKey(), journalContentSearch, false);
4897
4898 clearUniqueFindersCache(journalContentSearch);
4899 cacheUniqueFindersCache(journalContentSearch);
4900
4901 journalContentSearch.resetOriginalValues();
4902
4903 return journalContentSearch;
4904 }
4905
4906 protected JournalContentSearch toUnwrappedModel(
4907 JournalContentSearch journalContentSearch) {
4908 if (journalContentSearch instanceof JournalContentSearchImpl) {
4909 return journalContentSearch;
4910 }
4911
4912 JournalContentSearchImpl journalContentSearchImpl = new JournalContentSearchImpl();
4913
4914 journalContentSearchImpl.setNew(journalContentSearch.isNew());
4915 journalContentSearchImpl.setPrimaryKey(journalContentSearch.getPrimaryKey());
4916
4917 journalContentSearchImpl.setContentSearchId(journalContentSearch.getContentSearchId());
4918 journalContentSearchImpl.setGroupId(journalContentSearch.getGroupId());
4919 journalContentSearchImpl.setCompanyId(journalContentSearch.getCompanyId());
4920 journalContentSearchImpl.setPrivateLayout(journalContentSearch.isPrivateLayout());
4921 journalContentSearchImpl.setLayoutId(journalContentSearch.getLayoutId());
4922 journalContentSearchImpl.setPortletId(journalContentSearch.getPortletId());
4923 journalContentSearchImpl.setArticleId(journalContentSearch.getArticleId());
4924
4925 return journalContentSearchImpl;
4926 }
4927
4928
4935 @Override
4936 public JournalContentSearch findByPrimaryKey(Serializable primaryKey)
4937 throws NoSuchContentSearchException {
4938 JournalContentSearch journalContentSearch = fetchByPrimaryKey(primaryKey);
4939
4940 if (journalContentSearch == null) {
4941 if (_log.isWarnEnabled()) {
4942 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4943 }
4944
4945 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4946 primaryKey);
4947 }
4948
4949 return journalContentSearch;
4950 }
4951
4952
4959 @Override
4960 public JournalContentSearch findByPrimaryKey(long contentSearchId)
4961 throws NoSuchContentSearchException {
4962 return findByPrimaryKey((Serializable)contentSearchId);
4963 }
4964
4965
4971 @Override
4972 public JournalContentSearch fetchByPrimaryKey(Serializable primaryKey) {
4973 JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4974 JournalContentSearchImpl.class, primaryKey);
4975
4976 if (journalContentSearch == _nullJournalContentSearch) {
4977 return null;
4978 }
4979
4980 if (journalContentSearch == null) {
4981 Session session = null;
4982
4983 try {
4984 session = openSession();
4985
4986 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
4987 primaryKey);
4988
4989 if (journalContentSearch != null) {
4990 cacheResult(journalContentSearch);
4991 }
4992 else {
4993 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
4994 JournalContentSearchImpl.class, primaryKey,
4995 _nullJournalContentSearch);
4996 }
4997 }
4998 catch (Exception e) {
4999 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
5000 JournalContentSearchImpl.class, primaryKey);
5001
5002 throw processException(e);
5003 }
5004 finally {
5005 closeSession(session);
5006 }
5007 }
5008
5009 return journalContentSearch;
5010 }
5011
5012
5018 @Override
5019 public JournalContentSearch fetchByPrimaryKey(long contentSearchId) {
5020 return fetchByPrimaryKey((Serializable)contentSearchId);
5021 }
5022
5023 @Override
5024 public Map<Serializable, JournalContentSearch> fetchByPrimaryKeys(
5025 Set<Serializable> primaryKeys) {
5026 if (primaryKeys.isEmpty()) {
5027 return Collections.emptyMap();
5028 }
5029
5030 Map<Serializable, JournalContentSearch> map = new HashMap<Serializable, JournalContentSearch>();
5031
5032 if (primaryKeys.size() == 1) {
5033 Iterator<Serializable> iterator = primaryKeys.iterator();
5034
5035 Serializable primaryKey = iterator.next();
5036
5037 JournalContentSearch journalContentSearch = fetchByPrimaryKey(primaryKey);
5038
5039 if (journalContentSearch != null) {
5040 map.put(primaryKey, journalContentSearch);
5041 }
5042
5043 return map;
5044 }
5045
5046 Set<Serializable> uncachedPrimaryKeys = null;
5047
5048 for (Serializable primaryKey : primaryKeys) {
5049 JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
5050 JournalContentSearchImpl.class, primaryKey);
5051
5052 if (journalContentSearch == null) {
5053 if (uncachedPrimaryKeys == null) {
5054 uncachedPrimaryKeys = new HashSet<Serializable>();
5055 }
5056
5057 uncachedPrimaryKeys.add(primaryKey);
5058 }
5059 else {
5060 map.put(primaryKey, journalContentSearch);
5061 }
5062 }
5063
5064 if (uncachedPrimaryKeys == null) {
5065 return map;
5066 }
5067
5068 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
5069 1);
5070
5071 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE_PKS_IN);
5072
5073 for (Serializable primaryKey : uncachedPrimaryKeys) {
5074 query.append(String.valueOf(primaryKey));
5075
5076 query.append(StringPool.COMMA);
5077 }
5078
5079 query.setIndex(query.index() - 1);
5080
5081 query.append(StringPool.CLOSE_PARENTHESIS);
5082
5083 String sql = query.toString();
5084
5085 Session session = null;
5086
5087 try {
5088 session = openSession();
5089
5090 Query q = session.createQuery(sql);
5091
5092 for (JournalContentSearch journalContentSearch : (List<JournalContentSearch>)q.list()) {
5093 map.put(journalContentSearch.getPrimaryKeyObj(),
5094 journalContentSearch);
5095
5096 cacheResult(journalContentSearch);
5097
5098 uncachedPrimaryKeys.remove(journalContentSearch.getPrimaryKeyObj());
5099 }
5100
5101 for (Serializable primaryKey : uncachedPrimaryKeys) {
5102 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
5103 JournalContentSearchImpl.class, primaryKey,
5104 _nullJournalContentSearch);
5105 }
5106 }
5107 catch (Exception e) {
5108 throw processException(e);
5109 }
5110 finally {
5111 closeSession(session);
5112 }
5113
5114 return map;
5115 }
5116
5117
5122 @Override
5123 public List<JournalContentSearch> findAll() {
5124 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5125 }
5126
5127
5138 @Override
5139 public List<JournalContentSearch> findAll(int start, int end) {
5140 return findAll(start, end, null);
5141 }
5142
5143
5155 @Override
5156 public List<JournalContentSearch> findAll(int start, int end,
5157 OrderByComparator<JournalContentSearch> orderByComparator) {
5158 boolean pagination = true;
5159 FinderPath finderPath = null;
5160 Object[] finderArgs = null;
5161
5162 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5163 (orderByComparator == null)) {
5164 pagination = false;
5165 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5166 finderArgs = FINDER_ARGS_EMPTY;
5167 }
5168 else {
5169 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5170 finderArgs = new Object[] { start, end, orderByComparator };
5171 }
5172
5173 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(finderPath,
5174 finderArgs, this);
5175
5176 if (list == null) {
5177 StringBundler query = null;
5178 String sql = null;
5179
5180 if (orderByComparator != null) {
5181 query = new StringBundler(2 +
5182 (orderByComparator.getOrderByFields().length * 3));
5183
5184 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH);
5185
5186 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5187 orderByComparator);
5188
5189 sql = query.toString();
5190 }
5191 else {
5192 sql = _SQL_SELECT_JOURNALCONTENTSEARCH;
5193
5194 if (pagination) {
5195 sql = sql.concat(JournalContentSearchModelImpl.ORDER_BY_JPQL);
5196 }
5197 }
5198
5199 Session session = null;
5200
5201 try {
5202 session = openSession();
5203
5204 Query q = session.createQuery(sql);
5205
5206 if (!pagination) {
5207 list = (List<JournalContentSearch>)QueryUtil.list(q,
5208 getDialect(), start, end, false);
5209
5210 Collections.sort(list);
5211
5212 list = Collections.unmodifiableList(list);
5213 }
5214 else {
5215 list = (List<JournalContentSearch>)QueryUtil.list(q,
5216 getDialect(), start, end);
5217 }
5218
5219 cacheResult(list);
5220
5221 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5222 }
5223 catch (Exception e) {
5224 FinderCacheUtil.removeResult(finderPath, finderArgs);
5225
5226 throw processException(e);
5227 }
5228 finally {
5229 closeSession(session);
5230 }
5231 }
5232
5233 return list;
5234 }
5235
5236
5240 @Override
5241 public void removeAll() {
5242 for (JournalContentSearch journalContentSearch : findAll()) {
5243 remove(journalContentSearch);
5244 }
5245 }
5246
5247
5252 @Override
5253 public int countAll() {
5254 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5255 FINDER_ARGS_EMPTY, this);
5256
5257 if (count == null) {
5258 Session session = null;
5259
5260 try {
5261 session = openSession();
5262
5263 Query q = session.createQuery(_SQL_COUNT_JOURNALCONTENTSEARCH);
5264
5265 count = (Long)q.uniqueResult();
5266
5267 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5268 FINDER_ARGS_EMPTY, count);
5269 }
5270 catch (Exception e) {
5271 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5272 FINDER_ARGS_EMPTY);
5273
5274 throw processException(e);
5275 }
5276 finally {
5277 closeSession(session);
5278 }
5279 }
5280
5281 return count.intValue();
5282 }
5283
5284
5287 public void afterPropertiesSet() {
5288 }
5289
5290 public void destroy() {
5291 EntityCacheUtil.removeCache(JournalContentSearchImpl.class.getName());
5292 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5293 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5294 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5295 }
5296
5297 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch";
5298 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE_PKS_IN = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE contentSearchId IN (";
5299 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE ";
5300 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch";
5301 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH_WHERE = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch WHERE ";
5302 private static final String _ORDER_BY_ENTITY_ALIAS = "journalContentSearch.";
5303 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalContentSearch exists with the primary key ";
5304 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalContentSearch exists with the key {";
5305 private static final Log _log = LogFactoryUtil.getLog(JournalContentSearchPersistenceImpl.class);
5306 private static final JournalContentSearch _nullJournalContentSearch = new JournalContentSearchImpl() {
5307 @Override
5308 public Object clone() {
5309 return this;
5310 }
5311
5312 @Override
5313 public CacheModel<JournalContentSearch> toCacheModel() {
5314 return _nullJournalContentSearchCacheModel;
5315 }
5316 };
5317
5318 private static final CacheModel<JournalContentSearch> _nullJournalContentSearchCacheModel =
5319 new CacheModel<JournalContentSearch>() {
5320 @Override
5321 public JournalContentSearch toEntityModel() {
5322 return _nullJournalContentSearch;
5323 }
5324 };
5325 }