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