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