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