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