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