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