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