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