1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.journal.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.kernel.annotation.BeanReference;
19  import com.liferay.portal.kernel.cache.CacheRegistry;
20  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
21  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
22  import com.liferay.portal.kernel.dao.orm.FinderPath;
23  import com.liferay.portal.kernel.dao.orm.Query;
24  import com.liferay.portal.kernel.dao.orm.QueryPos;
25  import com.liferay.portal.kernel.dao.orm.QueryUtil;
26  import com.liferay.portal.kernel.dao.orm.Session;
27  import com.liferay.portal.kernel.exception.SystemException;
28  import com.liferay.portal.kernel.log.Log;
29  import com.liferay.portal.kernel.log.LogFactoryUtil;
30  import com.liferay.portal.kernel.util.GetterUtil;
31  import com.liferay.portal.kernel.util.OrderByComparator;
32  import com.liferay.portal.kernel.util.StringBundler;
33  import com.liferay.portal.kernel.util.StringPool;
34  import com.liferay.portal.kernel.util.StringUtil;
35  import com.liferay.portal.kernel.util.Validator;
36  import com.liferay.portal.model.ModelListener;
37  import com.liferay.portal.service.persistence.BatchSessionUtil;
38  import com.liferay.portal.service.persistence.GroupPersistence;
39  import com.liferay.portal.service.persistence.LayoutPersistence;
40  import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
41  import com.liferay.portal.service.persistence.ResourcePersistence;
42  import com.liferay.portal.service.persistence.UserPersistence;
43  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
44  
45  import com.liferay.portlet.journal.NoSuchContentSearchException;
46  import com.liferay.portlet.journal.model.JournalContentSearch;
47  import com.liferay.portlet.journal.model.impl.JournalContentSearchImpl;
48  import com.liferay.portlet.journal.model.impl.JournalContentSearchModelImpl;
49  
50  import java.io.Serializable;
51  
52  import java.util.ArrayList;
53  import java.util.Collections;
54  import java.util.List;
55  
56  /**
57   * <a href="JournalContentSearchPersistenceImpl.java.html"><b><i>View Source</i></b></a>
58   *
59   * <p>
60   * ServiceBuilder generated this class. Modifications in this class will be
61   * overwritten the next time is generated.
62   * </p>
63   *
64   * @author    Brian Wing Shun Chan
65   * @see       JournalContentSearchPersistence
66   * @see       JournalContentSearchUtil
67   * @generated
68   */
69  public class JournalContentSearchPersistenceImpl extends BasePersistenceImpl<JournalContentSearch>
70      implements JournalContentSearchPersistence {
71      public static final String FINDER_CLASS_NAME_ENTITY = JournalContentSearchImpl.class.getName();
72      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
73          ".List";
74      public static final FinderPath FINDER_PATH_FIND_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
75              JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
76              FINDER_CLASS_NAME_LIST, "findByArticleId",
77              new String[] { String.class.getName() });
78      public static final FinderPath FINDER_PATH_FIND_BY_OBC_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
79              JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
80              FINDER_CLASS_NAME_LIST, "findByArticleId",
81              new String[] {
82                  String.class.getName(),
83                  
84              "java.lang.Integer", "java.lang.Integer",
85                  "com.liferay.portal.kernel.util.OrderByComparator"
86              });
87      public static final FinderPath FINDER_PATH_COUNT_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
88              JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
89              FINDER_CLASS_NAME_LIST, "countByArticleId",
90              new String[] { String.class.getName() });
91      public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
92              JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
93              FINDER_CLASS_NAME_LIST, "findByG_P",
94              new String[] { Long.class.getName(), Boolean.class.getName() });
95      public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
96              JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
97              FINDER_CLASS_NAME_LIST, "findByG_P",
98              new String[] {
99                  Long.class.getName(), Boolean.class.getName(),
100                 
101             "java.lang.Integer", "java.lang.Integer",
102                 "com.liferay.portal.kernel.util.OrderByComparator"
103             });
104     public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
105             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
106             FINDER_CLASS_NAME_LIST, "countByG_P",
107             new String[] { Long.class.getName(), Boolean.class.getName() });
108     public static final FinderPath FINDER_PATH_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
109             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
110             FINDER_CLASS_NAME_LIST, "findByG_A",
111             new String[] { Long.class.getName(), String.class.getName() });
112     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
113             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
114             FINDER_CLASS_NAME_LIST, "findByG_A",
115             new String[] {
116                 Long.class.getName(), String.class.getName(),
117                 
118             "java.lang.Integer", "java.lang.Integer",
119                 "com.liferay.portal.kernel.util.OrderByComparator"
120             });
121     public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
122             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
123             FINDER_CLASS_NAME_LIST, "countByG_A",
124             new String[] { Long.class.getName(), String.class.getName() });
125     public static final FinderPath FINDER_PATH_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
126             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
127             FINDER_CLASS_NAME_LIST, "findByG_P_L",
128             new String[] {
129                 Long.class.getName(), Boolean.class.getName(),
130                 Long.class.getName()
131             });
132     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
133             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
134             FINDER_CLASS_NAME_LIST, "findByG_P_L",
135             new String[] {
136                 Long.class.getName(), Boolean.class.getName(),
137                 Long.class.getName(),
138                 
139             "java.lang.Integer", "java.lang.Integer",
140                 "com.liferay.portal.kernel.util.OrderByComparator"
141             });
142     public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
143             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
144             FINDER_CLASS_NAME_LIST, "countByG_P_L",
145             new String[] {
146                 Long.class.getName(), Boolean.class.getName(),
147                 Long.class.getName()
148             });
149     public static final FinderPath FINDER_PATH_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
150             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
151             FINDER_CLASS_NAME_LIST, "findByG_P_A",
152             new String[] {
153                 Long.class.getName(), Boolean.class.getName(),
154                 String.class.getName()
155             });
156     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
157             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
158             FINDER_CLASS_NAME_LIST, "findByG_P_A",
159             new String[] {
160                 Long.class.getName(), Boolean.class.getName(),
161                 String.class.getName(),
162                 
163             "java.lang.Integer", "java.lang.Integer",
164                 "com.liferay.portal.kernel.util.OrderByComparator"
165             });
166     public static final FinderPath FINDER_PATH_COUNT_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
167             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
168             FINDER_CLASS_NAME_LIST, "countByG_P_A",
169             new String[] {
170                 Long.class.getName(), Boolean.class.getName(),
171                 String.class.getName()
172             });
173     public static final FinderPath FINDER_PATH_FIND_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
174             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
175             FINDER_CLASS_NAME_LIST, "findByG_P_L_P",
176             new String[] {
177                 Long.class.getName(), Boolean.class.getName(),
178                 Long.class.getName(), String.class.getName()
179             });
180     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
181             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
182             FINDER_CLASS_NAME_LIST, "findByG_P_L_P",
183             new String[] {
184                 Long.class.getName(), Boolean.class.getName(),
185                 Long.class.getName(), String.class.getName(),
186                 
187             "java.lang.Integer", "java.lang.Integer",
188                 "com.liferay.portal.kernel.util.OrderByComparator"
189             });
190     public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
191             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
192             FINDER_CLASS_NAME_LIST, "countByG_P_L_P",
193             new String[] {
194                 Long.class.getName(), Boolean.class.getName(),
195                 Long.class.getName(), String.class.getName()
196             });
197     public static final FinderPath FINDER_PATH_FETCH_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
198             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
199             FINDER_CLASS_NAME_ENTITY, "fetchByG_P_L_P_A",
200             new String[] {
201                 Long.class.getName(), Boolean.class.getName(),
202                 Long.class.getName(), String.class.getName(),
203                 String.class.getName()
204             });
205     public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
206             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
207             FINDER_CLASS_NAME_LIST, "countByG_P_L_P_A",
208             new String[] {
209                 Long.class.getName(), Boolean.class.getName(),
210                 Long.class.getName(), String.class.getName(),
211                 String.class.getName()
212             });
213     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
214             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
215             FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
216     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
217             JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
218             FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
219 
220     public void cacheResult(JournalContentSearch journalContentSearch) {
221         EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
222             JournalContentSearchImpl.class,
223             journalContentSearch.getPrimaryKey(), journalContentSearch);
224 
225         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
226             new Object[] {
227                 new Long(journalContentSearch.getGroupId()),
228                 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
229                 new Long(journalContentSearch.getLayoutId()),
230                 
231             journalContentSearch.getPortletId(),
232                 
233             journalContentSearch.getArticleId()
234             }, journalContentSearch);
235     }
236 
237     public void cacheResult(List<JournalContentSearch> journalContentSearchs) {
238         for (JournalContentSearch journalContentSearch : journalContentSearchs) {
239             if (EntityCacheUtil.getResult(
240                         JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
241                         JournalContentSearchImpl.class,
242                         journalContentSearch.getPrimaryKey(), this) == null) {
243                 cacheResult(journalContentSearch);
244             }
245         }
246     }
247 
248     public void clearCache() {
249         CacheRegistry.clear(JournalContentSearchImpl.class.getName());
250         EntityCacheUtil.clearCache(JournalContentSearchImpl.class.getName());
251         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
252         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
253     }
254 
255     public JournalContentSearch create(long contentSearchId) {
256         JournalContentSearch journalContentSearch = new JournalContentSearchImpl();
257 
258         journalContentSearch.setNew(true);
259         journalContentSearch.setPrimaryKey(contentSearchId);
260 
261         return journalContentSearch;
262     }
263 
264     public JournalContentSearch remove(Serializable primaryKey)
265         throws NoSuchModelException, SystemException {
266         return remove(((Long)primaryKey).longValue());
267     }
268 
269     public JournalContentSearch remove(long contentSearchId)
270         throws NoSuchContentSearchException, SystemException {
271         Session session = null;
272 
273         try {
274             session = openSession();
275 
276             JournalContentSearch journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
277                     new Long(contentSearchId));
278 
279             if (journalContentSearch == null) {
280                 if (_log.isWarnEnabled()) {
281                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
282                         contentSearchId);
283                 }
284 
285                 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
286                     contentSearchId);
287             }
288 
289             return remove(journalContentSearch);
290         }
291         catch (NoSuchContentSearchException nsee) {
292             throw nsee;
293         }
294         catch (Exception e) {
295             throw processException(e);
296         }
297         finally {
298             closeSession(session);
299         }
300     }
301 
302     public JournalContentSearch remove(
303         JournalContentSearch journalContentSearch) throws SystemException {
304         for (ModelListener<JournalContentSearch> listener : listeners) {
305             listener.onBeforeRemove(journalContentSearch);
306         }
307 
308         journalContentSearch = removeImpl(journalContentSearch);
309 
310         for (ModelListener<JournalContentSearch> listener : listeners) {
311             listener.onAfterRemove(journalContentSearch);
312         }
313 
314         return journalContentSearch;
315     }
316 
317     protected JournalContentSearch removeImpl(
318         JournalContentSearch journalContentSearch) throws SystemException {
319         journalContentSearch = toUnwrappedModel(journalContentSearch);
320 
321         Session session = null;
322 
323         try {
324             session = openSession();
325 
326             if (journalContentSearch.isCachedModel() ||
327                     BatchSessionUtil.isEnabled()) {
328                 Object staleObject = session.get(JournalContentSearchImpl.class,
329                         journalContentSearch.getPrimaryKeyObj());
330 
331                 if (staleObject != null) {
332                     session.evict(staleObject);
333                 }
334             }
335 
336             session.delete(journalContentSearch);
337 
338             session.flush();
339         }
340         catch (Exception e) {
341             throw processException(e);
342         }
343         finally {
344             closeSession(session);
345         }
346 
347         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
348 
349         JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
350 
351         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
352             new Object[] {
353                 new Long(journalContentSearchModelImpl.getOriginalGroupId()),
354                 Boolean.valueOf(
355                     journalContentSearchModelImpl.getOriginalPrivateLayout()),
356                 new Long(journalContentSearchModelImpl.getOriginalLayoutId()),
357                 
358             journalContentSearchModelImpl.getOriginalPortletId(),
359                 
360             journalContentSearchModelImpl.getOriginalArticleId()
361             });
362 
363         EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
364             JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
365 
366         return journalContentSearch;
367     }
368 
369     public JournalContentSearch updateImpl(
370         com.liferay.portlet.journal.model.JournalContentSearch journalContentSearch,
371         boolean merge) throws SystemException {
372         journalContentSearch = toUnwrappedModel(journalContentSearch);
373 
374         boolean isNew = journalContentSearch.isNew();
375 
376         JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
377 
378         Session session = null;
379 
380         try {
381             session = openSession();
382 
383             BatchSessionUtil.update(session, journalContentSearch, merge);
384 
385             journalContentSearch.setNew(false);
386         }
387         catch (Exception e) {
388             throw processException(e);
389         }
390         finally {
391             closeSession(session);
392         }
393 
394         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
395 
396         EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
397             JournalContentSearchImpl.class,
398             journalContentSearch.getPrimaryKey(), journalContentSearch);
399 
400         if (!isNew &&
401                 ((journalContentSearch.getGroupId() != journalContentSearchModelImpl.getOriginalGroupId()) ||
402                 (journalContentSearch.getPrivateLayout() != journalContentSearchModelImpl.getOriginalPrivateLayout()) ||
403                 (journalContentSearch.getLayoutId() != journalContentSearchModelImpl.getOriginalLayoutId()) ||
404                 !Validator.equals(journalContentSearch.getPortletId(),
405                     journalContentSearchModelImpl.getOriginalPortletId()) ||
406                 !Validator.equals(journalContentSearch.getArticleId(),
407                     journalContentSearchModelImpl.getOriginalArticleId()))) {
408             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
409                 new Object[] {
410                     new Long(journalContentSearchModelImpl.getOriginalGroupId()),
411                     Boolean.valueOf(
412                         journalContentSearchModelImpl.getOriginalPrivateLayout()),
413                     new Long(journalContentSearchModelImpl.getOriginalLayoutId()),
414                     
415                 journalContentSearchModelImpl.getOriginalPortletId(),
416                     
417                 journalContentSearchModelImpl.getOriginalArticleId()
418                 });
419         }
420 
421         if (isNew ||
422                 ((journalContentSearch.getGroupId() != journalContentSearchModelImpl.getOriginalGroupId()) ||
423                 (journalContentSearch.getPrivateLayout() != journalContentSearchModelImpl.getOriginalPrivateLayout()) ||
424                 (journalContentSearch.getLayoutId() != journalContentSearchModelImpl.getOriginalLayoutId()) ||
425                 !Validator.equals(journalContentSearch.getPortletId(),
426                     journalContentSearchModelImpl.getOriginalPortletId()) ||
427                 !Validator.equals(journalContentSearch.getArticleId(),
428                     journalContentSearchModelImpl.getOriginalArticleId()))) {
429             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
430                 new Object[] {
431                     new Long(journalContentSearch.getGroupId()),
432                     Boolean.valueOf(journalContentSearch.getPrivateLayout()),
433                     new Long(journalContentSearch.getLayoutId()),
434                     
435                 journalContentSearch.getPortletId(),
436                     
437                 journalContentSearch.getArticleId()
438                 }, journalContentSearch);
439         }
440 
441         return journalContentSearch;
442     }
443 
444     protected JournalContentSearch toUnwrappedModel(
445         JournalContentSearch journalContentSearch) {
446         if (journalContentSearch instanceof JournalContentSearchImpl) {
447             return journalContentSearch;
448         }
449 
450         JournalContentSearchImpl journalContentSearchImpl = new JournalContentSearchImpl();
451 
452         journalContentSearchImpl.setNew(journalContentSearch.isNew());
453         journalContentSearchImpl.setPrimaryKey(journalContentSearch.getPrimaryKey());
454 
455         journalContentSearchImpl.setContentSearchId(journalContentSearch.getContentSearchId());
456         journalContentSearchImpl.setGroupId(journalContentSearch.getGroupId());
457         journalContentSearchImpl.setCompanyId(journalContentSearch.getCompanyId());
458         journalContentSearchImpl.setPrivateLayout(journalContentSearch.isPrivateLayout());
459         journalContentSearchImpl.setLayoutId(journalContentSearch.getLayoutId());
460         journalContentSearchImpl.setPortletId(journalContentSearch.getPortletId());
461         journalContentSearchImpl.setArticleId(journalContentSearch.getArticleId());
462 
463         return journalContentSearchImpl;
464     }
465 
466     public JournalContentSearch findByPrimaryKey(Serializable primaryKey)
467         throws NoSuchModelException, SystemException {
468         return findByPrimaryKey(((Long)primaryKey).longValue());
469     }
470 
471     public JournalContentSearch findByPrimaryKey(long contentSearchId)
472         throws NoSuchContentSearchException, SystemException {
473         JournalContentSearch journalContentSearch = fetchByPrimaryKey(contentSearchId);
474 
475         if (journalContentSearch == null) {
476             if (_log.isWarnEnabled()) {
477                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contentSearchId);
478             }
479 
480             throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
481                 contentSearchId);
482         }
483 
484         return journalContentSearch;
485     }
486 
487     public JournalContentSearch fetchByPrimaryKey(Serializable primaryKey)
488         throws SystemException {
489         return fetchByPrimaryKey(((Long)primaryKey).longValue());
490     }
491 
492     public JournalContentSearch fetchByPrimaryKey(long contentSearchId)
493         throws SystemException {
494         JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
495                 JournalContentSearchImpl.class, contentSearchId, this);
496 
497         if (journalContentSearch == null) {
498             Session session = null;
499 
500             try {
501                 session = openSession();
502 
503                 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
504                         new Long(contentSearchId));
505             }
506             catch (Exception e) {
507                 throw processException(e);
508             }
509             finally {
510                 if (journalContentSearch != null) {
511                     cacheResult(journalContentSearch);
512                 }
513 
514                 closeSession(session);
515             }
516         }
517 
518         return journalContentSearch;
519     }
520 
521     public List<JournalContentSearch> findByArticleId(String articleId)
522         throws SystemException {
523         Object[] finderArgs = new Object[] { articleId };
524 
525         List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ARTICLEID,
526                 finderArgs, this);
527 
528         if (list == null) {
529             Session session = null;
530 
531             try {
532                 session = openSession();
533 
534                 StringBundler query = new StringBundler(2);
535 
536                 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
537 
538                 if (articleId == null) {
539                     query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
540                 }
541                 else {
542                     if (articleId.equals(StringPool.BLANK)) {
543                         query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
544                     }
545                     else {
546                         query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
547                     }
548                 }
549 
550                 String sql = query.toString();
551 
552                 Query q = session.createQuery(sql);
553 
554                 QueryPos qPos = QueryPos.getInstance(q);
555 
556                 if (articleId != null) {
557                     qPos.add(articleId);
558                 }
559 
560                 list = q.list();
561             }
562             catch (Exception e) {
563                 throw processException(e);
564             }
565             finally {
566                 if (list == null) {
567                     list = new ArrayList<JournalContentSearch>();
568                 }
569 
570                 cacheResult(list);
571 
572                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ARTICLEID,
573                     finderArgs, list);
574 
575                 closeSession(session);
576             }
577         }
578 
579         return list;
580     }
581 
582     public List<JournalContentSearch> findByArticleId(String articleId,
583         int start, int end) throws SystemException {
584         return findByArticleId(articleId, start, end, null);
585     }
586 
587     public List<JournalContentSearch> findByArticleId(String articleId,
588         int start, int end, OrderByComparator orderByComparator)
589         throws SystemException {
590         Object[] finderArgs = new Object[] {
591                 articleId,
592                 
593                 String.valueOf(start), String.valueOf(end),
594                 String.valueOf(orderByComparator)
595             };
596 
597         List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ARTICLEID,
598                 finderArgs, this);
599 
600         if (list == null) {
601             Session session = null;
602 
603             try {
604                 session = openSession();
605 
606                 StringBundler query = null;
607 
608                 if (orderByComparator != null) {
609                     query = new StringBundler(3 +
610                             (orderByComparator.getOrderByFields().length * 3));
611                 }
612                 else {
613                     query = new StringBundler(2);
614                 }
615 
616                 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
617 
618                 if (articleId == null) {
619                     query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
620                 }
621                 else {
622                     if (articleId.equals(StringPool.BLANK)) {
623                         query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
624                     }
625                     else {
626                         query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
627                     }
628                 }
629 
630                 if (orderByComparator != null) {
631                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
632                         orderByComparator);
633                 }
634 
635                 String sql = query.toString();
636 
637                 Query q = session.createQuery(sql);
638 
639                 QueryPos qPos = QueryPos.getInstance(q);
640 
641                 if (articleId != null) {
642                     qPos.add(articleId);
643                 }
644 
645                 list = (List<JournalContentSearch>)QueryUtil.list(q,
646                         getDialect(), start, end);
647             }
648             catch (Exception e) {
649                 throw processException(e);
650             }
651             finally {
652                 if (list == null) {
653                     list = new ArrayList<JournalContentSearch>();
654                 }
655 
656                 cacheResult(list);
657 
658                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ARTICLEID,
659                     finderArgs, list);
660 
661                 closeSession(session);
662             }
663         }
664 
665         return list;
666     }
667 
668     public JournalContentSearch findByArticleId_First(String articleId,
669         OrderByComparator orderByComparator)
670         throws NoSuchContentSearchException, SystemException {
671         List<JournalContentSearch> list = findByArticleId(articleId, 0, 1,
672                 orderByComparator);
673 
674         if (list.isEmpty()) {
675             StringBundler msg = new StringBundler(4);
676 
677             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
678 
679             msg.append("articleId=");
680             msg.append(articleId);
681 
682             msg.append(StringPool.CLOSE_CURLY_BRACE);
683 
684             throw new NoSuchContentSearchException(msg.toString());
685         }
686         else {
687             return list.get(0);
688         }
689     }
690 
691     public JournalContentSearch findByArticleId_Last(String articleId,
692         OrderByComparator orderByComparator)
693         throws NoSuchContentSearchException, SystemException {
694         int count = countByArticleId(articleId);
695 
696         List<JournalContentSearch> list = findByArticleId(articleId, count - 1,
697                 count, orderByComparator);
698 
699         if (list.isEmpty()) {
700             StringBundler msg = new StringBundler(4);
701 
702             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
703 
704             msg.append("articleId=");
705             msg.append(articleId);
706 
707             msg.append(StringPool.CLOSE_CURLY_BRACE);
708 
709             throw new NoSuchContentSearchException(msg.toString());
710         }
711         else {
712             return list.get(0);
713         }
714     }
715 
716     public JournalContentSearch[] findByArticleId_PrevAndNext(
717         long contentSearchId, String articleId,
718         OrderByComparator orderByComparator)
719         throws NoSuchContentSearchException, SystemException {
720         JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
721 
722         int count = countByArticleId(articleId);
723 
724         Session session = null;
725 
726         try {
727             session = openSession();
728 
729             StringBundler query = null;
730 
731             if (orderByComparator != null) {
732                 query = new StringBundler(3 +
733                         (orderByComparator.getOrderByFields().length * 3));
734             }
735             else {
736                 query = new StringBundler(2);
737             }
738 
739             query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
740 
741             if (articleId == null) {
742                 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
743             }
744             else {
745                 if (articleId.equals(StringPool.BLANK)) {
746                     query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
747                 }
748                 else {
749                     query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
750                 }
751             }
752 
753             if (orderByComparator != null) {
754                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
755                     orderByComparator);
756             }
757 
758             String sql = query.toString();
759 
760             Query q = session.createQuery(sql);
761 
762             QueryPos qPos = QueryPos.getInstance(q);
763 
764             if (articleId != null) {
765                 qPos.add(articleId);
766             }
767 
768             Object[] objArray = QueryUtil.getPrevAndNext(q, count,
769                     orderByComparator, journalContentSearch);
770 
771             JournalContentSearch[] array = new JournalContentSearchImpl[3];
772 
773             array[0] = (JournalContentSearch)objArray[0];
774             array[1] = (JournalContentSearch)objArray[1];
775             array[2] = (JournalContentSearch)objArray[2];
776 
777             return array;
778         }
779         catch (Exception e) {
780             throw processException(e);
781         }
782         finally {
783             closeSession(session);
784         }
785     }
786 
787     public List<JournalContentSearch> findByG_P(long groupId,
788         boolean privateLayout) throws SystemException {
789         Object[] finderArgs = new Object[] {
790                 new Long(groupId), Boolean.valueOf(privateLayout)
791             };
792 
793         List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
794                 finderArgs, this);
795 
796         if (list == null) {
797             Session session = null;
798 
799             try {
800                 session = openSession();
801 
802                 StringBundler query = new StringBundler(3);
803 
804                 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
805 
806                 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
807 
808                 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
809 
810                 String sql = query.toString();
811 
812                 Query q = session.createQuery(sql);
813 
814                 QueryPos qPos = QueryPos.getInstance(q);
815 
816                 qPos.add(groupId);
817 
818                 qPos.add(privateLayout);
819 
820                 list = q.list();
821             }
822             catch (Exception e) {
823                 throw processException(e);
824             }
825             finally {
826                 if (list == null) {
827                     list = new ArrayList<JournalContentSearch>();
828                 }
829 
830                 cacheResult(list);
831 
832                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
833                     list);
834 
835                 closeSession(session);
836             }
837         }
838 
839         return list;
840     }
841 
842     public List<JournalContentSearch> findByG_P(long groupId,
843         boolean privateLayout, int start, int end) throws SystemException {
844         return findByG_P(groupId, privateLayout, start, end, null);
845     }
846 
847     public List<JournalContentSearch> findByG_P(long groupId,
848         boolean privateLayout, int start, int end,
849         OrderByComparator orderByComparator) throws SystemException {
850         Object[] finderArgs = new Object[] {
851                 new Long(groupId), Boolean.valueOf(privateLayout),
852                 
853                 String.valueOf(start), String.valueOf(end),
854                 String.valueOf(orderByComparator)
855             };
856 
857         List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_P,
858                 finderArgs, this);
859 
860         if (list == null) {
861             Session session = null;
862 
863             try {
864                 session = openSession();
865 
866                 StringBundler query = null;
867 
868                 if (orderByComparator != null) {
869                     query = new StringBundler(4 +
870                             (orderByComparator.getOrderByFields().length * 3));
871                 }
872                 else {
873                     query = new StringBundler(3);
874                 }
875 
876                 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
877 
878                 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
879 
880                 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
881 
882                 if (orderByComparator != null) {
883                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
884                         orderByComparator);
885                 }
886 
887                 String sql = query.toString();
888 
889                 Query q = session.createQuery(sql);
890 
891                 QueryPos qPos = QueryPos.getInstance(q);
892 
893                 qPos.add(groupId);
894 
895                 qPos.add(privateLayout);
896 
897                 list = (List<JournalContentSearch>)QueryUtil.list(q,
898                         getDialect(), start, end);
899             }
900             catch (Exception e) {
901                 throw processException(e);
902             }
903             finally {
904                 if (list == null) {
905                     list = new ArrayList<JournalContentSearch>();
906                 }
907 
908                 cacheResult(list);
909 
910                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_P,
911                     finderArgs, list);
912 
913                 closeSession(session);
914             }
915         }
916 
917         return list;
918     }
919 
920     public JournalContentSearch findByG_P_First(long groupId,
921         boolean privateLayout, OrderByComparator orderByComparator)
922         throws NoSuchContentSearchException, SystemException {
923         List<JournalContentSearch> list = findByG_P(groupId, privateLayout, 0,
924                 1, orderByComparator);
925 
926         if (list.isEmpty()) {
927             StringBundler msg = new StringBundler(6);
928 
929             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
930 
931             msg.append("groupId=");
932             msg.append(groupId);
933 
934             msg.append(", privateLayout=");
935             msg.append(privateLayout);
936 
937             msg.append(StringPool.CLOSE_CURLY_BRACE);
938 
939             throw new NoSuchContentSearchException(msg.toString());
940         }
941         else {
942             return list.get(0);
943         }
944     }
945 
946     public JournalContentSearch findByG_P_Last(long groupId,
947         boolean privateLayout, OrderByComparator orderByComparator)
948         throws NoSuchContentSearchException, SystemException {
949         int count = countByG_P(groupId, privateLayout);
950 
951         List<JournalContentSearch> list = findByG_P(groupId, privateLayout,
952                 count - 1, count, orderByComparator);
953 
954         if (list.isEmpty()) {
955             StringBundler msg = new StringBundler(6);
956 
957             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
958 
959             msg.append("groupId=");
960             msg.append(groupId);
961 
962             msg.append(", privateLayout=");
963             msg.append(privateLayout);
964 
965             msg.append(StringPool.CLOSE_CURLY_BRACE);
966 
967             throw new NoSuchContentSearchException(msg.toString());
968         }
969         else {
970             return list.get(0);
971         }
972     }
973 
974     public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
975         long groupId, boolean privateLayout, OrderByComparator orderByComparator)
976         throws NoSuchContentSearchException, SystemException {
977         JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
978 
979         int count = countByG_P(groupId, privateLayout);
980 
981         Session session = null;
982 
983         try {
984             session = openSession();
985 
986             StringBundler query = null;
987 
988             if (orderByComparator != null) {
989                 query = new StringBundler(4 +
990                         (orderByComparator.getOrderByFields().length * 3));
991             }
992             else {
993                 query = new StringBundler(3);
994             }
995 
996             query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
997 
998             query.append(_FINDER_COLUMN_G_P_GROUPID_2);
999 
1000            query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1001
1002            if (orderByComparator != null) {
1003                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1004                    orderByComparator);
1005            }
1006
1007            String sql = query.toString();
1008
1009            Query q = session.createQuery(sql);
1010
1011            QueryPos qPos = QueryPos.getInstance(q);
1012
1013            qPos.add(groupId);
1014
1015            qPos.add(privateLayout);
1016
1017            Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1018                    orderByComparator, journalContentSearch);
1019
1020            JournalContentSearch[] array = new JournalContentSearchImpl[3];
1021
1022            array[0] = (JournalContentSearch)objArray[0];
1023            array[1] = (JournalContentSearch)objArray[1];
1024            array[2] = (JournalContentSearch)objArray[2];
1025
1026            return array;
1027        }
1028        catch (Exception e) {
1029            throw processException(e);
1030        }
1031        finally {
1032            closeSession(session);
1033        }
1034    }
1035
1036    public List<JournalContentSearch> findByG_A(long groupId, String articleId)
1037        throws SystemException {
1038        Object[] finderArgs = new Object[] { new Long(groupId), articleId };
1039
1040        List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_A,
1041                finderArgs, this);
1042
1043        if (list == null) {
1044            Session session = null;
1045
1046            try {
1047                session = openSession();
1048
1049                StringBundler query = new StringBundler(3);
1050
1051                query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1052
1053                query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1054
1055                if (articleId == null) {
1056                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1057                }
1058                else {
1059                    if (articleId.equals(StringPool.BLANK)) {
1060                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1061                    }
1062                    else {
1063                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1064                    }
1065                }
1066
1067                String sql = query.toString();
1068
1069                Query q = session.createQuery(sql);
1070
1071                QueryPos qPos = QueryPos.getInstance(q);
1072
1073                qPos.add(groupId);
1074
1075                if (articleId != null) {
1076                    qPos.add(articleId);
1077                }
1078
1079                list = q.list();
1080            }
1081            catch (Exception e) {
1082                throw processException(e);
1083            }
1084            finally {
1085                if (list == null) {
1086                    list = new ArrayList<JournalContentSearch>();
1087                }
1088
1089                cacheResult(list);
1090
1091                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_A, finderArgs,
1092                    list);
1093
1094                closeSession(session);
1095            }
1096        }
1097
1098        return list;
1099    }
1100
1101    public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1102        int start, int end) throws SystemException {
1103        return findByG_A(groupId, articleId, start, end, null);
1104    }
1105
1106    public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1107        int start, int end, OrderByComparator orderByComparator)
1108        throws SystemException {
1109        Object[] finderArgs = new Object[] {
1110                new Long(groupId),
1111                
1112                articleId,
1113                
1114                String.valueOf(start), String.valueOf(end),
1115                String.valueOf(orderByComparator)
1116            };
1117
1118        List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_A,
1119                finderArgs, this);
1120
1121        if (list == null) {
1122            Session session = null;
1123
1124            try {
1125                session = openSession();
1126
1127                StringBundler query = null;
1128
1129                if (orderByComparator != null) {
1130                    query = new StringBundler(4 +
1131                            (orderByComparator.getOrderByFields().length * 3));
1132                }
1133                else {
1134                    query = new StringBundler(3);
1135                }
1136
1137                query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1138
1139                query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1140
1141                if (articleId == null) {
1142                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1143                }
1144                else {
1145                    if (articleId.equals(StringPool.BLANK)) {
1146                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1147                    }
1148                    else {
1149                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1150                    }
1151                }
1152
1153                if (orderByComparator != null) {
1154                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1155                        orderByComparator);
1156                }
1157
1158                String sql = query.toString();
1159
1160                Query q = session.createQuery(sql);
1161
1162                QueryPos qPos = QueryPos.getInstance(q);
1163
1164                qPos.add(groupId);
1165
1166                if (articleId != null) {
1167                    qPos.add(articleId);
1168                }
1169
1170                list = (List<JournalContentSearch>)QueryUtil.list(q,
1171                        getDialect(), start, end);
1172            }
1173            catch (Exception e) {
1174                throw processException(e);
1175            }
1176            finally {
1177                if (list == null) {
1178                    list = new ArrayList<JournalContentSearch>();
1179                }
1180
1181                cacheResult(list);
1182
1183                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_A,
1184                    finderArgs, list);
1185
1186                closeSession(session);
1187            }
1188        }
1189
1190        return list;
1191    }
1192
1193    public JournalContentSearch findByG_A_First(long groupId, String articleId,
1194        OrderByComparator orderByComparator)
1195        throws NoSuchContentSearchException, SystemException {
1196        List<JournalContentSearch> list = findByG_A(groupId, articleId, 0, 1,
1197                orderByComparator);
1198
1199        if (list.isEmpty()) {
1200            StringBundler msg = new StringBundler(6);
1201
1202            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1203
1204            msg.append("groupId=");
1205            msg.append(groupId);
1206
1207            msg.append(", articleId=");
1208            msg.append(articleId);
1209
1210            msg.append(StringPool.CLOSE_CURLY_BRACE);
1211
1212            throw new NoSuchContentSearchException(msg.toString());
1213        }
1214        else {
1215            return list.get(0);
1216        }
1217    }
1218
1219    public JournalContentSearch findByG_A_Last(long groupId, String articleId,
1220        OrderByComparator orderByComparator)
1221        throws NoSuchContentSearchException, SystemException {
1222        int count = countByG_A(groupId, articleId);
1223
1224        List<JournalContentSearch> list = findByG_A(groupId, articleId,
1225                count - 1, count, orderByComparator);
1226
1227        if (list.isEmpty()) {
1228            StringBundler msg = new StringBundler(6);
1229
1230            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1231
1232            msg.append("groupId=");
1233            msg.append(groupId);
1234
1235            msg.append(", articleId=");
1236            msg.append(articleId);
1237
1238            msg.append(StringPool.CLOSE_CURLY_BRACE);
1239
1240            throw new NoSuchContentSearchException(msg.toString());
1241        }
1242        else {
1243            return list.get(0);
1244        }
1245    }
1246
1247    public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
1248        long groupId, String articleId, OrderByComparator orderByComparator)
1249        throws NoSuchContentSearchException, SystemException {
1250        JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1251
1252        int count = countByG_A(groupId, articleId);
1253
1254        Session session = null;
1255
1256        try {
1257            session = openSession();
1258
1259            StringBundler query = null;
1260
1261            if (orderByComparator != null) {
1262                query = new StringBundler(4 +
1263                        (orderByComparator.getOrderByFields().length * 3));
1264            }
1265            else {
1266                query = new StringBundler(3);
1267            }
1268
1269            query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1270
1271            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1272
1273            if (articleId == null) {
1274                query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1275            }
1276            else {
1277                if (articleId.equals(StringPool.BLANK)) {
1278                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1279                }
1280                else {
1281                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1282                }
1283            }
1284
1285            if (orderByComparator != null) {
1286                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1287                    orderByComparator);
1288            }
1289
1290            String sql = query.toString();
1291
1292            Query q = session.createQuery(sql);
1293
1294            QueryPos qPos = QueryPos.getInstance(q);
1295
1296            qPos.add(groupId);
1297
1298            if (articleId != null) {
1299                qPos.add(articleId);
1300            }
1301
1302            Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1303                    orderByComparator, journalContentSearch);
1304
1305            JournalContentSearch[] array = new JournalContentSearchImpl[3];
1306
1307            array[0] = (JournalContentSearch)objArray[0];
1308            array[1] = (JournalContentSearch)objArray[1];
1309            array[2] = (JournalContentSearch)objArray[2];
1310
1311            return array;
1312        }
1313        catch (Exception e) {
1314            throw processException(e);
1315        }
1316        finally {
1317            closeSession(session);
1318        }
1319    }
1320
1321    public List<JournalContentSearch> findByG_P_L(long groupId,
1322        boolean privateLayout, long layoutId) throws SystemException {
1323        Object[] finderArgs = new Object[] {
1324                new Long(groupId), Boolean.valueOf(privateLayout),
1325                new Long(layoutId)
1326            };
1327
1328        List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_L,
1329                finderArgs, this);
1330
1331        if (list == null) {
1332            Session session = null;
1333
1334            try {
1335                session = openSession();
1336
1337                StringBundler query = new StringBundler(4);
1338
1339                query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1340
1341                query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1342
1343                query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1344
1345                query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1346
1347                String sql = query.toString();
1348
1349                Query q = session.createQuery(sql);
1350
1351                QueryPos qPos = QueryPos.getInstance(q);
1352
1353                qPos.add(groupId);
1354
1355                qPos.add(privateLayout);
1356
1357                qPos.add(layoutId);
1358
1359                list = q.list();
1360            }
1361            catch (Exception e) {
1362                throw processException(e);
1363            }
1364            finally {
1365                if (list == null) {
1366                    list = new ArrayList<JournalContentSearch>();
1367                }
1368
1369                cacheResult(list);
1370
1371                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_L,
1372                    finderArgs, list);
1373
1374                closeSession(session);
1375            }
1376        }
1377
1378        return list;
1379    }
1380
1381    public List<JournalContentSearch> findByG_P_L(long groupId,
1382        boolean privateLayout, long layoutId, int start, int end)
1383        throws SystemException {
1384        return findByG_P_L(groupId, privateLayout, layoutId, start, end, null);
1385    }
1386
1387    public List<JournalContentSearch> findByG_P_L(long groupId,
1388        boolean privateLayout, long layoutId, int start, int end,
1389        OrderByComparator orderByComparator) throws SystemException {
1390        Object[] finderArgs = new Object[] {
1391                new Long(groupId), Boolean.valueOf(privateLayout),
1392                new Long(layoutId),
1393                
1394                String.valueOf(start), String.valueOf(end),
1395                String.valueOf(orderByComparator)
1396            };
1397
1398        List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_P_L,
1399                finderArgs, this);
1400
1401        if (list == null) {
1402            Session session = null;
1403
1404            try {
1405                session = openSession();
1406
1407                StringBundler query = null;
1408
1409                if (orderByComparator != null) {
1410                    query = new StringBundler(5 +
1411                            (orderByComparator.getOrderByFields().length * 3));
1412                }
1413                else {
1414                    query = new StringBundler(4);
1415                }
1416
1417                query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1418
1419                query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1420
1421                query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1422
1423                query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1424
1425                if (orderByComparator != null) {
1426                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1427                        orderByComparator);
1428                }
1429
1430                String sql = query.toString();
1431
1432                Query q = session.createQuery(sql);
1433
1434                QueryPos qPos = QueryPos.getInstance(q);
1435
1436                qPos.add(groupId);
1437
1438                qPos.add(privateLayout);
1439
1440                qPos.add(layoutId);
1441
1442                list = (List<JournalContentSearch>)QueryUtil.list(q,
1443                        getDialect(), start, end);
1444            }
1445            catch (Exception e) {
1446                throw processException(e);
1447            }
1448            finally {
1449                if (list == null) {
1450                    list = new ArrayList<JournalContentSearch>();
1451                }
1452
1453                cacheResult(list);
1454
1455                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_P_L,
1456                    finderArgs, list);
1457
1458                closeSession(session);
1459            }
1460        }
1461
1462        return list;
1463    }
1464
1465    public JournalContentSearch findByG_P_L_First(long groupId,
1466        boolean privateLayout, long layoutId,
1467        OrderByComparator orderByComparator)
1468        throws NoSuchContentSearchException, SystemException {
1469        List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
1470                layoutId, 0, 1, orderByComparator);
1471
1472        if (list.isEmpty()) {
1473            StringBundler msg = new StringBundler(8);
1474
1475            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1476
1477            msg.append("groupId=");
1478            msg.append(groupId);
1479
1480            msg.append(", privateLayout=");
1481            msg.append(privateLayout);
1482
1483            msg.append(", layoutId=");
1484            msg.append(layoutId);
1485
1486            msg.append(StringPool.CLOSE_CURLY_BRACE);
1487
1488            throw new NoSuchContentSearchException(msg.toString());
1489        }
1490        else {
1491            return list.get(0);
1492        }
1493    }
1494
1495    public JournalContentSearch findByG_P_L_Last(long groupId,
1496        boolean privateLayout, long layoutId,
1497        OrderByComparator orderByComparator)
1498        throws NoSuchContentSearchException, SystemException {
1499        int count = countByG_P_L(groupId, privateLayout, layoutId);
1500
1501        List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
1502                layoutId, count - 1, count, orderByComparator);
1503
1504        if (list.isEmpty()) {
1505            StringBundler msg = new StringBundler(8);
1506
1507            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1508
1509            msg.append("groupId=");
1510            msg.append(groupId);
1511
1512            msg.append(", privateLayout=");
1513            msg.append(privateLayout);
1514
1515            msg.append(", layoutId=");
1516            msg.append(layoutId);
1517
1518            msg.append(StringPool.CLOSE_CURLY_BRACE);
1519
1520            throw new NoSuchContentSearchException(msg.toString());
1521        }
1522        else {
1523            return list.get(0);
1524        }
1525    }
1526
1527    public JournalContentSearch[] findByG_P_L_PrevAndNext(
1528        long contentSearchId, long groupId, boolean privateLayout,
1529        long layoutId, OrderByComparator orderByComparator)
1530        throws NoSuchContentSearchException, SystemException {
1531        JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1532
1533        int count = countByG_P_L(groupId, privateLayout, layoutId);
1534
1535        Session session = null;
1536
1537        try {
1538            session = openSession();
1539
1540            StringBundler query = null;
1541
1542            if (orderByComparator != null) {
1543                query = new StringBundler(5 +
1544                        (orderByComparator.getOrderByFields().length * 3));
1545            }
1546            else {
1547                query = new StringBundler(4);
1548            }
1549
1550            query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1551
1552            query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1553
1554            query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1555
1556            query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1557
1558            if (orderByComparator != null) {
1559                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1560                    orderByComparator);
1561            }
1562
1563            String sql = query.toString();
1564
1565            Query q = session.createQuery(sql);
1566
1567            QueryPos qPos = QueryPos.getInstance(q);
1568
1569            qPos.add(groupId);
1570
1571            qPos.add(privateLayout);
1572
1573            qPos.add(layoutId);
1574
1575            Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1576                    orderByComparator, journalContentSearch);
1577
1578            JournalContentSearch[] array = new JournalContentSearchImpl[3];
1579
1580            array[0] = (JournalContentSearch)objArray[0];
1581            array[1] = (JournalContentSearch)objArray[1];
1582            array[2] = (JournalContentSearch)objArray[2];
1583
1584            return array;
1585        }
1586        catch (Exception e) {
1587            throw processException(e);
1588        }
1589        finally {
1590            closeSession(session);
1591        }
1592    }
1593
1594    public List<JournalContentSearch> findByG_P_A(long groupId,
1595        boolean privateLayout, String articleId) throws SystemException {
1596        Object[] finderArgs = new Object[] {
1597                new Long(groupId), Boolean.valueOf(privateLayout),
1598                
1599                articleId
1600            };
1601
1602        List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_A,
1603                finderArgs, this);
1604
1605        if (list == null) {
1606            Session session = null;
1607
1608            try {
1609                session = openSession();
1610
1611                StringBundler query = new StringBundler(4);
1612
1613                query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1614
1615                query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
1616
1617                query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
1618
1619                if (articleId == null) {
1620                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
1621                }
1622                else {
1623                    if (articleId.equals(StringPool.BLANK)) {
1624                        query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
1625                    }
1626                    else {
1627                        query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
1628                    }
1629                }
1630
1631                String sql = query.toString();
1632
1633                Query q = session.createQuery(sql);
1634
1635                QueryPos qPos = QueryPos.getInstance(q);
1636
1637                qPos.add(groupId);
1638
1639                qPos.add(privateLayout);
1640
1641                if (articleId != null) {
1642                    qPos.add(articleId);
1643                }
1644
1645                list = q.list();
1646            }
1647            catch (Exception e) {
1648                throw processException(e);
1649            }
1650            finally {
1651                if (list == null) {
1652                    list = new ArrayList<JournalContentSearch>();
1653                }
1654
1655                cacheResult(list);
1656
1657                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_A,
1658                    finderArgs, list);
1659
1660                closeSession(session);
1661            }
1662        }
1663
1664        return list;
1665    }
1666
1667    public List<JournalContentSearch> findByG_P_A(long groupId,
1668        boolean privateLayout, String articleId, int start, int end)
1669        throws SystemException {
1670        return findByG_P_A(groupId, privateLayout, articleId, start, end, null);
1671    }
1672
1673    public List<JournalContentSearch> findByG_P_A(long groupId,
1674        boolean privateLayout, String articleId, int start, int end,
1675        OrderByComparator orderByComparator) throws SystemException {
1676        Object[] finderArgs = new Object[] {
1677                new Long(groupId), Boolean.valueOf(privateLayout),
1678                
1679                articleId,
1680                
1681                String.valueOf(start), String.valueOf(end),
1682                String.valueOf(orderByComparator)
1683            };
1684
1685        List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_P_A,
1686                finderArgs, this);
1687
1688        if (list == null) {
1689            Session session = null;
1690
1691            try {
1692                session = openSession();
1693
1694                StringBundler query = null;
1695
1696                if (orderByComparator != null) {
1697                    query = new StringBundler(5 +
1698                            (orderByComparator.getOrderByFields().length * 3));
1699                }
1700                else {
1701                    query = new StringBundler(4);
1702                }
1703
1704                query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1705
1706                query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
1707
1708                query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
1709
1710                if (articleId == null) {
1711                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
1712                }
1713                else {
1714                    if (articleId.equals(StringPool.BLANK)) {
1715                        query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
1716                    }
1717                    else {
1718                        query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
1719                    }
1720                }
1721
1722                if (orderByComparator != null) {
1723                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1724                        orderByComparator);
1725                }
1726
1727                String sql = query.toString();
1728
1729                Query q = session.createQuery(sql);
1730
1731                QueryPos qPos = QueryPos.getInstance(q);
1732
1733                qPos.add(groupId);
1734
1735                qPos.add(privateLayout);
1736
1737                if (articleId != null) {
1738                    qPos.add(articleId);
1739                }
1740
1741                list = (List<JournalContentSearch>)QueryUtil.list(q,
1742                        getDialect(), start, end);
1743            }
1744            catch (Exception e) {
1745                throw processException(e);
1746            }
1747            finally {
1748                if (list == null) {
1749                    list = new ArrayList<JournalContentSearch>();
1750                }
1751
1752                cacheResult(list);
1753
1754                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_P_A,
1755                    finderArgs, list);
1756
1757                closeSession(session);
1758            }
1759        }
1760
1761        return list;
1762    }
1763
1764    public JournalContentSearch findByG_P_A_First(long groupId,
1765        boolean privateLayout, String articleId,
1766        OrderByComparator orderByComparator)
1767        throws NoSuchContentSearchException, SystemException {
1768        List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
1769                articleId, 0, 1, orderByComparator);
1770
1771        if (list.isEmpty()) {
1772            StringBundler msg = new StringBundler(8);
1773
1774            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1775
1776            msg.append("groupId=");
1777            msg.append(groupId);
1778
1779            msg.append(", privateLayout=");
1780            msg.append(privateLayout);
1781
1782            msg.append(", articleId=");
1783            msg.append(articleId);
1784
1785            msg.append(StringPool.CLOSE_CURLY_BRACE);
1786
1787            throw new NoSuchContentSearchException(msg.toString());
1788        }
1789        else {
1790            return list.get(0);
1791        }
1792    }
1793
1794    public JournalContentSearch findByG_P_A_Last(long groupId,
1795        boolean privateLayout, String articleId,
1796        OrderByComparator orderByComparator)
1797        throws NoSuchContentSearchException, SystemException {
1798        int count = countByG_P_A(groupId, privateLayout, articleId);
1799
1800        List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
1801                articleId, count - 1, count, orderByComparator);
1802
1803        if (list.isEmpty()) {
1804            StringBundler msg = new StringBundler(8);
1805
1806            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1807
1808            msg.append("groupId=");
1809            msg.append(groupId);
1810
1811            msg.append(", privateLayout=");
1812            msg.append(privateLayout);
1813
1814            msg.append(", articleId=");
1815            msg.append(articleId);
1816
1817            msg.append(StringPool.CLOSE_CURLY_BRACE);
1818
1819            throw new NoSuchContentSearchException(msg.toString());
1820        }
1821        else {
1822            return list.get(0);
1823        }
1824    }
1825
1826    public JournalContentSearch[] findByG_P_A_PrevAndNext(
1827        long contentSearchId, long groupId, boolean privateLayout,
1828        String articleId, OrderByComparator orderByComparator)
1829        throws NoSuchContentSearchException, SystemException {
1830        JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1831
1832        int count = countByG_P_A(groupId, privateLayout, articleId);
1833
1834        Session session = null;
1835
1836        try {
1837            session = openSession();
1838
1839            StringBundler query = null;
1840
1841            if (orderByComparator != null) {
1842                query = new StringBundler(5 +
1843                        (orderByComparator.getOrderByFields().length * 3));
1844            }
1845            else {
1846                query = new StringBundler(4);
1847            }
1848
1849            query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1850
1851            query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
1852
1853            query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
1854
1855            if (articleId == null) {
1856                query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
1857            }
1858            else {
1859                if (articleId.equals(StringPool.BLANK)) {
1860                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
1861                }
1862                else {
1863                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
1864                }
1865            }
1866
1867            if (orderByComparator != null) {
1868                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1869                    orderByComparator);
1870            }
1871
1872            String sql = query.toString();
1873
1874            Query q = session.createQuery(sql);
1875
1876            QueryPos qPos = QueryPos.getInstance(q);
1877
1878            qPos.add(groupId);
1879
1880            qPos.add(privateLayout);
1881
1882            if (articleId != null) {
1883                qPos.add(articleId);
1884            }
1885
1886            Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1887                    orderByComparator, journalContentSearch);
1888
1889            JournalContentSearch[] array = new JournalContentSearchImpl[3];
1890
1891            array[0] = (JournalContentSearch)objArray[0];
1892            array[1] = (JournalContentSearch)objArray[1];
1893            array[2] = (JournalContentSearch)objArray[2];
1894
1895            return array;
1896        }
1897        catch (Exception e) {
1898            throw processException(e);
1899        }
1900        finally {
1901            closeSession(session);
1902        }
1903    }
1904
1905    public List<JournalContentSearch> findByG_P_L_P(long groupId,
1906        boolean privateLayout, long layoutId, String portletId)
1907        throws SystemException {
1908        Object[] finderArgs = new Object[] {
1909                new Long(groupId), Boolean.valueOf(privateLayout),
1910                new Long(layoutId),
1911                
1912                portletId
1913            };
1914
1915        List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_L_P,
1916                finderArgs, this);
1917
1918        if (list == null) {
1919            Session session = null;
1920
1921            try {
1922                session = openSession();
1923
1924                StringBundler query = new StringBundler(5);
1925
1926                query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1927
1928                query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
1929
1930                query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
1931
1932                query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
1933
1934                if (portletId == null) {
1935                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
1936                }
1937                else {
1938                    if (portletId.equals(StringPool.BLANK)) {
1939                        query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
1940                    }
1941                    else {
1942                        query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
1943                    }
1944                }
1945
1946                String sql = query.toString();
1947
1948                Query q = session.createQuery(sql);
1949
1950                QueryPos qPos = QueryPos.getInstance(q);
1951
1952                qPos.add(groupId);
1953
1954                qPos.add(privateLayout);
1955
1956                qPos.add(layoutId);
1957
1958                if (portletId != null) {
1959                    qPos.add(portletId);
1960                }
1961
1962                list = q.list();
1963            }
1964            catch (Exception e) {
1965                throw processException(e);
1966            }
1967            finally {
1968                if (list == null) {
1969                    list = new ArrayList<JournalContentSearch>();
1970                }
1971
1972                cacheResult(list);
1973
1974                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_L_P,
1975                    finderArgs, list);
1976
1977                closeSession(session);
1978            }
1979        }
1980
1981        return list;
1982    }
1983
1984    public List<JournalContentSearch> findByG_P_L_P(long groupId,
1985        boolean privateLayout, long layoutId, String portletId, int start,
1986        int end) throws SystemException {
1987        return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
1988            start, end, null);
1989    }
1990
1991    public List<JournalContentSearch> findByG_P_L_P(long groupId,
1992        boolean privateLayout, long layoutId, String portletId, int start,
1993        int end, OrderByComparator orderByComparator) throws SystemException {
1994        Object[] finderArgs = new Object[] {
1995                new Long(groupId), Boolean.valueOf(privateLayout),
1996                new Long(layoutId),
1997                
1998                portletId,
1999                
2000                String.valueOf(start), String.valueOf(end),
2001                String.valueOf(orderByComparator)
2002            };
2003
2004        List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_P_L_P,
2005                finderArgs, this);
2006
2007        if (list == null) {
2008            Session session = null;
2009
2010            try {
2011                session = openSession();
2012
2013                StringBundler query = null;
2014
2015                if (orderByComparator != null) {
2016                    query = new StringBundler(6 +
2017                            (orderByComparator.getOrderByFields().length * 3));
2018                }
2019                else {
2020                    query = new StringBundler(5);
2021                }
2022
2023                query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2024
2025                query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2026
2027                query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2028
2029                query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2030
2031                if (portletId == null) {
2032                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2033                }
2034                else {
2035                    if (portletId.equals(StringPool.BLANK)) {
2036                        query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2037                    }
2038                    else {
2039                        query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2040                    }
2041                }
2042
2043                if (orderByComparator != null) {
2044                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2045                        orderByComparator);
2046                }
2047
2048                String sql = query.toString();
2049
2050                Query q = session.createQuery(sql);
2051
2052                QueryPos qPos = QueryPos.getInstance(q);
2053
2054                qPos.add(groupId);
2055
2056                qPos.add(privateLayout);
2057
2058                qPos.add(layoutId);
2059
2060                if (portletId != null) {
2061                    qPos.add(portletId);
2062                }
2063
2064                list = (List<JournalContentSearch>)QueryUtil.list(q,
2065                        getDialect(), start, end);
2066            }
2067            catch (Exception e) {
2068                throw processException(e);
2069            }
2070            finally {
2071                if (list == null) {
2072                    list = new ArrayList<JournalContentSearch>();
2073                }
2074
2075                cacheResult(list);
2076
2077                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_P_L_P,
2078                    finderArgs, list);
2079
2080                closeSession(session);
2081            }
2082        }
2083
2084        return list;
2085    }
2086
2087    public JournalContentSearch findByG_P_L_P_First(long groupId,
2088        boolean privateLayout, long layoutId, String portletId,
2089        OrderByComparator orderByComparator)
2090        throws NoSuchContentSearchException, SystemException {
2091        List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
2092                layoutId, portletId, 0, 1, orderByComparator);
2093
2094        if (list.isEmpty()) {
2095            StringBundler msg = new StringBundler(10);
2096
2097            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2098
2099            msg.append("groupId=");
2100            msg.append(groupId);
2101
2102            msg.append(", privateLayout=");
2103            msg.append(privateLayout);
2104
2105            msg.append(", layoutId=");
2106            msg.append(layoutId);
2107
2108            msg.append(", portletId=");
2109            msg.append(portletId);
2110
2111            msg.append(StringPool.CLOSE_CURLY_BRACE);
2112
2113            throw new NoSuchContentSearchException(msg.toString());
2114        }
2115        else {
2116            return list.get(0);
2117        }
2118    }
2119
2120    public JournalContentSearch findByG_P_L_P_Last(long groupId,
2121        boolean privateLayout, long layoutId, String portletId,
2122        OrderByComparator orderByComparator)
2123        throws NoSuchContentSearchException, SystemException {
2124        int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
2125
2126        List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
2127                layoutId, portletId, count - 1, count, orderByComparator);
2128
2129        if (list.isEmpty()) {
2130            StringBundler msg = new StringBundler(10);
2131
2132            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2133
2134            msg.append("groupId=");
2135            msg.append(groupId);
2136
2137            msg.append(", privateLayout=");
2138            msg.append(privateLayout);
2139
2140            msg.append(", layoutId=");
2141            msg.append(layoutId);
2142
2143            msg.append(", portletId=");
2144            msg.append(portletId);
2145
2146            msg.append(StringPool.CLOSE_CURLY_BRACE);
2147
2148            throw new NoSuchContentSearchException(msg.toString());
2149        }
2150        else {
2151            return list.get(0);
2152        }
2153    }
2154
2155    public JournalContentSearch[] findByG_P_L_P_PrevAndNext(
2156        long contentSearchId, long groupId, boolean privateLayout,
2157        long layoutId, String portletId, OrderByComparator orderByComparator)
2158        throws NoSuchContentSearchException, SystemException {
2159        JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2160
2161        int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
2162
2163        Session session = null;
2164
2165        try {
2166            session = openSession();
2167
2168            StringBundler query = null;
2169
2170            if (orderByComparator != null) {
2171                query = new StringBundler(6 +
2172                        (orderByComparator.getOrderByFields().length * 3));
2173            }
2174            else {
2175                query = new StringBundler(5);
2176            }
2177
2178            query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2179
2180            query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2181
2182            query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2183
2184            query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2185
2186            if (portletId == null) {
2187                query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2188            }
2189            else {
2190                if (portletId.equals(StringPool.BLANK)) {
2191                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2192                }
2193                else {
2194                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2195                }
2196            }
2197
2198            if (orderByComparator != null) {
2199                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2200                    orderByComparator);
2201            }
2202
2203            String sql = query.toString();
2204
2205            Query q = session.createQuery(sql);
2206
2207            QueryPos qPos = QueryPos.getInstance(q);
2208
2209            qPos.add(groupId);
2210
2211            qPos.add(privateLayout);
2212
2213            qPos.add(layoutId);
2214
2215            if (portletId != null) {
2216                qPos.add(portletId);
2217            }
2218
2219            Object[] objArray = QueryUtil.getPrevAndNext(q, count,
2220                    orderByComparator, journalContentSearch);
2221
2222            JournalContentSearch[] array = new JournalContentSearchImpl[3];
2223
2224            array[0] = (JournalContentSearch)objArray[0];
2225            array[1] = (JournalContentSearch)objArray[1];
2226            array[2] = (JournalContentSearch)objArray[2];
2227
2228            return array;
2229        }
2230        catch (Exception e) {
2231            throw processException(e);
2232        }
2233        finally {
2234            closeSession(session);
2235        }
2236    }
2237
2238    public JournalContentSearch findByG_P_L_P_A(long groupId,
2239        boolean privateLayout, long layoutId, String portletId, String articleId)
2240        throws NoSuchContentSearchException, SystemException {
2241        JournalContentSearch journalContentSearch = fetchByG_P_L_P_A(groupId,
2242                privateLayout, layoutId, portletId, articleId);
2243
2244        if (journalContentSearch == null) {
2245            StringBundler msg = new StringBundler(12);
2246
2247            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2248
2249            msg.append("groupId=");
2250            msg.append(groupId);
2251
2252            msg.append(", privateLayout=");
2253            msg.append(privateLayout);
2254
2255            msg.append(", layoutId=");
2256            msg.append(layoutId);
2257
2258            msg.append(", portletId=");
2259            msg.append(portletId);
2260
2261            msg.append(", articleId=");
2262            msg.append(articleId);
2263
2264            msg.append(StringPool.CLOSE_CURLY_BRACE);
2265
2266            if (_log.isWarnEnabled()) {
2267                _log.warn(msg.toString());
2268            }
2269
2270            throw new NoSuchContentSearchException(msg.toString());
2271        }
2272
2273        return journalContentSearch;
2274    }
2275
2276    public JournalContentSearch fetchByG_P_L_P_A(long groupId,
2277        boolean privateLayout, long layoutId, String portletId, String articleId)
2278        throws SystemException {
2279        return fetchByG_P_L_P_A(groupId, privateLayout, layoutId, portletId,
2280            articleId, true);
2281    }
2282
2283    public JournalContentSearch fetchByG_P_L_P_A(long groupId,
2284        boolean privateLayout, long layoutId, String portletId,
2285        String articleId, boolean retrieveFromCache) throws SystemException {
2286        Object[] finderArgs = new Object[] {
2287                new Long(groupId), Boolean.valueOf(privateLayout),
2288                new Long(layoutId),
2289                
2290                portletId,
2291                
2292                articleId
2293            };
2294
2295        Object result = null;
2296
2297        if (retrieveFromCache) {
2298            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
2299                    finderArgs, this);
2300        }
2301
2302        if (result == null) {
2303            Session session = null;
2304
2305            try {
2306                session = openSession();
2307
2308                StringBundler query = new StringBundler(6);
2309
2310                query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2311
2312                query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
2313
2314                query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
2315
2316                query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
2317
2318                if (portletId == null) {
2319                    query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
2320                }
2321                else {
2322                    if (portletId.equals(StringPool.BLANK)) {
2323                        query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
2324                    }
2325                    else {
2326                        query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
2327                    }
2328                }
2329
2330                if (articleId == null) {
2331                    query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
2332                }
2333                else {
2334                    if (articleId.equals(StringPool.BLANK)) {
2335                        query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
2336                    }
2337                    else {
2338                        query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
2339                    }
2340                }
2341
2342                String sql = query.toString();
2343
2344                Query q = session.createQuery(sql);
2345
2346                QueryPos qPos = QueryPos.getInstance(q);
2347
2348                qPos.add(groupId);
2349
2350                qPos.add(privateLayout);
2351
2352                qPos.add(layoutId);
2353
2354                if (portletId != null) {
2355                    qPos.add(portletId);
2356                }
2357
2358                if (articleId != null) {
2359                    qPos.add(articleId);
2360                }
2361
2362                List<JournalContentSearch> list = q.list();
2363
2364                result = list;
2365
2366                JournalContentSearch journalContentSearch = null;
2367
2368                if (list.isEmpty()) {
2369                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
2370                        finderArgs, list);
2371                }
2372                else {
2373                    journalContentSearch = list.get(0);
2374
2375                    cacheResult(journalContentSearch);
2376
2377                    if ((journalContentSearch.getGroupId() != groupId) ||
2378                            (journalContentSearch.getPrivateLayout() != privateLayout) ||
2379                            (journalContentSearch.getLayoutId() != layoutId) ||
2380                            (journalContentSearch.getPortletId() == null) ||
2381                            !journalContentSearch.getPortletId()
2382                                                     .equals(portletId) ||
2383                            (journalContentSearch.getArticleId() == null) ||
2384                            !journalContentSearch.getArticleId()
2385                                                     .equals(articleId)) {
2386                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
2387                            finderArgs, journalContentSearch);
2388                    }
2389                }
2390
2391                return journalContentSearch;
2392            }
2393            catch (Exception e) {
2394                throw processException(e);
2395            }
2396            finally {
2397                if (result == null) {
2398                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
2399                        finderArgs, new ArrayList<JournalContentSearch>());
2400                }
2401
2402                closeSession(session);
2403            }
2404        }
2405        else {
2406            if (result instanceof List<?>) {
2407                return null;
2408            }
2409            else {
2410                return (JournalContentSearch)result;
2411            }
2412        }
2413    }
2414
2415    public List<JournalContentSearch> findAll() throws SystemException {
2416        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2417    }
2418
2419    public List<JournalContentSearch> findAll(int start, int end)
2420        throws SystemException {
2421        return findAll(start, end, null);
2422    }
2423
2424    public List<JournalContentSearch> findAll(int start, int end,
2425        OrderByComparator orderByComparator) throws SystemException {
2426        Object[] finderArgs = new Object[] {
2427                String.valueOf(start), String.valueOf(end),
2428                String.valueOf(orderByComparator)
2429            };
2430
2431        List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2432                finderArgs, this);
2433
2434        if (list == null) {
2435            Session session = null;
2436
2437            try {
2438                session = openSession();
2439
2440                StringBundler query = null;
2441                String sql = null;
2442
2443                if (orderByComparator != null) {
2444                    query = new StringBundler(2 +
2445                            (orderByComparator.getOrderByFields().length * 3));
2446
2447                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH);
2448
2449                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2450                        orderByComparator);
2451
2452                    sql = query.toString();
2453                }
2454
2455                sql = _SQL_SELECT_JOURNALCONTENTSEARCH;
2456
2457                Query q = session.createQuery(sql);
2458
2459                if (orderByComparator == null) {
2460                    list = (List<JournalContentSearch>)QueryUtil.list(q,
2461                            getDialect(), start, end, false);
2462
2463                    Collections.sort(list);
2464                }
2465                else {
2466                    list = (List<JournalContentSearch>)QueryUtil.list(q,
2467                            getDialect(), start, end);
2468                }
2469            }
2470            catch (Exception e) {
2471                throw processException(e);
2472            }
2473            finally {
2474                if (list == null) {
2475                    list = new ArrayList<JournalContentSearch>();
2476                }
2477
2478                cacheResult(list);
2479
2480                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2481
2482                closeSession(session);
2483            }
2484        }
2485
2486        return list;
2487    }
2488
2489    public void removeByArticleId(String articleId) throws SystemException {
2490        for (JournalContentSearch journalContentSearch : findByArticleId(
2491                articleId)) {
2492            remove(journalContentSearch);
2493        }
2494    }
2495
2496    public void removeByG_P(long groupId, boolean privateLayout)
2497        throws SystemException {
2498        for (JournalContentSearch journalContentSearch : findByG_P(groupId,
2499                privateLayout)) {
2500            remove(journalContentSearch);
2501        }
2502    }
2503
2504    public void removeByG_A(long groupId, String articleId)
2505        throws SystemException {
2506        for (JournalContentSearch journalContentSearch : findByG_A(groupId,
2507                articleId)) {
2508            remove(journalContentSearch);
2509        }
2510    }
2511
2512    public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId)
2513        throws SystemException {
2514        for (JournalContentSearch journalContentSearch : findByG_P_L(groupId,
2515                privateLayout, layoutId)) {
2516            remove(journalContentSearch);
2517        }
2518    }
2519
2520    public void removeByG_P_A(long groupId, boolean privateLayout,
2521        String articleId) throws SystemException {
2522        for (JournalContentSearch journalContentSearch : findByG_P_A(groupId,
2523                privateLayout, articleId)) {
2524            remove(journalContentSearch);
2525        }
2526    }
2527
2528    public void removeByG_P_L_P(long groupId, boolean privateLayout,
2529        long layoutId, String portletId) throws SystemException {
2530        for (JournalContentSearch journalContentSearch : findByG_P_L_P(
2531                groupId, privateLayout, layoutId, portletId)) {
2532            remove(journalContentSearch);
2533        }
2534    }
2535
2536    public void removeByG_P_L_P_A(long groupId, boolean privateLayout,
2537        long layoutId, String portletId, String articleId)
2538        throws NoSuchContentSearchException, SystemException {
2539        JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
2540                privateLayout, layoutId, portletId, articleId);
2541
2542        remove(journalContentSearch);
2543    }
2544
2545    public void removeAll() throws SystemException {
2546        for (JournalContentSearch journalContentSearch : findAll()) {
2547            remove(journalContentSearch);
2548        }
2549    }
2550
2551    public int countByArticleId(String articleId) throws SystemException {
2552        Object[] finderArgs = new Object[] { articleId };
2553
2554        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ARTICLEID,
2555                finderArgs, this);
2556
2557        if (count == null) {
2558            Session session = null;
2559
2560            try {
2561                session = openSession();
2562
2563                StringBundler query = new StringBundler(2);
2564
2565                query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2566
2567                if (articleId == null) {
2568                    query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
2569                }
2570                else {
2571                    if (articleId.equals(StringPool.BLANK)) {
2572                        query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
2573                    }
2574                    else {
2575                        query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
2576                    }
2577                }
2578
2579                String sql = query.toString();
2580
2581                Query q = session.createQuery(sql);
2582
2583                QueryPos qPos = QueryPos.getInstance(q);
2584
2585                if (articleId != null) {
2586                    qPos.add(articleId);
2587                }
2588
2589                count = (Long)q.uniqueResult();
2590            }
2591            catch (Exception e) {
2592                throw processException(e);
2593            }
2594            finally {
2595                if (count == null) {
2596                    count = Long.valueOf(0);
2597                }
2598
2599                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ARTICLEID,
2600                    finderArgs, count);
2601
2602                closeSession(session);
2603            }
2604        }
2605
2606        return count.intValue();
2607    }
2608
2609    public int countByG_P(long groupId, boolean privateLayout)
2610        throws SystemException {
2611        Object[] finderArgs = new Object[] {
2612                new Long(groupId), Boolean.valueOf(privateLayout)
2613            };
2614
2615        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2616                finderArgs, this);
2617
2618        if (count == null) {
2619            Session session = null;
2620
2621            try {
2622                session = openSession();
2623
2624                StringBundler query = new StringBundler(3);
2625
2626                query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2627
2628                query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2629
2630                query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
2631
2632                String sql = query.toString();
2633
2634                Query q = session.createQuery(sql);
2635
2636                QueryPos qPos = QueryPos.getInstance(q);
2637
2638                qPos.add(groupId);
2639
2640                qPos.add(privateLayout);
2641
2642                count = (Long)q.uniqueResult();
2643            }
2644            catch (Exception e) {
2645                throw processException(e);
2646            }
2647            finally {
2648                if (count == null) {
2649                    count = Long.valueOf(0);
2650                }
2651
2652                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2653                    count);
2654
2655                closeSession(session);
2656            }
2657        }
2658
2659        return count.intValue();
2660    }
2661
2662    public int countByG_A(long groupId, String articleId)
2663        throws SystemException {
2664        Object[] finderArgs = new Object[] { new Long(groupId), articleId };
2665
2666        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
2667                finderArgs, this);
2668
2669        if (count == null) {
2670            Session session = null;
2671
2672            try {
2673                session = openSession();
2674
2675                StringBundler query = new StringBundler(3);
2676
2677                query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2678
2679                query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2680
2681                if (articleId == null) {
2682                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2683                }
2684                else {
2685                    if (articleId.equals(StringPool.BLANK)) {
2686                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2687                    }
2688                    else {
2689                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2690                    }
2691                }
2692
2693                String sql = query.toString();
2694
2695                Query q = session.createQuery(sql);
2696
2697                QueryPos qPos = QueryPos.getInstance(q);
2698
2699                qPos.add(groupId);
2700
2701                if (articleId != null) {
2702                    qPos.add(articleId);
2703                }
2704
2705                count = (Long)q.uniqueResult();
2706            }
2707            catch (Exception e) {
2708                throw processException(e);
2709            }
2710            finally {
2711                if (count == null) {
2712                    count = Long.valueOf(0);
2713                }
2714
2715                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
2716                    count);
2717
2718                closeSession(session);
2719            }
2720        }
2721
2722        return count.intValue();
2723    }
2724
2725    public int countByG_P_L(long groupId, boolean privateLayout, long layoutId)
2726        throws SystemException {
2727        Object[] finderArgs = new Object[] {
2728                new Long(groupId), Boolean.valueOf(privateLayout),
2729                new Long(layoutId)
2730            };
2731
2732        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L,
2733                finderArgs, this);
2734
2735        if (count == null) {
2736            Session session = null;
2737
2738            try {
2739                session = openSession();
2740
2741                StringBundler query = new StringBundler(4);
2742
2743                query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2744
2745                query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2746
2747                query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2748
2749                query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2750
2751                String sql = query.toString();
2752
2753                Query q = session.createQuery(sql);
2754
2755                QueryPos qPos = QueryPos.getInstance(q);
2756
2757                qPos.add(groupId);
2758
2759                qPos.add(privateLayout);
2760
2761                qPos.add(layoutId);
2762
2763                count = (Long)q.uniqueResult();
2764            }
2765            catch (Exception e) {
2766                throw processException(e);
2767            }
2768            finally {
2769                if (count == null) {
2770                    count = Long.valueOf(0);
2771                }
2772
2773                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L,
2774                    finderArgs, count);
2775
2776                closeSession(session);
2777            }
2778        }
2779
2780        return count.intValue();
2781    }
2782
2783    public int countByG_P_A(long groupId, boolean privateLayout,
2784        String articleId) throws SystemException {
2785        Object[] finderArgs = new Object[] {
2786                new Long(groupId), Boolean.valueOf(privateLayout),
2787                
2788                articleId
2789            };
2790
2791        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_A,
2792                finderArgs, this);
2793
2794        if (count == null) {
2795            Session session = null;
2796
2797            try {
2798                session = openSession();
2799
2800                StringBundler query = new StringBundler(4);
2801
2802                query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2803
2804                query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2805
2806                query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2807
2808                if (articleId == null) {
2809                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2810                }
2811                else {
2812                    if (articleId.equals(StringPool.BLANK)) {
2813                        query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2814                    }
2815                    else {
2816                        query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2817                    }
2818                }
2819
2820                String sql = query.toString();
2821
2822                Query q = session.createQuery(sql);
2823
2824                QueryPos qPos = QueryPos.getInstance(q);
2825
2826                qPos.add(groupId);
2827
2828                qPos.add(privateLayout);
2829
2830                if (articleId != null) {
2831                    qPos.add(articleId);
2832                }
2833
2834                count = (Long)q.uniqueResult();
2835            }
2836            catch (Exception e) {
2837                throw processException(e);
2838            }
2839            finally {
2840                if (count == null) {
2841                    count = Long.valueOf(0);
2842                }
2843
2844                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_A,
2845                    finderArgs, count);
2846
2847                closeSession(session);
2848            }
2849        }
2850
2851        return count.intValue();
2852    }
2853
2854    public int countByG_P_L_P(long groupId, boolean privateLayout,
2855        long layoutId, String portletId) throws SystemException {
2856        Object[] finderArgs = new Object[] {
2857                new Long(groupId), Boolean.valueOf(privateLayout),
2858                new Long(layoutId),
2859                
2860                portletId
2861            };
2862
2863        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P,
2864                finderArgs, this);
2865
2866        if (count == null) {
2867            Session session = null;
2868
2869            try {
2870                session = openSession();
2871
2872                StringBundler query = new StringBundler(5);
2873
2874                query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2875
2876                query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2877
2878                query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2879
2880                query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2881
2882                if (portletId == null) {
2883                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2884                }
2885                else {
2886                    if (portletId.equals(StringPool.BLANK)) {
2887                        query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2888                    }
2889                    else {
2890                        query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2891                    }
2892                }
2893
2894                String sql = query.toString();
2895
2896                Query q = session.createQuery(sql);
2897
2898                QueryPos qPos = QueryPos.getInstance(q);
2899
2900                qPos.add(groupId);
2901
2902                qPos.add(privateLayout);
2903
2904                qPos.add(layoutId);
2905
2906                if (portletId != null) {
2907                    qPos.add(portletId);
2908                }
2909
2910                count = (Long)q.uniqueResult();
2911            }
2912            catch (Exception e) {
2913                throw processException(e);
2914            }
2915            finally {
2916                if (count == null) {
2917                    count = Long.valueOf(0);
2918                }
2919
2920                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P,
2921                    finderArgs, count);
2922
2923                closeSession(session);
2924            }
2925        }
2926
2927        return count.intValue();
2928    }
2929
2930    public int countByG_P_L_P_A(long groupId, boolean privateLayout,
2931        long layoutId, String portletId, String articleId)
2932        throws SystemException {
2933        Object[] finderArgs = new Object[] {
2934                new Long(groupId), Boolean.valueOf(privateLayout),
2935                new Long(layoutId),
2936                
2937                portletId,
2938                
2939                articleId
2940            };
2941
2942        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
2943                finderArgs, this);
2944
2945        if (count == null) {
2946            Session session = null;
2947
2948            try {
2949                session = openSession();
2950
2951                StringBundler query = new StringBundler(6);
2952
2953                query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2954
2955                query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
2956
2957                query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
2958
2959                query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
2960
2961                if (portletId == null) {
2962                    query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
2963                }
2964                else {
2965                    if (portletId.equals(StringPool.BLANK)) {
2966                        query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
2967                    }
2968                    else {
2969                        query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
2970                    }
2971                }
2972
2973                if (articleId == null) {
2974                    query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
2975                }
2976                else {
2977                    if (articleId.equals(StringPool.BLANK)) {
2978                        query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
2979                    }
2980                    else {
2981                        query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
2982                    }
2983                }
2984
2985                String sql = query.toString();
2986
2987                Query q = session.createQuery(sql);
2988
2989                QueryPos qPos = QueryPos.getInstance(q);
2990
2991                qPos.add(groupId);
2992
2993                qPos.add(privateLayout);
2994
2995                qPos.add(layoutId);
2996
2997                if (portletId != null) {
2998                    qPos.add(portletId);
2999                }
3000
3001                if (articleId != null) {
3002                    qPos.add(articleId);
3003                }
3004
3005                count = (Long)q.uniqueResult();
3006            }
3007            catch (Exception e) {
3008                throw processException(e);
3009            }
3010            finally {
3011                if (count == null) {
3012                    count = Long.valueOf(0);
3013                }
3014
3015                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
3016                    finderArgs, count);
3017
3018                closeSession(session);
3019            }
3020        }
3021
3022        return count.intValue();
3023    }
3024
3025    public int countAll() throws SystemException {
3026        Object[] finderArgs = new Object[0];
3027
3028        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3029                finderArgs, this);
3030
3031        if (count == null) {
3032            Session session = null;
3033
3034            try {
3035                session = openSession();
3036
3037                Query q = session.createQuery(_SQL_COUNT_JOURNALCONTENTSEARCH);
3038
3039                count = (Long)q.uniqueResult();
3040            }
3041            catch (Exception e) {
3042                throw processException(e);
3043            }
3044            finally {
3045                if (count == null) {
3046                    count = Long.valueOf(0);
3047                }
3048
3049                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3050                    count);
3051
3052                closeSession(session);
3053            }
3054        }
3055
3056        return count.intValue();
3057    }
3058
3059    public void afterPropertiesSet() {
3060        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3061                    com.liferay.portal.util.PropsUtil.get(
3062                        "value.object.listener.com.liferay.portlet.journal.model.JournalContentSearch")));
3063
3064        if (listenerClassNames.length > 0) {
3065            try {
3066                List<ModelListener<JournalContentSearch>> listenersList = new ArrayList<ModelListener<JournalContentSearch>>();
3067
3068                for (String listenerClassName : listenerClassNames) {
3069                    listenersList.add((ModelListener<JournalContentSearch>)Class.forName(
3070                            listenerClassName).newInstance());
3071                }
3072
3073                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3074            }
3075            catch (Exception e) {
3076                _log.error(e);
3077            }
3078        }
3079    }
3080
3081    @BeanReference(type = JournalArticlePersistence.class)
3082    protected JournalArticlePersistence journalArticlePersistence;
3083    @BeanReference(type = JournalArticleImagePersistence.class)
3084    protected JournalArticleImagePersistence journalArticleImagePersistence;
3085    @BeanReference(type = JournalArticleResourcePersistence.class)
3086    protected JournalArticleResourcePersistence journalArticleResourcePersistence;
3087    @BeanReference(type = JournalContentSearchPersistence.class)
3088    protected JournalContentSearchPersistence journalContentSearchPersistence;
3089    @BeanReference(type = JournalFeedPersistence.class)
3090    protected JournalFeedPersistence journalFeedPersistence;
3091    @BeanReference(type = JournalStructurePersistence.class)
3092    protected JournalStructurePersistence journalStructurePersistence;
3093    @BeanReference(type = JournalTemplatePersistence.class)
3094    protected JournalTemplatePersistence journalTemplatePersistence;
3095    @BeanReference(type = GroupPersistence.class)
3096    protected GroupPersistence groupPersistence;
3097    @BeanReference(type = LayoutPersistence.class)
3098    protected LayoutPersistence layoutPersistence;
3099    @BeanReference(type = PortletPreferencesPersistence.class)
3100    protected PortletPreferencesPersistence portletPreferencesPersistence;
3101    @BeanReference(type = ResourcePersistence.class)
3102    protected ResourcePersistence resourcePersistence;
3103    @BeanReference(type = UserPersistence.class)
3104    protected UserPersistence userPersistence;
3105    private static final String _SQL_SELECT_JOURNALCONTENTSEARCH = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch";
3106    private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE ";
3107    private static final String _SQL_COUNT_JOURNALCONTENTSEARCH = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch";
3108    private static final String _SQL_COUNT_JOURNALCONTENTSEARCH_WHERE = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch WHERE ";
3109    private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3110    private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3111    private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3112    private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3113    private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ?";
3114    private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3115    private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3116    private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3117    private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3118    private static final String _FINDER_COLUMN_G_P_L_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3119    private static final String _FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3120    private static final String _FINDER_COLUMN_G_P_L_LAYOUTID_2 = "journalContentSearch.layoutId = ?";
3121    private static final String _FINDER_COLUMN_G_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3122    private static final String _FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3123    private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3124    private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3125    private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3126    private static final String _FINDER_COLUMN_G_P_L_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3127    private static final String _FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3128    private static final String _FINDER_COLUMN_G_P_L_P_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
3129    private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
3130    private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_2 = "journalContentSearch.portletId = ?";
3131    private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?)";
3132    private static final String _FINDER_COLUMN_G_P_L_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3133    private static final String _FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3134    private static final String _FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
3135    private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_1 = "journalContentSearch.portletId IS NULL AND ";
3136    private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_2 = "journalContentSearch.portletId = ? AND ";
3137    private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?) AND ";
3138    private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3139    private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3140    private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3141    private static final String _ORDER_BY_ENTITY_ALIAS = "journalContentSearch.";
3142    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalContentSearch exists with the primary key ";
3143    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalContentSearch exists with the key {";
3144    private static Log _log = LogFactoryUtil.getLog(JournalContentSearchPersistenceImpl.class);
3145}