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