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