001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.BatchSessionUtil;
039    import com.liferay.portal.service.persistence.GroupPersistence;
040    import com.liferay.portal.service.persistence.LayoutPersistence;
041    import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
042    import com.liferay.portal.service.persistence.ResourcePersistence;
043    import com.liferay.portal.service.persistence.UserPersistence;
044    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045    
046    import com.liferay.portlet.journal.NoSuchContentSearchException;
047    import com.liferay.portlet.journal.model.JournalContentSearch;
048    import com.liferay.portlet.journal.model.impl.JournalContentSearchImpl;
049    import com.liferay.portlet.journal.model.impl.JournalContentSearchModelImpl;
050    
051    import java.io.Serializable;
052    
053    import java.util.ArrayList;
054    import java.util.Collections;
055    import java.util.List;
056    
057    /**
058     * The persistence implementation for the journal content search service.
059     *
060     * <p>
061     * Never modify or reference this class directly. Always use {@link JournalContentSearchUtil} to access the journal content search persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
062     * </p>
063     *
064     * <p>
065     * Caching information and settings can be found in <code>portal.properties</code>
066     * </p>
067     *
068     * @author Brian Wing Shun Chan
069     * @see JournalContentSearchPersistence
070     * @see JournalContentSearchUtil
071     * @generated
072     */
073    public class JournalContentSearchPersistenceImpl extends BasePersistenceImpl<JournalContentSearch>
074            implements JournalContentSearchPersistence {
075            public static final String FINDER_CLASS_NAME_ENTITY = JournalContentSearchImpl.class.getName();
076            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
077                    ".List";
078            public static final FinderPath FINDER_PATH_FIND_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
079                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
080                            FINDER_CLASS_NAME_LIST, "findByArticleId",
081                            new String[] {
082                                    String.class.getName(),
083                                    
084                            "java.lang.Integer", "java.lang.Integer",
085                                    "com.liferay.portal.kernel.util.OrderByComparator"
086                            });
087            public static final FinderPath FINDER_PATH_COUNT_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
088                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
089                            FINDER_CLASS_NAME_LIST, "countByArticleId",
090                            new String[] { String.class.getName() });
091            public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
092                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
093                            FINDER_CLASS_NAME_LIST, "findByG_P",
094                            new String[] {
095                                    Long.class.getName(), Boolean.class.getName(),
096                                    
097                            "java.lang.Integer", "java.lang.Integer",
098                                    "com.liferay.portal.kernel.util.OrderByComparator"
099                            });
100            public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
101                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
102                            FINDER_CLASS_NAME_LIST, "countByG_P",
103                            new String[] { Long.class.getName(), Boolean.class.getName() });
104            public static final FinderPath FINDER_PATH_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
105                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
106                            FINDER_CLASS_NAME_LIST, "findByG_A",
107                            new String[] {
108                                    Long.class.getName(), String.class.getName(),
109                                    
110                            "java.lang.Integer", "java.lang.Integer",
111                                    "com.liferay.portal.kernel.util.OrderByComparator"
112                            });
113            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
114                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
115                            FINDER_CLASS_NAME_LIST, "countByG_A",
116                            new String[] { Long.class.getName(), String.class.getName() });
117            public static final FinderPath FINDER_PATH_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
118                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
119                            FINDER_CLASS_NAME_LIST, "findByG_P_L",
120                            new String[] {
121                                    Long.class.getName(), Boolean.class.getName(),
122                                    Long.class.getName(),
123                                    
124                            "java.lang.Integer", "java.lang.Integer",
125                                    "com.liferay.portal.kernel.util.OrderByComparator"
126                            });
127            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
128                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
129                            FINDER_CLASS_NAME_LIST, "countByG_P_L",
130                            new String[] {
131                                    Long.class.getName(), Boolean.class.getName(),
132                                    Long.class.getName()
133                            });
134            public static final FinderPath FINDER_PATH_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
135                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
136                            FINDER_CLASS_NAME_LIST, "findByG_P_A",
137                            new String[] {
138                                    Long.class.getName(), Boolean.class.getName(),
139                                    String.class.getName(),
140                                    
141                            "java.lang.Integer", "java.lang.Integer",
142                                    "com.liferay.portal.kernel.util.OrderByComparator"
143                            });
144            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
145                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
146                            FINDER_CLASS_NAME_LIST, "countByG_P_A",
147                            new String[] {
148                                    Long.class.getName(), Boolean.class.getName(),
149                                    String.class.getName()
150                            });
151            public static final FinderPath FINDER_PATH_FIND_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
152                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
153                            FINDER_CLASS_NAME_LIST, "findByG_P_L_P",
154                            new String[] {
155                                    Long.class.getName(), Boolean.class.getName(),
156                                    Long.class.getName(), String.class.getName(),
157                                    
158                            "java.lang.Integer", "java.lang.Integer",
159                                    "com.liferay.portal.kernel.util.OrderByComparator"
160                            });
161            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
162                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
163                            FINDER_CLASS_NAME_LIST, "countByG_P_L_P",
164                            new String[] {
165                                    Long.class.getName(), Boolean.class.getName(),
166                                    Long.class.getName(), String.class.getName()
167                            });
168            public static final FinderPath FINDER_PATH_FETCH_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
169                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
170                            FINDER_CLASS_NAME_ENTITY, "fetchByG_P_L_P_A",
171                            new String[] {
172                                    Long.class.getName(), Boolean.class.getName(),
173                                    Long.class.getName(), String.class.getName(),
174                                    String.class.getName()
175                            });
176            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
177                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
178                            FINDER_CLASS_NAME_LIST, "countByG_P_L_P_A",
179                            new String[] {
180                                    Long.class.getName(), Boolean.class.getName(),
181                                    Long.class.getName(), String.class.getName(),
182                                    String.class.getName()
183                            });
184            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
185                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
186                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
187            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
188                            JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
189                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
190    
191            /**
192             * Caches the journal content search in the entity cache if it is enabled.
193             *
194             * @param journalContentSearch the journal content search to cache
195             */
196            public void cacheResult(JournalContentSearch journalContentSearch) {
197                    EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
198                            JournalContentSearchImpl.class,
199                            journalContentSearch.getPrimaryKey(), journalContentSearch);
200    
201                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
202                            new Object[] {
203                                    new Long(journalContentSearch.getGroupId()),
204                                    Boolean.valueOf(journalContentSearch.getPrivateLayout()),
205                                    new Long(journalContentSearch.getLayoutId()),
206                                    
207                            journalContentSearch.getPortletId(),
208                                    
209                            journalContentSearch.getArticleId()
210                            }, journalContentSearch);
211            }
212    
213            /**
214             * Caches the journal content searchs in the entity cache if it is enabled.
215             *
216             * @param journalContentSearchs the journal content searchs to cache
217             */
218            public void cacheResult(List<JournalContentSearch> journalContentSearchs) {
219                    for (JournalContentSearch journalContentSearch : journalContentSearchs) {
220                            if (EntityCacheUtil.getResult(
221                                                    JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
222                                                    JournalContentSearchImpl.class,
223                                                    journalContentSearch.getPrimaryKey(), this) == null) {
224                                    cacheResult(journalContentSearch);
225                            }
226                    }
227            }
228    
229            /**
230             * Clears the cache for all journal content searchs.
231             *
232             * <p>
233             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
234             * </p>
235             */
236            public void clearCache() {
237                    CacheRegistryUtil.clear(JournalContentSearchImpl.class.getName());
238                    EntityCacheUtil.clearCache(JournalContentSearchImpl.class.getName());
239                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
240                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
241            }
242    
243            /**
244             * Clears the cache for the journal content search.
245             *
246             * <p>
247             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
248             * </p>
249             */
250            public void clearCache(JournalContentSearch journalContentSearch) {
251                    EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
252                            JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
253    
254                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
255                            new Object[] {
256                                    new Long(journalContentSearch.getGroupId()),
257                                    Boolean.valueOf(journalContentSearch.getPrivateLayout()),
258                                    new Long(journalContentSearch.getLayoutId()),
259                                    
260                            journalContentSearch.getPortletId(),
261                                    
262                            journalContentSearch.getArticleId()
263                            });
264            }
265    
266            /**
267             * Creates a new journal content search with the primary key. Does not add the journal content search to the database.
268             *
269             * @param contentSearchId the primary key for the new journal content search
270             * @return the new journal content search
271             */
272            public JournalContentSearch create(long contentSearchId) {
273                    JournalContentSearch journalContentSearch = new JournalContentSearchImpl();
274    
275                    journalContentSearch.setNew(true);
276                    journalContentSearch.setPrimaryKey(contentSearchId);
277    
278                    return journalContentSearch;
279            }
280    
281            /**
282             * Removes the journal content search with the primary key from the database. Also notifies the appropriate model listeners.
283             *
284             * @param primaryKey the primary key of the journal content search to remove
285             * @return the journal content search that was removed
286             * @throws com.liferay.portal.NoSuchModelException if a journal content search with the primary key could not be found
287             * @throws SystemException if a system exception occurred
288             */
289            public JournalContentSearch remove(Serializable primaryKey)
290                    throws NoSuchModelException, SystemException {
291                    return remove(((Long)primaryKey).longValue());
292            }
293    
294            /**
295             * Removes the journal content search with the primary key from the database. Also notifies the appropriate model listeners.
296             *
297             * @param contentSearchId the primary key of the journal content search to remove
298             * @return the journal content search that was removed
299             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a journal content search with the primary key could not be found
300             * @throws SystemException if a system exception occurred
301             */
302            public JournalContentSearch remove(long contentSearchId)
303                    throws NoSuchContentSearchException, SystemException {
304                    Session session = null;
305    
306                    try {
307                            session = openSession();
308    
309                            JournalContentSearch journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
310                                            new Long(contentSearchId));
311    
312                            if (journalContentSearch == null) {
313                                    if (_log.isWarnEnabled()) {
314                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
315                                                    contentSearchId);
316                                    }
317    
318                                    throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
319                                            contentSearchId);
320                            }
321    
322                            return remove(journalContentSearch);
323                    }
324                    catch (NoSuchContentSearchException nsee) {
325                            throw nsee;
326                    }
327                    catch (Exception e) {
328                            throw processException(e);
329                    }
330                    finally {
331                            closeSession(session);
332                    }
333            }
334    
335            protected JournalContentSearch removeImpl(
336                    JournalContentSearch journalContentSearch) throws SystemException {
337                    journalContentSearch = toUnwrappedModel(journalContentSearch);
338    
339                    Session session = null;
340    
341                    try {
342                            session = openSession();
343    
344                            BatchSessionUtil.delete(session, journalContentSearch);
345                    }
346                    catch (Exception e) {
347                            throw processException(e);
348                    }
349                    finally {
350                            closeSession(session);
351                    }
352    
353                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
354    
355                    JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
356    
357                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
358                            new Object[] {
359                                    new Long(journalContentSearchModelImpl.getOriginalGroupId()),
360                                    Boolean.valueOf(
361                                            journalContentSearchModelImpl.getOriginalPrivateLayout()),
362                                    new Long(journalContentSearchModelImpl.getOriginalLayoutId()),
363                                    
364                            journalContentSearchModelImpl.getOriginalPortletId(),
365                                    
366                            journalContentSearchModelImpl.getOriginalArticleId()
367                            });
368    
369                    EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
370                            JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
371    
372                    return journalContentSearch;
373            }
374    
375            public JournalContentSearch updateImpl(
376                    com.liferay.portlet.journal.model.JournalContentSearch journalContentSearch,
377                    boolean merge) throws SystemException {
378                    journalContentSearch = toUnwrappedModel(journalContentSearch);
379    
380                    boolean isNew = journalContentSearch.isNew();
381    
382                    JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
383    
384                    Session session = null;
385    
386                    try {
387                            session = openSession();
388    
389                            BatchSessionUtil.update(session, journalContentSearch, merge);
390    
391                            journalContentSearch.setNew(false);
392                    }
393                    catch (Exception e) {
394                            throw processException(e);
395                    }
396                    finally {
397                            closeSession(session);
398                    }
399    
400                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
401    
402                    EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
403                            JournalContentSearchImpl.class,
404                            journalContentSearch.getPrimaryKey(), journalContentSearch);
405    
406                    if (!isNew &&
407                                    ((journalContentSearch.getGroupId() != journalContentSearchModelImpl.getOriginalGroupId()) ||
408                                    (journalContentSearch.getPrivateLayout() != journalContentSearchModelImpl.getOriginalPrivateLayout()) ||
409                                    (journalContentSearch.getLayoutId() != journalContentSearchModelImpl.getOriginalLayoutId()) ||
410                                    !Validator.equals(journalContentSearch.getPortletId(),
411                                            journalContentSearchModelImpl.getOriginalPortletId()) ||
412                                    !Validator.equals(journalContentSearch.getArticleId(),
413                                            journalContentSearchModelImpl.getOriginalArticleId()))) {
414                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
415                                    new Object[] {
416                                            new Long(journalContentSearchModelImpl.getOriginalGroupId()),
417                                            Boolean.valueOf(
418                                                    journalContentSearchModelImpl.getOriginalPrivateLayout()),
419                                            new Long(journalContentSearchModelImpl.getOriginalLayoutId()),
420                                            
421                                    journalContentSearchModelImpl.getOriginalPortletId(),
422                                            
423                                    journalContentSearchModelImpl.getOriginalArticleId()
424                                    });
425                    }
426    
427                    if (isNew ||
428                                    ((journalContentSearch.getGroupId() != journalContentSearchModelImpl.getOriginalGroupId()) ||
429                                    (journalContentSearch.getPrivateLayout() != journalContentSearchModelImpl.getOriginalPrivateLayout()) ||
430                                    (journalContentSearch.getLayoutId() != journalContentSearchModelImpl.getOriginalLayoutId()) ||
431                                    !Validator.equals(journalContentSearch.getPortletId(),
432                                            journalContentSearchModelImpl.getOriginalPortletId()) ||
433                                    !Validator.equals(journalContentSearch.getArticleId(),
434                                            journalContentSearchModelImpl.getOriginalArticleId()))) {
435                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
436                                    new Object[] {
437                                            new Long(journalContentSearch.getGroupId()),
438                                            Boolean.valueOf(journalContentSearch.getPrivateLayout()),
439                                            new Long(journalContentSearch.getLayoutId()),
440                                            
441                                    journalContentSearch.getPortletId(),
442                                            
443                                    journalContentSearch.getArticleId()
444                                    }, journalContentSearch);
445                    }
446    
447                    return journalContentSearch;
448            }
449    
450            protected JournalContentSearch toUnwrappedModel(
451                    JournalContentSearch journalContentSearch) {
452                    if (journalContentSearch instanceof JournalContentSearchImpl) {
453                            return journalContentSearch;
454                    }
455    
456                    JournalContentSearchImpl journalContentSearchImpl = new JournalContentSearchImpl();
457    
458                    journalContentSearchImpl.setNew(journalContentSearch.isNew());
459                    journalContentSearchImpl.setPrimaryKey(journalContentSearch.getPrimaryKey());
460    
461                    journalContentSearchImpl.setContentSearchId(journalContentSearch.getContentSearchId());
462                    journalContentSearchImpl.setGroupId(journalContentSearch.getGroupId());
463                    journalContentSearchImpl.setCompanyId(journalContentSearch.getCompanyId());
464                    journalContentSearchImpl.setPrivateLayout(journalContentSearch.isPrivateLayout());
465                    journalContentSearchImpl.setLayoutId(journalContentSearch.getLayoutId());
466                    journalContentSearchImpl.setPortletId(journalContentSearch.getPortletId());
467                    journalContentSearchImpl.setArticleId(journalContentSearch.getArticleId());
468    
469                    return journalContentSearchImpl;
470            }
471    
472            /**
473             * Finds the journal content search with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
474             *
475             * @param primaryKey the primary key of the journal content search to find
476             * @return the journal content search
477             * @throws com.liferay.portal.NoSuchModelException if a journal content search with the primary key could not be found
478             * @throws SystemException if a system exception occurred
479             */
480            public JournalContentSearch findByPrimaryKey(Serializable primaryKey)
481                    throws NoSuchModelException, SystemException {
482                    return findByPrimaryKey(((Long)primaryKey).longValue());
483            }
484    
485            /**
486             * Finds the journal content search with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchContentSearchException} if it could not be found.
487             *
488             * @param contentSearchId the primary key of the journal content search to find
489             * @return the journal content search
490             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a journal content search with the primary key could not be found
491             * @throws SystemException if a system exception occurred
492             */
493            public JournalContentSearch findByPrimaryKey(long contentSearchId)
494                    throws NoSuchContentSearchException, SystemException {
495                    JournalContentSearch journalContentSearch = fetchByPrimaryKey(contentSearchId);
496    
497                    if (journalContentSearch == null) {
498                            if (_log.isWarnEnabled()) {
499                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contentSearchId);
500                            }
501    
502                            throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
503                                    contentSearchId);
504                    }
505    
506                    return journalContentSearch;
507            }
508    
509            /**
510             * Finds the journal content search with the primary key or returns <code>null</code> if it could not be found.
511             *
512             * @param primaryKey the primary key of the journal content search to find
513             * @return the journal content search, or <code>null</code> if a journal content search with the primary key could not be found
514             * @throws SystemException if a system exception occurred
515             */
516            public JournalContentSearch fetchByPrimaryKey(Serializable primaryKey)
517                    throws SystemException {
518                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
519            }
520    
521            /**
522             * Finds the journal content search with the primary key or returns <code>null</code> if it could not be found.
523             *
524             * @param contentSearchId the primary key of the journal content search to find
525             * @return the journal content search, or <code>null</code> if a journal content search with the primary key could not be found
526             * @throws SystemException if a system exception occurred
527             */
528            public JournalContentSearch fetchByPrimaryKey(long contentSearchId)
529                    throws SystemException {
530                    JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
531                                    JournalContentSearchImpl.class, contentSearchId, this);
532    
533                    if (journalContentSearch == null) {
534                            Session session = null;
535    
536                            try {
537                                    session = openSession();
538    
539                                    journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
540                                                    new Long(contentSearchId));
541                            }
542                            catch (Exception e) {
543                                    throw processException(e);
544                            }
545                            finally {
546                                    if (journalContentSearch != null) {
547                                            cacheResult(journalContentSearch);
548                                    }
549    
550                                    closeSession(session);
551                            }
552                    }
553    
554                    return journalContentSearch;
555            }
556    
557            /**
558             * Finds all the journal content searchs where articleId = &#63;.
559             *
560             * @param articleId the article id to search with
561             * @return the matching journal content searchs
562             * @throws SystemException if a system exception occurred
563             */
564            public List<JournalContentSearch> findByArticleId(String articleId)
565                    throws SystemException {
566                    return findByArticleId(articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
567                            null);
568            }
569    
570            /**
571             * Finds a range of all the journal content searchs where articleId = &#63;.
572             *
573             * <p>
574             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
575             * </p>
576             *
577             * @param articleId the article id to search with
578             * @param start the lower bound of the range of journal content searchs to return
579             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
580             * @return the range of matching journal content searchs
581             * @throws SystemException if a system exception occurred
582             */
583            public List<JournalContentSearch> findByArticleId(String articleId,
584                    int start, int end) throws SystemException {
585                    return findByArticleId(articleId, start, end, null);
586            }
587    
588            /**
589             * Finds an ordered range of all the journal content searchs where articleId = &#63;.
590             *
591             * <p>
592             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
593             * </p>
594             *
595             * @param articleId the article id to search with
596             * @param start the lower bound of the range of journal content searchs to return
597             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
598             * @param orderByComparator the comparator to order the results by
599             * @return the ordered range of matching journal content searchs
600             * @throws SystemException if a system exception occurred
601             */
602            public List<JournalContentSearch> findByArticleId(String articleId,
603                    int start, int end, OrderByComparator orderByComparator)
604                    throws SystemException {
605                    Object[] finderArgs = new Object[] {
606                                    articleId,
607                                    
608                                    String.valueOf(start), String.valueOf(end),
609                                    String.valueOf(orderByComparator)
610                            };
611    
612                    List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ARTICLEID,
613                                    finderArgs, this);
614    
615                    if (list == null) {
616                            Session session = null;
617    
618                            try {
619                                    session = openSession();
620    
621                                    StringBundler query = null;
622    
623                                    if (orderByComparator != null) {
624                                            query = new StringBundler(3 +
625                                                            (orderByComparator.getOrderByFields().length * 3));
626                                    }
627                                    else {
628                                            query = new StringBundler(2);
629                                    }
630    
631                                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
632    
633                                    if (articleId == null) {
634                                            query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
635                                    }
636                                    else {
637                                            if (articleId.equals(StringPool.BLANK)) {
638                                                    query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
639                                            }
640                                            else {
641                                                    query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
642                                            }
643                                    }
644    
645                                    if (orderByComparator != null) {
646                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
647                                                    orderByComparator);
648                                    }
649    
650                                    String sql = query.toString();
651    
652                                    Query q = session.createQuery(sql);
653    
654                                    QueryPos qPos = QueryPos.getInstance(q);
655    
656                                    if (articleId != null) {
657                                            qPos.add(articleId);
658                                    }
659    
660                                    list = (List<JournalContentSearch>)QueryUtil.list(q,
661                                                    getDialect(), start, end);
662                            }
663                            catch (Exception e) {
664                                    throw processException(e);
665                            }
666                            finally {
667                                    if (list == null) {
668                                            list = new ArrayList<JournalContentSearch>();
669                                    }
670    
671                                    cacheResult(list);
672    
673                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ARTICLEID,
674                                            finderArgs, list);
675    
676                                    closeSession(session);
677                            }
678                    }
679    
680                    return list;
681            }
682    
683            /**
684             * Finds the first journal content search in the ordered set where articleId = &#63;.
685             *
686             * <p>
687             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
688             * </p>
689             *
690             * @param articleId the article id to search with
691             * @param orderByComparator the comparator to order the set by
692             * @return the first matching journal content search
693             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
694             * @throws SystemException if a system exception occurred
695             */
696            public JournalContentSearch findByArticleId_First(String articleId,
697                    OrderByComparator orderByComparator)
698                    throws NoSuchContentSearchException, SystemException {
699                    List<JournalContentSearch> list = findByArticleId(articleId, 0, 1,
700                                    orderByComparator);
701    
702                    if (list.isEmpty()) {
703                            StringBundler msg = new StringBundler(4);
704    
705                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
706    
707                            msg.append("articleId=");
708                            msg.append(articleId);
709    
710                            msg.append(StringPool.CLOSE_CURLY_BRACE);
711    
712                            throw new NoSuchContentSearchException(msg.toString());
713                    }
714                    else {
715                            return list.get(0);
716                    }
717            }
718    
719            /**
720             * Finds the last journal content search in the ordered set where articleId = &#63;.
721             *
722             * <p>
723             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
724             * </p>
725             *
726             * @param articleId the article id to search with
727             * @param orderByComparator the comparator to order the set by
728             * @return the last matching journal content search
729             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
730             * @throws SystemException if a system exception occurred
731             */
732            public JournalContentSearch findByArticleId_Last(String articleId,
733                    OrderByComparator orderByComparator)
734                    throws NoSuchContentSearchException, SystemException {
735                    int count = countByArticleId(articleId);
736    
737                    List<JournalContentSearch> list = findByArticleId(articleId, count - 1,
738                                    count, orderByComparator);
739    
740                    if (list.isEmpty()) {
741                            StringBundler msg = new StringBundler(4);
742    
743                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
744    
745                            msg.append("articleId=");
746                            msg.append(articleId);
747    
748                            msg.append(StringPool.CLOSE_CURLY_BRACE);
749    
750                            throw new NoSuchContentSearchException(msg.toString());
751                    }
752                    else {
753                            return list.get(0);
754                    }
755            }
756    
757            /**
758             * Finds the journal content searchs before and after the current journal content search in the ordered set where articleId = &#63;.
759             *
760             * <p>
761             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
762             * </p>
763             *
764             * @param contentSearchId the primary key of the current journal content search
765             * @param articleId the article id to search with
766             * @param orderByComparator the comparator to order the set by
767             * @return the previous, current, and next journal content search
768             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a journal content search with the primary key could not be found
769             * @throws SystemException if a system exception occurred
770             */
771            public JournalContentSearch[] findByArticleId_PrevAndNext(
772                    long contentSearchId, String articleId,
773                    OrderByComparator orderByComparator)
774                    throws NoSuchContentSearchException, SystemException {
775                    JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
776    
777                    Session session = null;
778    
779                    try {
780                            session = openSession();
781    
782                            JournalContentSearch[] array = new JournalContentSearchImpl[3];
783    
784                            array[0] = getByArticleId_PrevAndNext(session,
785                                            journalContentSearch, articleId, orderByComparator, true);
786    
787                            array[1] = journalContentSearch;
788    
789                            array[2] = getByArticleId_PrevAndNext(session,
790                                            journalContentSearch, articleId, orderByComparator, false);
791    
792                            return array;
793                    }
794                    catch (Exception e) {
795                            throw processException(e);
796                    }
797                    finally {
798                            closeSession(session);
799                    }
800            }
801    
802            protected JournalContentSearch getByArticleId_PrevAndNext(Session session,
803                    JournalContentSearch journalContentSearch, String articleId,
804                    OrderByComparator orderByComparator, boolean previous) {
805                    StringBundler query = null;
806    
807                    if (orderByComparator != null) {
808                            query = new StringBundler(6 +
809                                            (orderByComparator.getOrderByFields().length * 6));
810                    }
811                    else {
812                            query = new StringBundler(3);
813                    }
814    
815                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
816    
817                    if (articleId == null) {
818                            query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
819                    }
820                    else {
821                            if (articleId.equals(StringPool.BLANK)) {
822                                    query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
823                            }
824                            else {
825                                    query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
826                            }
827                    }
828    
829                    if (orderByComparator != null) {
830                            String[] orderByFields = orderByComparator.getOrderByFields();
831    
832                            if (orderByFields.length > 0) {
833                                    query.append(WHERE_AND);
834                            }
835    
836                            for (int i = 0; i < orderByFields.length; i++) {
837                                    query.append(_ORDER_BY_ENTITY_ALIAS);
838                                    query.append(orderByFields[i]);
839    
840                                    if ((i + 1) < orderByFields.length) {
841                                            if (orderByComparator.isAscending() ^ previous) {
842                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
843                                            }
844                                            else {
845                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
846                                            }
847                                    }
848                                    else {
849                                            if (orderByComparator.isAscending() ^ previous) {
850                                                    query.append(WHERE_GREATER_THAN);
851                                            }
852                                            else {
853                                                    query.append(WHERE_LESSER_THAN);
854                                            }
855                                    }
856                            }
857    
858                            query.append(ORDER_BY_CLAUSE);
859    
860                            for (int i = 0; i < orderByFields.length; i++) {
861                                    query.append(_ORDER_BY_ENTITY_ALIAS);
862                                    query.append(orderByFields[i]);
863    
864                                    if ((i + 1) < orderByFields.length) {
865                                            if (orderByComparator.isAscending() ^ previous) {
866                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
867                                            }
868                                            else {
869                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
870                                            }
871                                    }
872                                    else {
873                                            if (orderByComparator.isAscending() ^ previous) {
874                                                    query.append(ORDER_BY_ASC);
875                                            }
876                                            else {
877                                                    query.append(ORDER_BY_DESC);
878                                            }
879                                    }
880                            }
881                    }
882    
883                    String sql = query.toString();
884    
885                    Query q = session.createQuery(sql);
886    
887                    q.setFirstResult(0);
888                    q.setMaxResults(2);
889    
890                    QueryPos qPos = QueryPos.getInstance(q);
891    
892                    if (articleId != null) {
893                            qPos.add(articleId);
894                    }
895    
896                    if (orderByComparator != null) {
897                            Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
898    
899                            for (Object value : values) {
900                                    qPos.add(value);
901                            }
902                    }
903    
904                    List<JournalContentSearch> list = q.list();
905    
906                    if (list.size() == 2) {
907                            return list.get(1);
908                    }
909                    else {
910                            return null;
911                    }
912            }
913    
914            /**
915             * Finds all the journal content searchs where groupId = &#63; and privateLayout = &#63;.
916             *
917             * @param groupId the group id to search with
918             * @param privateLayout the private layout to search with
919             * @return the matching journal content searchs
920             * @throws SystemException if a system exception occurred
921             */
922            public List<JournalContentSearch> findByG_P(long groupId,
923                    boolean privateLayout) throws SystemException {
924                    return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
925                            QueryUtil.ALL_POS, null);
926            }
927    
928            /**
929             * Finds a range of all the journal content searchs where groupId = &#63; and privateLayout = &#63;.
930             *
931             * <p>
932             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
933             * </p>
934             *
935             * @param groupId the group id to search with
936             * @param privateLayout the private layout to search with
937             * @param start the lower bound of the range of journal content searchs to return
938             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
939             * @return the range of matching journal content searchs
940             * @throws SystemException if a system exception occurred
941             */
942            public List<JournalContentSearch> findByG_P(long groupId,
943                    boolean privateLayout, int start, int end) throws SystemException {
944                    return findByG_P(groupId, privateLayout, start, end, null);
945            }
946    
947            /**
948             * Finds an ordered range of all the journal content searchs where groupId = &#63; and privateLayout = &#63;.
949             *
950             * <p>
951             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
952             * </p>
953             *
954             * @param groupId the group id to search with
955             * @param privateLayout the private layout to search with
956             * @param start the lower bound of the range of journal content searchs to return
957             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
958             * @param orderByComparator the comparator to order the results by
959             * @return the ordered range of matching journal content searchs
960             * @throws SystemException if a system exception occurred
961             */
962            public List<JournalContentSearch> findByG_P(long groupId,
963                    boolean privateLayout, int start, int end,
964                    OrderByComparator orderByComparator) throws SystemException {
965                    Object[] finderArgs = new Object[] {
966                                    groupId, privateLayout,
967                                    
968                                    String.valueOf(start), String.valueOf(end),
969                                    String.valueOf(orderByComparator)
970                            };
971    
972                    List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
973                                    finderArgs, this);
974    
975                    if (list == null) {
976                            Session session = null;
977    
978                            try {
979                                    session = openSession();
980    
981                                    StringBundler query = null;
982    
983                                    if (orderByComparator != null) {
984                                            query = new StringBundler(4 +
985                                                            (orderByComparator.getOrderByFields().length * 3));
986                                    }
987                                    else {
988                                            query = new StringBundler(3);
989                                    }
990    
991                                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
992    
993                                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
994    
995                                    query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
996    
997                                    if (orderByComparator != null) {
998                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
999                                                    orderByComparator);
1000                                    }
1001    
1002                                    String sql = query.toString();
1003    
1004                                    Query q = session.createQuery(sql);
1005    
1006                                    QueryPos qPos = QueryPos.getInstance(q);
1007    
1008                                    qPos.add(groupId);
1009    
1010                                    qPos.add(privateLayout);
1011    
1012                                    list = (List<JournalContentSearch>)QueryUtil.list(q,
1013                                                    getDialect(), start, end);
1014                            }
1015                            catch (Exception e) {
1016                                    throw processException(e);
1017                            }
1018                            finally {
1019                                    if (list == null) {
1020                                            list = new ArrayList<JournalContentSearch>();
1021                                    }
1022    
1023                                    cacheResult(list);
1024    
1025                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
1026                                            list);
1027    
1028                                    closeSession(session);
1029                            }
1030                    }
1031    
1032                    return list;
1033            }
1034    
1035            /**
1036             * Finds the first journal content search in the ordered set where groupId = &#63; and privateLayout = &#63;.
1037             *
1038             * <p>
1039             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1040             * </p>
1041             *
1042             * @param groupId the group id to search with
1043             * @param privateLayout the private layout to search with
1044             * @param orderByComparator the comparator to order the set by
1045             * @return the first matching journal content search
1046             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
1047             * @throws SystemException if a system exception occurred
1048             */
1049            public JournalContentSearch findByG_P_First(long groupId,
1050                    boolean privateLayout, OrderByComparator orderByComparator)
1051                    throws NoSuchContentSearchException, SystemException {
1052                    List<JournalContentSearch> list = findByG_P(groupId, privateLayout, 0,
1053                                    1, orderByComparator);
1054    
1055                    if (list.isEmpty()) {
1056                            StringBundler msg = new StringBundler(6);
1057    
1058                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1059    
1060                            msg.append("groupId=");
1061                            msg.append(groupId);
1062    
1063                            msg.append(", privateLayout=");
1064                            msg.append(privateLayout);
1065    
1066                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1067    
1068                            throw new NoSuchContentSearchException(msg.toString());
1069                    }
1070                    else {
1071                            return list.get(0);
1072                    }
1073            }
1074    
1075            /**
1076             * Finds the last journal content search in the ordered set where groupId = &#63; and privateLayout = &#63;.
1077             *
1078             * <p>
1079             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1080             * </p>
1081             *
1082             * @param groupId the group id to search with
1083             * @param privateLayout the private layout to search with
1084             * @param orderByComparator the comparator to order the set by
1085             * @return the last matching journal content search
1086             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
1087             * @throws SystemException if a system exception occurred
1088             */
1089            public JournalContentSearch findByG_P_Last(long groupId,
1090                    boolean privateLayout, OrderByComparator orderByComparator)
1091                    throws NoSuchContentSearchException, SystemException {
1092                    int count = countByG_P(groupId, privateLayout);
1093    
1094                    List<JournalContentSearch> list = findByG_P(groupId, privateLayout,
1095                                    count - 1, count, orderByComparator);
1096    
1097                    if (list.isEmpty()) {
1098                            StringBundler msg = new StringBundler(6);
1099    
1100                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1101    
1102                            msg.append("groupId=");
1103                            msg.append(groupId);
1104    
1105                            msg.append(", privateLayout=");
1106                            msg.append(privateLayout);
1107    
1108                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1109    
1110                            throw new NoSuchContentSearchException(msg.toString());
1111                    }
1112                    else {
1113                            return list.get(0);
1114                    }
1115            }
1116    
1117            /**
1118             * Finds the journal content searchs before and after the current journal content search in the ordered set where groupId = &#63; and privateLayout = &#63;.
1119             *
1120             * <p>
1121             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1122             * </p>
1123             *
1124             * @param contentSearchId the primary key of the current journal content search
1125             * @param groupId the group id to search with
1126             * @param privateLayout the private layout to search with
1127             * @param orderByComparator the comparator to order the set by
1128             * @return the previous, current, and next journal content search
1129             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a journal content search with the primary key could not be found
1130             * @throws SystemException if a system exception occurred
1131             */
1132            public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
1133                    long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1134                    throws NoSuchContentSearchException, SystemException {
1135                    JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1136    
1137                    Session session = null;
1138    
1139                    try {
1140                            session = openSession();
1141    
1142                            JournalContentSearch[] array = new JournalContentSearchImpl[3];
1143    
1144                            array[0] = getByG_P_PrevAndNext(session, journalContentSearch,
1145                                            groupId, privateLayout, orderByComparator, true);
1146    
1147                            array[1] = journalContentSearch;
1148    
1149                            array[2] = getByG_P_PrevAndNext(session, journalContentSearch,
1150                                            groupId, privateLayout, orderByComparator, false);
1151    
1152                            return array;
1153                    }
1154                    catch (Exception e) {
1155                            throw processException(e);
1156                    }
1157                    finally {
1158                            closeSession(session);
1159                    }
1160            }
1161    
1162            protected JournalContentSearch getByG_P_PrevAndNext(Session session,
1163                    JournalContentSearch journalContentSearch, long groupId,
1164                    boolean privateLayout, OrderByComparator orderByComparator,
1165                    boolean previous) {
1166                    StringBundler query = null;
1167    
1168                    if (orderByComparator != null) {
1169                            query = new StringBundler(6 +
1170                                            (orderByComparator.getOrderByFields().length * 6));
1171                    }
1172                    else {
1173                            query = new StringBundler(3);
1174                    }
1175    
1176                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1177    
1178                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1179    
1180                    query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1181    
1182                    if (orderByComparator != null) {
1183                            String[] orderByFields = orderByComparator.getOrderByFields();
1184    
1185                            if (orderByFields.length > 0) {
1186                                    query.append(WHERE_AND);
1187                            }
1188    
1189                            for (int i = 0; i < orderByFields.length; i++) {
1190                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1191                                    query.append(orderByFields[i]);
1192    
1193                                    if ((i + 1) < orderByFields.length) {
1194                                            if (orderByComparator.isAscending() ^ previous) {
1195                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1196                                            }
1197                                            else {
1198                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1199                                            }
1200                                    }
1201                                    else {
1202                                            if (orderByComparator.isAscending() ^ previous) {
1203                                                    query.append(WHERE_GREATER_THAN);
1204                                            }
1205                                            else {
1206                                                    query.append(WHERE_LESSER_THAN);
1207                                            }
1208                                    }
1209                            }
1210    
1211                            query.append(ORDER_BY_CLAUSE);
1212    
1213                            for (int i = 0; i < orderByFields.length; i++) {
1214                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1215                                    query.append(orderByFields[i]);
1216    
1217                                    if ((i + 1) < orderByFields.length) {
1218                                            if (orderByComparator.isAscending() ^ previous) {
1219                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1220                                            }
1221                                            else {
1222                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1223                                            }
1224                                    }
1225                                    else {
1226                                            if (orderByComparator.isAscending() ^ previous) {
1227                                                    query.append(ORDER_BY_ASC);
1228                                            }
1229                                            else {
1230                                                    query.append(ORDER_BY_DESC);
1231                                            }
1232                                    }
1233                            }
1234                    }
1235    
1236                    String sql = query.toString();
1237    
1238                    Query q = session.createQuery(sql);
1239    
1240                    q.setFirstResult(0);
1241                    q.setMaxResults(2);
1242    
1243                    QueryPos qPos = QueryPos.getInstance(q);
1244    
1245                    qPos.add(groupId);
1246    
1247                    qPos.add(privateLayout);
1248    
1249                    if (orderByComparator != null) {
1250                            Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
1251    
1252                            for (Object value : values) {
1253                                    qPos.add(value);
1254                            }
1255                    }
1256    
1257                    List<JournalContentSearch> list = q.list();
1258    
1259                    if (list.size() == 2) {
1260                            return list.get(1);
1261                    }
1262                    else {
1263                            return null;
1264                    }
1265            }
1266    
1267            /**
1268             * Finds all the journal content searchs where groupId = &#63; and articleId = &#63;.
1269             *
1270             * @param groupId the group id to search with
1271             * @param articleId the article id to search with
1272             * @return the matching journal content searchs
1273             * @throws SystemException if a system exception occurred
1274             */
1275            public List<JournalContentSearch> findByG_A(long groupId, String articleId)
1276                    throws SystemException {
1277                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
1278                            QueryUtil.ALL_POS, null);
1279            }
1280    
1281            /**
1282             * Finds a range of all the journal content searchs where groupId = &#63; and articleId = &#63;.
1283             *
1284             * <p>
1285             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1286             * </p>
1287             *
1288             * @param groupId the group id to search with
1289             * @param articleId the article id to search with
1290             * @param start the lower bound of the range of journal content searchs to return
1291             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
1292             * @return the range of matching journal content searchs
1293             * @throws SystemException if a system exception occurred
1294             */
1295            public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1296                    int start, int end) throws SystemException {
1297                    return findByG_A(groupId, articleId, start, end, null);
1298            }
1299    
1300            /**
1301             * Finds an ordered range of all the journal content searchs where groupId = &#63; and articleId = &#63;.
1302             *
1303             * <p>
1304             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1305             * </p>
1306             *
1307             * @param groupId the group id to search with
1308             * @param articleId the article id to search with
1309             * @param start the lower bound of the range of journal content searchs to return
1310             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
1311             * @param orderByComparator the comparator to order the results by
1312             * @return the ordered range of matching journal content searchs
1313             * @throws SystemException if a system exception occurred
1314             */
1315            public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1316                    int start, int end, OrderByComparator orderByComparator)
1317                    throws SystemException {
1318                    Object[] finderArgs = new Object[] {
1319                                    groupId, articleId,
1320                                    
1321                                    String.valueOf(start), String.valueOf(end),
1322                                    String.valueOf(orderByComparator)
1323                            };
1324    
1325                    List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_A,
1326                                    finderArgs, this);
1327    
1328                    if (list == null) {
1329                            Session session = null;
1330    
1331                            try {
1332                                    session = openSession();
1333    
1334                                    StringBundler query = null;
1335    
1336                                    if (orderByComparator != null) {
1337                                            query = new StringBundler(4 +
1338                                                            (orderByComparator.getOrderByFields().length * 3));
1339                                    }
1340                                    else {
1341                                            query = new StringBundler(3);
1342                                    }
1343    
1344                                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1345    
1346                                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1347    
1348                                    if (articleId == null) {
1349                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1350                                    }
1351                                    else {
1352                                            if (articleId.equals(StringPool.BLANK)) {
1353                                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1354                                            }
1355                                            else {
1356                                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1357                                            }
1358                                    }
1359    
1360                                    if (orderByComparator != null) {
1361                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1362                                                    orderByComparator);
1363                                    }
1364    
1365                                    String sql = query.toString();
1366    
1367                                    Query q = session.createQuery(sql);
1368    
1369                                    QueryPos qPos = QueryPos.getInstance(q);
1370    
1371                                    qPos.add(groupId);
1372    
1373                                    if (articleId != null) {
1374                                            qPos.add(articleId);
1375                                    }
1376    
1377                                    list = (List<JournalContentSearch>)QueryUtil.list(q,
1378                                                    getDialect(), start, end);
1379                            }
1380                            catch (Exception e) {
1381                                    throw processException(e);
1382                            }
1383                            finally {
1384                                    if (list == null) {
1385                                            list = new ArrayList<JournalContentSearch>();
1386                                    }
1387    
1388                                    cacheResult(list);
1389    
1390                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_A, finderArgs,
1391                                            list);
1392    
1393                                    closeSession(session);
1394                            }
1395                    }
1396    
1397                    return list;
1398            }
1399    
1400            /**
1401             * Finds the first journal content search in the ordered set where groupId = &#63; and articleId = &#63;.
1402             *
1403             * <p>
1404             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1405             * </p>
1406             *
1407             * @param groupId the group id to search with
1408             * @param articleId the article id to search with
1409             * @param orderByComparator the comparator to order the set by
1410             * @return the first matching journal content search
1411             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
1412             * @throws SystemException if a system exception occurred
1413             */
1414            public JournalContentSearch findByG_A_First(long groupId, String articleId,
1415                    OrderByComparator orderByComparator)
1416                    throws NoSuchContentSearchException, SystemException {
1417                    List<JournalContentSearch> list = findByG_A(groupId, articleId, 0, 1,
1418                                    orderByComparator);
1419    
1420                    if (list.isEmpty()) {
1421                            StringBundler msg = new StringBundler(6);
1422    
1423                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1424    
1425                            msg.append("groupId=");
1426                            msg.append(groupId);
1427    
1428                            msg.append(", articleId=");
1429                            msg.append(articleId);
1430    
1431                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1432    
1433                            throw new NoSuchContentSearchException(msg.toString());
1434                    }
1435                    else {
1436                            return list.get(0);
1437                    }
1438            }
1439    
1440            /**
1441             * Finds the last journal content search in the ordered set where groupId = &#63; and articleId = &#63;.
1442             *
1443             * <p>
1444             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1445             * </p>
1446             *
1447             * @param groupId the group id to search with
1448             * @param articleId the article id to search with
1449             * @param orderByComparator the comparator to order the set by
1450             * @return the last matching journal content search
1451             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
1452             * @throws SystemException if a system exception occurred
1453             */
1454            public JournalContentSearch findByG_A_Last(long groupId, String articleId,
1455                    OrderByComparator orderByComparator)
1456                    throws NoSuchContentSearchException, SystemException {
1457                    int count = countByG_A(groupId, articleId);
1458    
1459                    List<JournalContentSearch> list = findByG_A(groupId, articleId,
1460                                    count - 1, count, orderByComparator);
1461    
1462                    if (list.isEmpty()) {
1463                            StringBundler msg = new StringBundler(6);
1464    
1465                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1466    
1467                            msg.append("groupId=");
1468                            msg.append(groupId);
1469    
1470                            msg.append(", articleId=");
1471                            msg.append(articleId);
1472    
1473                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1474    
1475                            throw new NoSuchContentSearchException(msg.toString());
1476                    }
1477                    else {
1478                            return list.get(0);
1479                    }
1480            }
1481    
1482            /**
1483             * Finds the journal content searchs before and after the current journal content search in the ordered set where groupId = &#63; and articleId = &#63;.
1484             *
1485             * <p>
1486             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1487             * </p>
1488             *
1489             * @param contentSearchId the primary key of the current journal content search
1490             * @param groupId the group id to search with
1491             * @param articleId the article id to search with
1492             * @param orderByComparator the comparator to order the set by
1493             * @return the previous, current, and next journal content search
1494             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a journal content search with the primary key could not be found
1495             * @throws SystemException if a system exception occurred
1496             */
1497            public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
1498                    long groupId, String articleId, OrderByComparator orderByComparator)
1499                    throws NoSuchContentSearchException, SystemException {
1500                    JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1501    
1502                    Session session = null;
1503    
1504                    try {
1505                            session = openSession();
1506    
1507                            JournalContentSearch[] array = new JournalContentSearchImpl[3];
1508    
1509                            array[0] = getByG_A_PrevAndNext(session, journalContentSearch,
1510                                            groupId, articleId, orderByComparator, true);
1511    
1512                            array[1] = journalContentSearch;
1513    
1514                            array[2] = getByG_A_PrevAndNext(session, journalContentSearch,
1515                                            groupId, articleId, orderByComparator, false);
1516    
1517                            return array;
1518                    }
1519                    catch (Exception e) {
1520                            throw processException(e);
1521                    }
1522                    finally {
1523                            closeSession(session);
1524                    }
1525            }
1526    
1527            protected JournalContentSearch getByG_A_PrevAndNext(Session session,
1528                    JournalContentSearch journalContentSearch, long groupId,
1529                    String articleId, OrderByComparator orderByComparator, boolean previous) {
1530                    StringBundler query = null;
1531    
1532                    if (orderByComparator != null) {
1533                            query = new StringBundler(6 +
1534                                            (orderByComparator.getOrderByFields().length * 6));
1535                    }
1536                    else {
1537                            query = new StringBundler(3);
1538                    }
1539    
1540                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1541    
1542                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1543    
1544                    if (articleId == null) {
1545                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1546                    }
1547                    else {
1548                            if (articleId.equals(StringPool.BLANK)) {
1549                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1550                            }
1551                            else {
1552                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1553                            }
1554                    }
1555    
1556                    if (orderByComparator != null) {
1557                            String[] orderByFields = orderByComparator.getOrderByFields();
1558    
1559                            if (orderByFields.length > 0) {
1560                                    query.append(WHERE_AND);
1561                            }
1562    
1563                            for (int i = 0; i < orderByFields.length; i++) {
1564                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1565                                    query.append(orderByFields[i]);
1566    
1567                                    if ((i + 1) < orderByFields.length) {
1568                                            if (orderByComparator.isAscending() ^ previous) {
1569                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1570                                            }
1571                                            else {
1572                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1573                                            }
1574                                    }
1575                                    else {
1576                                            if (orderByComparator.isAscending() ^ previous) {
1577                                                    query.append(WHERE_GREATER_THAN);
1578                                            }
1579                                            else {
1580                                                    query.append(WHERE_LESSER_THAN);
1581                                            }
1582                                    }
1583                            }
1584    
1585                            query.append(ORDER_BY_CLAUSE);
1586    
1587                            for (int i = 0; i < orderByFields.length; i++) {
1588                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1589                                    query.append(orderByFields[i]);
1590    
1591                                    if ((i + 1) < orderByFields.length) {
1592                                            if (orderByComparator.isAscending() ^ previous) {
1593                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1594                                            }
1595                                            else {
1596                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1597                                            }
1598                                    }
1599                                    else {
1600                                            if (orderByComparator.isAscending() ^ previous) {
1601                                                    query.append(ORDER_BY_ASC);
1602                                            }
1603                                            else {
1604                                                    query.append(ORDER_BY_DESC);
1605                                            }
1606                                    }
1607                            }
1608                    }
1609    
1610                    String sql = query.toString();
1611    
1612                    Query q = session.createQuery(sql);
1613    
1614                    q.setFirstResult(0);
1615                    q.setMaxResults(2);
1616    
1617                    QueryPos qPos = QueryPos.getInstance(q);
1618    
1619                    qPos.add(groupId);
1620    
1621                    if (articleId != null) {
1622                            qPos.add(articleId);
1623                    }
1624    
1625                    if (orderByComparator != null) {
1626                            Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
1627    
1628                            for (Object value : values) {
1629                                    qPos.add(value);
1630                            }
1631                    }
1632    
1633                    List<JournalContentSearch> list = q.list();
1634    
1635                    if (list.size() == 2) {
1636                            return list.get(1);
1637                    }
1638                    else {
1639                            return null;
1640                    }
1641            }
1642    
1643            /**
1644             * Finds all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63;.
1645             *
1646             * @param groupId the group id to search with
1647             * @param privateLayout the private layout to search with
1648             * @param layoutId the layout id to search with
1649             * @return the matching journal content searchs
1650             * @throws SystemException if a system exception occurred
1651             */
1652            public List<JournalContentSearch> findByG_P_L(long groupId,
1653                    boolean privateLayout, long layoutId) throws SystemException {
1654                    return findByG_P_L(groupId, privateLayout, layoutId, QueryUtil.ALL_POS,
1655                            QueryUtil.ALL_POS, null);
1656            }
1657    
1658            /**
1659             * Finds a range of all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63;.
1660             *
1661             * <p>
1662             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1663             * </p>
1664             *
1665             * @param groupId the group id to search with
1666             * @param privateLayout the private layout to search with
1667             * @param layoutId the layout id to search with
1668             * @param start the lower bound of the range of journal content searchs to return
1669             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
1670             * @return the range of matching journal content searchs
1671             * @throws SystemException if a system exception occurred
1672             */
1673            public List<JournalContentSearch> findByG_P_L(long groupId,
1674                    boolean privateLayout, long layoutId, int start, int end)
1675                    throws SystemException {
1676                    return findByG_P_L(groupId, privateLayout, layoutId, start, end, null);
1677            }
1678    
1679            /**
1680             * Finds an ordered range of all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63;.
1681             *
1682             * <p>
1683             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1684             * </p>
1685             *
1686             * @param groupId the group id to search with
1687             * @param privateLayout the private layout to search with
1688             * @param layoutId the layout id to search with
1689             * @param start the lower bound of the range of journal content searchs to return
1690             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
1691             * @param orderByComparator the comparator to order the results by
1692             * @return the ordered range of matching journal content searchs
1693             * @throws SystemException if a system exception occurred
1694             */
1695            public List<JournalContentSearch> findByG_P_L(long groupId,
1696                    boolean privateLayout, long layoutId, int start, int end,
1697                    OrderByComparator orderByComparator) throws SystemException {
1698                    Object[] finderArgs = new Object[] {
1699                                    groupId, privateLayout, layoutId,
1700                                    
1701                                    String.valueOf(start), String.valueOf(end),
1702                                    String.valueOf(orderByComparator)
1703                            };
1704    
1705                    List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_L,
1706                                    finderArgs, this);
1707    
1708                    if (list == null) {
1709                            Session session = null;
1710    
1711                            try {
1712                                    session = openSession();
1713    
1714                                    StringBundler query = null;
1715    
1716                                    if (orderByComparator != null) {
1717                                            query = new StringBundler(5 +
1718                                                            (orderByComparator.getOrderByFields().length * 3));
1719                                    }
1720                                    else {
1721                                            query = new StringBundler(4);
1722                                    }
1723    
1724                                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1725    
1726                                    query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1727    
1728                                    query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1729    
1730                                    query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1731    
1732                                    if (orderByComparator != null) {
1733                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1734                                                    orderByComparator);
1735                                    }
1736    
1737                                    String sql = query.toString();
1738    
1739                                    Query q = session.createQuery(sql);
1740    
1741                                    QueryPos qPos = QueryPos.getInstance(q);
1742    
1743                                    qPos.add(groupId);
1744    
1745                                    qPos.add(privateLayout);
1746    
1747                                    qPos.add(layoutId);
1748    
1749                                    list = (List<JournalContentSearch>)QueryUtil.list(q,
1750                                                    getDialect(), start, end);
1751                            }
1752                            catch (Exception e) {
1753                                    throw processException(e);
1754                            }
1755                            finally {
1756                                    if (list == null) {
1757                                            list = new ArrayList<JournalContentSearch>();
1758                                    }
1759    
1760                                    cacheResult(list);
1761    
1762                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_L,
1763                                            finderArgs, list);
1764    
1765                                    closeSession(session);
1766                            }
1767                    }
1768    
1769                    return list;
1770            }
1771    
1772            /**
1773             * Finds the first journal content search in the ordered set where groupId = &#63; and privateLayout = &#63; and layoutId = &#63;.
1774             *
1775             * <p>
1776             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1777             * </p>
1778             *
1779             * @param groupId the group id to search with
1780             * @param privateLayout the private layout to search with
1781             * @param layoutId the layout id to search with
1782             * @param orderByComparator the comparator to order the set by
1783             * @return the first matching journal content search
1784             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
1785             * @throws SystemException if a system exception occurred
1786             */
1787            public JournalContentSearch findByG_P_L_First(long groupId,
1788                    boolean privateLayout, long layoutId,
1789                    OrderByComparator orderByComparator)
1790                    throws NoSuchContentSearchException, SystemException {
1791                    List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
1792                                    layoutId, 0, 1, orderByComparator);
1793    
1794                    if (list.isEmpty()) {
1795                            StringBundler msg = new StringBundler(8);
1796    
1797                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1798    
1799                            msg.append("groupId=");
1800                            msg.append(groupId);
1801    
1802                            msg.append(", privateLayout=");
1803                            msg.append(privateLayout);
1804    
1805                            msg.append(", layoutId=");
1806                            msg.append(layoutId);
1807    
1808                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1809    
1810                            throw new NoSuchContentSearchException(msg.toString());
1811                    }
1812                    else {
1813                            return list.get(0);
1814                    }
1815            }
1816    
1817            /**
1818             * Finds the last journal content search in the ordered set where groupId = &#63; and privateLayout = &#63; and layoutId = &#63;.
1819             *
1820             * <p>
1821             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1822             * </p>
1823             *
1824             * @param groupId the group id to search with
1825             * @param privateLayout the private layout to search with
1826             * @param layoutId the layout id to search with
1827             * @param orderByComparator the comparator to order the set by
1828             * @return the last matching journal content search
1829             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
1830             * @throws SystemException if a system exception occurred
1831             */
1832            public JournalContentSearch findByG_P_L_Last(long groupId,
1833                    boolean privateLayout, long layoutId,
1834                    OrderByComparator orderByComparator)
1835                    throws NoSuchContentSearchException, SystemException {
1836                    int count = countByG_P_L(groupId, privateLayout, layoutId);
1837    
1838                    List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
1839                                    layoutId, count - 1, count, orderByComparator);
1840    
1841                    if (list.isEmpty()) {
1842                            StringBundler msg = new StringBundler(8);
1843    
1844                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1845    
1846                            msg.append("groupId=");
1847                            msg.append(groupId);
1848    
1849                            msg.append(", privateLayout=");
1850                            msg.append(privateLayout);
1851    
1852                            msg.append(", layoutId=");
1853                            msg.append(layoutId);
1854    
1855                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1856    
1857                            throw new NoSuchContentSearchException(msg.toString());
1858                    }
1859                    else {
1860                            return list.get(0);
1861                    }
1862            }
1863    
1864            /**
1865             * Finds the journal content searchs before and after the current journal content search in the ordered set where groupId = &#63; and privateLayout = &#63; and layoutId = &#63;.
1866             *
1867             * <p>
1868             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1869             * </p>
1870             *
1871             * @param contentSearchId the primary key of the current journal content search
1872             * @param groupId the group id to search with
1873             * @param privateLayout the private layout to search with
1874             * @param layoutId the layout id to search with
1875             * @param orderByComparator the comparator to order the set by
1876             * @return the previous, current, and next journal content search
1877             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a journal content search with the primary key could not be found
1878             * @throws SystemException if a system exception occurred
1879             */
1880            public JournalContentSearch[] findByG_P_L_PrevAndNext(
1881                    long contentSearchId, long groupId, boolean privateLayout,
1882                    long layoutId, OrderByComparator orderByComparator)
1883                    throws NoSuchContentSearchException, SystemException {
1884                    JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1885    
1886                    Session session = null;
1887    
1888                    try {
1889                            session = openSession();
1890    
1891                            JournalContentSearch[] array = new JournalContentSearchImpl[3];
1892    
1893                            array[0] = getByG_P_L_PrevAndNext(session, journalContentSearch,
1894                                            groupId, privateLayout, layoutId, orderByComparator, true);
1895    
1896                            array[1] = journalContentSearch;
1897    
1898                            array[2] = getByG_P_L_PrevAndNext(session, journalContentSearch,
1899                                            groupId, privateLayout, layoutId, orderByComparator, false);
1900    
1901                            return array;
1902                    }
1903                    catch (Exception e) {
1904                            throw processException(e);
1905                    }
1906                    finally {
1907                            closeSession(session);
1908                    }
1909            }
1910    
1911            protected JournalContentSearch getByG_P_L_PrevAndNext(Session session,
1912                    JournalContentSearch journalContentSearch, long groupId,
1913                    boolean privateLayout, long layoutId,
1914                    OrderByComparator orderByComparator, boolean previous) {
1915                    StringBundler query = null;
1916    
1917                    if (orderByComparator != null) {
1918                            query = new StringBundler(6 +
1919                                            (orderByComparator.getOrderByFields().length * 6));
1920                    }
1921                    else {
1922                            query = new StringBundler(3);
1923                    }
1924    
1925                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1926    
1927                    query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1928    
1929                    query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1930    
1931                    query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1932    
1933                    if (orderByComparator != null) {
1934                            String[] orderByFields = orderByComparator.getOrderByFields();
1935    
1936                            if (orderByFields.length > 0) {
1937                                    query.append(WHERE_AND);
1938                            }
1939    
1940                            for (int i = 0; i < orderByFields.length; i++) {
1941                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1942                                    query.append(orderByFields[i]);
1943    
1944                                    if ((i + 1) < orderByFields.length) {
1945                                            if (orderByComparator.isAscending() ^ previous) {
1946                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1947                                            }
1948                                            else {
1949                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1950                                            }
1951                                    }
1952                                    else {
1953                                            if (orderByComparator.isAscending() ^ previous) {
1954                                                    query.append(WHERE_GREATER_THAN);
1955                                            }
1956                                            else {
1957                                                    query.append(WHERE_LESSER_THAN);
1958                                            }
1959                                    }
1960                            }
1961    
1962                            query.append(ORDER_BY_CLAUSE);
1963    
1964                            for (int i = 0; i < orderByFields.length; i++) {
1965                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1966                                    query.append(orderByFields[i]);
1967    
1968                                    if ((i + 1) < orderByFields.length) {
1969                                            if (orderByComparator.isAscending() ^ previous) {
1970                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1971                                            }
1972                                            else {
1973                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1974                                            }
1975                                    }
1976                                    else {
1977                                            if (orderByComparator.isAscending() ^ previous) {
1978                                                    query.append(ORDER_BY_ASC);
1979                                            }
1980                                            else {
1981                                                    query.append(ORDER_BY_DESC);
1982                                            }
1983                                    }
1984                            }
1985                    }
1986    
1987                    String sql = query.toString();
1988    
1989                    Query q = session.createQuery(sql);
1990    
1991                    q.setFirstResult(0);
1992                    q.setMaxResults(2);
1993    
1994                    QueryPos qPos = QueryPos.getInstance(q);
1995    
1996                    qPos.add(groupId);
1997    
1998                    qPos.add(privateLayout);
1999    
2000                    qPos.add(layoutId);
2001    
2002                    if (orderByComparator != null) {
2003                            Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
2004    
2005                            for (Object value : values) {
2006                                    qPos.add(value);
2007                            }
2008                    }
2009    
2010                    List<JournalContentSearch> list = q.list();
2011    
2012                    if (list.size() == 2) {
2013                            return list.get(1);
2014                    }
2015                    else {
2016                            return null;
2017                    }
2018            }
2019    
2020            /**
2021             * Finds all the journal content searchs where groupId = &#63; and privateLayout = &#63; and articleId = &#63;.
2022             *
2023             * @param groupId the group id to search with
2024             * @param privateLayout the private layout to search with
2025             * @param articleId the article id to search with
2026             * @return the matching journal content searchs
2027             * @throws SystemException if a system exception occurred
2028             */
2029            public List<JournalContentSearch> findByG_P_A(long groupId,
2030                    boolean privateLayout, String articleId) throws SystemException {
2031                    return findByG_P_A(groupId, privateLayout, articleId,
2032                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2033            }
2034    
2035            /**
2036             * Finds a range of all the journal content searchs where groupId = &#63; and privateLayout = &#63; and articleId = &#63;.
2037             *
2038             * <p>
2039             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2040             * </p>
2041             *
2042             * @param groupId the group id to search with
2043             * @param privateLayout the private layout to search with
2044             * @param articleId the article id to search with
2045             * @param start the lower bound of the range of journal content searchs to return
2046             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
2047             * @return the range of matching journal content searchs
2048             * @throws SystemException if a system exception occurred
2049             */
2050            public List<JournalContentSearch> findByG_P_A(long groupId,
2051                    boolean privateLayout, String articleId, int start, int end)
2052                    throws SystemException {
2053                    return findByG_P_A(groupId, privateLayout, articleId, start, end, null);
2054            }
2055    
2056            /**
2057             * Finds an ordered range of all the journal content searchs where groupId = &#63; and privateLayout = &#63; and articleId = &#63;.
2058             *
2059             * <p>
2060             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2061             * </p>
2062             *
2063             * @param groupId the group id to search with
2064             * @param privateLayout the private layout to search with
2065             * @param articleId the article id to search with
2066             * @param start the lower bound of the range of journal content searchs to return
2067             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
2068             * @param orderByComparator the comparator to order the results by
2069             * @return the ordered range of matching journal content searchs
2070             * @throws SystemException if a system exception occurred
2071             */
2072            public List<JournalContentSearch> findByG_P_A(long groupId,
2073                    boolean privateLayout, String articleId, int start, int end,
2074                    OrderByComparator orderByComparator) throws SystemException {
2075                    Object[] finderArgs = new Object[] {
2076                                    groupId, privateLayout, articleId,
2077                                    
2078                                    String.valueOf(start), String.valueOf(end),
2079                                    String.valueOf(orderByComparator)
2080                            };
2081    
2082                    List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_A,
2083                                    finderArgs, this);
2084    
2085                    if (list == null) {
2086                            Session session = null;
2087    
2088                            try {
2089                                    session = openSession();
2090    
2091                                    StringBundler query = null;
2092    
2093                                    if (orderByComparator != null) {
2094                                            query = new StringBundler(5 +
2095                                                            (orderByComparator.getOrderByFields().length * 3));
2096                                    }
2097                                    else {
2098                                            query = new StringBundler(4);
2099                                    }
2100    
2101                                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2102    
2103                                    query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2104    
2105                                    query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2106    
2107                                    if (articleId == null) {
2108                                            query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2109                                    }
2110                                    else {
2111                                            if (articleId.equals(StringPool.BLANK)) {
2112                                                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2113                                            }
2114                                            else {
2115                                                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2116                                            }
2117                                    }
2118    
2119                                    if (orderByComparator != null) {
2120                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2121                                                    orderByComparator);
2122                                    }
2123    
2124                                    String sql = query.toString();
2125    
2126                                    Query q = session.createQuery(sql);
2127    
2128                                    QueryPos qPos = QueryPos.getInstance(q);
2129    
2130                                    qPos.add(groupId);
2131    
2132                                    qPos.add(privateLayout);
2133    
2134                                    if (articleId != null) {
2135                                            qPos.add(articleId);
2136                                    }
2137    
2138                                    list = (List<JournalContentSearch>)QueryUtil.list(q,
2139                                                    getDialect(), start, end);
2140                            }
2141                            catch (Exception e) {
2142                                    throw processException(e);
2143                            }
2144                            finally {
2145                                    if (list == null) {
2146                                            list = new ArrayList<JournalContentSearch>();
2147                                    }
2148    
2149                                    cacheResult(list);
2150    
2151                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_A,
2152                                            finderArgs, list);
2153    
2154                                    closeSession(session);
2155                            }
2156                    }
2157    
2158                    return list;
2159            }
2160    
2161            /**
2162             * Finds the first journal content search in the ordered set where groupId = &#63; and privateLayout = &#63; and articleId = &#63;.
2163             *
2164             * <p>
2165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2166             * </p>
2167             *
2168             * @param groupId the group id to search with
2169             * @param privateLayout the private layout to search with
2170             * @param articleId the article id to search with
2171             * @param orderByComparator the comparator to order the set by
2172             * @return the first matching journal content search
2173             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
2174             * @throws SystemException if a system exception occurred
2175             */
2176            public JournalContentSearch findByG_P_A_First(long groupId,
2177                    boolean privateLayout, String articleId,
2178                    OrderByComparator orderByComparator)
2179                    throws NoSuchContentSearchException, SystemException {
2180                    List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
2181                                    articleId, 0, 1, orderByComparator);
2182    
2183                    if (list.isEmpty()) {
2184                            StringBundler msg = new StringBundler(8);
2185    
2186                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2187    
2188                            msg.append("groupId=");
2189                            msg.append(groupId);
2190    
2191                            msg.append(", privateLayout=");
2192                            msg.append(privateLayout);
2193    
2194                            msg.append(", articleId=");
2195                            msg.append(articleId);
2196    
2197                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2198    
2199                            throw new NoSuchContentSearchException(msg.toString());
2200                    }
2201                    else {
2202                            return list.get(0);
2203                    }
2204            }
2205    
2206            /**
2207             * Finds the last journal content search in the ordered set where groupId = &#63; and privateLayout = &#63; and articleId = &#63;.
2208             *
2209             * <p>
2210             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2211             * </p>
2212             *
2213             * @param groupId the group id to search with
2214             * @param privateLayout the private layout to search with
2215             * @param articleId the article id to search with
2216             * @param orderByComparator the comparator to order the set by
2217             * @return the last matching journal content search
2218             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
2219             * @throws SystemException if a system exception occurred
2220             */
2221            public JournalContentSearch findByG_P_A_Last(long groupId,
2222                    boolean privateLayout, String articleId,
2223                    OrderByComparator orderByComparator)
2224                    throws NoSuchContentSearchException, SystemException {
2225                    int count = countByG_P_A(groupId, privateLayout, articleId);
2226    
2227                    List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
2228                                    articleId, count - 1, count, orderByComparator);
2229    
2230                    if (list.isEmpty()) {
2231                            StringBundler msg = new StringBundler(8);
2232    
2233                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2234    
2235                            msg.append("groupId=");
2236                            msg.append(groupId);
2237    
2238                            msg.append(", privateLayout=");
2239                            msg.append(privateLayout);
2240    
2241                            msg.append(", articleId=");
2242                            msg.append(articleId);
2243    
2244                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2245    
2246                            throw new NoSuchContentSearchException(msg.toString());
2247                    }
2248                    else {
2249                            return list.get(0);
2250                    }
2251            }
2252    
2253            /**
2254             * Finds the journal content searchs before and after the current journal content search in the ordered set where groupId = &#63; and privateLayout = &#63; and articleId = &#63;.
2255             *
2256             * <p>
2257             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2258             * </p>
2259             *
2260             * @param contentSearchId the primary key of the current journal content search
2261             * @param groupId the group id to search with
2262             * @param privateLayout the private layout to search with
2263             * @param articleId the article id to search with
2264             * @param orderByComparator the comparator to order the set by
2265             * @return the previous, current, and next journal content search
2266             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a journal content search with the primary key could not be found
2267             * @throws SystemException if a system exception occurred
2268             */
2269            public JournalContentSearch[] findByG_P_A_PrevAndNext(
2270                    long contentSearchId, long groupId, boolean privateLayout,
2271                    String articleId, OrderByComparator orderByComparator)
2272                    throws NoSuchContentSearchException, SystemException {
2273                    JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2274    
2275                    Session session = null;
2276    
2277                    try {
2278                            session = openSession();
2279    
2280                            JournalContentSearch[] array = new JournalContentSearchImpl[3];
2281    
2282                            array[0] = getByG_P_A_PrevAndNext(session, journalContentSearch,
2283                                            groupId, privateLayout, articleId, orderByComparator, true);
2284    
2285                            array[1] = journalContentSearch;
2286    
2287                            array[2] = getByG_P_A_PrevAndNext(session, journalContentSearch,
2288                                            groupId, privateLayout, articleId, orderByComparator, false);
2289    
2290                            return array;
2291                    }
2292                    catch (Exception e) {
2293                            throw processException(e);
2294                    }
2295                    finally {
2296                            closeSession(session);
2297                    }
2298            }
2299    
2300            protected JournalContentSearch getByG_P_A_PrevAndNext(Session session,
2301                    JournalContentSearch journalContentSearch, long groupId,
2302                    boolean privateLayout, String articleId,
2303                    OrderByComparator orderByComparator, boolean previous) {
2304                    StringBundler query = null;
2305    
2306                    if (orderByComparator != null) {
2307                            query = new StringBundler(6 +
2308                                            (orderByComparator.getOrderByFields().length * 6));
2309                    }
2310                    else {
2311                            query = new StringBundler(3);
2312                    }
2313    
2314                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2315    
2316                    query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2317    
2318                    query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2319    
2320                    if (articleId == null) {
2321                            query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2322                    }
2323                    else {
2324                            if (articleId.equals(StringPool.BLANK)) {
2325                                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2326                            }
2327                            else {
2328                                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2329                            }
2330                    }
2331    
2332                    if (orderByComparator != null) {
2333                            String[] orderByFields = orderByComparator.getOrderByFields();
2334    
2335                            if (orderByFields.length > 0) {
2336                                    query.append(WHERE_AND);
2337                            }
2338    
2339                            for (int i = 0; i < orderByFields.length; i++) {
2340                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2341                                    query.append(orderByFields[i]);
2342    
2343                                    if ((i + 1) < orderByFields.length) {
2344                                            if (orderByComparator.isAscending() ^ previous) {
2345                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2346                                            }
2347                                            else {
2348                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2349                                            }
2350                                    }
2351                                    else {
2352                                            if (orderByComparator.isAscending() ^ previous) {
2353                                                    query.append(WHERE_GREATER_THAN);
2354                                            }
2355                                            else {
2356                                                    query.append(WHERE_LESSER_THAN);
2357                                            }
2358                                    }
2359                            }
2360    
2361                            query.append(ORDER_BY_CLAUSE);
2362    
2363                            for (int i = 0; i < orderByFields.length; i++) {
2364                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2365                                    query.append(orderByFields[i]);
2366    
2367                                    if ((i + 1) < orderByFields.length) {
2368                                            if (orderByComparator.isAscending() ^ previous) {
2369                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2370                                            }
2371                                            else {
2372                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2373                                            }
2374                                    }
2375                                    else {
2376                                            if (orderByComparator.isAscending() ^ previous) {
2377                                                    query.append(ORDER_BY_ASC);
2378                                            }
2379                                            else {
2380                                                    query.append(ORDER_BY_DESC);
2381                                            }
2382                                    }
2383                            }
2384                    }
2385    
2386                    String sql = query.toString();
2387    
2388                    Query q = session.createQuery(sql);
2389    
2390                    q.setFirstResult(0);
2391                    q.setMaxResults(2);
2392    
2393                    QueryPos qPos = QueryPos.getInstance(q);
2394    
2395                    qPos.add(groupId);
2396    
2397                    qPos.add(privateLayout);
2398    
2399                    if (articleId != null) {
2400                            qPos.add(articleId);
2401                    }
2402    
2403                    if (orderByComparator != null) {
2404                            Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
2405    
2406                            for (Object value : values) {
2407                                    qPos.add(value);
2408                            }
2409                    }
2410    
2411                    List<JournalContentSearch> list = q.list();
2412    
2413                    if (list.size() == 2) {
2414                            return list.get(1);
2415                    }
2416                    else {
2417                            return null;
2418                    }
2419            }
2420    
2421            /**
2422             * Finds all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63;.
2423             *
2424             * @param groupId the group id to search with
2425             * @param privateLayout the private layout to search with
2426             * @param layoutId the layout id to search with
2427             * @param portletId the portlet id to search with
2428             * @return the matching journal content searchs
2429             * @throws SystemException if a system exception occurred
2430             */
2431            public List<JournalContentSearch> findByG_P_L_P(long groupId,
2432                    boolean privateLayout, long layoutId, String portletId)
2433                    throws SystemException {
2434                    return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
2435                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2436            }
2437    
2438            /**
2439             * Finds a range of all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63;.
2440             *
2441             * <p>
2442             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2443             * </p>
2444             *
2445             * @param groupId the group id to search with
2446             * @param privateLayout the private layout to search with
2447             * @param layoutId the layout id to search with
2448             * @param portletId the portlet id to search with
2449             * @param start the lower bound of the range of journal content searchs to return
2450             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
2451             * @return the range of matching journal content searchs
2452             * @throws SystemException if a system exception occurred
2453             */
2454            public List<JournalContentSearch> findByG_P_L_P(long groupId,
2455                    boolean privateLayout, long layoutId, String portletId, int start,
2456                    int end) throws SystemException {
2457                    return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
2458                            start, end, null);
2459            }
2460    
2461            /**
2462             * Finds an ordered range of all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63;.
2463             *
2464             * <p>
2465             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2466             * </p>
2467             *
2468             * @param groupId the group id to search with
2469             * @param privateLayout the private layout to search with
2470             * @param layoutId the layout id to search with
2471             * @param portletId the portlet id to search with
2472             * @param start the lower bound of the range of journal content searchs to return
2473             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
2474             * @param orderByComparator the comparator to order the results by
2475             * @return the ordered range of matching journal content searchs
2476             * @throws SystemException if a system exception occurred
2477             */
2478            public List<JournalContentSearch> findByG_P_L_P(long groupId,
2479                    boolean privateLayout, long layoutId, String portletId, int start,
2480                    int end, OrderByComparator orderByComparator) throws SystemException {
2481                    Object[] finderArgs = new Object[] {
2482                                    groupId, privateLayout, layoutId, portletId,
2483                                    
2484                                    String.valueOf(start), String.valueOf(end),
2485                                    String.valueOf(orderByComparator)
2486                            };
2487    
2488                    List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_L_P,
2489                                    finderArgs, this);
2490    
2491                    if (list == null) {
2492                            Session session = null;
2493    
2494                            try {
2495                                    session = openSession();
2496    
2497                                    StringBundler query = null;
2498    
2499                                    if (orderByComparator != null) {
2500                                            query = new StringBundler(6 +
2501                                                            (orderByComparator.getOrderByFields().length * 3));
2502                                    }
2503                                    else {
2504                                            query = new StringBundler(5);
2505                                    }
2506    
2507                                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2508    
2509                                    query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2510    
2511                                    query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2512    
2513                                    query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2514    
2515                                    if (portletId == null) {
2516                                            query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2517                                    }
2518                                    else {
2519                                            if (portletId.equals(StringPool.BLANK)) {
2520                                                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2521                                            }
2522                                            else {
2523                                                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2524                                            }
2525                                    }
2526    
2527                                    if (orderByComparator != null) {
2528                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2529                                                    orderByComparator);
2530                                    }
2531    
2532                                    String sql = query.toString();
2533    
2534                                    Query q = session.createQuery(sql);
2535    
2536                                    QueryPos qPos = QueryPos.getInstance(q);
2537    
2538                                    qPos.add(groupId);
2539    
2540                                    qPos.add(privateLayout);
2541    
2542                                    qPos.add(layoutId);
2543    
2544                                    if (portletId != null) {
2545                                            qPos.add(portletId);
2546                                    }
2547    
2548                                    list = (List<JournalContentSearch>)QueryUtil.list(q,
2549                                                    getDialect(), start, end);
2550                            }
2551                            catch (Exception e) {
2552                                    throw processException(e);
2553                            }
2554                            finally {
2555                                    if (list == null) {
2556                                            list = new ArrayList<JournalContentSearch>();
2557                                    }
2558    
2559                                    cacheResult(list);
2560    
2561                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_L_P,
2562                                            finderArgs, list);
2563    
2564                                    closeSession(session);
2565                            }
2566                    }
2567    
2568                    return list;
2569            }
2570    
2571            /**
2572             * Finds the first journal content search in the ordered set where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63;.
2573             *
2574             * <p>
2575             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2576             * </p>
2577             *
2578             * @param groupId the group id to search with
2579             * @param privateLayout the private layout to search with
2580             * @param layoutId the layout id to search with
2581             * @param portletId the portlet id to search with
2582             * @param orderByComparator the comparator to order the set by
2583             * @return the first matching journal content search
2584             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
2585             * @throws SystemException if a system exception occurred
2586             */
2587            public JournalContentSearch findByG_P_L_P_First(long groupId,
2588                    boolean privateLayout, long layoutId, String portletId,
2589                    OrderByComparator orderByComparator)
2590                    throws NoSuchContentSearchException, SystemException {
2591                    List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
2592                                    layoutId, portletId, 0, 1, orderByComparator);
2593    
2594                    if (list.isEmpty()) {
2595                            StringBundler msg = new StringBundler(10);
2596    
2597                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2598    
2599                            msg.append("groupId=");
2600                            msg.append(groupId);
2601    
2602                            msg.append(", privateLayout=");
2603                            msg.append(privateLayout);
2604    
2605                            msg.append(", layoutId=");
2606                            msg.append(layoutId);
2607    
2608                            msg.append(", portletId=");
2609                            msg.append(portletId);
2610    
2611                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2612    
2613                            throw new NoSuchContentSearchException(msg.toString());
2614                    }
2615                    else {
2616                            return list.get(0);
2617                    }
2618            }
2619    
2620            /**
2621             * Finds the last journal content search in the ordered set where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63;.
2622             *
2623             * <p>
2624             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2625             * </p>
2626             *
2627             * @param groupId the group id to search with
2628             * @param privateLayout the private layout to search with
2629             * @param layoutId the layout id to search with
2630             * @param portletId the portlet id to search with
2631             * @param orderByComparator the comparator to order the set by
2632             * @return the last matching journal content search
2633             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
2634             * @throws SystemException if a system exception occurred
2635             */
2636            public JournalContentSearch findByG_P_L_P_Last(long groupId,
2637                    boolean privateLayout, long layoutId, String portletId,
2638                    OrderByComparator orderByComparator)
2639                    throws NoSuchContentSearchException, SystemException {
2640                    int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
2641    
2642                    List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
2643                                    layoutId, portletId, count - 1, count, orderByComparator);
2644    
2645                    if (list.isEmpty()) {
2646                            StringBundler msg = new StringBundler(10);
2647    
2648                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2649    
2650                            msg.append("groupId=");
2651                            msg.append(groupId);
2652    
2653                            msg.append(", privateLayout=");
2654                            msg.append(privateLayout);
2655    
2656                            msg.append(", layoutId=");
2657                            msg.append(layoutId);
2658    
2659                            msg.append(", portletId=");
2660                            msg.append(portletId);
2661    
2662                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2663    
2664                            throw new NoSuchContentSearchException(msg.toString());
2665                    }
2666                    else {
2667                            return list.get(0);
2668                    }
2669            }
2670    
2671            /**
2672             * Finds the journal content searchs before and after the current journal content search in the ordered set where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63;.
2673             *
2674             * <p>
2675             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2676             * </p>
2677             *
2678             * @param contentSearchId the primary key of the current journal content search
2679             * @param groupId the group id to search with
2680             * @param privateLayout the private layout to search with
2681             * @param layoutId the layout id to search with
2682             * @param portletId the portlet id to search with
2683             * @param orderByComparator the comparator to order the set by
2684             * @return the previous, current, and next journal content search
2685             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a journal content search with the primary key could not be found
2686             * @throws SystemException if a system exception occurred
2687             */
2688            public JournalContentSearch[] findByG_P_L_P_PrevAndNext(
2689                    long contentSearchId, long groupId, boolean privateLayout,
2690                    long layoutId, String portletId, OrderByComparator orderByComparator)
2691                    throws NoSuchContentSearchException, SystemException {
2692                    JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2693    
2694                    Session session = null;
2695    
2696                    try {
2697                            session = openSession();
2698    
2699                            JournalContentSearch[] array = new JournalContentSearchImpl[3];
2700    
2701                            array[0] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
2702                                            groupId, privateLayout, layoutId, portletId,
2703                                            orderByComparator, true);
2704    
2705                            array[1] = journalContentSearch;
2706    
2707                            array[2] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
2708                                            groupId, privateLayout, layoutId, portletId,
2709                                            orderByComparator, false);
2710    
2711                            return array;
2712                    }
2713                    catch (Exception e) {
2714                            throw processException(e);
2715                    }
2716                    finally {
2717                            closeSession(session);
2718                    }
2719            }
2720    
2721            protected JournalContentSearch getByG_P_L_P_PrevAndNext(Session session,
2722                    JournalContentSearch journalContentSearch, long groupId,
2723                    boolean privateLayout, long layoutId, String portletId,
2724                    OrderByComparator orderByComparator, boolean previous) {
2725                    StringBundler query = null;
2726    
2727                    if (orderByComparator != null) {
2728                            query = new StringBundler(6 +
2729                                            (orderByComparator.getOrderByFields().length * 6));
2730                    }
2731                    else {
2732                            query = new StringBundler(3);
2733                    }
2734    
2735                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2736    
2737                    query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2738    
2739                    query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2740    
2741                    query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2742    
2743                    if (portletId == null) {
2744                            query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2745                    }
2746                    else {
2747                            if (portletId.equals(StringPool.BLANK)) {
2748                                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2749                            }
2750                            else {
2751                                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2752                            }
2753                    }
2754    
2755                    if (orderByComparator != null) {
2756                            String[] orderByFields = orderByComparator.getOrderByFields();
2757    
2758                            if (orderByFields.length > 0) {
2759                                    query.append(WHERE_AND);
2760                            }
2761    
2762                            for (int i = 0; i < orderByFields.length; i++) {
2763                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2764                                    query.append(orderByFields[i]);
2765    
2766                                    if ((i + 1) < orderByFields.length) {
2767                                            if (orderByComparator.isAscending() ^ previous) {
2768                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2769                                            }
2770                                            else {
2771                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2772                                            }
2773                                    }
2774                                    else {
2775                                            if (orderByComparator.isAscending() ^ previous) {
2776                                                    query.append(WHERE_GREATER_THAN);
2777                                            }
2778                                            else {
2779                                                    query.append(WHERE_LESSER_THAN);
2780                                            }
2781                                    }
2782                            }
2783    
2784                            query.append(ORDER_BY_CLAUSE);
2785    
2786                            for (int i = 0; i < orderByFields.length; i++) {
2787                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2788                                    query.append(orderByFields[i]);
2789    
2790                                    if ((i + 1) < orderByFields.length) {
2791                                            if (orderByComparator.isAscending() ^ previous) {
2792                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2793                                            }
2794                                            else {
2795                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2796                                            }
2797                                    }
2798                                    else {
2799                                            if (orderByComparator.isAscending() ^ previous) {
2800                                                    query.append(ORDER_BY_ASC);
2801                                            }
2802                                            else {
2803                                                    query.append(ORDER_BY_DESC);
2804                                            }
2805                                    }
2806                            }
2807                    }
2808    
2809                    String sql = query.toString();
2810    
2811                    Query q = session.createQuery(sql);
2812    
2813                    q.setFirstResult(0);
2814                    q.setMaxResults(2);
2815    
2816                    QueryPos qPos = QueryPos.getInstance(q);
2817    
2818                    qPos.add(groupId);
2819    
2820                    qPos.add(privateLayout);
2821    
2822                    qPos.add(layoutId);
2823    
2824                    if (portletId != null) {
2825                            qPos.add(portletId);
2826                    }
2827    
2828                    if (orderByComparator != null) {
2829                            Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
2830    
2831                            for (Object value : values) {
2832                                    qPos.add(value);
2833                            }
2834                    }
2835    
2836                    List<JournalContentSearch> list = q.list();
2837    
2838                    if (list.size() == 2) {
2839                            return list.get(1);
2840                    }
2841                    else {
2842                            return null;
2843                    }
2844            }
2845    
2846            /**
2847             * Finds the journal content search where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63; and articleId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchContentSearchException} if it could not be found.
2848             *
2849             * @param groupId the group id to search with
2850             * @param privateLayout the private layout to search with
2851             * @param layoutId the layout id to search with
2852             * @param portletId the portlet id to search with
2853             * @param articleId the article id to search with
2854             * @return the matching journal content search
2855             * @throws com.liferay.portlet.journal.NoSuchContentSearchException if a matching journal content search could not be found
2856             * @throws SystemException if a system exception occurred
2857             */
2858            public JournalContentSearch findByG_P_L_P_A(long groupId,
2859                    boolean privateLayout, long layoutId, String portletId, String articleId)
2860                    throws NoSuchContentSearchException, SystemException {
2861                    JournalContentSearch journalContentSearch = fetchByG_P_L_P_A(groupId,
2862                                    privateLayout, layoutId, portletId, articleId);
2863    
2864                    if (journalContentSearch == null) {
2865                            StringBundler msg = new StringBundler(12);
2866    
2867                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2868    
2869                            msg.append("groupId=");
2870                            msg.append(groupId);
2871    
2872                            msg.append(", privateLayout=");
2873                            msg.append(privateLayout);
2874    
2875                            msg.append(", layoutId=");
2876                            msg.append(layoutId);
2877    
2878                            msg.append(", portletId=");
2879                            msg.append(portletId);
2880    
2881                            msg.append(", articleId=");
2882                            msg.append(articleId);
2883    
2884                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2885    
2886                            if (_log.isWarnEnabled()) {
2887                                    _log.warn(msg.toString());
2888                            }
2889    
2890                            throw new NoSuchContentSearchException(msg.toString());
2891                    }
2892    
2893                    return journalContentSearch;
2894            }
2895    
2896            /**
2897             * Finds the journal content search where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63; and articleId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2898             *
2899             * @param groupId the group id to search with
2900             * @param privateLayout the private layout to search with
2901             * @param layoutId the layout id to search with
2902             * @param portletId the portlet id to search with
2903             * @param articleId the article id to search with
2904             * @return the matching journal content search, or <code>null</code> if a matching journal content search could not be found
2905             * @throws SystemException if a system exception occurred
2906             */
2907            public JournalContentSearch fetchByG_P_L_P_A(long groupId,
2908                    boolean privateLayout, long layoutId, String portletId, String articleId)
2909                    throws SystemException {
2910                    return fetchByG_P_L_P_A(groupId, privateLayout, layoutId, portletId,
2911                            articleId, true);
2912            }
2913    
2914            /**
2915             * Finds the journal content search where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63; and articleId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2916             *
2917             * @param groupId the group id to search with
2918             * @param privateLayout the private layout to search with
2919             * @param layoutId the layout id to search with
2920             * @param portletId the portlet id to search with
2921             * @param articleId the article id to search with
2922             * @return the matching journal content search, or <code>null</code> if a matching journal content search could not be found
2923             * @throws SystemException if a system exception occurred
2924             */
2925            public JournalContentSearch fetchByG_P_L_P_A(long groupId,
2926                    boolean privateLayout, long layoutId, String portletId,
2927                    String articleId, boolean retrieveFromCache) throws SystemException {
2928                    Object[] finderArgs = new Object[] {
2929                                    groupId, privateLayout, layoutId, portletId, articleId
2930                            };
2931    
2932                    Object result = null;
2933    
2934                    if (retrieveFromCache) {
2935                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
2936                                            finderArgs, this);
2937                    }
2938    
2939                    if (result == null) {
2940                            Session session = null;
2941    
2942                            try {
2943                                    session = openSession();
2944    
2945                                    StringBundler query = new StringBundler(6);
2946    
2947                                    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2948    
2949                                    query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
2950    
2951                                    query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
2952    
2953                                    query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
2954    
2955                                    if (portletId == null) {
2956                                            query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
2957                                    }
2958                                    else {
2959                                            if (portletId.equals(StringPool.BLANK)) {
2960                                                    query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
2961                                            }
2962                                            else {
2963                                                    query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
2964                                            }
2965                                    }
2966    
2967                                    if (articleId == null) {
2968                                            query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
2969                                    }
2970                                    else {
2971                                            if (articleId.equals(StringPool.BLANK)) {
2972                                                    query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
2973                                            }
2974                                            else {
2975                                                    query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
2976                                            }
2977                                    }
2978    
2979                                    String sql = query.toString();
2980    
2981                                    Query q = session.createQuery(sql);
2982    
2983                                    QueryPos qPos = QueryPos.getInstance(q);
2984    
2985                                    qPos.add(groupId);
2986    
2987                                    qPos.add(privateLayout);
2988    
2989                                    qPos.add(layoutId);
2990    
2991                                    if (portletId != null) {
2992                                            qPos.add(portletId);
2993                                    }
2994    
2995                                    if (articleId != null) {
2996                                            qPos.add(articleId);
2997                                    }
2998    
2999                                    List<JournalContentSearch> list = q.list();
3000    
3001                                    result = list;
3002    
3003                                    JournalContentSearch journalContentSearch = null;
3004    
3005                                    if (list.isEmpty()) {
3006                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3007                                                    finderArgs, list);
3008                                    }
3009                                    else {
3010                                            journalContentSearch = list.get(0);
3011    
3012                                            cacheResult(journalContentSearch);
3013    
3014                                            if ((journalContentSearch.getGroupId() != groupId) ||
3015                                                            (journalContentSearch.getPrivateLayout() != privateLayout) ||
3016                                                            (journalContentSearch.getLayoutId() != layoutId) ||
3017                                                            (journalContentSearch.getPortletId() == null) ||
3018                                                            !journalContentSearch.getPortletId()
3019                                                                                                             .equals(portletId) ||
3020                                                            (journalContentSearch.getArticleId() == null) ||
3021                                                            !journalContentSearch.getArticleId()
3022                                                                                                             .equals(articleId)) {
3023                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3024                                                            finderArgs, journalContentSearch);
3025                                            }
3026                                    }
3027    
3028                                    return journalContentSearch;
3029                            }
3030                            catch (Exception e) {
3031                                    throw processException(e);
3032                            }
3033                            finally {
3034                                    if (result == null) {
3035                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3036                                                    finderArgs, new ArrayList<JournalContentSearch>());
3037                                    }
3038    
3039                                    closeSession(session);
3040                            }
3041                    }
3042                    else {
3043                            if (result instanceof List<?>) {
3044                                    return null;
3045                            }
3046                            else {
3047                                    return (JournalContentSearch)result;
3048                            }
3049                    }
3050            }
3051    
3052            /**
3053             * Finds all the journal content searchs.
3054             *
3055             * @return the journal content searchs
3056             * @throws SystemException if a system exception occurred
3057             */
3058            public List<JournalContentSearch> findAll() throws SystemException {
3059                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3060            }
3061    
3062            /**
3063             * Finds a range of all the journal content searchs.
3064             *
3065             * <p>
3066             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3067             * </p>
3068             *
3069             * @param start the lower bound of the range of journal content searchs to return
3070             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
3071             * @return the range of journal content searchs
3072             * @throws SystemException if a system exception occurred
3073             */
3074            public List<JournalContentSearch> findAll(int start, int end)
3075                    throws SystemException {
3076                    return findAll(start, end, null);
3077            }
3078    
3079            /**
3080             * Finds an ordered range of all the journal content searchs.
3081             *
3082             * <p>
3083             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3084             * </p>
3085             *
3086             * @param start the lower bound of the range of journal content searchs to return
3087             * @param end the upper bound of the range of journal content searchs to return (not inclusive)
3088             * @param orderByComparator the comparator to order the results by
3089             * @return the ordered range of journal content searchs
3090             * @throws SystemException if a system exception occurred
3091             */
3092            public List<JournalContentSearch> findAll(int start, int end,
3093                    OrderByComparator orderByComparator) throws SystemException {
3094                    Object[] finderArgs = new Object[] {
3095                                    String.valueOf(start), String.valueOf(end),
3096                                    String.valueOf(orderByComparator)
3097                            };
3098    
3099                    List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3100                                    finderArgs, this);
3101    
3102                    if (list == null) {
3103                            Session session = null;
3104    
3105                            try {
3106                                    session = openSession();
3107    
3108                                    StringBundler query = null;
3109                                    String sql = null;
3110    
3111                                    if (orderByComparator != null) {
3112                                            query = new StringBundler(2 +
3113                                                            (orderByComparator.getOrderByFields().length * 3));
3114    
3115                                            query.append(_SQL_SELECT_JOURNALCONTENTSEARCH);
3116    
3117                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3118                                                    orderByComparator);
3119    
3120                                            sql = query.toString();
3121                                    }
3122                                    else {
3123                                            sql = _SQL_SELECT_JOURNALCONTENTSEARCH;
3124                                    }
3125    
3126                                    Query q = session.createQuery(sql);
3127    
3128                                    if (orderByComparator == null) {
3129                                            list = (List<JournalContentSearch>)QueryUtil.list(q,
3130                                                            getDialect(), start, end, false);
3131    
3132                                            Collections.sort(list);
3133                                    }
3134                                    else {
3135                                            list = (List<JournalContentSearch>)QueryUtil.list(q,
3136                                                            getDialect(), start, end);
3137                                    }
3138                            }
3139                            catch (Exception e) {
3140                                    throw processException(e);
3141                            }
3142                            finally {
3143                                    if (list == null) {
3144                                            list = new ArrayList<JournalContentSearch>();
3145                                    }
3146    
3147                                    cacheResult(list);
3148    
3149                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
3150    
3151                                    closeSession(session);
3152                            }
3153                    }
3154    
3155                    return list;
3156            }
3157    
3158            /**
3159             * Removes all the journal content searchs where articleId = &#63; from the database.
3160             *
3161             * @param articleId the article id to search with
3162             * @throws SystemException if a system exception occurred
3163             */
3164            public void removeByArticleId(String articleId) throws SystemException {
3165                    for (JournalContentSearch journalContentSearch : findByArticleId(
3166                                    articleId)) {
3167                            remove(journalContentSearch);
3168                    }
3169            }
3170    
3171            /**
3172             * Removes all the journal content searchs where groupId = &#63; and privateLayout = &#63; from the database.
3173             *
3174             * @param groupId the group id to search with
3175             * @param privateLayout the private layout to search with
3176             * @throws SystemException if a system exception occurred
3177             */
3178            public void removeByG_P(long groupId, boolean privateLayout)
3179                    throws SystemException {
3180                    for (JournalContentSearch journalContentSearch : findByG_P(groupId,
3181                                    privateLayout)) {
3182                            remove(journalContentSearch);
3183                    }
3184            }
3185    
3186            /**
3187             * Removes all the journal content searchs where groupId = &#63; and articleId = &#63; from the database.
3188             *
3189             * @param groupId the group id to search with
3190             * @param articleId the article id to search with
3191             * @throws SystemException if a system exception occurred
3192             */
3193            public void removeByG_A(long groupId, String articleId)
3194                    throws SystemException {
3195                    for (JournalContentSearch journalContentSearch : findByG_A(groupId,
3196                                    articleId)) {
3197                            remove(journalContentSearch);
3198                    }
3199            }
3200    
3201            /**
3202             * Removes all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; from the database.
3203             *
3204             * @param groupId the group id to search with
3205             * @param privateLayout the private layout to search with
3206             * @param layoutId the layout id to search with
3207             * @throws SystemException if a system exception occurred
3208             */
3209            public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId)
3210                    throws SystemException {
3211                    for (JournalContentSearch journalContentSearch : findByG_P_L(groupId,
3212                                    privateLayout, layoutId)) {
3213                            remove(journalContentSearch);
3214                    }
3215            }
3216    
3217            /**
3218             * Removes all the journal content searchs where groupId = &#63; and privateLayout = &#63; and articleId = &#63; from the database.
3219             *
3220             * @param groupId the group id to search with
3221             * @param privateLayout the private layout to search with
3222             * @param articleId the article id to search with
3223             * @throws SystemException if a system exception occurred
3224             */
3225            public void removeByG_P_A(long groupId, boolean privateLayout,
3226                    String articleId) throws SystemException {
3227                    for (JournalContentSearch journalContentSearch : findByG_P_A(groupId,
3228                                    privateLayout, articleId)) {
3229                            remove(journalContentSearch);
3230                    }
3231            }
3232    
3233            /**
3234             * Removes all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63; from the database.
3235             *
3236             * @param groupId the group id to search with
3237             * @param privateLayout the private layout to search with
3238             * @param layoutId the layout id to search with
3239             * @param portletId the portlet id to search with
3240             * @throws SystemException if a system exception occurred
3241             */
3242            public void removeByG_P_L_P(long groupId, boolean privateLayout,
3243                    long layoutId, String portletId) throws SystemException {
3244                    for (JournalContentSearch journalContentSearch : findByG_P_L_P(
3245                                    groupId, privateLayout, layoutId, portletId)) {
3246                            remove(journalContentSearch);
3247                    }
3248            }
3249    
3250            /**
3251             * Removes the journal content search where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63; and articleId = &#63; from the database.
3252             *
3253             * @param groupId the group id to search with
3254             * @param privateLayout the private layout to search with
3255             * @param layoutId the layout id to search with
3256             * @param portletId the portlet id to search with
3257             * @param articleId the article id to search with
3258             * @throws SystemException if a system exception occurred
3259             */
3260            public void removeByG_P_L_P_A(long groupId, boolean privateLayout,
3261                    long layoutId, String portletId, String articleId)
3262                    throws NoSuchContentSearchException, SystemException {
3263                    JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
3264                                    privateLayout, layoutId, portletId, articleId);
3265    
3266                    remove(journalContentSearch);
3267            }
3268    
3269            /**
3270             * Removes all the journal content searchs from the database.
3271             *
3272             * @throws SystemException if a system exception occurred
3273             */
3274            public void removeAll() throws SystemException {
3275                    for (JournalContentSearch journalContentSearch : findAll()) {
3276                            remove(journalContentSearch);
3277                    }
3278            }
3279    
3280            /**
3281             * Counts all the journal content searchs where articleId = &#63;.
3282             *
3283             * @param articleId the article id to search with
3284             * @return the number of matching journal content searchs
3285             * @throws SystemException if a system exception occurred
3286             */
3287            public int countByArticleId(String articleId) throws SystemException {
3288                    Object[] finderArgs = new Object[] { articleId };
3289    
3290                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ARTICLEID,
3291                                    finderArgs, this);
3292    
3293                    if (count == null) {
3294                            Session session = null;
3295    
3296                            try {
3297                                    session = openSession();
3298    
3299                                    StringBundler query = new StringBundler(2);
3300    
3301                                    query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3302    
3303                                    if (articleId == null) {
3304                                            query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
3305                                    }
3306                                    else {
3307                                            if (articleId.equals(StringPool.BLANK)) {
3308                                                    query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
3309                                            }
3310                                            else {
3311                                                    query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
3312                                            }
3313                                    }
3314    
3315                                    String sql = query.toString();
3316    
3317                                    Query q = session.createQuery(sql);
3318    
3319                                    QueryPos qPos = QueryPos.getInstance(q);
3320    
3321                                    if (articleId != null) {
3322                                            qPos.add(articleId);
3323                                    }
3324    
3325                                    count = (Long)q.uniqueResult();
3326                            }
3327                            catch (Exception e) {
3328                                    throw processException(e);
3329                            }
3330                            finally {
3331                                    if (count == null) {
3332                                            count = Long.valueOf(0);
3333                                    }
3334    
3335                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ARTICLEID,
3336                                            finderArgs, count);
3337    
3338                                    closeSession(session);
3339                            }
3340                    }
3341    
3342                    return count.intValue();
3343            }
3344    
3345            /**
3346             * Counts all the journal content searchs where groupId = &#63; and privateLayout = &#63;.
3347             *
3348             * @param groupId the group id to search with
3349             * @param privateLayout the private layout to search with
3350             * @return the number of matching journal content searchs
3351             * @throws SystemException if a system exception occurred
3352             */
3353            public int countByG_P(long groupId, boolean privateLayout)
3354                    throws SystemException {
3355                    Object[] finderArgs = new Object[] { groupId, privateLayout };
3356    
3357                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
3358                                    finderArgs, this);
3359    
3360                    if (count == null) {
3361                            Session session = null;
3362    
3363                            try {
3364                                    session = openSession();
3365    
3366                                    StringBundler query = new StringBundler(3);
3367    
3368                                    query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3369    
3370                                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3371    
3372                                    query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
3373    
3374                                    String sql = query.toString();
3375    
3376                                    Query q = session.createQuery(sql);
3377    
3378                                    QueryPos qPos = QueryPos.getInstance(q);
3379    
3380                                    qPos.add(groupId);
3381    
3382                                    qPos.add(privateLayout);
3383    
3384                                    count = (Long)q.uniqueResult();
3385                            }
3386                            catch (Exception e) {
3387                                    throw processException(e);
3388                            }
3389                            finally {
3390                                    if (count == null) {
3391                                            count = Long.valueOf(0);
3392                                    }
3393    
3394                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
3395                                            count);
3396    
3397                                    closeSession(session);
3398                            }
3399                    }
3400    
3401                    return count.intValue();
3402            }
3403    
3404            /**
3405             * Counts all the journal content searchs where groupId = &#63; and articleId = &#63;.
3406             *
3407             * @param groupId the group id to search with
3408             * @param articleId the article id to search with
3409             * @return the number of matching journal content searchs
3410             * @throws SystemException if a system exception occurred
3411             */
3412            public int countByG_A(long groupId, String articleId)
3413                    throws SystemException {
3414                    Object[] finderArgs = new Object[] { groupId, articleId };
3415    
3416                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
3417                                    finderArgs, this);
3418    
3419                    if (count == null) {
3420                            Session session = null;
3421    
3422                            try {
3423                                    session = openSession();
3424    
3425                                    StringBundler query = new StringBundler(3);
3426    
3427                                    query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3428    
3429                                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
3430    
3431                                    if (articleId == null) {
3432                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
3433                                    }
3434                                    else {
3435                                            if (articleId.equals(StringPool.BLANK)) {
3436                                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
3437                                            }
3438                                            else {
3439                                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
3440                                            }
3441                                    }
3442    
3443                                    String sql = query.toString();
3444    
3445                                    Query q = session.createQuery(sql);
3446    
3447                                    QueryPos qPos = QueryPos.getInstance(q);
3448    
3449                                    qPos.add(groupId);
3450    
3451                                    if (articleId != null) {
3452                                            qPos.add(articleId);
3453                                    }
3454    
3455                                    count = (Long)q.uniqueResult();
3456                            }
3457                            catch (Exception e) {
3458                                    throw processException(e);
3459                            }
3460                            finally {
3461                                    if (count == null) {
3462                                            count = Long.valueOf(0);
3463                                    }
3464    
3465                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
3466                                            count);
3467    
3468                                    closeSession(session);
3469                            }
3470                    }
3471    
3472                    return count.intValue();
3473            }
3474    
3475            /**
3476             * Counts all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63;.
3477             *
3478             * @param groupId the group id to search with
3479             * @param privateLayout the private layout to search with
3480             * @param layoutId the layout id to search with
3481             * @return the number of matching journal content searchs
3482             * @throws SystemException if a system exception occurred
3483             */
3484            public int countByG_P_L(long groupId, boolean privateLayout, long layoutId)
3485                    throws SystemException {
3486                    Object[] finderArgs = new Object[] { groupId, privateLayout, layoutId };
3487    
3488                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L,
3489                                    finderArgs, this);
3490    
3491                    if (count == null) {
3492                            Session session = null;
3493    
3494                            try {
3495                                    session = openSession();
3496    
3497                                    StringBundler query = new StringBundler(4);
3498    
3499                                    query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3500    
3501                                    query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
3502    
3503                                    query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
3504    
3505                                    query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
3506    
3507                                    String sql = query.toString();
3508    
3509                                    Query q = session.createQuery(sql);
3510    
3511                                    QueryPos qPos = QueryPos.getInstance(q);
3512    
3513                                    qPos.add(groupId);
3514    
3515                                    qPos.add(privateLayout);
3516    
3517                                    qPos.add(layoutId);
3518    
3519                                    count = (Long)q.uniqueResult();
3520                            }
3521                            catch (Exception e) {
3522                                    throw processException(e);
3523                            }
3524                            finally {
3525                                    if (count == null) {
3526                                            count = Long.valueOf(0);
3527                                    }
3528    
3529                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L,
3530                                            finderArgs, count);
3531    
3532                                    closeSession(session);
3533                            }
3534                    }
3535    
3536                    return count.intValue();
3537            }
3538    
3539            /**
3540             * Counts all the journal content searchs where groupId = &#63; and privateLayout = &#63; and articleId = &#63;.
3541             *
3542             * @param groupId the group id to search with
3543             * @param privateLayout the private layout to search with
3544             * @param articleId the article id to search with
3545             * @return the number of matching journal content searchs
3546             * @throws SystemException if a system exception occurred
3547             */
3548            public int countByG_P_A(long groupId, boolean privateLayout,
3549                    String articleId) throws SystemException {
3550                    Object[] finderArgs = new Object[] { groupId, privateLayout, articleId };
3551    
3552                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_A,
3553                                    finderArgs, this);
3554    
3555                    if (count == null) {
3556                            Session session = null;
3557    
3558                            try {
3559                                    session = openSession();
3560    
3561                                    StringBundler query = new StringBundler(4);
3562    
3563                                    query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3564    
3565                                    query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
3566    
3567                                    query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
3568    
3569                                    if (articleId == null) {
3570                                            query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
3571                                    }
3572                                    else {
3573                                            if (articleId.equals(StringPool.BLANK)) {
3574                                                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
3575                                            }
3576                                            else {
3577                                                    query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
3578                                            }
3579                                    }
3580    
3581                                    String sql = query.toString();
3582    
3583                                    Query q = session.createQuery(sql);
3584    
3585                                    QueryPos qPos = QueryPos.getInstance(q);
3586    
3587                                    qPos.add(groupId);
3588    
3589                                    qPos.add(privateLayout);
3590    
3591                                    if (articleId != null) {
3592                                            qPos.add(articleId);
3593                                    }
3594    
3595                                    count = (Long)q.uniqueResult();
3596                            }
3597                            catch (Exception e) {
3598                                    throw processException(e);
3599                            }
3600                            finally {
3601                                    if (count == null) {
3602                                            count = Long.valueOf(0);
3603                                    }
3604    
3605                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_A,
3606                                            finderArgs, count);
3607    
3608                                    closeSession(session);
3609                            }
3610                    }
3611    
3612                    return count.intValue();
3613            }
3614    
3615            /**
3616             * Counts all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63;.
3617             *
3618             * @param groupId the group id to search with
3619             * @param privateLayout the private layout to search with
3620             * @param layoutId the layout id to search with
3621             * @param portletId the portlet id to search with
3622             * @return the number of matching journal content searchs
3623             * @throws SystemException if a system exception occurred
3624             */
3625            public int countByG_P_L_P(long groupId, boolean privateLayout,
3626                    long layoutId, String portletId) throws SystemException {
3627                    Object[] finderArgs = new Object[] {
3628                                    groupId, privateLayout, layoutId, portletId
3629                            };
3630    
3631                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P,
3632                                    finderArgs, this);
3633    
3634                    if (count == null) {
3635                            Session session = null;
3636    
3637                            try {
3638                                    session = openSession();
3639    
3640                                    StringBundler query = new StringBundler(5);
3641    
3642                                    query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3643    
3644                                    query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3645    
3646                                    query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3647    
3648                                    query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3649    
3650                                    if (portletId == null) {
3651                                            query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3652                                    }
3653                                    else {
3654                                            if (portletId.equals(StringPool.BLANK)) {
3655                                                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3656                                            }
3657                                            else {
3658                                                    query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3659                                            }
3660                                    }
3661    
3662                                    String sql = query.toString();
3663    
3664                                    Query q = session.createQuery(sql);
3665    
3666                                    QueryPos qPos = QueryPos.getInstance(q);
3667    
3668                                    qPos.add(groupId);
3669    
3670                                    qPos.add(privateLayout);
3671    
3672                                    qPos.add(layoutId);
3673    
3674                                    if (portletId != null) {
3675                                            qPos.add(portletId);
3676                                    }
3677    
3678                                    count = (Long)q.uniqueResult();
3679                            }
3680                            catch (Exception e) {
3681                                    throw processException(e);
3682                            }
3683                            finally {
3684                                    if (count == null) {
3685                                            count = Long.valueOf(0);
3686                                    }
3687    
3688                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P,
3689                                            finderArgs, count);
3690    
3691                                    closeSession(session);
3692                            }
3693                    }
3694    
3695                    return count.intValue();
3696            }
3697    
3698            /**
3699             * Counts all the journal content searchs where groupId = &#63; and privateLayout = &#63; and layoutId = &#63; and portletId = &#63; and articleId = &#63;.
3700             *
3701             * @param groupId the group id to search with
3702             * @param privateLayout the private layout to search with
3703             * @param layoutId the layout id to search with
3704             * @param portletId the portlet id to search with
3705             * @param articleId the article id to search with
3706             * @return the number of matching journal content searchs
3707             * @throws SystemException if a system exception occurred
3708             */
3709            public int countByG_P_L_P_A(long groupId, boolean privateLayout,
3710                    long layoutId, String portletId, String articleId)
3711                    throws SystemException {
3712                    Object[] finderArgs = new Object[] {
3713                                    groupId, privateLayout, layoutId, portletId, articleId
3714                            };
3715    
3716                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
3717                                    finderArgs, this);
3718    
3719                    if (count == null) {
3720                            Session session = null;
3721    
3722                            try {
3723                                    session = openSession();
3724    
3725                                    StringBundler query = new StringBundler(6);
3726    
3727                                    query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3728    
3729                                    query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
3730    
3731                                    query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
3732    
3733                                    query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
3734    
3735                                    if (portletId == null) {
3736                                            query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
3737                                    }
3738                                    else {
3739                                            if (portletId.equals(StringPool.BLANK)) {
3740                                                    query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
3741                                            }
3742                                            else {
3743                                                    query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
3744                                            }
3745                                    }
3746    
3747                                    if (articleId == null) {
3748                                            query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
3749                                    }
3750                                    else {
3751                                            if (articleId.equals(StringPool.BLANK)) {
3752                                                    query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
3753                                            }
3754                                            else {
3755                                                    query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
3756                                            }
3757                                    }
3758    
3759                                    String sql = query.toString();
3760    
3761                                    Query q = session.createQuery(sql);
3762    
3763                                    QueryPos qPos = QueryPos.getInstance(q);
3764    
3765                                    qPos.add(groupId);
3766    
3767                                    qPos.add(privateLayout);
3768    
3769                                    qPos.add(layoutId);
3770    
3771                                    if (portletId != null) {
3772                                            qPos.add(portletId);
3773                                    }
3774    
3775                                    if (articleId != null) {
3776                                            qPos.add(articleId);
3777                                    }
3778    
3779                                    count = (Long)q.uniqueResult();
3780                            }
3781                            catch (Exception e) {
3782                                    throw processException(e);
3783                            }
3784                            finally {
3785                                    if (count == null) {
3786                                            count = Long.valueOf(0);
3787                                    }
3788    
3789                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
3790                                            finderArgs, count);
3791    
3792                                    closeSession(session);
3793                            }
3794                    }
3795    
3796                    return count.intValue();
3797            }
3798    
3799            /**
3800             * Counts all the journal content searchs.
3801             *
3802             * @return the number of journal content searchs
3803             * @throws SystemException if a system exception occurred
3804             */
3805            public int countAll() throws SystemException {
3806                    Object[] finderArgs = new Object[0];
3807    
3808                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3809                                    finderArgs, this);
3810    
3811                    if (count == null) {
3812                            Session session = null;
3813    
3814                            try {
3815                                    session = openSession();
3816    
3817                                    Query q = session.createQuery(_SQL_COUNT_JOURNALCONTENTSEARCH);
3818    
3819                                    count = (Long)q.uniqueResult();
3820                            }
3821                            catch (Exception e) {
3822                                    throw processException(e);
3823                            }
3824                            finally {
3825                                    if (count == null) {
3826                                            count = Long.valueOf(0);
3827                                    }
3828    
3829                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3830                                            count);
3831    
3832                                    closeSession(session);
3833                            }
3834                    }
3835    
3836                    return count.intValue();
3837            }
3838    
3839            /**
3840             * Initializes the journal content search persistence.
3841             */
3842            public void afterPropertiesSet() {
3843                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3844                                            com.liferay.portal.util.PropsUtil.get(
3845                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalContentSearch")));
3846    
3847                    if (listenerClassNames.length > 0) {
3848                            try {
3849                                    List<ModelListener<JournalContentSearch>> listenersList = new ArrayList<ModelListener<JournalContentSearch>>();
3850    
3851                                    for (String listenerClassName : listenerClassNames) {
3852                                            listenersList.add((ModelListener<JournalContentSearch>)InstanceFactory.newInstance(
3853                                                            listenerClassName));
3854                                    }
3855    
3856                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3857                            }
3858                            catch (Exception e) {
3859                                    _log.error(e);
3860                            }
3861                    }
3862            }
3863    
3864            public void destroy() {
3865                    EntityCacheUtil.removeCache(JournalContentSearchImpl.class.getName());
3866                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3867                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
3868            }
3869    
3870            @BeanReference(type = JournalArticlePersistence.class)
3871            protected JournalArticlePersistence journalArticlePersistence;
3872            @BeanReference(type = JournalArticleImagePersistence.class)
3873            protected JournalArticleImagePersistence journalArticleImagePersistence;
3874            @BeanReference(type = JournalArticleResourcePersistence.class)
3875            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
3876            @BeanReference(type = JournalContentSearchPersistence.class)
3877            protected JournalContentSearchPersistence journalContentSearchPersistence;
3878            @BeanReference(type = JournalFeedPersistence.class)
3879            protected JournalFeedPersistence journalFeedPersistence;
3880            @BeanReference(type = JournalStructurePersistence.class)
3881            protected JournalStructurePersistence journalStructurePersistence;
3882            @BeanReference(type = JournalTemplatePersistence.class)
3883            protected JournalTemplatePersistence journalTemplatePersistence;
3884            @BeanReference(type = GroupPersistence.class)
3885            protected GroupPersistence groupPersistence;
3886            @BeanReference(type = LayoutPersistence.class)
3887            protected LayoutPersistence layoutPersistence;
3888            @BeanReference(type = PortletPreferencesPersistence.class)
3889            protected PortletPreferencesPersistence portletPreferencesPersistence;
3890            @BeanReference(type = ResourcePersistence.class)
3891            protected ResourcePersistence resourcePersistence;
3892            @BeanReference(type = UserPersistence.class)
3893            protected UserPersistence userPersistence;
3894            private static final String _SQL_SELECT_JOURNALCONTENTSEARCH = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch";
3895            private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE ";
3896            private static final String _SQL_COUNT_JOURNALCONTENTSEARCH = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch";
3897            private static final String _SQL_COUNT_JOURNALCONTENTSEARCH_WHERE = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch WHERE ";
3898            private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3899            private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3900            private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3901            private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3902            private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ?";
3903            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3904            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3905            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3906            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3907            private static final String _FINDER_COLUMN_G_P_L_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3908            private static final String _FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3909            private static final String _FINDER_COLUMN_G_P_L_LAYOUTID_2 = "journalContentSearch.layoutId = ?";
3910            private static final String _FINDER_COLUMN_G_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3911            private static final String _FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3912            private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3913            private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3914            private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3915            private static final String _FINDER_COLUMN_G_P_L_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3916            private static final String _FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3917            private static final String _FINDER_COLUMN_G_P_L_P_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
3918            private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
3919            private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_2 = "journalContentSearch.portletId = ?";
3920            private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?)";
3921            private static final String _FINDER_COLUMN_G_P_L_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3922            private static final String _FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3923            private static final String _FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
3924            private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_1 = "journalContentSearch.portletId IS NULL AND ";
3925            private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_2 = "journalContentSearch.portletId = ? AND ";
3926            private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?) AND ";
3927            private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3928            private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3929            private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3930            private static final String _ORDER_BY_ENTITY_ALIAS = "journalContentSearch.";
3931            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalContentSearch exists with the primary key ";
3932            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalContentSearch exists with the key {";
3933            private static Log _log = LogFactoryUtil.getLog(JournalContentSearchPersistenceImpl.class);
3934    }