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