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