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