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