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.wiki.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.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.sanitizer.Sanitizer;
032    import com.liferay.portal.kernel.sanitizer.SanitizerException;
033    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
034    import com.liferay.portal.kernel.util.ContentTypes;
035    import com.liferay.portal.kernel.util.GetterUtil;
036    import com.liferay.portal.kernel.util.OrderByComparator;
037    import com.liferay.portal.kernel.util.SetUtil;
038    import com.liferay.portal.kernel.util.StringBundler;
039    import com.liferay.portal.kernel.util.StringPool;
040    import com.liferay.portal.kernel.util.StringUtil;
041    import com.liferay.portal.kernel.util.Validator;
042    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
043    import com.liferay.portal.model.CacheModel;
044    import com.liferay.portal.security.auth.PrincipalThreadLocal;
045    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
047    
048    import com.liferay.portlet.wiki.NoSuchPageException;
049    import com.liferay.portlet.wiki.model.WikiPage;
050    import com.liferay.portlet.wiki.model.impl.WikiPageImpl;
051    import com.liferay.portlet.wiki.model.impl.WikiPageModelImpl;
052    import com.liferay.portlet.wiki.service.persistence.WikiPagePersistence;
053    
054    import java.io.Serializable;
055    
056    import java.util.Collections;
057    import java.util.HashMap;
058    import java.util.HashSet;
059    import java.util.Iterator;
060    import java.util.List;
061    import java.util.Map;
062    import java.util.Set;
063    
064    /**
065     * The persistence implementation for the wiki page service.
066     *
067     * <p>
068     * Caching information and settings can be found in <code>portal.properties</code>
069     * </p>
070     *
071     * @author Brian Wing Shun Chan
072     * @see WikiPagePersistence
073     * @see WikiPageUtil
074     * @generated
075     */
076    @ProviderType
077    public class WikiPagePersistenceImpl extends BasePersistenceImpl<WikiPage>
078            implements WikiPagePersistence {
079            /*
080             * NOTE FOR DEVELOPERS:
081             *
082             * Never modify or reference this class directly. Always use {@link WikiPageUtil} to access the wiki page persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
083             */
084            public static final String FINDER_CLASS_NAME_ENTITY = WikiPageImpl.class.getName();
085            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086                    ".List1";
087            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
088                    ".List2";
089            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
090                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
092            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
093                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
095            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
096                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
098            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
099                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
100                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
101                            new String[] {
102                                    String.class.getName(),
103                                    
104                            Integer.class.getName(), Integer.class.getName(),
105                                    OrderByComparator.class.getName()
106                            });
107            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
108                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
110                            new String[] { String.class.getName() },
111                            WikiPageModelImpl.UUID_COLUMN_BITMASK |
112                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
113                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
114                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
115            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
116                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
117                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
118                            new String[] { String.class.getName() });
119    
120            /**
121             * Returns all the wiki pages where uuid = &#63;.
122             *
123             * @param uuid the uuid
124             * @return the matching wiki pages
125             */
126            @Override
127            public List<WikiPage> findByUuid(String uuid) {
128                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
129            }
130    
131            /**
132             * Returns a range of all the wiki pages where uuid = &#63;.
133             *
134             * <p>
135             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
136             * </p>
137             *
138             * @param uuid the uuid
139             * @param start the lower bound of the range of wiki pages
140             * @param end the upper bound of the range of wiki pages (not inclusive)
141             * @return the range of matching wiki pages
142             */
143            @Override
144            public List<WikiPage> findByUuid(String uuid, int start, int end) {
145                    return findByUuid(uuid, start, end, null);
146            }
147    
148            /**
149             * Returns an ordered range of all the wiki pages where uuid = &#63;.
150             *
151             * <p>
152             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
153             * </p>
154             *
155             * @param uuid the uuid
156             * @param start the lower bound of the range of wiki pages
157             * @param end the upper bound of the range of wiki pages (not inclusive)
158             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
159             * @return the ordered range of matching wiki pages
160             */
161            @Override
162            public List<WikiPage> findByUuid(String uuid, int start, int end,
163                    OrderByComparator<WikiPage> orderByComparator) {
164                    boolean pagination = true;
165                    FinderPath finderPath = null;
166                    Object[] finderArgs = null;
167    
168                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
169                                    (orderByComparator == null)) {
170                            pagination = false;
171                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
172                            finderArgs = new Object[] { uuid };
173                    }
174                    else {
175                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
176                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
177                    }
178    
179                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
180                                    finderArgs, this);
181    
182                    if ((list != null) && !list.isEmpty()) {
183                            for (WikiPage wikiPage : list) {
184                                    if (!Validator.equals(uuid, wikiPage.getUuid())) {
185                                            list = null;
186    
187                                            break;
188                                    }
189                            }
190                    }
191    
192                    if (list == null) {
193                            StringBundler query = null;
194    
195                            if (orderByComparator != null) {
196                                    query = new StringBundler(3 +
197                                                    (orderByComparator.getOrderByFields().length * 3));
198                            }
199                            else {
200                                    query = new StringBundler(3);
201                            }
202    
203                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
204    
205                            boolean bindUuid = false;
206    
207                            if (uuid == null) {
208                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
209                            }
210                            else if (uuid.equals(StringPool.BLANK)) {
211                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
212                            }
213                            else {
214                                    bindUuid = true;
215    
216                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
217                            }
218    
219                            if (orderByComparator != null) {
220                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
221                                            orderByComparator);
222                            }
223                            else
224                             if (pagination) {
225                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
226                            }
227    
228                            String sql = query.toString();
229    
230                            Session session = null;
231    
232                            try {
233                                    session = openSession();
234    
235                                    Query q = session.createQuery(sql);
236    
237                                    QueryPos qPos = QueryPos.getInstance(q);
238    
239                                    if (bindUuid) {
240                                            qPos.add(uuid);
241                                    }
242    
243                                    if (!pagination) {
244                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
245                                                            start, end, false);
246    
247                                            Collections.sort(list);
248    
249                                            list = Collections.unmodifiableList(list);
250                                    }
251                                    else {
252                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
253                                                            start, end);
254                                    }
255    
256                                    cacheResult(list);
257    
258                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
259                            }
260                            catch (Exception e) {
261                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
262    
263                                    throw processException(e);
264                            }
265                            finally {
266                                    closeSession(session);
267                            }
268                    }
269    
270                    return list;
271            }
272    
273            /**
274             * Returns the first wiki page in the ordered set where uuid = &#63;.
275             *
276             * @param uuid the uuid
277             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
278             * @return the first matching wiki page
279             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
280             */
281            @Override
282            public WikiPage findByUuid_First(String uuid,
283                    OrderByComparator<WikiPage> orderByComparator)
284                    throws NoSuchPageException {
285                    WikiPage wikiPage = fetchByUuid_First(uuid, orderByComparator);
286    
287                    if (wikiPage != null) {
288                            return wikiPage;
289                    }
290    
291                    StringBundler msg = new StringBundler(4);
292    
293                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
294    
295                    msg.append("uuid=");
296                    msg.append(uuid);
297    
298                    msg.append(StringPool.CLOSE_CURLY_BRACE);
299    
300                    throw new NoSuchPageException(msg.toString());
301            }
302    
303            /**
304             * Returns the first wiki page in the ordered set where uuid = &#63;.
305             *
306             * @param uuid the uuid
307             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
308             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
309             */
310            @Override
311            public WikiPage fetchByUuid_First(String uuid,
312                    OrderByComparator<WikiPage> orderByComparator) {
313                    List<WikiPage> list = findByUuid(uuid, 0, 1, orderByComparator);
314    
315                    if (!list.isEmpty()) {
316                            return list.get(0);
317                    }
318    
319                    return null;
320            }
321    
322            /**
323             * Returns the last wiki page in the ordered set where uuid = &#63;.
324             *
325             * @param uuid the uuid
326             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
327             * @return the last matching wiki page
328             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
329             */
330            @Override
331            public WikiPage findByUuid_Last(String uuid,
332                    OrderByComparator<WikiPage> orderByComparator)
333                    throws NoSuchPageException {
334                    WikiPage wikiPage = fetchByUuid_Last(uuid, orderByComparator);
335    
336                    if (wikiPage != null) {
337                            return wikiPage;
338                    }
339    
340                    StringBundler msg = new StringBundler(4);
341    
342                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
343    
344                    msg.append("uuid=");
345                    msg.append(uuid);
346    
347                    msg.append(StringPool.CLOSE_CURLY_BRACE);
348    
349                    throw new NoSuchPageException(msg.toString());
350            }
351    
352            /**
353             * Returns the last wiki page in the ordered set where uuid = &#63;.
354             *
355             * @param uuid the uuid
356             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
357             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
358             */
359            @Override
360            public WikiPage fetchByUuid_Last(String uuid,
361                    OrderByComparator<WikiPage> orderByComparator) {
362                    int count = countByUuid(uuid);
363    
364                    if (count == 0) {
365                            return null;
366                    }
367    
368                    List<WikiPage> list = findByUuid(uuid, count - 1, count,
369                                    orderByComparator);
370    
371                    if (!list.isEmpty()) {
372                            return list.get(0);
373                    }
374    
375                    return null;
376            }
377    
378            /**
379             * Returns the wiki pages before and after the current wiki page in the ordered set where uuid = &#63;.
380             *
381             * @param pageId the primary key of the current wiki page
382             * @param uuid the uuid
383             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
384             * @return the previous, current, and next wiki page
385             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
386             */
387            @Override
388            public WikiPage[] findByUuid_PrevAndNext(long pageId, String uuid,
389                    OrderByComparator<WikiPage> orderByComparator)
390                    throws NoSuchPageException {
391                    WikiPage wikiPage = findByPrimaryKey(pageId);
392    
393                    Session session = null;
394    
395                    try {
396                            session = openSession();
397    
398                            WikiPage[] array = new WikiPageImpl[3];
399    
400                            array[0] = getByUuid_PrevAndNext(session, wikiPage, uuid,
401                                            orderByComparator, true);
402    
403                            array[1] = wikiPage;
404    
405                            array[2] = getByUuid_PrevAndNext(session, wikiPage, uuid,
406                                            orderByComparator, false);
407    
408                            return array;
409                    }
410                    catch (Exception e) {
411                            throw processException(e);
412                    }
413                    finally {
414                            closeSession(session);
415                    }
416            }
417    
418            protected WikiPage getByUuid_PrevAndNext(Session session,
419                    WikiPage wikiPage, String uuid,
420                    OrderByComparator<WikiPage> orderByComparator, 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_WIKIPAGE_WHERE);
432    
433                    boolean bindUuid = false;
434    
435                    if (uuid == null) {
436                            query.append(_FINDER_COLUMN_UUID_UUID_1);
437                    }
438                    else if (uuid.equals(StringPool.BLANK)) {
439                            query.append(_FINDER_COLUMN_UUID_UUID_3);
440                    }
441                    else {
442                            bindUuid = true;
443    
444                            query.append(_FINDER_COLUMN_UUID_UUID_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(WikiPageModelImpl.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 (bindUuid) {
516                            qPos.add(uuid);
517                    }
518    
519                    if (orderByComparator != null) {
520                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
521    
522                            for (Object value : values) {
523                                    qPos.add(value);
524                            }
525                    }
526    
527                    List<WikiPage> 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 wiki pages where uuid = &#63; from the database.
539             *
540             * @param uuid the uuid
541             */
542            @Override
543            public void removeByUuid(String uuid) {
544                    for (WikiPage wikiPage : findByUuid(uuid, QueryUtil.ALL_POS,
545                                    QueryUtil.ALL_POS, null)) {
546                            remove(wikiPage);
547                    }
548            }
549    
550            /**
551             * Returns the number of wiki pages where uuid = &#63;.
552             *
553             * @param uuid the uuid
554             * @return the number of matching wiki pages
555             */
556            @Override
557            public int countByUuid(String uuid) {
558                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
559    
560                    Object[] finderArgs = new Object[] { uuid };
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_WIKIPAGE_WHERE);
569    
570                            boolean bindUuid = false;
571    
572                            if (uuid == null) {
573                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
574                            }
575                            else if (uuid.equals(StringPool.BLANK)) {
576                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
577                            }
578                            else {
579                                    bindUuid = true;
580    
581                                    query.append(_FINDER_COLUMN_UUID_UUID_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 (bindUuid) {
596                                            qPos.add(uuid);
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_UUID_UUID_1 = "wikiPage.uuid IS NULL";
617            private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiPage.uuid = ?";
618            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = '')";
619            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
620                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
621                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
622                            new String[] { String.class.getName(), Long.class.getName() },
623                            WikiPageModelImpl.UUID_COLUMN_BITMASK |
624                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK);
625            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
626                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
627                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
628                            new String[] { String.class.getName(), Long.class.getName() });
629    
630            /**
631             * Returns the wiki page where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.wiki.NoSuchPageException} if it could not be found.
632             *
633             * @param uuid the uuid
634             * @param groupId the group ID
635             * @return the matching wiki page
636             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
637             */
638            @Override
639            public WikiPage findByUUID_G(String uuid, long groupId)
640                    throws NoSuchPageException {
641                    WikiPage wikiPage = fetchByUUID_G(uuid, groupId);
642    
643                    if (wikiPage == null) {
644                            StringBundler msg = new StringBundler(6);
645    
646                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
647    
648                            msg.append("uuid=");
649                            msg.append(uuid);
650    
651                            msg.append(", groupId=");
652                            msg.append(groupId);
653    
654                            msg.append(StringPool.CLOSE_CURLY_BRACE);
655    
656                            if (_log.isWarnEnabled()) {
657                                    _log.warn(msg.toString());
658                            }
659    
660                            throw new NoSuchPageException(msg.toString());
661                    }
662    
663                    return wikiPage;
664            }
665    
666            /**
667             * Returns the wiki page where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
668             *
669             * @param uuid the uuid
670             * @param groupId the group ID
671             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
672             */
673            @Override
674            public WikiPage fetchByUUID_G(String uuid, long groupId) {
675                    return fetchByUUID_G(uuid, groupId, true);
676            }
677    
678            /**
679             * Returns the wiki page where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
680             *
681             * @param uuid the uuid
682             * @param groupId the group ID
683             * @param retrieveFromCache whether to use the finder cache
684             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
685             */
686            @Override
687            public WikiPage fetchByUUID_G(String uuid, long groupId,
688                    boolean retrieveFromCache) {
689                    Object[] finderArgs = new Object[] { uuid, groupId };
690    
691                    Object result = null;
692    
693                    if (retrieveFromCache) {
694                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
695                                            finderArgs, this);
696                    }
697    
698                    if (result instanceof WikiPage) {
699                            WikiPage wikiPage = (WikiPage)result;
700    
701                            if (!Validator.equals(uuid, wikiPage.getUuid()) ||
702                                            (groupId != wikiPage.getGroupId())) {
703                                    result = null;
704                            }
705                    }
706    
707                    if (result == null) {
708                            StringBundler query = new StringBundler(4);
709    
710                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
711    
712                            boolean bindUuid = false;
713    
714                            if (uuid == null) {
715                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
716                            }
717                            else if (uuid.equals(StringPool.BLANK)) {
718                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
719                            }
720                            else {
721                                    bindUuid = true;
722    
723                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
724                            }
725    
726                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
727    
728                            String sql = query.toString();
729    
730                            Session session = null;
731    
732                            try {
733                                    session = openSession();
734    
735                                    Query q = session.createQuery(sql);
736    
737                                    QueryPos qPos = QueryPos.getInstance(q);
738    
739                                    if (bindUuid) {
740                                            qPos.add(uuid);
741                                    }
742    
743                                    qPos.add(groupId);
744    
745                                    List<WikiPage> list = q.list();
746    
747                                    if (list.isEmpty()) {
748                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
749                                                    finderArgs, list);
750                                    }
751                                    else {
752                                            WikiPage wikiPage = list.get(0);
753    
754                                            result = wikiPage;
755    
756                                            cacheResult(wikiPage);
757    
758                                            if ((wikiPage.getUuid() == null) ||
759                                                            !wikiPage.getUuid().equals(uuid) ||
760                                                            (wikiPage.getGroupId() != groupId)) {
761                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
762                                                            finderArgs, wikiPage);
763                                            }
764                                    }
765                            }
766                            catch (Exception e) {
767                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
768                                            finderArgs);
769    
770                                    throw processException(e);
771                            }
772                            finally {
773                                    closeSession(session);
774                            }
775                    }
776    
777                    if (result instanceof List<?>) {
778                            return null;
779                    }
780                    else {
781                            return (WikiPage)result;
782                    }
783            }
784    
785            /**
786             * Removes the wiki page where uuid = &#63; and groupId = &#63; from the database.
787             *
788             * @param uuid the uuid
789             * @param groupId the group ID
790             * @return the wiki page that was removed
791             */
792            @Override
793            public WikiPage removeByUUID_G(String uuid, long groupId)
794                    throws NoSuchPageException {
795                    WikiPage wikiPage = findByUUID_G(uuid, groupId);
796    
797                    return remove(wikiPage);
798            }
799    
800            /**
801             * Returns the number of wiki pages where uuid = &#63; and groupId = &#63;.
802             *
803             * @param uuid the uuid
804             * @param groupId the group ID
805             * @return the number of matching wiki pages
806             */
807            @Override
808            public int countByUUID_G(String uuid, long groupId) {
809                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
810    
811                    Object[] finderArgs = new Object[] { uuid, groupId };
812    
813                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
814                                    this);
815    
816                    if (count == null) {
817                            StringBundler query = new StringBundler(3);
818    
819                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
820    
821                            boolean bindUuid = false;
822    
823                            if (uuid == null) {
824                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
825                            }
826                            else if (uuid.equals(StringPool.BLANK)) {
827                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
828                            }
829                            else {
830                                    bindUuid = true;
831    
832                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
833                            }
834    
835                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
836    
837                            String sql = query.toString();
838    
839                            Session session = null;
840    
841                            try {
842                                    session = openSession();
843    
844                                    Query q = session.createQuery(sql);
845    
846                                    QueryPos qPos = QueryPos.getInstance(q);
847    
848                                    if (bindUuid) {
849                                            qPos.add(uuid);
850                                    }
851    
852                                    qPos.add(groupId);
853    
854                                    count = (Long)q.uniqueResult();
855    
856                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
857                            }
858                            catch (Exception e) {
859                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
860    
861                                    throw processException(e);
862                            }
863                            finally {
864                                    closeSession(session);
865                            }
866                    }
867    
868                    return count.intValue();
869            }
870    
871            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiPage.uuid IS NULL AND ";
872            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiPage.uuid = ? AND ";
873            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = '') AND ";
874            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiPage.groupId = ?";
875            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
876                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
877                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
878                            new String[] {
879                                    String.class.getName(), Long.class.getName(),
880                                    
881                            Integer.class.getName(), Integer.class.getName(),
882                                    OrderByComparator.class.getName()
883                            });
884            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
885                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
886                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
887                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
888                            new String[] { String.class.getName(), Long.class.getName() },
889                            WikiPageModelImpl.UUID_COLUMN_BITMASK |
890                            WikiPageModelImpl.COMPANYID_COLUMN_BITMASK |
891                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
892                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
893                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
894            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
895                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
896                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
897                            new String[] { String.class.getName(), Long.class.getName() });
898    
899            /**
900             * Returns all the wiki pages where uuid = &#63; and companyId = &#63;.
901             *
902             * @param uuid the uuid
903             * @param companyId the company ID
904             * @return the matching wiki pages
905             */
906            @Override
907            public List<WikiPage> findByUuid_C(String uuid, long companyId) {
908                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
909                            QueryUtil.ALL_POS, null);
910            }
911    
912            /**
913             * Returns a range of all the wiki pages where uuid = &#63; and companyId = &#63;.
914             *
915             * <p>
916             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
917             * </p>
918             *
919             * @param uuid the uuid
920             * @param companyId the company ID
921             * @param start the lower bound of the range of wiki pages
922             * @param end the upper bound of the range of wiki pages (not inclusive)
923             * @return the range of matching wiki pages
924             */
925            @Override
926            public List<WikiPage> findByUuid_C(String uuid, long companyId, int start,
927                    int end) {
928                    return findByUuid_C(uuid, companyId, start, end, null);
929            }
930    
931            /**
932             * Returns an ordered range of all the wiki pages where uuid = &#63; and companyId = &#63;.
933             *
934             * <p>
935             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
936             * </p>
937             *
938             * @param uuid the uuid
939             * @param companyId the company ID
940             * @param start the lower bound of the range of wiki pages
941             * @param end the upper bound of the range of wiki pages (not inclusive)
942             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
943             * @return the ordered range of matching wiki pages
944             */
945            @Override
946            public List<WikiPage> findByUuid_C(String uuid, long companyId, int start,
947                    int end, OrderByComparator<WikiPage> orderByComparator) {
948                    boolean pagination = true;
949                    FinderPath finderPath = null;
950                    Object[] finderArgs = null;
951    
952                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
953                                    (orderByComparator == null)) {
954                            pagination = false;
955                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
956                            finderArgs = new Object[] { uuid, companyId };
957                    }
958                    else {
959                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
960                            finderArgs = new Object[] {
961                                            uuid, companyId,
962                                            
963                                            start, end, orderByComparator
964                                    };
965                    }
966    
967                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
968                                    finderArgs, this);
969    
970                    if ((list != null) && !list.isEmpty()) {
971                            for (WikiPage wikiPage : list) {
972                                    if (!Validator.equals(uuid, wikiPage.getUuid()) ||
973                                                    (companyId != wikiPage.getCompanyId())) {
974                                            list = null;
975    
976                                            break;
977                                    }
978                            }
979                    }
980    
981                    if (list == null) {
982                            StringBundler query = null;
983    
984                            if (orderByComparator != null) {
985                                    query = new StringBundler(4 +
986                                                    (orderByComparator.getOrderByFields().length * 3));
987                            }
988                            else {
989                                    query = new StringBundler(4);
990                            }
991    
992                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
993    
994                            boolean bindUuid = false;
995    
996                            if (uuid == null) {
997                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
998                            }
999                            else if (uuid.equals(StringPool.BLANK)) {
1000                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1001                            }
1002                            else {
1003                                    bindUuid = true;
1004    
1005                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1006                            }
1007    
1008                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1009    
1010                            if (orderByComparator != null) {
1011                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1012                                            orderByComparator);
1013                            }
1014                            else
1015                             if (pagination) {
1016                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1017                            }
1018    
1019                            String sql = query.toString();
1020    
1021                            Session session = null;
1022    
1023                            try {
1024                                    session = openSession();
1025    
1026                                    Query q = session.createQuery(sql);
1027    
1028                                    QueryPos qPos = QueryPos.getInstance(q);
1029    
1030                                    if (bindUuid) {
1031                                            qPos.add(uuid);
1032                                    }
1033    
1034                                    qPos.add(companyId);
1035    
1036                                    if (!pagination) {
1037                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
1038                                                            start, end, false);
1039    
1040                                            Collections.sort(list);
1041    
1042                                            list = Collections.unmodifiableList(list);
1043                                    }
1044                                    else {
1045                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
1046                                                            start, end);
1047                                    }
1048    
1049                                    cacheResult(list);
1050    
1051                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1052                            }
1053                            catch (Exception e) {
1054                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1055    
1056                                    throw processException(e);
1057                            }
1058                            finally {
1059                                    closeSession(session);
1060                            }
1061                    }
1062    
1063                    return list;
1064            }
1065    
1066            /**
1067             * Returns the first wiki page in the ordered set where uuid = &#63; and companyId = &#63;.
1068             *
1069             * @param uuid the uuid
1070             * @param companyId the company ID
1071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1072             * @return the first matching wiki page
1073             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1074             */
1075            @Override
1076            public WikiPage findByUuid_C_First(String uuid, long companyId,
1077                    OrderByComparator<WikiPage> orderByComparator)
1078                    throws NoSuchPageException {
1079                    WikiPage wikiPage = fetchByUuid_C_First(uuid, companyId,
1080                                    orderByComparator);
1081    
1082                    if (wikiPage != null) {
1083                            return wikiPage;
1084                    }
1085    
1086                    StringBundler msg = new StringBundler(6);
1087    
1088                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1089    
1090                    msg.append("uuid=");
1091                    msg.append(uuid);
1092    
1093                    msg.append(", companyId=");
1094                    msg.append(companyId);
1095    
1096                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1097    
1098                    throw new NoSuchPageException(msg.toString());
1099            }
1100    
1101            /**
1102             * Returns the first wiki page in the ordered set where uuid = &#63; and companyId = &#63;.
1103             *
1104             * @param uuid the uuid
1105             * @param companyId the company ID
1106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1107             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
1108             */
1109            @Override
1110            public WikiPage fetchByUuid_C_First(String uuid, long companyId,
1111                    OrderByComparator<WikiPage> orderByComparator) {
1112                    List<WikiPage> list = findByUuid_C(uuid, companyId, 0, 1,
1113                                    orderByComparator);
1114    
1115                    if (!list.isEmpty()) {
1116                            return list.get(0);
1117                    }
1118    
1119                    return null;
1120            }
1121    
1122            /**
1123             * Returns the last wiki page in the ordered set where uuid = &#63; and companyId = &#63;.
1124             *
1125             * @param uuid the uuid
1126             * @param companyId the company ID
1127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1128             * @return the last matching wiki page
1129             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1130             */
1131            @Override
1132            public WikiPage findByUuid_C_Last(String uuid, long companyId,
1133                    OrderByComparator<WikiPage> orderByComparator)
1134                    throws NoSuchPageException {
1135                    WikiPage wikiPage = fetchByUuid_C_Last(uuid, companyId,
1136                                    orderByComparator);
1137    
1138                    if (wikiPage != null) {
1139                            return wikiPage;
1140                    }
1141    
1142                    StringBundler msg = new StringBundler(6);
1143    
1144                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1145    
1146                    msg.append("uuid=");
1147                    msg.append(uuid);
1148    
1149                    msg.append(", companyId=");
1150                    msg.append(companyId);
1151    
1152                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1153    
1154                    throw new NoSuchPageException(msg.toString());
1155            }
1156    
1157            /**
1158             * Returns the last wiki page in the ordered set where uuid = &#63; and companyId = &#63;.
1159             *
1160             * @param uuid the uuid
1161             * @param companyId the company ID
1162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1163             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
1164             */
1165            @Override
1166            public WikiPage fetchByUuid_C_Last(String uuid, long companyId,
1167                    OrderByComparator<WikiPage> orderByComparator) {
1168                    int count = countByUuid_C(uuid, companyId);
1169    
1170                    if (count == 0) {
1171                            return null;
1172                    }
1173    
1174                    List<WikiPage> list = findByUuid_C(uuid, companyId, count - 1, count,
1175                                    orderByComparator);
1176    
1177                    if (!list.isEmpty()) {
1178                            return list.get(0);
1179                    }
1180    
1181                    return null;
1182            }
1183    
1184            /**
1185             * Returns the wiki pages before and after the current wiki page in the ordered set where uuid = &#63; and companyId = &#63;.
1186             *
1187             * @param pageId the primary key of the current wiki page
1188             * @param uuid the uuid
1189             * @param companyId the company ID
1190             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1191             * @return the previous, current, and next wiki page
1192             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
1193             */
1194            @Override
1195            public WikiPage[] findByUuid_C_PrevAndNext(long pageId, String uuid,
1196                    long companyId, OrderByComparator<WikiPage> orderByComparator)
1197                    throws NoSuchPageException {
1198                    WikiPage wikiPage = findByPrimaryKey(pageId);
1199    
1200                    Session session = null;
1201    
1202                    try {
1203                            session = openSession();
1204    
1205                            WikiPage[] array = new WikiPageImpl[3];
1206    
1207                            array[0] = getByUuid_C_PrevAndNext(session, wikiPage, uuid,
1208                                            companyId, orderByComparator, true);
1209    
1210                            array[1] = wikiPage;
1211    
1212                            array[2] = getByUuid_C_PrevAndNext(session, wikiPage, uuid,
1213                                            companyId, orderByComparator, false);
1214    
1215                            return array;
1216                    }
1217                    catch (Exception e) {
1218                            throw processException(e);
1219                    }
1220                    finally {
1221                            closeSession(session);
1222                    }
1223            }
1224    
1225            protected WikiPage getByUuid_C_PrevAndNext(Session session,
1226                    WikiPage wikiPage, String uuid, long companyId,
1227                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
1228                    StringBundler query = null;
1229    
1230                    if (orderByComparator != null) {
1231                            query = new StringBundler(6 +
1232                                            (orderByComparator.getOrderByFields().length * 6));
1233                    }
1234                    else {
1235                            query = new StringBundler(3);
1236                    }
1237    
1238                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1239    
1240                    boolean bindUuid = false;
1241    
1242                    if (uuid == null) {
1243                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1244                    }
1245                    else if (uuid.equals(StringPool.BLANK)) {
1246                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1247                    }
1248                    else {
1249                            bindUuid = true;
1250    
1251                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1252                    }
1253    
1254                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1255    
1256                    if (orderByComparator != null) {
1257                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1258    
1259                            if (orderByConditionFields.length > 0) {
1260                                    query.append(WHERE_AND);
1261                            }
1262    
1263                            for (int i = 0; i < orderByConditionFields.length; i++) {
1264                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1265                                    query.append(orderByConditionFields[i]);
1266    
1267                                    if ((i + 1) < orderByConditionFields.length) {
1268                                            if (orderByComparator.isAscending() ^ previous) {
1269                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1270                                            }
1271                                            else {
1272                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1273                                            }
1274                                    }
1275                                    else {
1276                                            if (orderByComparator.isAscending() ^ previous) {
1277                                                    query.append(WHERE_GREATER_THAN);
1278                                            }
1279                                            else {
1280                                                    query.append(WHERE_LESSER_THAN);
1281                                            }
1282                                    }
1283                            }
1284    
1285                            query.append(ORDER_BY_CLAUSE);
1286    
1287                            String[] orderByFields = orderByComparator.getOrderByFields();
1288    
1289                            for (int i = 0; i < orderByFields.length; i++) {
1290                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1291                                    query.append(orderByFields[i]);
1292    
1293                                    if ((i + 1) < orderByFields.length) {
1294                                            if (orderByComparator.isAscending() ^ previous) {
1295                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1296                                            }
1297                                            else {
1298                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1299                                            }
1300                                    }
1301                                    else {
1302                                            if (orderByComparator.isAscending() ^ previous) {
1303                                                    query.append(ORDER_BY_ASC);
1304                                            }
1305                                            else {
1306                                                    query.append(ORDER_BY_DESC);
1307                                            }
1308                                    }
1309                            }
1310                    }
1311                    else {
1312                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1313                    }
1314    
1315                    String sql = query.toString();
1316    
1317                    Query q = session.createQuery(sql);
1318    
1319                    q.setFirstResult(0);
1320                    q.setMaxResults(2);
1321    
1322                    QueryPos qPos = QueryPos.getInstance(q);
1323    
1324                    if (bindUuid) {
1325                            qPos.add(uuid);
1326                    }
1327    
1328                    qPos.add(companyId);
1329    
1330                    if (orderByComparator != null) {
1331                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
1332    
1333                            for (Object value : values) {
1334                                    qPos.add(value);
1335                            }
1336                    }
1337    
1338                    List<WikiPage> list = q.list();
1339    
1340                    if (list.size() == 2) {
1341                            return list.get(1);
1342                    }
1343                    else {
1344                            return null;
1345                    }
1346            }
1347    
1348            /**
1349             * Removes all the wiki pages where uuid = &#63; and companyId = &#63; from the database.
1350             *
1351             * @param uuid the uuid
1352             * @param companyId the company ID
1353             */
1354            @Override
1355            public void removeByUuid_C(String uuid, long companyId) {
1356                    for (WikiPage wikiPage : findByUuid_C(uuid, companyId,
1357                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1358                            remove(wikiPage);
1359                    }
1360            }
1361    
1362            /**
1363             * Returns the number of wiki pages where uuid = &#63; and companyId = &#63;.
1364             *
1365             * @param uuid the uuid
1366             * @param companyId the company ID
1367             * @return the number of matching wiki pages
1368             */
1369            @Override
1370            public int countByUuid_C(String uuid, long companyId) {
1371                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1372    
1373                    Object[] finderArgs = new Object[] { uuid, companyId };
1374    
1375                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1376                                    this);
1377    
1378                    if (count == null) {
1379                            StringBundler query = new StringBundler(3);
1380    
1381                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
1382    
1383                            boolean bindUuid = false;
1384    
1385                            if (uuid == null) {
1386                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1387                            }
1388                            else if (uuid.equals(StringPool.BLANK)) {
1389                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1390                            }
1391                            else {
1392                                    bindUuid = true;
1393    
1394                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1395                            }
1396    
1397                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1398    
1399                            String sql = query.toString();
1400    
1401                            Session session = null;
1402    
1403                            try {
1404                                    session = openSession();
1405    
1406                                    Query q = session.createQuery(sql);
1407    
1408                                    QueryPos qPos = QueryPos.getInstance(q);
1409    
1410                                    if (bindUuid) {
1411                                            qPos.add(uuid);
1412                                    }
1413    
1414                                    qPos.add(companyId);
1415    
1416                                    count = (Long)q.uniqueResult();
1417    
1418                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1419                            }
1420                            catch (Exception e) {
1421                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1422    
1423                                    throw processException(e);
1424                            }
1425                            finally {
1426                                    closeSession(session);
1427                            }
1428                    }
1429    
1430                    return count.intValue();
1431            }
1432    
1433            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "wikiPage.uuid IS NULL AND ";
1434            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "wikiPage.uuid = ? AND ";
1435            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = '') AND ";
1436            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "wikiPage.companyId = ?";
1437            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1438                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1439                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
1440                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByResourcePrimKey",
1441                            new String[] {
1442                                    Long.class.getName(),
1443                                    
1444                            Integer.class.getName(), Integer.class.getName(),
1445                                    OrderByComparator.class.getName()
1446                            });
1447            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1448                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1449                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
1450                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
1451                            new String[] { Long.class.getName() },
1452                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
1453                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
1454                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
1455                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
1456            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1457                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
1458                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1459                            "countByResourcePrimKey", new String[] { Long.class.getName() });
1460    
1461            /**
1462             * Returns all the wiki pages where resourcePrimKey = &#63;.
1463             *
1464             * @param resourcePrimKey the resource prim key
1465             * @return the matching wiki pages
1466             */
1467            @Override
1468            public List<WikiPage> findByResourcePrimKey(long resourcePrimKey) {
1469                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
1470                            QueryUtil.ALL_POS, null);
1471            }
1472    
1473            /**
1474             * Returns a range of all the wiki pages where resourcePrimKey = &#63;.
1475             *
1476             * <p>
1477             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
1478             * </p>
1479             *
1480             * @param resourcePrimKey the resource prim key
1481             * @param start the lower bound of the range of wiki pages
1482             * @param end the upper bound of the range of wiki pages (not inclusive)
1483             * @return the range of matching wiki pages
1484             */
1485            @Override
1486            public List<WikiPage> findByResourcePrimKey(long resourcePrimKey,
1487                    int start, int end) {
1488                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
1489            }
1490    
1491            /**
1492             * Returns an ordered range of all the wiki pages where resourcePrimKey = &#63;.
1493             *
1494             * <p>
1495             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
1496             * </p>
1497             *
1498             * @param resourcePrimKey the resource prim key
1499             * @param start the lower bound of the range of wiki pages
1500             * @param end the upper bound of the range of wiki pages (not inclusive)
1501             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1502             * @return the ordered range of matching wiki pages
1503             */
1504            @Override
1505            public List<WikiPage> findByResourcePrimKey(long resourcePrimKey,
1506                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
1507                    boolean pagination = true;
1508                    FinderPath finderPath = null;
1509                    Object[] finderArgs = null;
1510    
1511                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1512                                    (orderByComparator == null)) {
1513                            pagination = false;
1514                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1515                            finderArgs = new Object[] { resourcePrimKey };
1516                    }
1517                    else {
1518                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1519                            finderArgs = new Object[] {
1520                                            resourcePrimKey,
1521                                            
1522                                            start, end, orderByComparator
1523                                    };
1524                    }
1525    
1526                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
1527                                    finderArgs, this);
1528    
1529                    if ((list != null) && !list.isEmpty()) {
1530                            for (WikiPage wikiPage : list) {
1531                                    if ((resourcePrimKey != wikiPage.getResourcePrimKey())) {
1532                                            list = null;
1533    
1534                                            break;
1535                                    }
1536                            }
1537                    }
1538    
1539                    if (list == null) {
1540                            StringBundler query = null;
1541    
1542                            if (orderByComparator != null) {
1543                                    query = new StringBundler(3 +
1544                                                    (orderByComparator.getOrderByFields().length * 3));
1545                            }
1546                            else {
1547                                    query = new StringBundler(3);
1548                            }
1549    
1550                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1551    
1552                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1553    
1554                            if (orderByComparator != null) {
1555                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1556                                            orderByComparator);
1557                            }
1558                            else
1559                             if (pagination) {
1560                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1561                            }
1562    
1563                            String sql = query.toString();
1564    
1565                            Session session = null;
1566    
1567                            try {
1568                                    session = openSession();
1569    
1570                                    Query q = session.createQuery(sql);
1571    
1572                                    QueryPos qPos = QueryPos.getInstance(q);
1573    
1574                                    qPos.add(resourcePrimKey);
1575    
1576                                    if (!pagination) {
1577                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
1578                                                            start, end, false);
1579    
1580                                            Collections.sort(list);
1581    
1582                                            list = Collections.unmodifiableList(list);
1583                                    }
1584                                    else {
1585                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
1586                                                            start, end);
1587                                    }
1588    
1589                                    cacheResult(list);
1590    
1591                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1592                            }
1593                            catch (Exception e) {
1594                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1595    
1596                                    throw processException(e);
1597                            }
1598                            finally {
1599                                    closeSession(session);
1600                            }
1601                    }
1602    
1603                    return list;
1604            }
1605    
1606            /**
1607             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63;.
1608             *
1609             * @param resourcePrimKey the resource prim key
1610             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1611             * @return the first matching wiki page
1612             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1613             */
1614            @Override
1615            public WikiPage findByResourcePrimKey_First(long resourcePrimKey,
1616                    OrderByComparator<WikiPage> orderByComparator)
1617                    throws NoSuchPageException {
1618                    WikiPage wikiPage = fetchByResourcePrimKey_First(resourcePrimKey,
1619                                    orderByComparator);
1620    
1621                    if (wikiPage != null) {
1622                            return wikiPage;
1623                    }
1624    
1625                    StringBundler msg = new StringBundler(4);
1626    
1627                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1628    
1629                    msg.append("resourcePrimKey=");
1630                    msg.append(resourcePrimKey);
1631    
1632                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1633    
1634                    throw new NoSuchPageException(msg.toString());
1635            }
1636    
1637            /**
1638             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63;.
1639             *
1640             * @param resourcePrimKey the resource prim key
1641             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1642             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
1643             */
1644            @Override
1645            public WikiPage fetchByResourcePrimKey_First(long resourcePrimKey,
1646                    OrderByComparator<WikiPage> orderByComparator) {
1647                    List<WikiPage> list = findByResourcePrimKey(resourcePrimKey, 0, 1,
1648                                    orderByComparator);
1649    
1650                    if (!list.isEmpty()) {
1651                            return list.get(0);
1652                    }
1653    
1654                    return null;
1655            }
1656    
1657            /**
1658             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63;.
1659             *
1660             * @param resourcePrimKey the resource prim key
1661             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1662             * @return the last matching wiki page
1663             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1664             */
1665            @Override
1666            public WikiPage findByResourcePrimKey_Last(long resourcePrimKey,
1667                    OrderByComparator<WikiPage> orderByComparator)
1668                    throws NoSuchPageException {
1669                    WikiPage wikiPage = fetchByResourcePrimKey_Last(resourcePrimKey,
1670                                    orderByComparator);
1671    
1672                    if (wikiPage != null) {
1673                            return wikiPage;
1674                    }
1675    
1676                    StringBundler msg = new StringBundler(4);
1677    
1678                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1679    
1680                    msg.append("resourcePrimKey=");
1681                    msg.append(resourcePrimKey);
1682    
1683                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1684    
1685                    throw new NoSuchPageException(msg.toString());
1686            }
1687    
1688            /**
1689             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63;.
1690             *
1691             * @param resourcePrimKey the resource prim key
1692             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1693             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
1694             */
1695            @Override
1696            public WikiPage fetchByResourcePrimKey_Last(long resourcePrimKey,
1697                    OrderByComparator<WikiPage> orderByComparator) {
1698                    int count = countByResourcePrimKey(resourcePrimKey);
1699    
1700                    if (count == 0) {
1701                            return null;
1702                    }
1703    
1704                    List<WikiPage> list = findByResourcePrimKey(resourcePrimKey, count - 1,
1705                                    count, orderByComparator);
1706    
1707                    if (!list.isEmpty()) {
1708                            return list.get(0);
1709                    }
1710    
1711                    return null;
1712            }
1713    
1714            /**
1715             * Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63;.
1716             *
1717             * @param pageId the primary key of the current wiki page
1718             * @param resourcePrimKey the resource prim key
1719             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1720             * @return the previous, current, and next wiki page
1721             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
1722             */
1723            @Override
1724            public WikiPage[] findByResourcePrimKey_PrevAndNext(long pageId,
1725                    long resourcePrimKey, OrderByComparator<WikiPage> orderByComparator)
1726                    throws NoSuchPageException {
1727                    WikiPage wikiPage = findByPrimaryKey(pageId);
1728    
1729                    Session session = null;
1730    
1731                    try {
1732                            session = openSession();
1733    
1734                            WikiPage[] array = new WikiPageImpl[3];
1735    
1736                            array[0] = getByResourcePrimKey_PrevAndNext(session, wikiPage,
1737                                            resourcePrimKey, orderByComparator, true);
1738    
1739                            array[1] = wikiPage;
1740    
1741                            array[2] = getByResourcePrimKey_PrevAndNext(session, wikiPage,
1742                                            resourcePrimKey, orderByComparator, false);
1743    
1744                            return array;
1745                    }
1746                    catch (Exception e) {
1747                            throw processException(e);
1748                    }
1749                    finally {
1750                            closeSession(session);
1751                    }
1752            }
1753    
1754            protected WikiPage getByResourcePrimKey_PrevAndNext(Session session,
1755                    WikiPage wikiPage, long resourcePrimKey,
1756                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
1757                    StringBundler query = null;
1758    
1759                    if (orderByComparator != null) {
1760                            query = new StringBundler(6 +
1761                                            (orderByComparator.getOrderByFields().length * 6));
1762                    }
1763                    else {
1764                            query = new StringBundler(3);
1765                    }
1766    
1767                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1768    
1769                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1770    
1771                    if (orderByComparator != null) {
1772                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1773    
1774                            if (orderByConditionFields.length > 0) {
1775                                    query.append(WHERE_AND);
1776                            }
1777    
1778                            for (int i = 0; i < orderByConditionFields.length; i++) {
1779                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1780                                    query.append(orderByConditionFields[i]);
1781    
1782                                    if ((i + 1) < orderByConditionFields.length) {
1783                                            if (orderByComparator.isAscending() ^ previous) {
1784                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1785                                            }
1786                                            else {
1787                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1788                                            }
1789                                    }
1790                                    else {
1791                                            if (orderByComparator.isAscending() ^ previous) {
1792                                                    query.append(WHERE_GREATER_THAN);
1793                                            }
1794                                            else {
1795                                                    query.append(WHERE_LESSER_THAN);
1796                                            }
1797                                    }
1798                            }
1799    
1800                            query.append(ORDER_BY_CLAUSE);
1801    
1802                            String[] orderByFields = orderByComparator.getOrderByFields();
1803    
1804                            for (int i = 0; i < orderByFields.length; i++) {
1805                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1806                                    query.append(orderByFields[i]);
1807    
1808                                    if ((i + 1) < orderByFields.length) {
1809                                            if (orderByComparator.isAscending() ^ previous) {
1810                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1811                                            }
1812                                            else {
1813                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1814                                            }
1815                                    }
1816                                    else {
1817                                            if (orderByComparator.isAscending() ^ previous) {
1818                                                    query.append(ORDER_BY_ASC);
1819                                            }
1820                                            else {
1821                                                    query.append(ORDER_BY_DESC);
1822                                            }
1823                                    }
1824                            }
1825                    }
1826                    else {
1827                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1828                    }
1829    
1830                    String sql = query.toString();
1831    
1832                    Query q = session.createQuery(sql);
1833    
1834                    q.setFirstResult(0);
1835                    q.setMaxResults(2);
1836    
1837                    QueryPos qPos = QueryPos.getInstance(q);
1838    
1839                    qPos.add(resourcePrimKey);
1840    
1841                    if (orderByComparator != null) {
1842                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
1843    
1844                            for (Object value : values) {
1845                                    qPos.add(value);
1846                            }
1847                    }
1848    
1849                    List<WikiPage> list = q.list();
1850    
1851                    if (list.size() == 2) {
1852                            return list.get(1);
1853                    }
1854                    else {
1855                            return null;
1856                    }
1857            }
1858    
1859            /**
1860             * Removes all the wiki pages where resourcePrimKey = &#63; from the database.
1861             *
1862             * @param resourcePrimKey the resource prim key
1863             */
1864            @Override
1865            public void removeByResourcePrimKey(long resourcePrimKey) {
1866                    for (WikiPage wikiPage : findByResourcePrimKey(resourcePrimKey,
1867                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1868                            remove(wikiPage);
1869                    }
1870            }
1871    
1872            /**
1873             * Returns the number of wiki pages where resourcePrimKey = &#63;.
1874             *
1875             * @param resourcePrimKey the resource prim key
1876             * @return the number of matching wiki pages
1877             */
1878            @Override
1879            public int countByResourcePrimKey(long resourcePrimKey) {
1880                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY;
1881    
1882                    Object[] finderArgs = new Object[] { resourcePrimKey };
1883    
1884                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1885                                    this);
1886    
1887                    if (count == null) {
1888                            StringBundler query = new StringBundler(2);
1889    
1890                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
1891    
1892                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1893    
1894                            String sql = query.toString();
1895    
1896                            Session session = null;
1897    
1898                            try {
1899                                    session = openSession();
1900    
1901                                    Query q = session.createQuery(sql);
1902    
1903                                    QueryPos qPos = QueryPos.getInstance(q);
1904    
1905                                    qPos.add(resourcePrimKey);
1906    
1907                                    count = (Long)q.uniqueResult();
1908    
1909                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1910                            }
1911                            catch (Exception e) {
1912                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1913    
1914                                    throw processException(e);
1915                            }
1916                            finally {
1917                                    closeSession(session);
1918                            }
1919                    }
1920    
1921                    return count.intValue();
1922            }
1923    
1924            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
1925                    "wikiPage.resourcePrimKey = ?";
1926            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1927                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
1928                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByNodeId",
1929                            new String[] {
1930                                    Long.class.getName(),
1931                                    
1932                            Integer.class.getName(), Integer.class.getName(),
1933                                    OrderByComparator.class.getName()
1934                            });
1935            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID =
1936                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1937                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
1938                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByNodeId",
1939                            new String[] { Long.class.getName() },
1940                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
1941                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
1942                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
1943            public static final FinderPath FINDER_PATH_COUNT_BY_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1944                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
1945                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByNodeId",
1946                            new String[] { Long.class.getName() });
1947    
1948            /**
1949             * Returns all the wiki pages where nodeId = &#63;.
1950             *
1951             * @param nodeId the node ID
1952             * @return the matching wiki pages
1953             */
1954            @Override
1955            public List<WikiPage> findByNodeId(long nodeId) {
1956                    return findByNodeId(nodeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1957            }
1958    
1959            /**
1960             * Returns a range of all the wiki pages where nodeId = &#63;.
1961             *
1962             * <p>
1963             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
1964             * </p>
1965             *
1966             * @param nodeId the node ID
1967             * @param start the lower bound of the range of wiki pages
1968             * @param end the upper bound of the range of wiki pages (not inclusive)
1969             * @return the range of matching wiki pages
1970             */
1971            @Override
1972            public List<WikiPage> findByNodeId(long nodeId, int start, int end) {
1973                    return findByNodeId(nodeId, start, end, null);
1974            }
1975    
1976            /**
1977             * Returns an ordered range of all the wiki pages where nodeId = &#63;.
1978             *
1979             * <p>
1980             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
1981             * </p>
1982             *
1983             * @param nodeId the node ID
1984             * @param start the lower bound of the range of wiki pages
1985             * @param end the upper bound of the range of wiki pages (not inclusive)
1986             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1987             * @return the ordered range of matching wiki pages
1988             */
1989            @Override
1990            public List<WikiPage> findByNodeId(long nodeId, int start, int end,
1991                    OrderByComparator<WikiPage> orderByComparator) {
1992                    boolean pagination = true;
1993                    FinderPath finderPath = null;
1994                    Object[] finderArgs = null;
1995    
1996                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1997                                    (orderByComparator == null)) {
1998                            pagination = false;
1999                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID;
2000                            finderArgs = new Object[] { nodeId };
2001                    }
2002                    else {
2003                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NODEID;
2004                            finderArgs = new Object[] { nodeId, start, end, orderByComparator };
2005                    }
2006    
2007                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
2008                                    finderArgs, this);
2009    
2010                    if ((list != null) && !list.isEmpty()) {
2011                            for (WikiPage wikiPage : list) {
2012                                    if ((nodeId != wikiPage.getNodeId())) {
2013                                            list = null;
2014    
2015                                            break;
2016                                    }
2017                            }
2018                    }
2019    
2020                    if (list == null) {
2021                            StringBundler query = null;
2022    
2023                            if (orderByComparator != null) {
2024                                    query = new StringBundler(3 +
2025                                                    (orderByComparator.getOrderByFields().length * 3));
2026                            }
2027                            else {
2028                                    query = new StringBundler(3);
2029                            }
2030    
2031                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2032    
2033                            query.append(_FINDER_COLUMN_NODEID_NODEID_2);
2034    
2035                            if (orderByComparator != null) {
2036                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2037                                            orderByComparator);
2038                            }
2039                            else
2040                             if (pagination) {
2041                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2042                            }
2043    
2044                            String sql = query.toString();
2045    
2046                            Session session = null;
2047    
2048                            try {
2049                                    session = openSession();
2050    
2051                                    Query q = session.createQuery(sql);
2052    
2053                                    QueryPos qPos = QueryPos.getInstance(q);
2054    
2055                                    qPos.add(nodeId);
2056    
2057                                    if (!pagination) {
2058                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
2059                                                            start, end, false);
2060    
2061                                            Collections.sort(list);
2062    
2063                                            list = Collections.unmodifiableList(list);
2064                                    }
2065                                    else {
2066                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
2067                                                            start, end);
2068                                    }
2069    
2070                                    cacheResult(list);
2071    
2072                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2073                            }
2074                            catch (Exception e) {
2075                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2076    
2077                                    throw processException(e);
2078                            }
2079                            finally {
2080                                    closeSession(session);
2081                            }
2082                    }
2083    
2084                    return list;
2085            }
2086    
2087            /**
2088             * Returns the first wiki page in the ordered set where nodeId = &#63;.
2089             *
2090             * @param nodeId the node ID
2091             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2092             * @return the first matching wiki page
2093             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2094             */
2095            @Override
2096            public WikiPage findByNodeId_First(long nodeId,
2097                    OrderByComparator<WikiPage> orderByComparator)
2098                    throws NoSuchPageException {
2099                    WikiPage wikiPage = fetchByNodeId_First(nodeId, orderByComparator);
2100    
2101                    if (wikiPage != null) {
2102                            return wikiPage;
2103                    }
2104    
2105                    StringBundler msg = new StringBundler(4);
2106    
2107                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2108    
2109                    msg.append("nodeId=");
2110                    msg.append(nodeId);
2111    
2112                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2113    
2114                    throw new NoSuchPageException(msg.toString());
2115            }
2116    
2117            /**
2118             * Returns the first wiki page in the ordered set where nodeId = &#63;.
2119             *
2120             * @param nodeId the node ID
2121             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2122             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
2123             */
2124            @Override
2125            public WikiPage fetchByNodeId_First(long nodeId,
2126                    OrderByComparator<WikiPage> orderByComparator) {
2127                    List<WikiPage> list = findByNodeId(nodeId, 0, 1, orderByComparator);
2128    
2129                    if (!list.isEmpty()) {
2130                            return list.get(0);
2131                    }
2132    
2133                    return null;
2134            }
2135    
2136            /**
2137             * Returns the last wiki page in the ordered set where nodeId = &#63;.
2138             *
2139             * @param nodeId the node ID
2140             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2141             * @return the last matching wiki page
2142             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2143             */
2144            @Override
2145            public WikiPage findByNodeId_Last(long nodeId,
2146                    OrderByComparator<WikiPage> orderByComparator)
2147                    throws NoSuchPageException {
2148                    WikiPage wikiPage = fetchByNodeId_Last(nodeId, orderByComparator);
2149    
2150                    if (wikiPage != null) {
2151                            return wikiPage;
2152                    }
2153    
2154                    StringBundler msg = new StringBundler(4);
2155    
2156                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2157    
2158                    msg.append("nodeId=");
2159                    msg.append(nodeId);
2160    
2161                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2162    
2163                    throw new NoSuchPageException(msg.toString());
2164            }
2165    
2166            /**
2167             * Returns the last wiki page in the ordered set where nodeId = &#63;.
2168             *
2169             * @param nodeId the node ID
2170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2171             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
2172             */
2173            @Override
2174            public WikiPage fetchByNodeId_Last(long nodeId,
2175                    OrderByComparator<WikiPage> orderByComparator) {
2176                    int count = countByNodeId(nodeId);
2177    
2178                    if (count == 0) {
2179                            return null;
2180                    }
2181    
2182                    List<WikiPage> list = findByNodeId(nodeId, count - 1, count,
2183                                    orderByComparator);
2184    
2185                    if (!list.isEmpty()) {
2186                            return list.get(0);
2187                    }
2188    
2189                    return null;
2190            }
2191    
2192            /**
2193             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63;.
2194             *
2195             * @param pageId the primary key of the current wiki page
2196             * @param nodeId the node ID
2197             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2198             * @return the previous, current, and next wiki page
2199             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
2200             */
2201            @Override
2202            public WikiPage[] findByNodeId_PrevAndNext(long pageId, long nodeId,
2203                    OrderByComparator<WikiPage> orderByComparator)
2204                    throws NoSuchPageException {
2205                    WikiPage wikiPage = findByPrimaryKey(pageId);
2206    
2207                    Session session = null;
2208    
2209                    try {
2210                            session = openSession();
2211    
2212                            WikiPage[] array = new WikiPageImpl[3];
2213    
2214                            array[0] = getByNodeId_PrevAndNext(session, wikiPage, nodeId,
2215                                            orderByComparator, true);
2216    
2217                            array[1] = wikiPage;
2218    
2219                            array[2] = getByNodeId_PrevAndNext(session, wikiPage, nodeId,
2220                                            orderByComparator, false);
2221    
2222                            return array;
2223                    }
2224                    catch (Exception e) {
2225                            throw processException(e);
2226                    }
2227                    finally {
2228                            closeSession(session);
2229                    }
2230            }
2231    
2232            protected WikiPage getByNodeId_PrevAndNext(Session session,
2233                    WikiPage wikiPage, long nodeId,
2234                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
2235                    StringBundler query = null;
2236    
2237                    if (orderByComparator != null) {
2238                            query = new StringBundler(6 +
2239                                            (orderByComparator.getOrderByFields().length * 6));
2240                    }
2241                    else {
2242                            query = new StringBundler(3);
2243                    }
2244    
2245                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2246    
2247                    query.append(_FINDER_COLUMN_NODEID_NODEID_2);
2248    
2249                    if (orderByComparator != null) {
2250                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2251    
2252                            if (orderByConditionFields.length > 0) {
2253                                    query.append(WHERE_AND);
2254                            }
2255    
2256                            for (int i = 0; i < orderByConditionFields.length; i++) {
2257                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2258                                    query.append(orderByConditionFields[i]);
2259    
2260                                    if ((i + 1) < orderByConditionFields.length) {
2261                                            if (orderByComparator.isAscending() ^ previous) {
2262                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2263                                            }
2264                                            else {
2265                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2266                                            }
2267                                    }
2268                                    else {
2269                                            if (orderByComparator.isAscending() ^ previous) {
2270                                                    query.append(WHERE_GREATER_THAN);
2271                                            }
2272                                            else {
2273                                                    query.append(WHERE_LESSER_THAN);
2274                                            }
2275                                    }
2276                            }
2277    
2278                            query.append(ORDER_BY_CLAUSE);
2279    
2280                            String[] orderByFields = orderByComparator.getOrderByFields();
2281    
2282                            for (int i = 0; i < orderByFields.length; i++) {
2283                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2284                                    query.append(orderByFields[i]);
2285    
2286                                    if ((i + 1) < orderByFields.length) {
2287                                            if (orderByComparator.isAscending() ^ previous) {
2288                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2289                                            }
2290                                            else {
2291                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2292                                            }
2293                                    }
2294                                    else {
2295                                            if (orderByComparator.isAscending() ^ previous) {
2296                                                    query.append(ORDER_BY_ASC);
2297                                            }
2298                                            else {
2299                                                    query.append(ORDER_BY_DESC);
2300                                            }
2301                                    }
2302                            }
2303                    }
2304                    else {
2305                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2306                    }
2307    
2308                    String sql = query.toString();
2309    
2310                    Query q = session.createQuery(sql);
2311    
2312                    q.setFirstResult(0);
2313                    q.setMaxResults(2);
2314    
2315                    QueryPos qPos = QueryPos.getInstance(q);
2316    
2317                    qPos.add(nodeId);
2318    
2319                    if (orderByComparator != null) {
2320                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
2321    
2322                            for (Object value : values) {
2323                                    qPos.add(value);
2324                            }
2325                    }
2326    
2327                    List<WikiPage> list = q.list();
2328    
2329                    if (list.size() == 2) {
2330                            return list.get(1);
2331                    }
2332                    else {
2333                            return null;
2334                    }
2335            }
2336    
2337            /**
2338             * Removes all the wiki pages where nodeId = &#63; from the database.
2339             *
2340             * @param nodeId the node ID
2341             */
2342            @Override
2343            public void removeByNodeId(long nodeId) {
2344                    for (WikiPage wikiPage : findByNodeId(nodeId, QueryUtil.ALL_POS,
2345                                    QueryUtil.ALL_POS, null)) {
2346                            remove(wikiPage);
2347                    }
2348            }
2349    
2350            /**
2351             * Returns the number of wiki pages where nodeId = &#63;.
2352             *
2353             * @param nodeId the node ID
2354             * @return the number of matching wiki pages
2355             */
2356            @Override
2357            public int countByNodeId(long nodeId) {
2358                    FinderPath finderPath = FINDER_PATH_COUNT_BY_NODEID;
2359    
2360                    Object[] finderArgs = new Object[] { nodeId };
2361    
2362                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2363                                    this);
2364    
2365                    if (count == null) {
2366                            StringBundler query = new StringBundler(2);
2367    
2368                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
2369    
2370                            query.append(_FINDER_COLUMN_NODEID_NODEID_2);
2371    
2372                            String sql = query.toString();
2373    
2374                            Session session = null;
2375    
2376                            try {
2377                                    session = openSession();
2378    
2379                                    Query q = session.createQuery(sql);
2380    
2381                                    QueryPos qPos = QueryPos.getInstance(q);
2382    
2383                                    qPos.add(nodeId);
2384    
2385                                    count = (Long)q.uniqueResult();
2386    
2387                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2388                            }
2389                            catch (Exception e) {
2390                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2391    
2392                                    throw processException(e);
2393                            }
2394                            finally {
2395                                    closeSession(session);
2396                            }
2397                    }
2398    
2399                    return count.intValue();
2400            }
2401    
2402            private static final String _FINDER_COLUMN_NODEID_NODEID_2 = "wikiPage.nodeId = ?";
2403            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2404                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
2405                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFormat",
2406                            new String[] {
2407                                    String.class.getName(),
2408                                    
2409                            Integer.class.getName(), Integer.class.getName(),
2410                                    OrderByComparator.class.getName()
2411                            });
2412            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT =
2413                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2414                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
2415                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFormat",
2416                            new String[] { String.class.getName() },
2417                            WikiPageModelImpl.FORMAT_COLUMN_BITMASK |
2418                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
2419                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
2420                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
2421            public static final FinderPath FINDER_PATH_COUNT_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2422                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
2423                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFormat",
2424                            new String[] { String.class.getName() });
2425    
2426            /**
2427             * Returns all the wiki pages where format = &#63;.
2428             *
2429             * @param format the format
2430             * @return the matching wiki pages
2431             */
2432            @Override
2433            public List<WikiPage> findByFormat(String format) {
2434                    return findByFormat(format, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2435            }
2436    
2437            /**
2438             * Returns a range of all the wiki pages where format = &#63;.
2439             *
2440             * <p>
2441             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
2442             * </p>
2443             *
2444             * @param format the format
2445             * @param start the lower bound of the range of wiki pages
2446             * @param end the upper bound of the range of wiki pages (not inclusive)
2447             * @return the range of matching wiki pages
2448             */
2449            @Override
2450            public List<WikiPage> findByFormat(String format, int start, int end) {
2451                    return findByFormat(format, start, end, null);
2452            }
2453    
2454            /**
2455             * Returns an ordered range of all the wiki pages where format = &#63;.
2456             *
2457             * <p>
2458             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
2459             * </p>
2460             *
2461             * @param format the format
2462             * @param start the lower bound of the range of wiki pages
2463             * @param end the upper bound of the range of wiki pages (not inclusive)
2464             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2465             * @return the ordered range of matching wiki pages
2466             */
2467            @Override
2468            public List<WikiPage> findByFormat(String format, int start, int end,
2469                    OrderByComparator<WikiPage> orderByComparator) {
2470                    boolean pagination = true;
2471                    FinderPath finderPath = null;
2472                    Object[] finderArgs = null;
2473    
2474                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2475                                    (orderByComparator == null)) {
2476                            pagination = false;
2477                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT;
2478                            finderArgs = new Object[] { format };
2479                    }
2480                    else {
2481                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FORMAT;
2482                            finderArgs = new Object[] { format, start, end, orderByComparator };
2483                    }
2484    
2485                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
2486                                    finderArgs, this);
2487    
2488                    if ((list != null) && !list.isEmpty()) {
2489                            for (WikiPage wikiPage : list) {
2490                                    if (!Validator.equals(format, wikiPage.getFormat())) {
2491                                            list = null;
2492    
2493                                            break;
2494                                    }
2495                            }
2496                    }
2497    
2498                    if (list == null) {
2499                            StringBundler query = null;
2500    
2501                            if (orderByComparator != null) {
2502                                    query = new StringBundler(3 +
2503                                                    (orderByComparator.getOrderByFields().length * 3));
2504                            }
2505                            else {
2506                                    query = new StringBundler(3);
2507                            }
2508    
2509                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2510    
2511                            boolean bindFormat = false;
2512    
2513                            if (format == null) {
2514                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
2515                            }
2516                            else if (format.equals(StringPool.BLANK)) {
2517                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
2518                            }
2519                            else {
2520                                    bindFormat = true;
2521    
2522                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
2523                            }
2524    
2525                            if (orderByComparator != null) {
2526                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2527                                            orderByComparator);
2528                            }
2529                            else
2530                             if (pagination) {
2531                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2532                            }
2533    
2534                            String sql = query.toString();
2535    
2536                            Session session = null;
2537    
2538                            try {
2539                                    session = openSession();
2540    
2541                                    Query q = session.createQuery(sql);
2542    
2543                                    QueryPos qPos = QueryPos.getInstance(q);
2544    
2545                                    if (bindFormat) {
2546                                            qPos.add(format);
2547                                    }
2548    
2549                                    if (!pagination) {
2550                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
2551                                                            start, end, false);
2552    
2553                                            Collections.sort(list);
2554    
2555                                            list = Collections.unmodifiableList(list);
2556                                    }
2557                                    else {
2558                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
2559                                                            start, end);
2560                                    }
2561    
2562                                    cacheResult(list);
2563    
2564                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2565                            }
2566                            catch (Exception e) {
2567                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2568    
2569                                    throw processException(e);
2570                            }
2571                            finally {
2572                                    closeSession(session);
2573                            }
2574                    }
2575    
2576                    return list;
2577            }
2578    
2579            /**
2580             * Returns the first wiki page in the ordered set where format = &#63;.
2581             *
2582             * @param format the format
2583             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2584             * @return the first matching wiki page
2585             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2586             */
2587            @Override
2588            public WikiPage findByFormat_First(String format,
2589                    OrderByComparator<WikiPage> orderByComparator)
2590                    throws NoSuchPageException {
2591                    WikiPage wikiPage = fetchByFormat_First(format, orderByComparator);
2592    
2593                    if (wikiPage != null) {
2594                            return wikiPage;
2595                    }
2596    
2597                    StringBundler msg = new StringBundler(4);
2598    
2599                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2600    
2601                    msg.append("format=");
2602                    msg.append(format);
2603    
2604                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2605    
2606                    throw new NoSuchPageException(msg.toString());
2607            }
2608    
2609            /**
2610             * Returns the first wiki page in the ordered set where format = &#63;.
2611             *
2612             * @param format the format
2613             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2614             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
2615             */
2616            @Override
2617            public WikiPage fetchByFormat_First(String format,
2618                    OrderByComparator<WikiPage> orderByComparator) {
2619                    List<WikiPage> list = findByFormat(format, 0, 1, orderByComparator);
2620    
2621                    if (!list.isEmpty()) {
2622                            return list.get(0);
2623                    }
2624    
2625                    return null;
2626            }
2627    
2628            /**
2629             * Returns the last wiki page in the ordered set where format = &#63;.
2630             *
2631             * @param format the format
2632             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2633             * @return the last matching wiki page
2634             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2635             */
2636            @Override
2637            public WikiPage findByFormat_Last(String format,
2638                    OrderByComparator<WikiPage> orderByComparator)
2639                    throws NoSuchPageException {
2640                    WikiPage wikiPage = fetchByFormat_Last(format, orderByComparator);
2641    
2642                    if (wikiPage != null) {
2643                            return wikiPage;
2644                    }
2645    
2646                    StringBundler msg = new StringBundler(4);
2647    
2648                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2649    
2650                    msg.append("format=");
2651                    msg.append(format);
2652    
2653                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2654    
2655                    throw new NoSuchPageException(msg.toString());
2656            }
2657    
2658            /**
2659             * Returns the last wiki page in the ordered set where format = &#63;.
2660             *
2661             * @param format the format
2662             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2663             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
2664             */
2665            @Override
2666            public WikiPage fetchByFormat_Last(String format,
2667                    OrderByComparator<WikiPage> orderByComparator) {
2668                    int count = countByFormat(format);
2669    
2670                    if (count == 0) {
2671                            return null;
2672                    }
2673    
2674                    List<WikiPage> list = findByFormat(format, count - 1, count,
2675                                    orderByComparator);
2676    
2677                    if (!list.isEmpty()) {
2678                            return list.get(0);
2679                    }
2680    
2681                    return null;
2682            }
2683    
2684            /**
2685             * Returns the wiki pages before and after the current wiki page in the ordered set where format = &#63;.
2686             *
2687             * @param pageId the primary key of the current wiki page
2688             * @param format the format
2689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2690             * @return the previous, current, and next wiki page
2691             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
2692             */
2693            @Override
2694            public WikiPage[] findByFormat_PrevAndNext(long pageId, String format,
2695                    OrderByComparator<WikiPage> orderByComparator)
2696                    throws NoSuchPageException {
2697                    WikiPage wikiPage = findByPrimaryKey(pageId);
2698    
2699                    Session session = null;
2700    
2701                    try {
2702                            session = openSession();
2703    
2704                            WikiPage[] array = new WikiPageImpl[3];
2705    
2706                            array[0] = getByFormat_PrevAndNext(session, wikiPage, format,
2707                                            orderByComparator, true);
2708    
2709                            array[1] = wikiPage;
2710    
2711                            array[2] = getByFormat_PrevAndNext(session, wikiPage, format,
2712                                            orderByComparator, false);
2713    
2714                            return array;
2715                    }
2716                    catch (Exception e) {
2717                            throw processException(e);
2718                    }
2719                    finally {
2720                            closeSession(session);
2721                    }
2722            }
2723    
2724            protected WikiPage getByFormat_PrevAndNext(Session session,
2725                    WikiPage wikiPage, String format,
2726                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
2727                    StringBundler query = null;
2728    
2729                    if (orderByComparator != null) {
2730                            query = new StringBundler(6 +
2731                                            (orderByComparator.getOrderByFields().length * 6));
2732                    }
2733                    else {
2734                            query = new StringBundler(3);
2735                    }
2736    
2737                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2738    
2739                    boolean bindFormat = false;
2740    
2741                    if (format == null) {
2742                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
2743                    }
2744                    else if (format.equals(StringPool.BLANK)) {
2745                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
2746                    }
2747                    else {
2748                            bindFormat = true;
2749    
2750                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
2751                    }
2752    
2753                    if (orderByComparator != null) {
2754                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2755    
2756                            if (orderByConditionFields.length > 0) {
2757                                    query.append(WHERE_AND);
2758                            }
2759    
2760                            for (int i = 0; i < orderByConditionFields.length; i++) {
2761                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2762                                    query.append(orderByConditionFields[i]);
2763    
2764                                    if ((i + 1) < orderByConditionFields.length) {
2765                                            if (orderByComparator.isAscending() ^ previous) {
2766                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2767                                            }
2768                                            else {
2769                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2770                                            }
2771                                    }
2772                                    else {
2773                                            if (orderByComparator.isAscending() ^ previous) {
2774                                                    query.append(WHERE_GREATER_THAN);
2775                                            }
2776                                            else {
2777                                                    query.append(WHERE_LESSER_THAN);
2778                                            }
2779                                    }
2780                            }
2781    
2782                            query.append(ORDER_BY_CLAUSE);
2783    
2784                            String[] orderByFields = orderByComparator.getOrderByFields();
2785    
2786                            for (int i = 0; i < orderByFields.length; i++) {
2787                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2788                                    query.append(orderByFields[i]);
2789    
2790                                    if ((i + 1) < orderByFields.length) {
2791                                            if (orderByComparator.isAscending() ^ previous) {
2792                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2793                                            }
2794                                            else {
2795                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2796                                            }
2797                                    }
2798                                    else {
2799                                            if (orderByComparator.isAscending() ^ previous) {
2800                                                    query.append(ORDER_BY_ASC);
2801                                            }
2802                                            else {
2803                                                    query.append(ORDER_BY_DESC);
2804                                            }
2805                                    }
2806                            }
2807                    }
2808                    else {
2809                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2810                    }
2811    
2812                    String sql = query.toString();
2813    
2814                    Query q = session.createQuery(sql);
2815    
2816                    q.setFirstResult(0);
2817                    q.setMaxResults(2);
2818    
2819                    QueryPos qPos = QueryPos.getInstance(q);
2820    
2821                    if (bindFormat) {
2822                            qPos.add(format);
2823                    }
2824    
2825                    if (orderByComparator != null) {
2826                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
2827    
2828                            for (Object value : values) {
2829                                    qPos.add(value);
2830                            }
2831                    }
2832    
2833                    List<WikiPage> list = q.list();
2834    
2835                    if (list.size() == 2) {
2836                            return list.get(1);
2837                    }
2838                    else {
2839                            return null;
2840                    }
2841            }
2842    
2843            /**
2844             * Removes all the wiki pages where format = &#63; from the database.
2845             *
2846             * @param format the format
2847             */
2848            @Override
2849            public void removeByFormat(String format) {
2850                    for (WikiPage wikiPage : findByFormat(format, QueryUtil.ALL_POS,
2851                                    QueryUtil.ALL_POS, null)) {
2852                            remove(wikiPage);
2853                    }
2854            }
2855    
2856            /**
2857             * Returns the number of wiki pages where format = &#63;.
2858             *
2859             * @param format the format
2860             * @return the number of matching wiki pages
2861             */
2862            @Override
2863            public int countByFormat(String format) {
2864                    FinderPath finderPath = FINDER_PATH_COUNT_BY_FORMAT;
2865    
2866                    Object[] finderArgs = new Object[] { format };
2867    
2868                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2869                                    this);
2870    
2871                    if (count == null) {
2872                            StringBundler query = new StringBundler(2);
2873    
2874                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
2875    
2876                            boolean bindFormat = false;
2877    
2878                            if (format == null) {
2879                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
2880                            }
2881                            else if (format.equals(StringPool.BLANK)) {
2882                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
2883                            }
2884                            else {
2885                                    bindFormat = true;
2886    
2887                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
2888                            }
2889    
2890                            String sql = query.toString();
2891    
2892                            Session session = null;
2893    
2894                            try {
2895                                    session = openSession();
2896    
2897                                    Query q = session.createQuery(sql);
2898    
2899                                    QueryPos qPos = QueryPos.getInstance(q);
2900    
2901                                    if (bindFormat) {
2902                                            qPos.add(format);
2903                                    }
2904    
2905                                    count = (Long)q.uniqueResult();
2906    
2907                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2908                            }
2909                            catch (Exception e) {
2910                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2911    
2912                                    throw processException(e);
2913                            }
2914                            finally {
2915                                    closeSession(session);
2916                            }
2917                    }
2918    
2919                    return count.intValue();
2920            }
2921    
2922            private static final String _FINDER_COLUMN_FORMAT_FORMAT_1 = "wikiPage.format IS NULL";
2923            private static final String _FINDER_COLUMN_FORMAT_FORMAT_2 = "wikiPage.format = ?";
2924            private static final String _FINDER_COLUMN_FORMAT_FORMAT_3 = "(wikiPage.format IS NULL OR wikiPage.format = '')";
2925            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2926                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
2927                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_N",
2928                            new String[] {
2929                                    Long.class.getName(), Long.class.getName(),
2930                                    
2931                            Integer.class.getName(), Integer.class.getName(),
2932                                    OrderByComparator.class.getName()
2933                            });
2934            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2935                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
2936                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_N",
2937                            new String[] { Long.class.getName(), Long.class.getName() },
2938                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
2939                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
2940                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
2941                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
2942            public static final FinderPath FINDER_PATH_COUNT_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2943                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
2944                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N",
2945                            new String[] { Long.class.getName(), Long.class.getName() });
2946    
2947            /**
2948             * Returns all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
2949             *
2950             * @param resourcePrimKey the resource prim key
2951             * @param nodeId the node ID
2952             * @return the matching wiki pages
2953             */
2954            @Override
2955            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId) {
2956                    return findByR_N(resourcePrimKey, nodeId, QueryUtil.ALL_POS,
2957                            QueryUtil.ALL_POS, null);
2958            }
2959    
2960            /**
2961             * Returns a range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
2962             *
2963             * <p>
2964             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
2965             * </p>
2966             *
2967             * @param resourcePrimKey the resource prim key
2968             * @param nodeId the node ID
2969             * @param start the lower bound of the range of wiki pages
2970             * @param end the upper bound of the range of wiki pages (not inclusive)
2971             * @return the range of matching wiki pages
2972             */
2973            @Override
2974            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId,
2975                    int start, int end) {
2976                    return findByR_N(resourcePrimKey, nodeId, start, end, null);
2977            }
2978    
2979            /**
2980             * Returns an ordered range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
2981             *
2982             * <p>
2983             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
2984             * </p>
2985             *
2986             * @param resourcePrimKey the resource prim key
2987             * @param nodeId the node ID
2988             * @param start the lower bound of the range of wiki pages
2989             * @param end the upper bound of the range of wiki pages (not inclusive)
2990             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2991             * @return the ordered range of matching wiki pages
2992             */
2993            @Override
2994            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId,
2995                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
2996                    boolean pagination = true;
2997                    FinderPath finderPath = null;
2998                    Object[] finderArgs = null;
2999    
3000                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3001                                    (orderByComparator == null)) {
3002                            pagination = false;
3003                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N;
3004                            finderArgs = new Object[] { resourcePrimKey, nodeId };
3005                    }
3006                    else {
3007                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N;
3008                            finderArgs = new Object[] {
3009                                            resourcePrimKey, nodeId,
3010                                            
3011                                            start, end, orderByComparator
3012                                    };
3013                    }
3014    
3015                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
3016                                    finderArgs, this);
3017    
3018                    if ((list != null) && !list.isEmpty()) {
3019                            for (WikiPage wikiPage : list) {
3020                                    if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
3021                                                    (nodeId != wikiPage.getNodeId())) {
3022                                            list = null;
3023    
3024                                            break;
3025                                    }
3026                            }
3027                    }
3028    
3029                    if (list == null) {
3030                            StringBundler query = null;
3031    
3032                            if (orderByComparator != null) {
3033                                    query = new StringBundler(4 +
3034                                                    (orderByComparator.getOrderByFields().length * 3));
3035                            }
3036                            else {
3037                                    query = new StringBundler(4);
3038                            }
3039    
3040                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3041    
3042                            query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
3043    
3044                            query.append(_FINDER_COLUMN_R_N_NODEID_2);
3045    
3046                            if (orderByComparator != null) {
3047                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3048                                            orderByComparator);
3049                            }
3050                            else
3051                             if (pagination) {
3052                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3053                            }
3054    
3055                            String sql = query.toString();
3056    
3057                            Session session = null;
3058    
3059                            try {
3060                                    session = openSession();
3061    
3062                                    Query q = session.createQuery(sql);
3063    
3064                                    QueryPos qPos = QueryPos.getInstance(q);
3065    
3066                                    qPos.add(resourcePrimKey);
3067    
3068                                    qPos.add(nodeId);
3069    
3070                                    if (!pagination) {
3071                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3072                                                            start, end, false);
3073    
3074                                            Collections.sort(list);
3075    
3076                                            list = Collections.unmodifiableList(list);
3077                                    }
3078                                    else {
3079                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3080                                                            start, end);
3081                                    }
3082    
3083                                    cacheResult(list);
3084    
3085                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3086                            }
3087                            catch (Exception e) {
3088                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3089    
3090                                    throw processException(e);
3091                            }
3092                            finally {
3093                                    closeSession(session);
3094                            }
3095                    }
3096    
3097                    return list;
3098            }
3099    
3100            /**
3101             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
3102             *
3103             * @param resourcePrimKey the resource prim key
3104             * @param nodeId the node ID
3105             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3106             * @return the first matching wiki page
3107             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3108             */
3109            @Override
3110            public WikiPage findByR_N_First(long resourcePrimKey, long nodeId,
3111                    OrderByComparator<WikiPage> orderByComparator)
3112                    throws NoSuchPageException {
3113                    WikiPage wikiPage = fetchByR_N_First(resourcePrimKey, nodeId,
3114                                    orderByComparator);
3115    
3116                    if (wikiPage != null) {
3117                            return wikiPage;
3118                    }
3119    
3120                    StringBundler msg = new StringBundler(6);
3121    
3122                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3123    
3124                    msg.append("resourcePrimKey=");
3125                    msg.append(resourcePrimKey);
3126    
3127                    msg.append(", nodeId=");
3128                    msg.append(nodeId);
3129    
3130                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3131    
3132                    throw new NoSuchPageException(msg.toString());
3133            }
3134    
3135            /**
3136             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
3137             *
3138             * @param resourcePrimKey the resource prim key
3139             * @param nodeId the node ID
3140             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3141             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
3142             */
3143            @Override
3144            public WikiPage fetchByR_N_First(long resourcePrimKey, long nodeId,
3145                    OrderByComparator<WikiPage> orderByComparator) {
3146                    List<WikiPage> list = findByR_N(resourcePrimKey, nodeId, 0, 1,
3147                                    orderByComparator);
3148    
3149                    if (!list.isEmpty()) {
3150                            return list.get(0);
3151                    }
3152    
3153                    return null;
3154            }
3155    
3156            /**
3157             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
3158             *
3159             * @param resourcePrimKey the resource prim key
3160             * @param nodeId the node ID
3161             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3162             * @return the last matching wiki page
3163             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3164             */
3165            @Override
3166            public WikiPage findByR_N_Last(long resourcePrimKey, long nodeId,
3167                    OrderByComparator<WikiPage> orderByComparator)
3168                    throws NoSuchPageException {
3169                    WikiPage wikiPage = fetchByR_N_Last(resourcePrimKey, nodeId,
3170                                    orderByComparator);
3171    
3172                    if (wikiPage != null) {
3173                            return wikiPage;
3174                    }
3175    
3176                    StringBundler msg = new StringBundler(6);
3177    
3178                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3179    
3180                    msg.append("resourcePrimKey=");
3181                    msg.append(resourcePrimKey);
3182    
3183                    msg.append(", nodeId=");
3184                    msg.append(nodeId);
3185    
3186                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3187    
3188                    throw new NoSuchPageException(msg.toString());
3189            }
3190    
3191            /**
3192             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
3193             *
3194             * @param resourcePrimKey the resource prim key
3195             * @param nodeId the node ID
3196             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3197             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
3198             */
3199            @Override
3200            public WikiPage fetchByR_N_Last(long resourcePrimKey, long nodeId,
3201                    OrderByComparator<WikiPage> orderByComparator) {
3202                    int count = countByR_N(resourcePrimKey, nodeId);
3203    
3204                    if (count == 0) {
3205                            return null;
3206                    }
3207    
3208                    List<WikiPage> list = findByR_N(resourcePrimKey, nodeId, count - 1,
3209                                    count, orderByComparator);
3210    
3211                    if (!list.isEmpty()) {
3212                            return list.get(0);
3213                    }
3214    
3215                    return null;
3216            }
3217    
3218            /**
3219             * Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
3220             *
3221             * @param pageId the primary key of the current wiki page
3222             * @param resourcePrimKey the resource prim key
3223             * @param nodeId the node ID
3224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3225             * @return the previous, current, and next wiki page
3226             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
3227             */
3228            @Override
3229            public WikiPage[] findByR_N_PrevAndNext(long pageId, long resourcePrimKey,
3230                    long nodeId, OrderByComparator<WikiPage> orderByComparator)
3231                    throws NoSuchPageException {
3232                    WikiPage wikiPage = findByPrimaryKey(pageId);
3233    
3234                    Session session = null;
3235    
3236                    try {
3237                            session = openSession();
3238    
3239                            WikiPage[] array = new WikiPageImpl[3];
3240    
3241                            array[0] = getByR_N_PrevAndNext(session, wikiPage, resourcePrimKey,
3242                                            nodeId, orderByComparator, true);
3243    
3244                            array[1] = wikiPage;
3245    
3246                            array[2] = getByR_N_PrevAndNext(session, wikiPage, resourcePrimKey,
3247                                            nodeId, orderByComparator, false);
3248    
3249                            return array;
3250                    }
3251                    catch (Exception e) {
3252                            throw processException(e);
3253                    }
3254                    finally {
3255                            closeSession(session);
3256                    }
3257            }
3258    
3259            protected WikiPage getByR_N_PrevAndNext(Session session, WikiPage wikiPage,
3260                    long resourcePrimKey, long nodeId,
3261                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
3262                    StringBundler query = null;
3263    
3264                    if (orderByComparator != null) {
3265                            query = new StringBundler(6 +
3266                                            (orderByComparator.getOrderByFields().length * 6));
3267                    }
3268                    else {
3269                            query = new StringBundler(3);
3270                    }
3271    
3272                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3273    
3274                    query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
3275    
3276                    query.append(_FINDER_COLUMN_R_N_NODEID_2);
3277    
3278                    if (orderByComparator != null) {
3279                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3280    
3281                            if (orderByConditionFields.length > 0) {
3282                                    query.append(WHERE_AND);
3283                            }
3284    
3285                            for (int i = 0; i < orderByConditionFields.length; i++) {
3286                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3287                                    query.append(orderByConditionFields[i]);
3288    
3289                                    if ((i + 1) < orderByConditionFields.length) {
3290                                            if (orderByComparator.isAscending() ^ previous) {
3291                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3292                                            }
3293                                            else {
3294                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3295                                            }
3296                                    }
3297                                    else {
3298                                            if (orderByComparator.isAscending() ^ previous) {
3299                                                    query.append(WHERE_GREATER_THAN);
3300                                            }
3301                                            else {
3302                                                    query.append(WHERE_LESSER_THAN);
3303                                            }
3304                                    }
3305                            }
3306    
3307                            query.append(ORDER_BY_CLAUSE);
3308    
3309                            String[] orderByFields = orderByComparator.getOrderByFields();
3310    
3311                            for (int i = 0; i < orderByFields.length; i++) {
3312                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3313                                    query.append(orderByFields[i]);
3314    
3315                                    if ((i + 1) < orderByFields.length) {
3316                                            if (orderByComparator.isAscending() ^ previous) {
3317                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3318                                            }
3319                                            else {
3320                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3321                                            }
3322                                    }
3323                                    else {
3324                                            if (orderByComparator.isAscending() ^ previous) {
3325                                                    query.append(ORDER_BY_ASC);
3326                                            }
3327                                            else {
3328                                                    query.append(ORDER_BY_DESC);
3329                                            }
3330                                    }
3331                            }
3332                    }
3333                    else {
3334                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3335                    }
3336    
3337                    String sql = query.toString();
3338    
3339                    Query q = session.createQuery(sql);
3340    
3341                    q.setFirstResult(0);
3342                    q.setMaxResults(2);
3343    
3344                    QueryPos qPos = QueryPos.getInstance(q);
3345    
3346                    qPos.add(resourcePrimKey);
3347    
3348                    qPos.add(nodeId);
3349    
3350                    if (orderByComparator != null) {
3351                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
3352    
3353                            for (Object value : values) {
3354                                    qPos.add(value);
3355                            }
3356                    }
3357    
3358                    List<WikiPage> list = q.list();
3359    
3360                    if (list.size() == 2) {
3361                            return list.get(1);
3362                    }
3363                    else {
3364                            return null;
3365                    }
3366            }
3367    
3368            /**
3369             * Removes all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; from the database.
3370             *
3371             * @param resourcePrimKey the resource prim key
3372             * @param nodeId the node ID
3373             */
3374            @Override
3375            public void removeByR_N(long resourcePrimKey, long nodeId) {
3376                    for (WikiPage wikiPage : findByR_N(resourcePrimKey, nodeId,
3377                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3378                            remove(wikiPage);
3379                    }
3380            }
3381    
3382            /**
3383             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
3384             *
3385             * @param resourcePrimKey the resource prim key
3386             * @param nodeId the node ID
3387             * @return the number of matching wiki pages
3388             */
3389            @Override
3390            public int countByR_N(long resourcePrimKey, long nodeId) {
3391                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_N;
3392    
3393                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId };
3394    
3395                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3396                                    this);
3397    
3398                    if (count == null) {
3399                            StringBundler query = new StringBundler(3);
3400    
3401                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3402    
3403                            query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
3404    
3405                            query.append(_FINDER_COLUMN_R_N_NODEID_2);
3406    
3407                            String sql = query.toString();
3408    
3409                            Session session = null;
3410    
3411                            try {
3412                                    session = openSession();
3413    
3414                                    Query q = session.createQuery(sql);
3415    
3416                                    QueryPos qPos = QueryPos.getInstance(q);
3417    
3418                                    qPos.add(resourcePrimKey);
3419    
3420                                    qPos.add(nodeId);
3421    
3422                                    count = (Long)q.uniqueResult();
3423    
3424                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3425                            }
3426                            catch (Exception e) {
3427                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3428    
3429                                    throw processException(e);
3430                            }
3431                            finally {
3432                                    closeSession(session);
3433                            }
3434                    }
3435    
3436                    return count.intValue();
3437            }
3438    
3439            private static final String _FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
3440            private static final String _FINDER_COLUMN_R_N_NODEID_2 = "wikiPage.nodeId = ?";
3441            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
3442                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
3443                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_S",
3444                            new String[] {
3445                                    Long.class.getName(), Integer.class.getName(),
3446                                    
3447                            Integer.class.getName(), Integer.class.getName(),
3448                                    OrderByComparator.class.getName()
3449                            });
3450            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
3451                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
3452                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_S",
3453                            new String[] { Long.class.getName(), Integer.class.getName() },
3454                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
3455                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
3456                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
3457                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
3458                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
3459            public static final FinderPath FINDER_PATH_COUNT_BY_R_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
3460                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
3461                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_S",
3462                            new String[] { Long.class.getName(), Integer.class.getName() });
3463    
3464            /**
3465             * Returns all the wiki pages where resourcePrimKey = &#63; and status = &#63;.
3466             *
3467             * @param resourcePrimKey the resource prim key
3468             * @param status the status
3469             * @return the matching wiki pages
3470             */
3471            @Override
3472            public List<WikiPage> findByR_S(long resourcePrimKey, int status) {
3473                    return findByR_S(resourcePrimKey, status, QueryUtil.ALL_POS,
3474                            QueryUtil.ALL_POS, null);
3475            }
3476    
3477            /**
3478             * Returns a range of all the wiki pages where resourcePrimKey = &#63; and status = &#63;.
3479             *
3480             * <p>
3481             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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.wiki.model.impl.WikiPageModelImpl}. 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.
3482             * </p>
3483             *
3484             * @param resourcePrimKey the resource prim key
3485             * @param status the status
3486             * @param start the lower bound of the range of wiki pages
3487             * @param end the upper bound of the range of wiki pages (not inclusive)
3488             * @return the range of matching wiki pages
3489             */
3490            @Override
3491            public List<WikiPage> findByR_S(long resourcePrimKey, int status,
3492                    int start, int end) {
3493                    return findByR_S(resourcePrimKey, status, start, end, null);
3494            }
3495    
3496            /**
3497             * Returns an ordered range of all the wiki pages where resourcePrimKey = &#63; and status = &#63;.
3498             *
3499             * <p>
3500             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
3501             * </p>
3502             *
3503             * @param resourcePrimKey the resource prim key
3504             * @param status the status
3505             * @param start the lower bound of the range of wiki pages
3506             * @param end the upper bound of the range of wiki pages (not inclusive)
3507             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3508             * @return the ordered range of matching wiki pages
3509             */
3510            @Override
3511            public List<WikiPage> findByR_S(long resourcePrimKey, int status,
3512                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
3513                    boolean pagination = true;
3514                    FinderPath finderPath = null;
3515                    Object[] finderArgs = null;
3516    
3517                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3518                                    (orderByComparator == null)) {
3519                            pagination = false;
3520                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S;
3521                            finderArgs = new Object[] { resourcePrimKey, status };
3522                    }
3523                    else {
3524                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S;
3525                            finderArgs = new Object[] {
3526                                            resourcePrimKey, status,
3527                                            
3528                                            start, end, orderByComparator
3529                                    };
3530                    }
3531    
3532                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
3533                                    finderArgs, this);
3534    
3535                    if ((list != null) && !list.isEmpty()) {
3536                            for (WikiPage wikiPage : list) {
3537                                    if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
3538                                                    (status != wikiPage.getStatus())) {
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(4 +
3551                                                    (orderByComparator.getOrderByFields().length * 3));
3552                            }
3553                            else {
3554                                    query = new StringBundler(4);
3555                            }
3556    
3557                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3558    
3559                            query.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2);
3560    
3561                            query.append(_FINDER_COLUMN_R_S_STATUS_2);
3562    
3563                            if (orderByComparator != null) {
3564                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3565                                            orderByComparator);
3566                            }
3567                            else
3568                             if (pagination) {
3569                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3570                            }
3571    
3572                            String sql = query.toString();
3573    
3574                            Session session = null;
3575    
3576                            try {
3577                                    session = openSession();
3578    
3579                                    Query q = session.createQuery(sql);
3580    
3581                                    QueryPos qPos = QueryPos.getInstance(q);
3582    
3583                                    qPos.add(resourcePrimKey);
3584    
3585                                    qPos.add(status);
3586    
3587                                    if (!pagination) {
3588                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3589                                                            start, end, false);
3590    
3591                                            Collections.sort(list);
3592    
3593                                            list = Collections.unmodifiableList(list);
3594                                    }
3595                                    else {
3596                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3597                                                            start, end);
3598                                    }
3599    
3600                                    cacheResult(list);
3601    
3602                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3603                            }
3604                            catch (Exception e) {
3605                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3606    
3607                                    throw processException(e);
3608                            }
3609                            finally {
3610                                    closeSession(session);
3611                            }
3612                    }
3613    
3614                    return list;
3615            }
3616    
3617            /**
3618             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and status = &#63;.
3619             *
3620             * @param resourcePrimKey the resource prim key
3621             * @param status the status
3622             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3623             * @return the first matching wiki page
3624             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3625             */
3626            @Override
3627            public WikiPage findByR_S_First(long resourcePrimKey, int status,
3628                    OrderByComparator<WikiPage> orderByComparator)
3629                    throws NoSuchPageException {
3630                    WikiPage wikiPage = fetchByR_S_First(resourcePrimKey, status,
3631                                    orderByComparator);
3632    
3633                    if (wikiPage != null) {
3634                            return wikiPage;
3635                    }
3636    
3637                    StringBundler msg = new StringBundler(6);
3638    
3639                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3640    
3641                    msg.append("resourcePrimKey=");
3642                    msg.append(resourcePrimKey);
3643    
3644                    msg.append(", status=");
3645                    msg.append(status);
3646    
3647                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3648    
3649                    throw new NoSuchPageException(msg.toString());
3650            }
3651    
3652            /**
3653             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and status = &#63;.
3654             *
3655             * @param resourcePrimKey the resource prim key
3656             * @param status the status
3657             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3658             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
3659             */
3660            @Override
3661            public WikiPage fetchByR_S_First(long resourcePrimKey, int status,
3662                    OrderByComparator<WikiPage> orderByComparator) {
3663                    List<WikiPage> list = findByR_S(resourcePrimKey, status, 0, 1,
3664                                    orderByComparator);
3665    
3666                    if (!list.isEmpty()) {
3667                            return list.get(0);
3668                    }
3669    
3670                    return null;
3671            }
3672    
3673            /**
3674             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and status = &#63;.
3675             *
3676             * @param resourcePrimKey the resource prim key
3677             * @param status the status
3678             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3679             * @return the last matching wiki page
3680             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3681             */
3682            @Override
3683            public WikiPage findByR_S_Last(long resourcePrimKey, int status,
3684                    OrderByComparator<WikiPage> orderByComparator)
3685                    throws NoSuchPageException {
3686                    WikiPage wikiPage = fetchByR_S_Last(resourcePrimKey, status,
3687                                    orderByComparator);
3688    
3689                    if (wikiPage != null) {
3690                            return wikiPage;
3691                    }
3692    
3693                    StringBundler msg = new StringBundler(6);
3694    
3695                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3696    
3697                    msg.append("resourcePrimKey=");
3698                    msg.append(resourcePrimKey);
3699    
3700                    msg.append(", status=");
3701                    msg.append(status);
3702    
3703                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3704    
3705                    throw new NoSuchPageException(msg.toString());
3706            }
3707    
3708            /**
3709             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and status = &#63;.
3710             *
3711             * @param resourcePrimKey the resource prim key
3712             * @param status the status
3713             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3714             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
3715             */
3716            @Override
3717            public WikiPage fetchByR_S_Last(long resourcePrimKey, int status,
3718                    OrderByComparator<WikiPage> orderByComparator) {
3719                    int count = countByR_S(resourcePrimKey, status);
3720    
3721                    if (count == 0) {
3722                            return null;
3723                    }
3724    
3725                    List<WikiPage> list = findByR_S(resourcePrimKey, status, count - 1,
3726                                    count, orderByComparator);
3727    
3728                    if (!list.isEmpty()) {
3729                            return list.get(0);
3730                    }
3731    
3732                    return null;
3733            }
3734    
3735            /**
3736             * Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and status = &#63;.
3737             *
3738             * @param pageId the primary key of the current wiki page
3739             * @param resourcePrimKey the resource prim key
3740             * @param status the status
3741             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3742             * @return the previous, current, and next wiki page
3743             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
3744             */
3745            @Override
3746            public WikiPage[] findByR_S_PrevAndNext(long pageId, long resourcePrimKey,
3747                    int status, OrderByComparator<WikiPage> orderByComparator)
3748                    throws NoSuchPageException {
3749                    WikiPage wikiPage = findByPrimaryKey(pageId);
3750    
3751                    Session session = null;
3752    
3753                    try {
3754                            session = openSession();
3755    
3756                            WikiPage[] array = new WikiPageImpl[3];
3757    
3758                            array[0] = getByR_S_PrevAndNext(session, wikiPage, resourcePrimKey,
3759                                            status, orderByComparator, true);
3760    
3761                            array[1] = wikiPage;
3762    
3763                            array[2] = getByR_S_PrevAndNext(session, wikiPage, resourcePrimKey,
3764                                            status, orderByComparator, false);
3765    
3766                            return array;
3767                    }
3768                    catch (Exception e) {
3769                            throw processException(e);
3770                    }
3771                    finally {
3772                            closeSession(session);
3773                    }
3774            }
3775    
3776            protected WikiPage getByR_S_PrevAndNext(Session session, WikiPage wikiPage,
3777                    long resourcePrimKey, int status,
3778                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
3779                    StringBundler query = null;
3780    
3781                    if (orderByComparator != null) {
3782                            query = new StringBundler(6 +
3783                                            (orderByComparator.getOrderByFields().length * 6));
3784                    }
3785                    else {
3786                            query = new StringBundler(3);
3787                    }
3788    
3789                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3790    
3791                    query.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2);
3792    
3793                    query.append(_FINDER_COLUMN_R_S_STATUS_2);
3794    
3795                    if (orderByComparator != null) {
3796                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3797    
3798                            if (orderByConditionFields.length > 0) {
3799                                    query.append(WHERE_AND);
3800                            }
3801    
3802                            for (int i = 0; i < orderByConditionFields.length; i++) {
3803                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3804                                    query.append(orderByConditionFields[i]);
3805    
3806                                    if ((i + 1) < orderByConditionFields.length) {
3807                                            if (orderByComparator.isAscending() ^ previous) {
3808                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3809                                            }
3810                                            else {
3811                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3812                                            }
3813                                    }
3814                                    else {
3815                                            if (orderByComparator.isAscending() ^ previous) {
3816                                                    query.append(WHERE_GREATER_THAN);
3817                                            }
3818                                            else {
3819                                                    query.append(WHERE_LESSER_THAN);
3820                                            }
3821                                    }
3822                            }
3823    
3824                            query.append(ORDER_BY_CLAUSE);
3825    
3826                            String[] orderByFields = orderByComparator.getOrderByFields();
3827    
3828                            for (int i = 0; i < orderByFields.length; i++) {
3829                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3830                                    query.append(orderByFields[i]);
3831    
3832                                    if ((i + 1) < orderByFields.length) {
3833                                            if (orderByComparator.isAscending() ^ previous) {
3834                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3835                                            }
3836                                            else {
3837                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3838                                            }
3839                                    }
3840                                    else {
3841                                            if (orderByComparator.isAscending() ^ previous) {
3842                                                    query.append(ORDER_BY_ASC);
3843                                            }
3844                                            else {
3845                                                    query.append(ORDER_BY_DESC);
3846                                            }
3847                                    }
3848                            }
3849                    }
3850                    else {
3851                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3852                    }
3853    
3854                    String sql = query.toString();
3855    
3856                    Query q = session.createQuery(sql);
3857    
3858                    q.setFirstResult(0);
3859                    q.setMaxResults(2);
3860    
3861                    QueryPos qPos = QueryPos.getInstance(q);
3862    
3863                    qPos.add(resourcePrimKey);
3864    
3865                    qPos.add(status);
3866    
3867                    if (orderByComparator != null) {
3868                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
3869    
3870                            for (Object value : values) {
3871                                    qPos.add(value);
3872                            }
3873                    }
3874    
3875                    List<WikiPage> list = q.list();
3876    
3877                    if (list.size() == 2) {
3878                            return list.get(1);
3879                    }
3880                    else {
3881                            return null;
3882                    }
3883            }
3884    
3885            /**
3886             * Removes all the wiki pages where resourcePrimKey = &#63; and status = &#63; from the database.
3887             *
3888             * @param resourcePrimKey the resource prim key
3889             * @param status the status
3890             */
3891            @Override
3892            public void removeByR_S(long resourcePrimKey, int status) {
3893                    for (WikiPage wikiPage : findByR_S(resourcePrimKey, status,
3894                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3895                            remove(wikiPage);
3896                    }
3897            }
3898    
3899            /**
3900             * Returns the number of wiki pages where resourcePrimKey = &#63; and status = &#63;.
3901             *
3902             * @param resourcePrimKey the resource prim key
3903             * @param status the status
3904             * @return the number of matching wiki pages
3905             */
3906            @Override
3907            public int countByR_S(long resourcePrimKey, int status) {
3908                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_S;
3909    
3910                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
3911    
3912                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3913                                    this);
3914    
3915                    if (count == null) {
3916                            StringBundler query = new StringBundler(3);
3917    
3918                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3919    
3920                            query.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2);
3921    
3922                            query.append(_FINDER_COLUMN_R_S_STATUS_2);
3923    
3924                            String sql = query.toString();
3925    
3926                            Session session = null;
3927    
3928                            try {
3929                                    session = openSession();
3930    
3931                                    Query q = session.createQuery(sql);
3932    
3933                                    QueryPos qPos = QueryPos.getInstance(q);
3934    
3935                                    qPos.add(resourcePrimKey);
3936    
3937                                    qPos.add(status);
3938    
3939                                    count = (Long)q.uniqueResult();
3940    
3941                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3942                            }
3943                            catch (Exception e) {
3944                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3945    
3946                                    throw processException(e);
3947                            }
3948                            finally {
3949                                    closeSession(session);
3950                            }
3951                    }
3952    
3953                    return count.intValue();
3954            }
3955    
3956            private static final String _FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
3957            private static final String _FINDER_COLUMN_R_S_STATUS_2 = "wikiPage.status = ?";
3958            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
3959                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
3960                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_T",
3961                            new String[] {
3962                                    Long.class.getName(), String.class.getName(),
3963                                    
3964                            Integer.class.getName(), Integer.class.getName(),
3965                                    OrderByComparator.class.getName()
3966                            });
3967            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
3968                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
3969                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_T",
3970                            new String[] { Long.class.getName(), String.class.getName() },
3971                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
3972                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
3973                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
3974            public static final FinderPath FINDER_PATH_COUNT_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
3975                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
3976                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T",
3977                            new String[] { Long.class.getName(), String.class.getName() });
3978    
3979            /**
3980             * Returns all the wiki pages where nodeId = &#63; and title = &#63;.
3981             *
3982             * @param nodeId the node ID
3983             * @param title the title
3984             * @return the matching wiki pages
3985             */
3986            @Override
3987            public List<WikiPage> findByN_T(long nodeId, String title) {
3988                    return findByN_T(nodeId, title, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3989                            null);
3990            }
3991    
3992            /**
3993             * Returns a range of all the wiki pages where nodeId = &#63; and title = &#63;.
3994             *
3995             * <p>
3996             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
3997             * </p>
3998             *
3999             * @param nodeId the node ID
4000             * @param title the title
4001             * @param start the lower bound of the range of wiki pages
4002             * @param end the upper bound of the range of wiki pages (not inclusive)
4003             * @return the range of matching wiki pages
4004             */
4005            @Override
4006            public List<WikiPage> findByN_T(long nodeId, String title, int start,
4007                    int end) {
4008                    return findByN_T(nodeId, title, start, end, null);
4009            }
4010    
4011            /**
4012             * Returns an ordered range of all the wiki pages where nodeId = &#63; and title = &#63;.
4013             *
4014             * <p>
4015             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
4016             * </p>
4017             *
4018             * @param nodeId the node ID
4019             * @param title the title
4020             * @param start the lower bound of the range of wiki pages
4021             * @param end the upper bound of the range of wiki pages (not inclusive)
4022             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4023             * @return the ordered range of matching wiki pages
4024             */
4025            @Override
4026            public List<WikiPage> findByN_T(long nodeId, String title, int start,
4027                    int end, OrderByComparator<WikiPage> orderByComparator) {
4028                    boolean pagination = true;
4029                    FinderPath finderPath = null;
4030                    Object[] finderArgs = null;
4031    
4032                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4033                                    (orderByComparator == null)) {
4034                            pagination = false;
4035                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T;
4036                            finderArgs = new Object[] { nodeId, title };
4037                    }
4038                    else {
4039                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T;
4040                            finderArgs = new Object[] {
4041                                            nodeId, title,
4042                                            
4043                                            start, end, orderByComparator
4044                                    };
4045                    }
4046    
4047                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
4048                                    finderArgs, this);
4049    
4050                    if ((list != null) && !list.isEmpty()) {
4051                            for (WikiPage wikiPage : list) {
4052                                    if ((nodeId != wikiPage.getNodeId()) ||
4053                                                    !Validator.equals(title, wikiPage.getTitle())) {
4054                                            list = null;
4055    
4056                                            break;
4057                                    }
4058                            }
4059                    }
4060    
4061                    if (list == null) {
4062                            StringBundler query = null;
4063    
4064                            if (orderByComparator != null) {
4065                                    query = new StringBundler(4 +
4066                                                    (orderByComparator.getOrderByFields().length * 3));
4067                            }
4068                            else {
4069                                    query = new StringBundler(4);
4070                            }
4071    
4072                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4073    
4074                            query.append(_FINDER_COLUMN_N_T_NODEID_2);
4075    
4076                            boolean bindTitle = false;
4077    
4078                            if (title == null) {
4079                                    query.append(_FINDER_COLUMN_N_T_TITLE_1);
4080                            }
4081                            else if (title.equals(StringPool.BLANK)) {
4082                                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
4083                            }
4084                            else {
4085                                    bindTitle = true;
4086    
4087                                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
4088                            }
4089    
4090                            if (orderByComparator != null) {
4091                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4092                                            orderByComparator);
4093                            }
4094                            else
4095                             if (pagination) {
4096                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4097                            }
4098    
4099                            String sql = query.toString();
4100    
4101                            Session session = null;
4102    
4103                            try {
4104                                    session = openSession();
4105    
4106                                    Query q = session.createQuery(sql);
4107    
4108                                    QueryPos qPos = QueryPos.getInstance(q);
4109    
4110                                    qPos.add(nodeId);
4111    
4112                                    if (bindTitle) {
4113                                            qPos.add(StringUtil.toLowerCase(title));
4114                                    }
4115    
4116                                    if (!pagination) {
4117                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
4118                                                            start, end, false);
4119    
4120                                            Collections.sort(list);
4121    
4122                                            list = Collections.unmodifiableList(list);
4123                                    }
4124                                    else {
4125                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
4126                                                            start, end);
4127                                    }
4128    
4129                                    cacheResult(list);
4130    
4131                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4132                            }
4133                            catch (Exception e) {
4134                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4135    
4136                                    throw processException(e);
4137                            }
4138                            finally {
4139                                    closeSession(session);
4140                            }
4141                    }
4142    
4143                    return list;
4144            }
4145    
4146            /**
4147             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63;.
4148             *
4149             * @param nodeId the node ID
4150             * @param title the title
4151             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4152             * @return the first matching wiki page
4153             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4154             */
4155            @Override
4156            public WikiPage findByN_T_First(long nodeId, String title,
4157                    OrderByComparator<WikiPage> orderByComparator)
4158                    throws NoSuchPageException {
4159                    WikiPage wikiPage = fetchByN_T_First(nodeId, title, orderByComparator);
4160    
4161                    if (wikiPage != null) {
4162                            return wikiPage;
4163                    }
4164    
4165                    StringBundler msg = new StringBundler(6);
4166    
4167                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4168    
4169                    msg.append("nodeId=");
4170                    msg.append(nodeId);
4171    
4172                    msg.append(", title=");
4173                    msg.append(title);
4174    
4175                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4176    
4177                    throw new NoSuchPageException(msg.toString());
4178            }
4179    
4180            /**
4181             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63;.
4182             *
4183             * @param nodeId the node ID
4184             * @param title the title
4185             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4186             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
4187             */
4188            @Override
4189            public WikiPage fetchByN_T_First(long nodeId, String title,
4190                    OrderByComparator<WikiPage> orderByComparator) {
4191                    List<WikiPage> list = findByN_T(nodeId, title, 0, 1, orderByComparator);
4192    
4193                    if (!list.isEmpty()) {
4194                            return list.get(0);
4195                    }
4196    
4197                    return null;
4198            }
4199    
4200            /**
4201             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63;.
4202             *
4203             * @param nodeId the node ID
4204             * @param title the title
4205             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4206             * @return the last matching wiki page
4207             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4208             */
4209            @Override
4210            public WikiPage findByN_T_Last(long nodeId, String title,
4211                    OrderByComparator<WikiPage> orderByComparator)
4212                    throws NoSuchPageException {
4213                    WikiPage wikiPage = fetchByN_T_Last(nodeId, title, orderByComparator);
4214    
4215                    if (wikiPage != null) {
4216                            return wikiPage;
4217                    }
4218    
4219                    StringBundler msg = new StringBundler(6);
4220    
4221                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4222    
4223                    msg.append("nodeId=");
4224                    msg.append(nodeId);
4225    
4226                    msg.append(", title=");
4227                    msg.append(title);
4228    
4229                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4230    
4231                    throw new NoSuchPageException(msg.toString());
4232            }
4233    
4234            /**
4235             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63;.
4236             *
4237             * @param nodeId the node ID
4238             * @param title the title
4239             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4240             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
4241             */
4242            @Override
4243            public WikiPage fetchByN_T_Last(long nodeId, String title,
4244                    OrderByComparator<WikiPage> orderByComparator) {
4245                    int count = countByN_T(nodeId, title);
4246    
4247                    if (count == 0) {
4248                            return null;
4249                    }
4250    
4251                    List<WikiPage> list = findByN_T(nodeId, title, count - 1, count,
4252                                    orderByComparator);
4253    
4254                    if (!list.isEmpty()) {
4255                            return list.get(0);
4256                    }
4257    
4258                    return null;
4259            }
4260    
4261            /**
4262             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63;.
4263             *
4264             * @param pageId the primary key of the current wiki page
4265             * @param nodeId the node ID
4266             * @param title the title
4267             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4268             * @return the previous, current, and next wiki page
4269             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
4270             */
4271            @Override
4272            public WikiPage[] findByN_T_PrevAndNext(long pageId, long nodeId,
4273                    String title, OrderByComparator<WikiPage> orderByComparator)
4274                    throws NoSuchPageException {
4275                    WikiPage wikiPage = findByPrimaryKey(pageId);
4276    
4277                    Session session = null;
4278    
4279                    try {
4280                            session = openSession();
4281    
4282                            WikiPage[] array = new WikiPageImpl[3];
4283    
4284                            array[0] = getByN_T_PrevAndNext(session, wikiPage, nodeId, title,
4285                                            orderByComparator, true);
4286    
4287                            array[1] = wikiPage;
4288    
4289                            array[2] = getByN_T_PrevAndNext(session, wikiPage, nodeId, title,
4290                                            orderByComparator, false);
4291    
4292                            return array;
4293                    }
4294                    catch (Exception e) {
4295                            throw processException(e);
4296                    }
4297                    finally {
4298                            closeSession(session);
4299                    }
4300            }
4301    
4302            protected WikiPage getByN_T_PrevAndNext(Session session, WikiPage wikiPage,
4303                    long nodeId, String title,
4304                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
4305                    StringBundler query = null;
4306    
4307                    if (orderByComparator != null) {
4308                            query = new StringBundler(6 +
4309                                            (orderByComparator.getOrderByFields().length * 6));
4310                    }
4311                    else {
4312                            query = new StringBundler(3);
4313                    }
4314    
4315                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4316    
4317                    query.append(_FINDER_COLUMN_N_T_NODEID_2);
4318    
4319                    boolean bindTitle = false;
4320    
4321                    if (title == null) {
4322                            query.append(_FINDER_COLUMN_N_T_TITLE_1);
4323                    }
4324                    else if (title.equals(StringPool.BLANK)) {
4325                            query.append(_FINDER_COLUMN_N_T_TITLE_3);
4326                    }
4327                    else {
4328                            bindTitle = true;
4329    
4330                            query.append(_FINDER_COLUMN_N_T_TITLE_2);
4331                    }
4332    
4333                    if (orderByComparator != null) {
4334                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4335    
4336                            if (orderByConditionFields.length > 0) {
4337                                    query.append(WHERE_AND);
4338                            }
4339    
4340                            for (int i = 0; i < orderByConditionFields.length; i++) {
4341                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4342                                    query.append(orderByConditionFields[i]);
4343    
4344                                    if ((i + 1) < orderByConditionFields.length) {
4345                                            if (orderByComparator.isAscending() ^ previous) {
4346                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4347                                            }
4348                                            else {
4349                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4350                                            }
4351                                    }
4352                                    else {
4353                                            if (orderByComparator.isAscending() ^ previous) {
4354                                                    query.append(WHERE_GREATER_THAN);
4355                                            }
4356                                            else {
4357                                                    query.append(WHERE_LESSER_THAN);
4358                                            }
4359                                    }
4360                            }
4361    
4362                            query.append(ORDER_BY_CLAUSE);
4363    
4364                            String[] orderByFields = orderByComparator.getOrderByFields();
4365    
4366                            for (int i = 0; i < orderByFields.length; i++) {
4367                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4368                                    query.append(orderByFields[i]);
4369    
4370                                    if ((i + 1) < orderByFields.length) {
4371                                            if (orderByComparator.isAscending() ^ previous) {
4372                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4373                                            }
4374                                            else {
4375                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4376                                            }
4377                                    }
4378                                    else {
4379                                            if (orderByComparator.isAscending() ^ previous) {
4380                                                    query.append(ORDER_BY_ASC);
4381                                            }
4382                                            else {
4383                                                    query.append(ORDER_BY_DESC);
4384                                            }
4385                                    }
4386                            }
4387                    }
4388                    else {
4389                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4390                    }
4391    
4392                    String sql = query.toString();
4393    
4394                    Query q = session.createQuery(sql);
4395    
4396                    q.setFirstResult(0);
4397                    q.setMaxResults(2);
4398    
4399                    QueryPos qPos = QueryPos.getInstance(q);
4400    
4401                    qPos.add(nodeId);
4402    
4403                    if (bindTitle) {
4404                            qPos.add(StringUtil.toLowerCase(title));
4405                    }
4406    
4407                    if (orderByComparator != null) {
4408                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
4409    
4410                            for (Object value : values) {
4411                                    qPos.add(value);
4412                            }
4413                    }
4414    
4415                    List<WikiPage> list = q.list();
4416    
4417                    if (list.size() == 2) {
4418                            return list.get(1);
4419                    }
4420                    else {
4421                            return null;
4422                    }
4423            }
4424    
4425            /**
4426             * Removes all the wiki pages where nodeId = &#63; and title = &#63; from the database.
4427             *
4428             * @param nodeId the node ID
4429             * @param title the title
4430             */
4431            @Override
4432            public void removeByN_T(long nodeId, String title) {
4433                    for (WikiPage wikiPage : findByN_T(nodeId, title, QueryUtil.ALL_POS,
4434                                    QueryUtil.ALL_POS, null)) {
4435                            remove(wikiPage);
4436                    }
4437            }
4438    
4439            /**
4440             * Returns the number of wiki pages where nodeId = &#63; and title = &#63;.
4441             *
4442             * @param nodeId the node ID
4443             * @param title the title
4444             * @return the number of matching wiki pages
4445             */
4446            @Override
4447            public int countByN_T(long nodeId, String title) {
4448                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_T;
4449    
4450                    Object[] finderArgs = new Object[] { nodeId, title };
4451    
4452                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4453                                    this);
4454    
4455                    if (count == null) {
4456                            StringBundler query = new StringBundler(3);
4457    
4458                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
4459    
4460                            query.append(_FINDER_COLUMN_N_T_NODEID_2);
4461    
4462                            boolean bindTitle = false;
4463    
4464                            if (title == null) {
4465                                    query.append(_FINDER_COLUMN_N_T_TITLE_1);
4466                            }
4467                            else if (title.equals(StringPool.BLANK)) {
4468                                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
4469                            }
4470                            else {
4471                                    bindTitle = true;
4472    
4473                                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
4474                            }
4475    
4476                            String sql = query.toString();
4477    
4478                            Session session = null;
4479    
4480                            try {
4481                                    session = openSession();
4482    
4483                                    Query q = session.createQuery(sql);
4484    
4485                                    QueryPos qPos = QueryPos.getInstance(q);
4486    
4487                                    qPos.add(nodeId);
4488    
4489                                    if (bindTitle) {
4490                                            qPos.add(StringUtil.toLowerCase(title));
4491                                    }
4492    
4493                                    count = (Long)q.uniqueResult();
4494    
4495                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4496                            }
4497                            catch (Exception e) {
4498                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4499    
4500                                    throw processException(e);
4501                            }
4502                            finally {
4503                                    closeSession(session);
4504                            }
4505                    }
4506    
4507                    return count.intValue();
4508            }
4509    
4510            private static final String _FINDER_COLUMN_N_T_NODEID_2 = "wikiPage.nodeId = ? AND ";
4511            private static final String _FINDER_COLUMN_N_T_TITLE_1 = "wikiPage.title IS NULL";
4512            private static final String _FINDER_COLUMN_N_T_TITLE_2 = "lower(wikiPage.title) = ?";
4513            private static final String _FINDER_COLUMN_N_T_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = '')";
4514            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
4515                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
4516                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H",
4517                            new String[] {
4518                                    Long.class.getName(), Boolean.class.getName(),
4519                                    
4520                            Integer.class.getName(), Integer.class.getName(),
4521                                    OrderByComparator.class.getName()
4522                            });
4523            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
4524                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
4525                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H",
4526                            new String[] { Long.class.getName(), Boolean.class.getName() },
4527                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
4528                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
4529                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
4530                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
4531            public static final FinderPath FINDER_PATH_COUNT_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
4532                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
4533                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H",
4534                            new String[] { Long.class.getName(), Boolean.class.getName() });
4535    
4536            /**
4537             * Returns all the wiki pages where nodeId = &#63; and head = &#63;.
4538             *
4539             * @param nodeId the node ID
4540             * @param head the head
4541             * @return the matching wiki pages
4542             */
4543            @Override
4544            public List<WikiPage> findByN_H(long nodeId, boolean head) {
4545                    return findByN_H(nodeId, head, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4546                            null);
4547            }
4548    
4549            /**
4550             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63;.
4551             *
4552             * <p>
4553             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
4554             * </p>
4555             *
4556             * @param nodeId the node ID
4557             * @param head the head
4558             * @param start the lower bound of the range of wiki pages
4559             * @param end the upper bound of the range of wiki pages (not inclusive)
4560             * @return the range of matching wiki pages
4561             */
4562            @Override
4563            public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
4564                    int end) {
4565                    return findByN_H(nodeId, head, start, end, null);
4566            }
4567    
4568            /**
4569             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63;.
4570             *
4571             * <p>
4572             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
4573             * </p>
4574             *
4575             * @param nodeId the node ID
4576             * @param head the head
4577             * @param start the lower bound of the range of wiki pages
4578             * @param end the upper bound of the range of wiki pages (not inclusive)
4579             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4580             * @return the ordered range of matching wiki pages
4581             */
4582            @Override
4583            public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
4584                    int end, OrderByComparator<WikiPage> orderByComparator) {
4585                    boolean pagination = true;
4586                    FinderPath finderPath = null;
4587                    Object[] finderArgs = null;
4588    
4589                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4590                                    (orderByComparator == null)) {
4591                            pagination = false;
4592                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H;
4593                            finderArgs = new Object[] { nodeId, head };
4594                    }
4595                    else {
4596                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H;
4597                            finderArgs = new Object[] {
4598                                            nodeId, head,
4599                                            
4600                                            start, end, orderByComparator
4601                                    };
4602                    }
4603    
4604                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
4605                                    finderArgs, this);
4606    
4607                    if ((list != null) && !list.isEmpty()) {
4608                            for (WikiPage wikiPage : list) {
4609                                    if ((nodeId != wikiPage.getNodeId()) ||
4610                                                    (head != wikiPage.getHead())) {
4611                                            list = null;
4612    
4613                                            break;
4614                                    }
4615                            }
4616                    }
4617    
4618                    if (list == null) {
4619                            StringBundler query = null;
4620    
4621                            if (orderByComparator != null) {
4622                                    query = new StringBundler(4 +
4623                                                    (orderByComparator.getOrderByFields().length * 3));
4624                            }
4625                            else {
4626                                    query = new StringBundler(4);
4627                            }
4628    
4629                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4630    
4631                            query.append(_FINDER_COLUMN_N_H_NODEID_2);
4632    
4633                            query.append(_FINDER_COLUMN_N_H_HEAD_2);
4634    
4635                            if (orderByComparator != null) {
4636                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4637                                            orderByComparator);
4638                            }
4639                            else
4640                             if (pagination) {
4641                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4642                            }
4643    
4644                            String sql = query.toString();
4645    
4646                            Session session = null;
4647    
4648                            try {
4649                                    session = openSession();
4650    
4651                                    Query q = session.createQuery(sql);
4652    
4653                                    QueryPos qPos = QueryPos.getInstance(q);
4654    
4655                                    qPos.add(nodeId);
4656    
4657                                    qPos.add(head);
4658    
4659                                    if (!pagination) {
4660                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
4661                                                            start, end, false);
4662    
4663                                            Collections.sort(list);
4664    
4665                                            list = Collections.unmodifiableList(list);
4666                                    }
4667                                    else {
4668                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
4669                                                            start, end);
4670                                    }
4671    
4672                                    cacheResult(list);
4673    
4674                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4675                            }
4676                            catch (Exception e) {
4677                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4678    
4679                                    throw processException(e);
4680                            }
4681                            finally {
4682                                    closeSession(session);
4683                            }
4684                    }
4685    
4686                    return list;
4687            }
4688    
4689            /**
4690             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63;.
4691             *
4692             * @param nodeId the node ID
4693             * @param head the head
4694             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4695             * @return the first matching wiki page
4696             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4697             */
4698            @Override
4699            public WikiPage findByN_H_First(long nodeId, boolean head,
4700                    OrderByComparator<WikiPage> orderByComparator)
4701                    throws NoSuchPageException {
4702                    WikiPage wikiPage = fetchByN_H_First(nodeId, head, orderByComparator);
4703    
4704                    if (wikiPage != null) {
4705                            return wikiPage;
4706                    }
4707    
4708                    StringBundler msg = new StringBundler(6);
4709    
4710                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4711    
4712                    msg.append("nodeId=");
4713                    msg.append(nodeId);
4714    
4715                    msg.append(", head=");
4716                    msg.append(head);
4717    
4718                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4719    
4720                    throw new NoSuchPageException(msg.toString());
4721            }
4722    
4723            /**
4724             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63;.
4725             *
4726             * @param nodeId the node ID
4727             * @param head the head
4728             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4729             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
4730             */
4731            @Override
4732            public WikiPage fetchByN_H_First(long nodeId, boolean head,
4733                    OrderByComparator<WikiPage> orderByComparator) {
4734                    List<WikiPage> list = findByN_H(nodeId, head, 0, 1, orderByComparator);
4735    
4736                    if (!list.isEmpty()) {
4737                            return list.get(0);
4738                    }
4739    
4740                    return null;
4741            }
4742    
4743            /**
4744             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63;.
4745             *
4746             * @param nodeId the node ID
4747             * @param head the head
4748             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4749             * @return the last matching wiki page
4750             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4751             */
4752            @Override
4753            public WikiPage findByN_H_Last(long nodeId, boolean head,
4754                    OrderByComparator<WikiPage> orderByComparator)
4755                    throws NoSuchPageException {
4756                    WikiPage wikiPage = fetchByN_H_Last(nodeId, head, orderByComparator);
4757    
4758                    if (wikiPage != null) {
4759                            return wikiPage;
4760                    }
4761    
4762                    StringBundler msg = new StringBundler(6);
4763    
4764                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4765    
4766                    msg.append("nodeId=");
4767                    msg.append(nodeId);
4768    
4769                    msg.append(", head=");
4770                    msg.append(head);
4771    
4772                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4773    
4774                    throw new NoSuchPageException(msg.toString());
4775            }
4776    
4777            /**
4778             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63;.
4779             *
4780             * @param nodeId the node ID
4781             * @param head the head
4782             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4783             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
4784             */
4785            @Override
4786            public WikiPage fetchByN_H_Last(long nodeId, boolean head,
4787                    OrderByComparator<WikiPage> orderByComparator) {
4788                    int count = countByN_H(nodeId, head);
4789    
4790                    if (count == 0) {
4791                            return null;
4792                    }
4793    
4794                    List<WikiPage> list = findByN_H(nodeId, head, count - 1, count,
4795                                    orderByComparator);
4796    
4797                    if (!list.isEmpty()) {
4798                            return list.get(0);
4799                    }
4800    
4801                    return null;
4802            }
4803    
4804            /**
4805             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63;.
4806             *
4807             * @param pageId the primary key of the current wiki page
4808             * @param nodeId the node ID
4809             * @param head the head
4810             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4811             * @return the previous, current, and next wiki page
4812             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
4813             */
4814            @Override
4815            public WikiPage[] findByN_H_PrevAndNext(long pageId, long nodeId,
4816                    boolean head, OrderByComparator<WikiPage> orderByComparator)
4817                    throws NoSuchPageException {
4818                    WikiPage wikiPage = findByPrimaryKey(pageId);
4819    
4820                    Session session = null;
4821    
4822                    try {
4823                            session = openSession();
4824    
4825                            WikiPage[] array = new WikiPageImpl[3];
4826    
4827                            array[0] = getByN_H_PrevAndNext(session, wikiPage, nodeId, head,
4828                                            orderByComparator, true);
4829    
4830                            array[1] = wikiPage;
4831    
4832                            array[2] = getByN_H_PrevAndNext(session, wikiPage, nodeId, head,
4833                                            orderByComparator, false);
4834    
4835                            return array;
4836                    }
4837                    catch (Exception e) {
4838                            throw processException(e);
4839                    }
4840                    finally {
4841                            closeSession(session);
4842                    }
4843            }
4844    
4845            protected WikiPage getByN_H_PrevAndNext(Session session, WikiPage wikiPage,
4846                    long nodeId, boolean head,
4847                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
4848                    StringBundler query = null;
4849    
4850                    if (orderByComparator != null) {
4851                            query = new StringBundler(6 +
4852                                            (orderByComparator.getOrderByFields().length * 6));
4853                    }
4854                    else {
4855                            query = new StringBundler(3);
4856                    }
4857    
4858                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4859    
4860                    query.append(_FINDER_COLUMN_N_H_NODEID_2);
4861    
4862                    query.append(_FINDER_COLUMN_N_H_HEAD_2);
4863    
4864                    if (orderByComparator != null) {
4865                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4866    
4867                            if (orderByConditionFields.length > 0) {
4868                                    query.append(WHERE_AND);
4869                            }
4870    
4871                            for (int i = 0; i < orderByConditionFields.length; i++) {
4872                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4873                                    query.append(orderByConditionFields[i]);
4874    
4875                                    if ((i + 1) < orderByConditionFields.length) {
4876                                            if (orderByComparator.isAscending() ^ previous) {
4877                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4878                                            }
4879                                            else {
4880                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4881                                            }
4882                                    }
4883                                    else {
4884                                            if (orderByComparator.isAscending() ^ previous) {
4885                                                    query.append(WHERE_GREATER_THAN);
4886                                            }
4887                                            else {
4888                                                    query.append(WHERE_LESSER_THAN);
4889                                            }
4890                                    }
4891                            }
4892    
4893                            query.append(ORDER_BY_CLAUSE);
4894    
4895                            String[] orderByFields = orderByComparator.getOrderByFields();
4896    
4897                            for (int i = 0; i < orderByFields.length; i++) {
4898                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4899                                    query.append(orderByFields[i]);
4900    
4901                                    if ((i + 1) < orderByFields.length) {
4902                                            if (orderByComparator.isAscending() ^ previous) {
4903                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4904                                            }
4905                                            else {
4906                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4907                                            }
4908                                    }
4909                                    else {
4910                                            if (orderByComparator.isAscending() ^ previous) {
4911                                                    query.append(ORDER_BY_ASC);
4912                                            }
4913                                            else {
4914                                                    query.append(ORDER_BY_DESC);
4915                                            }
4916                                    }
4917                            }
4918                    }
4919                    else {
4920                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4921                    }
4922    
4923                    String sql = query.toString();
4924    
4925                    Query q = session.createQuery(sql);
4926    
4927                    q.setFirstResult(0);
4928                    q.setMaxResults(2);
4929    
4930                    QueryPos qPos = QueryPos.getInstance(q);
4931    
4932                    qPos.add(nodeId);
4933    
4934                    qPos.add(head);
4935    
4936                    if (orderByComparator != null) {
4937                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
4938    
4939                            for (Object value : values) {
4940                                    qPos.add(value);
4941                            }
4942                    }
4943    
4944                    List<WikiPage> list = q.list();
4945    
4946                    if (list.size() == 2) {
4947                            return list.get(1);
4948                    }
4949                    else {
4950                            return null;
4951                    }
4952            }
4953    
4954            /**
4955             * Removes all the wiki pages where nodeId = &#63; and head = &#63; from the database.
4956             *
4957             * @param nodeId the node ID
4958             * @param head the head
4959             */
4960            @Override
4961            public void removeByN_H(long nodeId, boolean head) {
4962                    for (WikiPage wikiPage : findByN_H(nodeId, head, QueryUtil.ALL_POS,
4963                                    QueryUtil.ALL_POS, null)) {
4964                            remove(wikiPage);
4965                    }
4966            }
4967    
4968            /**
4969             * Returns the number of wiki pages where nodeId = &#63; and head = &#63;.
4970             *
4971             * @param nodeId the node ID
4972             * @param head the head
4973             * @return the number of matching wiki pages
4974             */
4975            @Override
4976            public int countByN_H(long nodeId, boolean head) {
4977                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_H;
4978    
4979                    Object[] finderArgs = new Object[] { nodeId, head };
4980    
4981                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4982                                    this);
4983    
4984                    if (count == null) {
4985                            StringBundler query = new StringBundler(3);
4986    
4987                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
4988    
4989                            query.append(_FINDER_COLUMN_N_H_NODEID_2);
4990    
4991                            query.append(_FINDER_COLUMN_N_H_HEAD_2);
4992    
4993                            String sql = query.toString();
4994    
4995                            Session session = null;
4996    
4997                            try {
4998                                    session = openSession();
4999    
5000                                    Query q = session.createQuery(sql);
5001    
5002                                    QueryPos qPos = QueryPos.getInstance(q);
5003    
5004                                    qPos.add(nodeId);
5005    
5006                                    qPos.add(head);
5007    
5008                                    count = (Long)q.uniqueResult();
5009    
5010                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5011                            }
5012                            catch (Exception e) {
5013                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5014    
5015                                    throw processException(e);
5016                            }
5017                            finally {
5018                                    closeSession(session);
5019                            }
5020                    }
5021    
5022                    return count.intValue();
5023            }
5024    
5025            private static final String _FINDER_COLUMN_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
5026            private static final String _FINDER_COLUMN_N_H_HEAD_2 = "wikiPage.head = ?";
5027            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5028                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
5029                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_P",
5030                            new String[] {
5031                                    Long.class.getName(), String.class.getName(),
5032                                    
5033                            Integer.class.getName(), Integer.class.getName(),
5034                                    OrderByComparator.class.getName()
5035                            });
5036            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5037                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
5038                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_P",
5039                            new String[] { Long.class.getName(), String.class.getName() },
5040                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
5041                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK |
5042                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
5043                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
5044            public static final FinderPath FINDER_PATH_COUNT_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5045                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
5046                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_P",
5047                            new String[] { Long.class.getName(), String.class.getName() });
5048    
5049            /**
5050             * Returns all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
5051             *
5052             * @param nodeId the node ID
5053             * @param parentTitle the parent title
5054             * @return the matching wiki pages
5055             */
5056            @Override
5057            public List<WikiPage> findByN_P(long nodeId, String parentTitle) {
5058                    return findByN_P(nodeId, parentTitle, QueryUtil.ALL_POS,
5059                            QueryUtil.ALL_POS, null);
5060            }
5061    
5062            /**
5063             * Returns a range of all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
5064             *
5065             * <p>
5066             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
5067             * </p>
5068             *
5069             * @param nodeId the node ID
5070             * @param parentTitle the parent title
5071             * @param start the lower bound of the range of wiki pages
5072             * @param end the upper bound of the range of wiki pages (not inclusive)
5073             * @return the range of matching wiki pages
5074             */
5075            @Override
5076            public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
5077                    int end) {
5078                    return findByN_P(nodeId, parentTitle, start, end, null);
5079            }
5080    
5081            /**
5082             * Returns an ordered range of all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
5083             *
5084             * <p>
5085             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
5086             * </p>
5087             *
5088             * @param nodeId the node ID
5089             * @param parentTitle the parent title
5090             * @param start the lower bound of the range of wiki pages
5091             * @param end the upper bound of the range of wiki pages (not inclusive)
5092             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5093             * @return the ordered range of matching wiki pages
5094             */
5095            @Override
5096            public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
5097                    int end, OrderByComparator<WikiPage> orderByComparator) {
5098                    boolean pagination = true;
5099                    FinderPath finderPath = null;
5100                    Object[] finderArgs = null;
5101    
5102                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5103                                    (orderByComparator == null)) {
5104                            pagination = false;
5105                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P;
5106                            finderArgs = new Object[] { nodeId, parentTitle };
5107                    }
5108                    else {
5109                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_P;
5110                            finderArgs = new Object[] {
5111                                            nodeId, parentTitle,
5112                                            
5113                                            start, end, orderByComparator
5114                                    };
5115                    }
5116    
5117                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
5118                                    finderArgs, this);
5119    
5120                    if ((list != null) && !list.isEmpty()) {
5121                            for (WikiPage wikiPage : list) {
5122                                    if ((nodeId != wikiPage.getNodeId()) ||
5123                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle())) {
5124                                            list = null;
5125    
5126                                            break;
5127                                    }
5128                            }
5129                    }
5130    
5131                    if (list == null) {
5132                            StringBundler query = null;
5133    
5134                            if (orderByComparator != null) {
5135                                    query = new StringBundler(4 +
5136                                                    (orderByComparator.getOrderByFields().length * 3));
5137                            }
5138                            else {
5139                                    query = new StringBundler(4);
5140                            }
5141    
5142                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5143    
5144                            query.append(_FINDER_COLUMN_N_P_NODEID_2);
5145    
5146                            boolean bindParentTitle = false;
5147    
5148                            if (parentTitle == null) {
5149                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
5150                            }
5151                            else if (parentTitle.equals(StringPool.BLANK)) {
5152                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
5153                            }
5154                            else {
5155                                    bindParentTitle = true;
5156    
5157                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
5158                            }
5159    
5160                            if (orderByComparator != null) {
5161                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5162                                            orderByComparator);
5163                            }
5164                            else
5165                             if (pagination) {
5166                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5167                            }
5168    
5169                            String sql = query.toString();
5170    
5171                            Session session = null;
5172    
5173                            try {
5174                                    session = openSession();
5175    
5176                                    Query q = session.createQuery(sql);
5177    
5178                                    QueryPos qPos = QueryPos.getInstance(q);
5179    
5180                                    qPos.add(nodeId);
5181    
5182                                    if (bindParentTitle) {
5183                                            qPos.add(StringUtil.toLowerCase(parentTitle));
5184                                    }
5185    
5186                                    if (!pagination) {
5187                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
5188                                                            start, end, false);
5189    
5190                                            Collections.sort(list);
5191    
5192                                            list = Collections.unmodifiableList(list);
5193                                    }
5194                                    else {
5195                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
5196                                                            start, end);
5197                                    }
5198    
5199                                    cacheResult(list);
5200    
5201                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5202                            }
5203                            catch (Exception e) {
5204                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5205    
5206                                    throw processException(e);
5207                            }
5208                            finally {
5209                                    closeSession(session);
5210                            }
5211                    }
5212    
5213                    return list;
5214            }
5215    
5216            /**
5217             * Returns the first wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
5218             *
5219             * @param nodeId the node ID
5220             * @param parentTitle the parent title
5221             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5222             * @return the first matching wiki page
5223             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5224             */
5225            @Override
5226            public WikiPage findByN_P_First(long nodeId, String parentTitle,
5227                    OrderByComparator<WikiPage> orderByComparator)
5228                    throws NoSuchPageException {
5229                    WikiPage wikiPage = fetchByN_P_First(nodeId, parentTitle,
5230                                    orderByComparator);
5231    
5232                    if (wikiPage != null) {
5233                            return wikiPage;
5234                    }
5235    
5236                    StringBundler msg = new StringBundler(6);
5237    
5238                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5239    
5240                    msg.append("nodeId=");
5241                    msg.append(nodeId);
5242    
5243                    msg.append(", parentTitle=");
5244                    msg.append(parentTitle);
5245    
5246                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5247    
5248                    throw new NoSuchPageException(msg.toString());
5249            }
5250    
5251            /**
5252             * Returns the first wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
5253             *
5254             * @param nodeId the node ID
5255             * @param parentTitle the parent title
5256             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5257             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
5258             */
5259            @Override
5260            public WikiPage fetchByN_P_First(long nodeId, String parentTitle,
5261                    OrderByComparator<WikiPage> orderByComparator) {
5262                    List<WikiPage> list = findByN_P(nodeId, parentTitle, 0, 1,
5263                                    orderByComparator);
5264    
5265                    if (!list.isEmpty()) {
5266                            return list.get(0);
5267                    }
5268    
5269                    return null;
5270            }
5271    
5272            /**
5273             * Returns the last wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
5274             *
5275             * @param nodeId the node ID
5276             * @param parentTitle the parent title
5277             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5278             * @return the last matching wiki page
5279             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5280             */
5281            @Override
5282            public WikiPage findByN_P_Last(long nodeId, String parentTitle,
5283                    OrderByComparator<WikiPage> orderByComparator)
5284                    throws NoSuchPageException {
5285                    WikiPage wikiPage = fetchByN_P_Last(nodeId, parentTitle,
5286                                    orderByComparator);
5287    
5288                    if (wikiPage != null) {
5289                            return wikiPage;
5290                    }
5291    
5292                    StringBundler msg = new StringBundler(6);
5293    
5294                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5295    
5296                    msg.append("nodeId=");
5297                    msg.append(nodeId);
5298    
5299                    msg.append(", parentTitle=");
5300                    msg.append(parentTitle);
5301    
5302                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5303    
5304                    throw new NoSuchPageException(msg.toString());
5305            }
5306    
5307            /**
5308             * Returns the last wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
5309             *
5310             * @param nodeId the node ID
5311             * @param parentTitle the parent title
5312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5313             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
5314             */
5315            @Override
5316            public WikiPage fetchByN_P_Last(long nodeId, String parentTitle,
5317                    OrderByComparator<WikiPage> orderByComparator) {
5318                    int count = countByN_P(nodeId, parentTitle);
5319    
5320                    if (count == 0) {
5321                            return null;
5322                    }
5323    
5324                    List<WikiPage> list = findByN_P(nodeId, parentTitle, count - 1, count,
5325                                    orderByComparator);
5326    
5327                    if (!list.isEmpty()) {
5328                            return list.get(0);
5329                    }
5330    
5331                    return null;
5332            }
5333    
5334            /**
5335             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
5336             *
5337             * @param pageId the primary key of the current wiki page
5338             * @param nodeId the node ID
5339             * @param parentTitle the parent title
5340             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5341             * @return the previous, current, and next wiki page
5342             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
5343             */
5344            @Override
5345            public WikiPage[] findByN_P_PrevAndNext(long pageId, long nodeId,
5346                    String parentTitle, OrderByComparator<WikiPage> orderByComparator)
5347                    throws NoSuchPageException {
5348                    WikiPage wikiPage = findByPrimaryKey(pageId);
5349    
5350                    Session session = null;
5351    
5352                    try {
5353                            session = openSession();
5354    
5355                            WikiPage[] array = new WikiPageImpl[3];
5356    
5357                            array[0] = getByN_P_PrevAndNext(session, wikiPage, nodeId,
5358                                            parentTitle, orderByComparator, true);
5359    
5360                            array[1] = wikiPage;
5361    
5362                            array[2] = getByN_P_PrevAndNext(session, wikiPage, nodeId,
5363                                            parentTitle, orderByComparator, false);
5364    
5365                            return array;
5366                    }
5367                    catch (Exception e) {
5368                            throw processException(e);
5369                    }
5370                    finally {
5371                            closeSession(session);
5372                    }
5373            }
5374    
5375            protected WikiPage getByN_P_PrevAndNext(Session session, WikiPage wikiPage,
5376                    long nodeId, String parentTitle,
5377                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
5378                    StringBundler query = null;
5379    
5380                    if (orderByComparator != null) {
5381                            query = new StringBundler(6 +
5382                                            (orderByComparator.getOrderByFields().length * 6));
5383                    }
5384                    else {
5385                            query = new StringBundler(3);
5386                    }
5387    
5388                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5389    
5390                    query.append(_FINDER_COLUMN_N_P_NODEID_2);
5391    
5392                    boolean bindParentTitle = false;
5393    
5394                    if (parentTitle == null) {
5395                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
5396                    }
5397                    else if (parentTitle.equals(StringPool.BLANK)) {
5398                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
5399                    }
5400                    else {
5401                            bindParentTitle = true;
5402    
5403                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
5404                    }
5405    
5406                    if (orderByComparator != null) {
5407                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5408    
5409                            if (orderByConditionFields.length > 0) {
5410                                    query.append(WHERE_AND);
5411                            }
5412    
5413                            for (int i = 0; i < orderByConditionFields.length; i++) {
5414                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5415                                    query.append(orderByConditionFields[i]);
5416    
5417                                    if ((i + 1) < orderByConditionFields.length) {
5418                                            if (orderByComparator.isAscending() ^ previous) {
5419                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5420                                            }
5421                                            else {
5422                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5423                                            }
5424                                    }
5425                                    else {
5426                                            if (orderByComparator.isAscending() ^ previous) {
5427                                                    query.append(WHERE_GREATER_THAN);
5428                                            }
5429                                            else {
5430                                                    query.append(WHERE_LESSER_THAN);
5431                                            }
5432                                    }
5433                            }
5434    
5435                            query.append(ORDER_BY_CLAUSE);
5436    
5437                            String[] orderByFields = orderByComparator.getOrderByFields();
5438    
5439                            for (int i = 0; i < orderByFields.length; i++) {
5440                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5441                                    query.append(orderByFields[i]);
5442    
5443                                    if ((i + 1) < orderByFields.length) {
5444                                            if (orderByComparator.isAscending() ^ previous) {
5445                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5446                                            }
5447                                            else {
5448                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5449                                            }
5450                                    }
5451                                    else {
5452                                            if (orderByComparator.isAscending() ^ previous) {
5453                                                    query.append(ORDER_BY_ASC);
5454                                            }
5455                                            else {
5456                                                    query.append(ORDER_BY_DESC);
5457                                            }
5458                                    }
5459                            }
5460                    }
5461                    else {
5462                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5463                    }
5464    
5465                    String sql = query.toString();
5466    
5467                    Query q = session.createQuery(sql);
5468    
5469                    q.setFirstResult(0);
5470                    q.setMaxResults(2);
5471    
5472                    QueryPos qPos = QueryPos.getInstance(q);
5473    
5474                    qPos.add(nodeId);
5475    
5476                    if (bindParentTitle) {
5477                            qPos.add(StringUtil.toLowerCase(parentTitle));
5478                    }
5479    
5480                    if (orderByComparator != null) {
5481                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
5482    
5483                            for (Object value : values) {
5484                                    qPos.add(value);
5485                            }
5486                    }
5487    
5488                    List<WikiPage> list = q.list();
5489    
5490                    if (list.size() == 2) {
5491                            return list.get(1);
5492                    }
5493                    else {
5494                            return null;
5495                    }
5496            }
5497    
5498            /**
5499             * Removes all the wiki pages where nodeId = &#63; and parentTitle = &#63; from the database.
5500             *
5501             * @param nodeId the node ID
5502             * @param parentTitle the parent title
5503             */
5504            @Override
5505            public void removeByN_P(long nodeId, String parentTitle) {
5506                    for (WikiPage wikiPage : findByN_P(nodeId, parentTitle,
5507                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5508                            remove(wikiPage);
5509                    }
5510            }
5511    
5512            /**
5513             * Returns the number of wiki pages where nodeId = &#63; and parentTitle = &#63;.
5514             *
5515             * @param nodeId the node ID
5516             * @param parentTitle the parent title
5517             * @return the number of matching wiki pages
5518             */
5519            @Override
5520            public int countByN_P(long nodeId, String parentTitle) {
5521                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_P;
5522    
5523                    Object[] finderArgs = new Object[] { nodeId, parentTitle };
5524    
5525                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5526                                    this);
5527    
5528                    if (count == null) {
5529                            StringBundler query = new StringBundler(3);
5530    
5531                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
5532    
5533                            query.append(_FINDER_COLUMN_N_P_NODEID_2);
5534    
5535                            boolean bindParentTitle = false;
5536    
5537                            if (parentTitle == null) {
5538                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
5539                            }
5540                            else if (parentTitle.equals(StringPool.BLANK)) {
5541                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
5542                            }
5543                            else {
5544                                    bindParentTitle = true;
5545    
5546                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
5547                            }
5548    
5549                            String sql = query.toString();
5550    
5551                            Session session = null;
5552    
5553                            try {
5554                                    session = openSession();
5555    
5556                                    Query q = session.createQuery(sql);
5557    
5558                                    QueryPos qPos = QueryPos.getInstance(q);
5559    
5560                                    qPos.add(nodeId);
5561    
5562                                    if (bindParentTitle) {
5563                                            qPos.add(StringUtil.toLowerCase(parentTitle));
5564                                    }
5565    
5566                                    count = (Long)q.uniqueResult();
5567    
5568                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5569                            }
5570                            catch (Exception e) {
5571                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5572    
5573                                    throw processException(e);
5574                            }
5575                            finally {
5576                                    closeSession(session);
5577                            }
5578                    }
5579    
5580                    return count.intValue();
5581            }
5582    
5583            private static final String _FINDER_COLUMN_N_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
5584            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
5585            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = ?";
5586            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = '')";
5587            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5588                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
5589                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_R",
5590                            new String[] {
5591                                    Long.class.getName(), String.class.getName(),
5592                                    
5593                            Integer.class.getName(), Integer.class.getName(),
5594                                    OrderByComparator.class.getName()
5595                            });
5596            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5597                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
5598                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_R",
5599                            new String[] { Long.class.getName(), String.class.getName() },
5600                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
5601                            WikiPageModelImpl.REDIRECTTITLE_COLUMN_BITMASK |
5602                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
5603                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
5604            public static final FinderPath FINDER_PATH_COUNT_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5605                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
5606                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_R",
5607                            new String[] { Long.class.getName(), String.class.getName() });
5608    
5609            /**
5610             * Returns all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
5611             *
5612             * @param nodeId the node ID
5613             * @param redirectTitle the redirect title
5614             * @return the matching wiki pages
5615             */
5616            @Override
5617            public List<WikiPage> findByN_R(long nodeId, String redirectTitle) {
5618                    return findByN_R(nodeId, redirectTitle, QueryUtil.ALL_POS,
5619                            QueryUtil.ALL_POS, null);
5620            }
5621    
5622            /**
5623             * Returns a range of all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
5624             *
5625             * <p>
5626             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
5627             * </p>
5628             *
5629             * @param nodeId the node ID
5630             * @param redirectTitle the redirect title
5631             * @param start the lower bound of the range of wiki pages
5632             * @param end the upper bound of the range of wiki pages (not inclusive)
5633             * @return the range of matching wiki pages
5634             */
5635            @Override
5636            public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
5637                    int start, int end) {
5638                    return findByN_R(nodeId, redirectTitle, start, end, null);
5639            }
5640    
5641            /**
5642             * Returns an ordered range of all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
5643             *
5644             * <p>
5645             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
5646             * </p>
5647             *
5648             * @param nodeId the node ID
5649             * @param redirectTitle the redirect title
5650             * @param start the lower bound of the range of wiki pages
5651             * @param end the upper bound of the range of wiki pages (not inclusive)
5652             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5653             * @return the ordered range of matching wiki pages
5654             */
5655            @Override
5656            public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
5657                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
5658                    boolean pagination = true;
5659                    FinderPath finderPath = null;
5660                    Object[] finderArgs = null;
5661    
5662                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5663                                    (orderByComparator == null)) {
5664                            pagination = false;
5665                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R;
5666                            finderArgs = new Object[] { nodeId, redirectTitle };
5667                    }
5668                    else {
5669                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_R;
5670                            finderArgs = new Object[] {
5671                                            nodeId, redirectTitle,
5672                                            
5673                                            start, end, orderByComparator
5674                                    };
5675                    }
5676    
5677                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
5678                                    finderArgs, this);
5679    
5680                    if ((list != null) && !list.isEmpty()) {
5681                            for (WikiPage wikiPage : list) {
5682                                    if ((nodeId != wikiPage.getNodeId()) ||
5683                                                    !Validator.equals(redirectTitle,
5684                                                            wikiPage.getRedirectTitle())) {
5685                                            list = null;
5686    
5687                                            break;
5688                                    }
5689                            }
5690                    }
5691    
5692                    if (list == null) {
5693                            StringBundler query = null;
5694    
5695                            if (orderByComparator != null) {
5696                                    query = new StringBundler(4 +
5697                                                    (orderByComparator.getOrderByFields().length * 3));
5698                            }
5699                            else {
5700                                    query = new StringBundler(4);
5701                            }
5702    
5703                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5704    
5705                            query.append(_FINDER_COLUMN_N_R_NODEID_2);
5706    
5707                            boolean bindRedirectTitle = false;
5708    
5709                            if (redirectTitle == null) {
5710                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
5711                            }
5712                            else if (redirectTitle.equals(StringPool.BLANK)) {
5713                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
5714                            }
5715                            else {
5716                                    bindRedirectTitle = true;
5717    
5718                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
5719                            }
5720    
5721                            if (orderByComparator != null) {
5722                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5723                                            orderByComparator);
5724                            }
5725                            else
5726                             if (pagination) {
5727                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5728                            }
5729    
5730                            String sql = query.toString();
5731    
5732                            Session session = null;
5733    
5734                            try {
5735                                    session = openSession();
5736    
5737                                    Query q = session.createQuery(sql);
5738    
5739                                    QueryPos qPos = QueryPos.getInstance(q);
5740    
5741                                    qPos.add(nodeId);
5742    
5743                                    if (bindRedirectTitle) {
5744                                            qPos.add(StringUtil.toLowerCase(redirectTitle));
5745                                    }
5746    
5747                                    if (!pagination) {
5748                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
5749                                                            start, end, false);
5750    
5751                                            Collections.sort(list);
5752    
5753                                            list = Collections.unmodifiableList(list);
5754                                    }
5755                                    else {
5756                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
5757                                                            start, end);
5758                                    }
5759    
5760                                    cacheResult(list);
5761    
5762                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5763                            }
5764                            catch (Exception e) {
5765                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5766    
5767                                    throw processException(e);
5768                            }
5769                            finally {
5770                                    closeSession(session);
5771                            }
5772                    }
5773    
5774                    return list;
5775            }
5776    
5777            /**
5778             * Returns the first wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
5779             *
5780             * @param nodeId the node ID
5781             * @param redirectTitle the redirect title
5782             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5783             * @return the first matching wiki page
5784             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5785             */
5786            @Override
5787            public WikiPage findByN_R_First(long nodeId, String redirectTitle,
5788                    OrderByComparator<WikiPage> orderByComparator)
5789                    throws NoSuchPageException {
5790                    WikiPage wikiPage = fetchByN_R_First(nodeId, redirectTitle,
5791                                    orderByComparator);
5792    
5793                    if (wikiPage != null) {
5794                            return wikiPage;
5795                    }
5796    
5797                    StringBundler msg = new StringBundler(6);
5798    
5799                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5800    
5801                    msg.append("nodeId=");
5802                    msg.append(nodeId);
5803    
5804                    msg.append(", redirectTitle=");
5805                    msg.append(redirectTitle);
5806    
5807                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5808    
5809                    throw new NoSuchPageException(msg.toString());
5810            }
5811    
5812            /**
5813             * Returns the first wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
5814             *
5815             * @param nodeId the node ID
5816             * @param redirectTitle the redirect title
5817             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5818             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
5819             */
5820            @Override
5821            public WikiPage fetchByN_R_First(long nodeId, String redirectTitle,
5822                    OrderByComparator<WikiPage> orderByComparator) {
5823                    List<WikiPage> list = findByN_R(nodeId, redirectTitle, 0, 1,
5824                                    orderByComparator);
5825    
5826                    if (!list.isEmpty()) {
5827                            return list.get(0);
5828                    }
5829    
5830                    return null;
5831            }
5832    
5833            /**
5834             * Returns the last wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
5835             *
5836             * @param nodeId the node ID
5837             * @param redirectTitle the redirect title
5838             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5839             * @return the last matching wiki page
5840             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5841             */
5842            @Override
5843            public WikiPage findByN_R_Last(long nodeId, String redirectTitle,
5844                    OrderByComparator<WikiPage> orderByComparator)
5845                    throws NoSuchPageException {
5846                    WikiPage wikiPage = fetchByN_R_Last(nodeId, redirectTitle,
5847                                    orderByComparator);
5848    
5849                    if (wikiPage != null) {
5850                            return wikiPage;
5851                    }
5852    
5853                    StringBundler msg = new StringBundler(6);
5854    
5855                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5856    
5857                    msg.append("nodeId=");
5858                    msg.append(nodeId);
5859    
5860                    msg.append(", redirectTitle=");
5861                    msg.append(redirectTitle);
5862    
5863                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5864    
5865                    throw new NoSuchPageException(msg.toString());
5866            }
5867    
5868            /**
5869             * Returns the last wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
5870             *
5871             * @param nodeId the node ID
5872             * @param redirectTitle the redirect title
5873             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5874             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
5875             */
5876            @Override
5877            public WikiPage fetchByN_R_Last(long nodeId, String redirectTitle,
5878                    OrderByComparator<WikiPage> orderByComparator) {
5879                    int count = countByN_R(nodeId, redirectTitle);
5880    
5881                    if (count == 0) {
5882                            return null;
5883                    }
5884    
5885                    List<WikiPage> list = findByN_R(nodeId, redirectTitle, count - 1,
5886                                    count, orderByComparator);
5887    
5888                    if (!list.isEmpty()) {
5889                            return list.get(0);
5890                    }
5891    
5892                    return null;
5893            }
5894    
5895            /**
5896             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
5897             *
5898             * @param pageId the primary key of the current wiki page
5899             * @param nodeId the node ID
5900             * @param redirectTitle the redirect title
5901             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5902             * @return the previous, current, and next wiki page
5903             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
5904             */
5905            @Override
5906            public WikiPage[] findByN_R_PrevAndNext(long pageId, long nodeId,
5907                    String redirectTitle, OrderByComparator<WikiPage> orderByComparator)
5908                    throws NoSuchPageException {
5909                    WikiPage wikiPage = findByPrimaryKey(pageId);
5910    
5911                    Session session = null;
5912    
5913                    try {
5914                            session = openSession();
5915    
5916                            WikiPage[] array = new WikiPageImpl[3];
5917    
5918                            array[0] = getByN_R_PrevAndNext(session, wikiPage, nodeId,
5919                                            redirectTitle, orderByComparator, true);
5920    
5921                            array[1] = wikiPage;
5922    
5923                            array[2] = getByN_R_PrevAndNext(session, wikiPage, nodeId,
5924                                            redirectTitle, orderByComparator, false);
5925    
5926                            return array;
5927                    }
5928                    catch (Exception e) {
5929                            throw processException(e);
5930                    }
5931                    finally {
5932                            closeSession(session);
5933                    }
5934            }
5935    
5936            protected WikiPage getByN_R_PrevAndNext(Session session, WikiPage wikiPage,
5937                    long nodeId, String redirectTitle,
5938                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
5939                    StringBundler query = null;
5940    
5941                    if (orderByComparator != null) {
5942                            query = new StringBundler(6 +
5943                                            (orderByComparator.getOrderByFields().length * 6));
5944                    }
5945                    else {
5946                            query = new StringBundler(3);
5947                    }
5948    
5949                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5950    
5951                    query.append(_FINDER_COLUMN_N_R_NODEID_2);
5952    
5953                    boolean bindRedirectTitle = false;
5954    
5955                    if (redirectTitle == null) {
5956                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
5957                    }
5958                    else if (redirectTitle.equals(StringPool.BLANK)) {
5959                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
5960                    }
5961                    else {
5962                            bindRedirectTitle = true;
5963    
5964                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
5965                    }
5966    
5967                    if (orderByComparator != null) {
5968                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5969    
5970                            if (orderByConditionFields.length > 0) {
5971                                    query.append(WHERE_AND);
5972                            }
5973    
5974                            for (int i = 0; i < orderByConditionFields.length; i++) {
5975                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5976                                    query.append(orderByConditionFields[i]);
5977    
5978                                    if ((i + 1) < orderByConditionFields.length) {
5979                                            if (orderByComparator.isAscending() ^ previous) {
5980                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5981                                            }
5982                                            else {
5983                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5984                                            }
5985                                    }
5986                                    else {
5987                                            if (orderByComparator.isAscending() ^ previous) {
5988                                                    query.append(WHERE_GREATER_THAN);
5989                                            }
5990                                            else {
5991                                                    query.append(WHERE_LESSER_THAN);
5992                                            }
5993                                    }
5994                            }
5995    
5996                            query.append(ORDER_BY_CLAUSE);
5997    
5998                            String[] orderByFields = orderByComparator.getOrderByFields();
5999    
6000                            for (int i = 0; i < orderByFields.length; i++) {
6001                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6002                                    query.append(orderByFields[i]);
6003    
6004                                    if ((i + 1) < orderByFields.length) {
6005                                            if (orderByComparator.isAscending() ^ previous) {
6006                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6007                                            }
6008                                            else {
6009                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6010                                            }
6011                                    }
6012                                    else {
6013                                            if (orderByComparator.isAscending() ^ previous) {
6014                                                    query.append(ORDER_BY_ASC);
6015                                            }
6016                                            else {
6017                                                    query.append(ORDER_BY_DESC);
6018                                            }
6019                                    }
6020                            }
6021                    }
6022                    else {
6023                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6024                    }
6025    
6026                    String sql = query.toString();
6027    
6028                    Query q = session.createQuery(sql);
6029    
6030                    q.setFirstResult(0);
6031                    q.setMaxResults(2);
6032    
6033                    QueryPos qPos = QueryPos.getInstance(q);
6034    
6035                    qPos.add(nodeId);
6036    
6037                    if (bindRedirectTitle) {
6038                            qPos.add(StringUtil.toLowerCase(redirectTitle));
6039                    }
6040    
6041                    if (orderByComparator != null) {
6042                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
6043    
6044                            for (Object value : values) {
6045                                    qPos.add(value);
6046                            }
6047                    }
6048    
6049                    List<WikiPage> list = q.list();
6050    
6051                    if (list.size() == 2) {
6052                            return list.get(1);
6053                    }
6054                    else {
6055                            return null;
6056                    }
6057            }
6058    
6059            /**
6060             * Removes all the wiki pages where nodeId = &#63; and redirectTitle = &#63; from the database.
6061             *
6062             * @param nodeId the node ID
6063             * @param redirectTitle the redirect title
6064             */
6065            @Override
6066            public void removeByN_R(long nodeId, String redirectTitle) {
6067                    for (WikiPage wikiPage : findByN_R(nodeId, redirectTitle,
6068                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6069                            remove(wikiPage);
6070                    }
6071            }
6072    
6073            /**
6074             * Returns the number of wiki pages where nodeId = &#63; and redirectTitle = &#63;.
6075             *
6076             * @param nodeId the node ID
6077             * @param redirectTitle the redirect title
6078             * @return the number of matching wiki pages
6079             */
6080            @Override
6081            public int countByN_R(long nodeId, String redirectTitle) {
6082                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_R;
6083    
6084                    Object[] finderArgs = new Object[] { nodeId, redirectTitle };
6085    
6086                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6087                                    this);
6088    
6089                    if (count == null) {
6090                            StringBundler query = new StringBundler(3);
6091    
6092                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
6093    
6094                            query.append(_FINDER_COLUMN_N_R_NODEID_2);
6095    
6096                            boolean bindRedirectTitle = false;
6097    
6098                            if (redirectTitle == null) {
6099                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
6100                            }
6101                            else if (redirectTitle.equals(StringPool.BLANK)) {
6102                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
6103                            }
6104                            else {
6105                                    bindRedirectTitle = true;
6106    
6107                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
6108                            }
6109    
6110                            String sql = query.toString();
6111    
6112                            Session session = null;
6113    
6114                            try {
6115                                    session = openSession();
6116    
6117                                    Query q = session.createQuery(sql);
6118    
6119                                    QueryPos qPos = QueryPos.getInstance(q);
6120    
6121                                    qPos.add(nodeId);
6122    
6123                                    if (bindRedirectTitle) {
6124                                            qPos.add(StringUtil.toLowerCase(redirectTitle));
6125                                    }
6126    
6127                                    count = (Long)q.uniqueResult();
6128    
6129                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6130                            }
6131                            catch (Exception e) {
6132                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6133    
6134                                    throw processException(e);
6135                            }
6136                            finally {
6137                                    closeSession(session);
6138                            }
6139                    }
6140    
6141                    return count.intValue();
6142            }
6143    
6144            private static final String _FINDER_COLUMN_N_R_NODEID_2 = "wikiPage.nodeId = ? AND ";
6145            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_1 = "wikiPage.redirectTitle IS NULL";
6146            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_2 = "lower(wikiPage.redirectTitle) = ?";
6147            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_3 = "(wikiPage.redirectTitle IS NULL OR wikiPage.redirectTitle = '')";
6148            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6149                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
6150                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_S",
6151                            new String[] {
6152                                    Long.class.getName(), Integer.class.getName(),
6153                                    
6154                            Integer.class.getName(), Integer.class.getName(),
6155                                    OrderByComparator.class.getName()
6156                            });
6157            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6158                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
6159                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_S",
6160                            new String[] { Long.class.getName(), Integer.class.getName() },
6161                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
6162                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
6163                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
6164                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
6165            public static final FinderPath FINDER_PATH_COUNT_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6166                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
6167                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_S",
6168                            new String[] { Long.class.getName(), Integer.class.getName() });
6169    
6170            /**
6171             * Returns all the wiki pages where nodeId = &#63; and status = &#63;.
6172             *
6173             * @param nodeId the node ID
6174             * @param status the status
6175             * @return the matching wiki pages
6176             */
6177            @Override
6178            public List<WikiPage> findByN_S(long nodeId, int status) {
6179                    return findByN_S(nodeId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6180                            null);
6181            }
6182    
6183            /**
6184             * Returns a range of all the wiki pages where nodeId = &#63; and status = &#63;.
6185             *
6186             * <p>
6187             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
6188             * </p>
6189             *
6190             * @param nodeId the node ID
6191             * @param status the status
6192             * @param start the lower bound of the range of wiki pages
6193             * @param end the upper bound of the range of wiki pages (not inclusive)
6194             * @return the range of matching wiki pages
6195             */
6196            @Override
6197            public List<WikiPage> findByN_S(long nodeId, int status, int start, int end) {
6198                    return findByN_S(nodeId, status, start, end, null);
6199            }
6200    
6201            /**
6202             * Returns an ordered range of all the wiki pages where nodeId = &#63; and status = &#63;.
6203             *
6204             * <p>
6205             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
6206             * </p>
6207             *
6208             * @param nodeId the node ID
6209             * @param status the status
6210             * @param start the lower bound of the range of wiki pages
6211             * @param end the upper bound of the range of wiki pages (not inclusive)
6212             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6213             * @return the ordered range of matching wiki pages
6214             */
6215            @Override
6216            public List<WikiPage> findByN_S(long nodeId, int status, int start,
6217                    int end, OrderByComparator<WikiPage> orderByComparator) {
6218                    boolean pagination = true;
6219                    FinderPath finderPath = null;
6220                    Object[] finderArgs = null;
6221    
6222                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6223                                    (orderByComparator == null)) {
6224                            pagination = false;
6225                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S;
6226                            finderArgs = new Object[] { nodeId, status };
6227                    }
6228                    else {
6229                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_S;
6230                            finderArgs = new Object[] {
6231                                            nodeId, status,
6232                                            
6233                                            start, end, orderByComparator
6234                                    };
6235                    }
6236    
6237                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
6238                                    finderArgs, this);
6239    
6240                    if ((list != null) && !list.isEmpty()) {
6241                            for (WikiPage wikiPage : list) {
6242                                    if ((nodeId != wikiPage.getNodeId()) ||
6243                                                    (status != wikiPage.getStatus())) {
6244                                            list = null;
6245    
6246                                            break;
6247                                    }
6248                            }
6249                    }
6250    
6251                    if (list == null) {
6252                            StringBundler query = null;
6253    
6254                            if (orderByComparator != null) {
6255                                    query = new StringBundler(4 +
6256                                                    (orderByComparator.getOrderByFields().length * 3));
6257                            }
6258                            else {
6259                                    query = new StringBundler(4);
6260                            }
6261    
6262                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6263    
6264                            query.append(_FINDER_COLUMN_N_S_NODEID_2);
6265    
6266                            query.append(_FINDER_COLUMN_N_S_STATUS_2);
6267    
6268                            if (orderByComparator != null) {
6269                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6270                                            orderByComparator);
6271                            }
6272                            else
6273                             if (pagination) {
6274                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6275                            }
6276    
6277                            String sql = query.toString();
6278    
6279                            Session session = null;
6280    
6281                            try {
6282                                    session = openSession();
6283    
6284                                    Query q = session.createQuery(sql);
6285    
6286                                    QueryPos qPos = QueryPos.getInstance(q);
6287    
6288                                    qPos.add(nodeId);
6289    
6290                                    qPos.add(status);
6291    
6292                                    if (!pagination) {
6293                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
6294                                                            start, end, false);
6295    
6296                                            Collections.sort(list);
6297    
6298                                            list = Collections.unmodifiableList(list);
6299                                    }
6300                                    else {
6301                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
6302                                                            start, end);
6303                                    }
6304    
6305                                    cacheResult(list);
6306    
6307                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6308                            }
6309                            catch (Exception e) {
6310                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6311    
6312                                    throw processException(e);
6313                            }
6314                            finally {
6315                                    closeSession(session);
6316                            }
6317                    }
6318    
6319                    return list;
6320            }
6321    
6322            /**
6323             * Returns the first wiki page in the ordered set where nodeId = &#63; and status = &#63;.
6324             *
6325             * @param nodeId the node ID
6326             * @param status the status
6327             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6328             * @return the first matching wiki page
6329             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6330             */
6331            @Override
6332            public WikiPage findByN_S_First(long nodeId, int status,
6333                    OrderByComparator<WikiPage> orderByComparator)
6334                    throws NoSuchPageException {
6335                    WikiPage wikiPage = fetchByN_S_First(nodeId, status, orderByComparator);
6336    
6337                    if (wikiPage != null) {
6338                            return wikiPage;
6339                    }
6340    
6341                    StringBundler msg = new StringBundler(6);
6342    
6343                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6344    
6345                    msg.append("nodeId=");
6346                    msg.append(nodeId);
6347    
6348                    msg.append(", status=");
6349                    msg.append(status);
6350    
6351                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6352    
6353                    throw new NoSuchPageException(msg.toString());
6354            }
6355    
6356            /**
6357             * Returns the first wiki page in the ordered set where nodeId = &#63; and status = &#63;.
6358             *
6359             * @param nodeId the node ID
6360             * @param status the status
6361             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6362             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
6363             */
6364            @Override
6365            public WikiPage fetchByN_S_First(long nodeId, int status,
6366                    OrderByComparator<WikiPage> orderByComparator) {
6367                    List<WikiPage> list = findByN_S(nodeId, status, 0, 1, orderByComparator);
6368    
6369                    if (!list.isEmpty()) {
6370                            return list.get(0);
6371                    }
6372    
6373                    return null;
6374            }
6375    
6376            /**
6377             * Returns the last wiki page in the ordered set where nodeId = &#63; and status = &#63;.
6378             *
6379             * @param nodeId the node ID
6380             * @param status the status
6381             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6382             * @return the last matching wiki page
6383             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6384             */
6385            @Override
6386            public WikiPage findByN_S_Last(long nodeId, int status,
6387                    OrderByComparator<WikiPage> orderByComparator)
6388                    throws NoSuchPageException {
6389                    WikiPage wikiPage = fetchByN_S_Last(nodeId, status, orderByComparator);
6390    
6391                    if (wikiPage != null) {
6392                            return wikiPage;
6393                    }
6394    
6395                    StringBundler msg = new StringBundler(6);
6396    
6397                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6398    
6399                    msg.append("nodeId=");
6400                    msg.append(nodeId);
6401    
6402                    msg.append(", status=");
6403                    msg.append(status);
6404    
6405                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6406    
6407                    throw new NoSuchPageException(msg.toString());
6408            }
6409    
6410            /**
6411             * Returns the last wiki page in the ordered set where nodeId = &#63; and status = &#63;.
6412             *
6413             * @param nodeId the node ID
6414             * @param status the status
6415             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6416             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
6417             */
6418            @Override
6419            public WikiPage fetchByN_S_Last(long nodeId, int status,
6420                    OrderByComparator<WikiPage> orderByComparator) {
6421                    int count = countByN_S(nodeId, status);
6422    
6423                    if (count == 0) {
6424                            return null;
6425                    }
6426    
6427                    List<WikiPage> list = findByN_S(nodeId, status, count - 1, count,
6428                                    orderByComparator);
6429    
6430                    if (!list.isEmpty()) {
6431                            return list.get(0);
6432                    }
6433    
6434                    return null;
6435            }
6436    
6437            /**
6438             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and status = &#63;.
6439             *
6440             * @param pageId the primary key of the current wiki page
6441             * @param nodeId the node ID
6442             * @param status the status
6443             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6444             * @return the previous, current, and next wiki page
6445             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
6446             */
6447            @Override
6448            public WikiPage[] findByN_S_PrevAndNext(long pageId, long nodeId,
6449                    int status, OrderByComparator<WikiPage> orderByComparator)
6450                    throws NoSuchPageException {
6451                    WikiPage wikiPage = findByPrimaryKey(pageId);
6452    
6453                    Session session = null;
6454    
6455                    try {
6456                            session = openSession();
6457    
6458                            WikiPage[] array = new WikiPageImpl[3];
6459    
6460                            array[0] = getByN_S_PrevAndNext(session, wikiPage, nodeId, status,
6461                                            orderByComparator, true);
6462    
6463                            array[1] = wikiPage;
6464    
6465                            array[2] = getByN_S_PrevAndNext(session, wikiPage, nodeId, status,
6466                                            orderByComparator, false);
6467    
6468                            return array;
6469                    }
6470                    catch (Exception e) {
6471                            throw processException(e);
6472                    }
6473                    finally {
6474                            closeSession(session);
6475                    }
6476            }
6477    
6478            protected WikiPage getByN_S_PrevAndNext(Session session, WikiPage wikiPage,
6479                    long nodeId, int status, OrderByComparator<WikiPage> orderByComparator,
6480                    boolean previous) {
6481                    StringBundler query = null;
6482    
6483                    if (orderByComparator != null) {
6484                            query = new StringBundler(6 +
6485                                            (orderByComparator.getOrderByFields().length * 6));
6486                    }
6487                    else {
6488                            query = new StringBundler(3);
6489                    }
6490    
6491                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6492    
6493                    query.append(_FINDER_COLUMN_N_S_NODEID_2);
6494    
6495                    query.append(_FINDER_COLUMN_N_S_STATUS_2);
6496    
6497                    if (orderByComparator != null) {
6498                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6499    
6500                            if (orderByConditionFields.length > 0) {
6501                                    query.append(WHERE_AND);
6502                            }
6503    
6504                            for (int i = 0; i < orderByConditionFields.length; i++) {
6505                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6506                                    query.append(orderByConditionFields[i]);
6507    
6508                                    if ((i + 1) < orderByConditionFields.length) {
6509                                            if (orderByComparator.isAscending() ^ previous) {
6510                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6511                                            }
6512                                            else {
6513                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6514                                            }
6515                                    }
6516                                    else {
6517                                            if (orderByComparator.isAscending() ^ previous) {
6518                                                    query.append(WHERE_GREATER_THAN);
6519                                            }
6520                                            else {
6521                                                    query.append(WHERE_LESSER_THAN);
6522                                            }
6523                                    }
6524                            }
6525    
6526                            query.append(ORDER_BY_CLAUSE);
6527    
6528                            String[] orderByFields = orderByComparator.getOrderByFields();
6529    
6530                            for (int i = 0; i < orderByFields.length; i++) {
6531                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6532                                    query.append(orderByFields[i]);
6533    
6534                                    if ((i + 1) < orderByFields.length) {
6535                                            if (orderByComparator.isAscending() ^ previous) {
6536                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6537                                            }
6538                                            else {
6539                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6540                                            }
6541                                    }
6542                                    else {
6543                                            if (orderByComparator.isAscending() ^ previous) {
6544                                                    query.append(ORDER_BY_ASC);
6545                                            }
6546                                            else {
6547                                                    query.append(ORDER_BY_DESC);
6548                                            }
6549                                    }
6550                            }
6551                    }
6552                    else {
6553                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6554                    }
6555    
6556                    String sql = query.toString();
6557    
6558                    Query q = session.createQuery(sql);
6559    
6560                    q.setFirstResult(0);
6561                    q.setMaxResults(2);
6562    
6563                    QueryPos qPos = QueryPos.getInstance(q);
6564    
6565                    qPos.add(nodeId);
6566    
6567                    qPos.add(status);
6568    
6569                    if (orderByComparator != null) {
6570                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
6571    
6572                            for (Object value : values) {
6573                                    qPos.add(value);
6574                            }
6575                    }
6576    
6577                    List<WikiPage> list = q.list();
6578    
6579                    if (list.size() == 2) {
6580                            return list.get(1);
6581                    }
6582                    else {
6583                            return null;
6584                    }
6585            }
6586    
6587            /**
6588             * Removes all the wiki pages where nodeId = &#63; and status = &#63; from the database.
6589             *
6590             * @param nodeId the node ID
6591             * @param status the status
6592             */
6593            @Override
6594            public void removeByN_S(long nodeId, int status) {
6595                    for (WikiPage wikiPage : findByN_S(nodeId, status, QueryUtil.ALL_POS,
6596                                    QueryUtil.ALL_POS, null)) {
6597                            remove(wikiPage);
6598                    }
6599            }
6600    
6601            /**
6602             * Returns the number of wiki pages where nodeId = &#63; and status = &#63;.
6603             *
6604             * @param nodeId the node ID
6605             * @param status the status
6606             * @return the number of matching wiki pages
6607             */
6608            @Override
6609            public int countByN_S(long nodeId, int status) {
6610                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_S;
6611    
6612                    Object[] finderArgs = new Object[] { nodeId, status };
6613    
6614                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6615                                    this);
6616    
6617                    if (count == null) {
6618                            StringBundler query = new StringBundler(3);
6619    
6620                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
6621    
6622                            query.append(_FINDER_COLUMN_N_S_NODEID_2);
6623    
6624                            query.append(_FINDER_COLUMN_N_S_STATUS_2);
6625    
6626                            String sql = query.toString();
6627    
6628                            Session session = null;
6629    
6630                            try {
6631                                    session = openSession();
6632    
6633                                    Query q = session.createQuery(sql);
6634    
6635                                    QueryPos qPos = QueryPos.getInstance(q);
6636    
6637                                    qPos.add(nodeId);
6638    
6639                                    qPos.add(status);
6640    
6641                                    count = (Long)q.uniqueResult();
6642    
6643                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6644                            }
6645                            catch (Exception e) {
6646                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6647    
6648                                    throw processException(e);
6649                            }
6650                            finally {
6651                                    closeSession(session);
6652                            }
6653                    }
6654    
6655                    return count.intValue();
6656            }
6657    
6658            private static final String _FINDER_COLUMN_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
6659            private static final String _FINDER_COLUMN_N_S_STATUS_2 = "wikiPage.status = ?";
6660            public static final FinderPath FINDER_PATH_FETCH_BY_R_N_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6661                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
6662                            FINDER_CLASS_NAME_ENTITY, "fetchByR_N_V",
6663                            new String[] {
6664                                    Long.class.getName(), Long.class.getName(),
6665                                    Double.class.getName()
6666                            },
6667                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
6668                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
6669                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
6670            public static final FinderPath FINDER_PATH_COUNT_BY_R_N_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6671                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
6672                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N_V",
6673                            new String[] {
6674                                    Long.class.getName(), Long.class.getName(),
6675                                    Double.class.getName()
6676                            });
6677    
6678            /**
6679             * Returns the wiki page where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63; or throws a {@link com.liferay.portlet.wiki.NoSuchPageException} if it could not be found.
6680             *
6681             * @param resourcePrimKey the resource prim key
6682             * @param nodeId the node ID
6683             * @param version the version
6684             * @return the matching wiki page
6685             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6686             */
6687            @Override
6688            public WikiPage findByR_N_V(long resourcePrimKey, long nodeId,
6689                    double version) throws NoSuchPageException {
6690                    WikiPage wikiPage = fetchByR_N_V(resourcePrimKey, nodeId, version);
6691    
6692                    if (wikiPage == null) {
6693                            StringBundler msg = new StringBundler(8);
6694    
6695                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6696    
6697                            msg.append("resourcePrimKey=");
6698                            msg.append(resourcePrimKey);
6699    
6700                            msg.append(", nodeId=");
6701                            msg.append(nodeId);
6702    
6703                            msg.append(", version=");
6704                            msg.append(version);
6705    
6706                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6707    
6708                            if (_log.isWarnEnabled()) {
6709                                    _log.warn(msg.toString());
6710                            }
6711    
6712                            throw new NoSuchPageException(msg.toString());
6713                    }
6714    
6715                    return wikiPage;
6716            }
6717    
6718            /**
6719             * Returns the wiki page where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
6720             *
6721             * @param resourcePrimKey the resource prim key
6722             * @param nodeId the node ID
6723             * @param version the version
6724             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
6725             */
6726            @Override
6727            public WikiPage fetchByR_N_V(long resourcePrimKey, long nodeId,
6728                    double version) {
6729                    return fetchByR_N_V(resourcePrimKey, nodeId, version, true);
6730            }
6731    
6732            /**
6733             * Returns the wiki page where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
6734             *
6735             * @param resourcePrimKey the resource prim key
6736             * @param nodeId the node ID
6737             * @param version the version
6738             * @param retrieveFromCache whether to use the finder cache
6739             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
6740             */
6741            @Override
6742            public WikiPage fetchByR_N_V(long resourcePrimKey, long nodeId,
6743                    double version, boolean retrieveFromCache) {
6744                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, version };
6745    
6746                    Object result = null;
6747    
6748                    if (retrieveFromCache) {
6749                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_R_N_V,
6750                                            finderArgs, this);
6751                    }
6752    
6753                    if (result instanceof WikiPage) {
6754                            WikiPage wikiPage = (WikiPage)result;
6755    
6756                            if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
6757                                            (nodeId != wikiPage.getNodeId()) ||
6758                                            (version != wikiPage.getVersion())) {
6759                                    result = null;
6760                            }
6761                    }
6762    
6763                    if (result == null) {
6764                            StringBundler query = new StringBundler(5);
6765    
6766                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6767    
6768                            query.append(_FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2);
6769    
6770                            query.append(_FINDER_COLUMN_R_N_V_NODEID_2);
6771    
6772                            query.append(_FINDER_COLUMN_R_N_V_VERSION_2);
6773    
6774                            String sql = query.toString();
6775    
6776                            Session session = null;
6777    
6778                            try {
6779                                    session = openSession();
6780    
6781                                    Query q = session.createQuery(sql);
6782    
6783                                    QueryPos qPos = QueryPos.getInstance(q);
6784    
6785                                    qPos.add(resourcePrimKey);
6786    
6787                                    qPos.add(nodeId);
6788    
6789                                    qPos.add(version);
6790    
6791                                    List<WikiPage> list = q.list();
6792    
6793                                    if (list.isEmpty()) {
6794                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
6795                                                    finderArgs, list);
6796                                    }
6797                                    else {
6798                                            WikiPage wikiPage = list.get(0);
6799    
6800                                            result = wikiPage;
6801    
6802                                            cacheResult(wikiPage);
6803    
6804                                            if ((wikiPage.getResourcePrimKey() != resourcePrimKey) ||
6805                                                            (wikiPage.getNodeId() != nodeId) ||
6806                                                            (wikiPage.getVersion() != version)) {
6807                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
6808                                                            finderArgs, wikiPage);
6809                                            }
6810                                    }
6811                            }
6812                            catch (Exception e) {
6813                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V,
6814                                            finderArgs);
6815    
6816                                    throw processException(e);
6817                            }
6818                            finally {
6819                                    closeSession(session);
6820                            }
6821                    }
6822    
6823                    if (result instanceof List<?>) {
6824                            return null;
6825                    }
6826                    else {
6827                            return (WikiPage)result;
6828                    }
6829            }
6830    
6831            /**
6832             * Removes the wiki page where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63; from the database.
6833             *
6834             * @param resourcePrimKey the resource prim key
6835             * @param nodeId the node ID
6836             * @param version the version
6837             * @return the wiki page that was removed
6838             */
6839            @Override
6840            public WikiPage removeByR_N_V(long resourcePrimKey, long nodeId,
6841                    double version) throws NoSuchPageException {
6842                    WikiPage wikiPage = findByR_N_V(resourcePrimKey, nodeId, version);
6843    
6844                    return remove(wikiPage);
6845            }
6846    
6847            /**
6848             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63;.
6849             *
6850             * @param resourcePrimKey the resource prim key
6851             * @param nodeId the node ID
6852             * @param version the version
6853             * @return the number of matching wiki pages
6854             */
6855            @Override
6856            public int countByR_N_V(long resourcePrimKey, long nodeId, double version) {
6857                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_N_V;
6858    
6859                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, version };
6860    
6861                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6862                                    this);
6863    
6864                    if (count == null) {
6865                            StringBundler query = new StringBundler(4);
6866    
6867                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
6868    
6869                            query.append(_FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2);
6870    
6871                            query.append(_FINDER_COLUMN_R_N_V_NODEID_2);
6872    
6873                            query.append(_FINDER_COLUMN_R_N_V_VERSION_2);
6874    
6875                            String sql = query.toString();
6876    
6877                            Session session = null;
6878    
6879                            try {
6880                                    session = openSession();
6881    
6882                                    Query q = session.createQuery(sql);
6883    
6884                                    QueryPos qPos = QueryPos.getInstance(q);
6885    
6886                                    qPos.add(resourcePrimKey);
6887    
6888                                    qPos.add(nodeId);
6889    
6890                                    qPos.add(version);
6891    
6892                                    count = (Long)q.uniqueResult();
6893    
6894                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6895                            }
6896                            catch (Exception e) {
6897                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6898    
6899                                    throw processException(e);
6900                            }
6901                            finally {
6902                                    closeSession(session);
6903                            }
6904                    }
6905    
6906                    return count.intValue();
6907            }
6908    
6909            private static final String _FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
6910            private static final String _FINDER_COLUMN_R_N_V_NODEID_2 = "wikiPage.nodeId = ? AND ";
6911            private static final String _FINDER_COLUMN_R_N_V_VERSION_2 = "wikiPage.version = ?";
6912            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6913                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
6914                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_N_H",
6915                            new String[] {
6916                                    Long.class.getName(), Long.class.getName(),
6917                                    Boolean.class.getName(),
6918                                    
6919                            Integer.class.getName(), Integer.class.getName(),
6920                                    OrderByComparator.class.getName()
6921                            });
6922            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6923                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
6924                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_N_H",
6925                            new String[] {
6926                                    Long.class.getName(), Long.class.getName(),
6927                                    Boolean.class.getName()
6928                            },
6929                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
6930                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
6931                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
6932                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
6933                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
6934            public static final FinderPath FINDER_PATH_COUNT_BY_R_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6935                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
6936                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N_H",
6937                            new String[] {
6938                                    Long.class.getName(), Long.class.getName(),
6939                                    Boolean.class.getName()
6940                            });
6941    
6942            /**
6943             * Returns all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
6944             *
6945             * @param resourcePrimKey the resource prim key
6946             * @param nodeId the node ID
6947             * @param head the head
6948             * @return the matching wiki pages
6949             */
6950            @Override
6951            public List<WikiPage> findByR_N_H(long resourcePrimKey, long nodeId,
6952                    boolean head) {
6953                    return findByR_N_H(resourcePrimKey, nodeId, head, QueryUtil.ALL_POS,
6954                            QueryUtil.ALL_POS, null);
6955            }
6956    
6957            /**
6958             * Returns a range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
6959             *
6960             * <p>
6961             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
6962             * </p>
6963             *
6964             * @param resourcePrimKey the resource prim key
6965             * @param nodeId the node ID
6966             * @param head the head
6967             * @param start the lower bound of the range of wiki pages
6968             * @param end the upper bound of the range of wiki pages (not inclusive)
6969             * @return the range of matching wiki pages
6970             */
6971            @Override
6972            public List<WikiPage> findByR_N_H(long resourcePrimKey, long nodeId,
6973                    boolean head, int start, int end) {
6974                    return findByR_N_H(resourcePrimKey, nodeId, head, start, end, null);
6975            }
6976    
6977            /**
6978             * Returns an ordered range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
6979             *
6980             * <p>
6981             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
6982             * </p>
6983             *
6984             * @param resourcePrimKey the resource prim key
6985             * @param nodeId the node ID
6986             * @param head the head
6987             * @param start the lower bound of the range of wiki pages
6988             * @param end the upper bound of the range of wiki pages (not inclusive)
6989             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6990             * @return the ordered range of matching wiki pages
6991             */
6992            @Override
6993            public List<WikiPage> findByR_N_H(long resourcePrimKey, long nodeId,
6994                    boolean head, int start, int end,
6995                    OrderByComparator<WikiPage> orderByComparator) {
6996                    boolean pagination = true;
6997                    FinderPath finderPath = null;
6998                    Object[] finderArgs = null;
6999    
7000                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7001                                    (orderByComparator == null)) {
7002                            pagination = false;
7003                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_H;
7004                            finderArgs = new Object[] { resourcePrimKey, nodeId, head };
7005                    }
7006                    else {
7007                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N_H;
7008                            finderArgs = new Object[] {
7009                                            resourcePrimKey, nodeId, head,
7010                                            
7011                                            start, end, orderByComparator
7012                                    };
7013                    }
7014    
7015                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
7016                                    finderArgs, this);
7017    
7018                    if ((list != null) && !list.isEmpty()) {
7019                            for (WikiPage wikiPage : list) {
7020                                    if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
7021                                                    (nodeId != wikiPage.getNodeId()) ||
7022                                                    (head != wikiPage.getHead())) {
7023                                            list = null;
7024    
7025                                            break;
7026                                    }
7027                            }
7028                    }
7029    
7030                    if (list == null) {
7031                            StringBundler query = null;
7032    
7033                            if (orderByComparator != null) {
7034                                    query = new StringBundler(5 +
7035                                                    (orderByComparator.getOrderByFields().length * 3));
7036                            }
7037                            else {
7038                                    query = new StringBundler(5);
7039                            }
7040    
7041                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
7042    
7043                            query.append(_FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2);
7044    
7045                            query.append(_FINDER_COLUMN_R_N_H_NODEID_2);
7046    
7047                            query.append(_FINDER_COLUMN_R_N_H_HEAD_2);
7048    
7049                            if (orderByComparator != null) {
7050                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7051                                            orderByComparator);
7052                            }
7053                            else
7054                             if (pagination) {
7055                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7056                            }
7057    
7058                            String sql = query.toString();
7059    
7060                            Session session = null;
7061    
7062                            try {
7063                                    session = openSession();
7064    
7065                                    Query q = session.createQuery(sql);
7066    
7067                                    QueryPos qPos = QueryPos.getInstance(q);
7068    
7069                                    qPos.add(resourcePrimKey);
7070    
7071                                    qPos.add(nodeId);
7072    
7073                                    qPos.add(head);
7074    
7075                                    if (!pagination) {
7076                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
7077                                                            start, end, false);
7078    
7079                                            Collections.sort(list);
7080    
7081                                            list = Collections.unmodifiableList(list);
7082                                    }
7083                                    else {
7084                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
7085                                                            start, end);
7086                                    }
7087    
7088                                    cacheResult(list);
7089    
7090                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7091                            }
7092                            catch (Exception e) {
7093                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7094    
7095                                    throw processException(e);
7096                            }
7097                            finally {
7098                                    closeSession(session);
7099                            }
7100                    }
7101    
7102                    return list;
7103            }
7104    
7105            /**
7106             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
7107             *
7108             * @param resourcePrimKey the resource prim key
7109             * @param nodeId the node ID
7110             * @param head the head
7111             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7112             * @return the first matching wiki page
7113             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7114             */
7115            @Override
7116            public WikiPage findByR_N_H_First(long resourcePrimKey, long nodeId,
7117                    boolean head, OrderByComparator<WikiPage> orderByComparator)
7118                    throws NoSuchPageException {
7119                    WikiPage wikiPage = fetchByR_N_H_First(resourcePrimKey, nodeId, head,
7120                                    orderByComparator);
7121    
7122                    if (wikiPage != null) {
7123                            return wikiPage;
7124                    }
7125    
7126                    StringBundler msg = new StringBundler(8);
7127    
7128                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7129    
7130                    msg.append("resourcePrimKey=");
7131                    msg.append(resourcePrimKey);
7132    
7133                    msg.append(", nodeId=");
7134                    msg.append(nodeId);
7135    
7136                    msg.append(", head=");
7137                    msg.append(head);
7138    
7139                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7140    
7141                    throw new NoSuchPageException(msg.toString());
7142            }
7143    
7144            /**
7145             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
7146             *
7147             * @param resourcePrimKey the resource prim key
7148             * @param nodeId the node ID
7149             * @param head the head
7150             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7151             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
7152             */
7153            @Override
7154            public WikiPage fetchByR_N_H_First(long resourcePrimKey, long nodeId,
7155                    boolean head, OrderByComparator<WikiPage> orderByComparator) {
7156                    List<WikiPage> list = findByR_N_H(resourcePrimKey, nodeId, head, 0, 1,
7157                                    orderByComparator);
7158    
7159                    if (!list.isEmpty()) {
7160                            return list.get(0);
7161                    }
7162    
7163                    return null;
7164            }
7165    
7166            /**
7167             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
7168             *
7169             * @param resourcePrimKey the resource prim key
7170             * @param nodeId the node ID
7171             * @param head the head
7172             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7173             * @return the last matching wiki page
7174             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7175             */
7176            @Override
7177            public WikiPage findByR_N_H_Last(long resourcePrimKey, long nodeId,
7178                    boolean head, OrderByComparator<WikiPage> orderByComparator)
7179                    throws NoSuchPageException {
7180                    WikiPage wikiPage = fetchByR_N_H_Last(resourcePrimKey, nodeId, head,
7181                                    orderByComparator);
7182    
7183                    if (wikiPage != null) {
7184                            return wikiPage;
7185                    }
7186    
7187                    StringBundler msg = new StringBundler(8);
7188    
7189                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7190    
7191                    msg.append("resourcePrimKey=");
7192                    msg.append(resourcePrimKey);
7193    
7194                    msg.append(", nodeId=");
7195                    msg.append(nodeId);
7196    
7197                    msg.append(", head=");
7198                    msg.append(head);
7199    
7200                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7201    
7202                    throw new NoSuchPageException(msg.toString());
7203            }
7204    
7205            /**
7206             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
7207             *
7208             * @param resourcePrimKey the resource prim key
7209             * @param nodeId the node ID
7210             * @param head the head
7211             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7212             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
7213             */
7214            @Override
7215            public WikiPage fetchByR_N_H_Last(long resourcePrimKey, long nodeId,
7216                    boolean head, OrderByComparator<WikiPage> orderByComparator) {
7217                    int count = countByR_N_H(resourcePrimKey, nodeId, head);
7218    
7219                    if (count == 0) {
7220                            return null;
7221                    }
7222    
7223                    List<WikiPage> list = findByR_N_H(resourcePrimKey, nodeId, head,
7224                                    count - 1, count, orderByComparator);
7225    
7226                    if (!list.isEmpty()) {
7227                            return list.get(0);
7228                    }
7229    
7230                    return null;
7231            }
7232    
7233            /**
7234             * Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
7235             *
7236             * @param pageId the primary key of the current wiki page
7237             * @param resourcePrimKey the resource prim key
7238             * @param nodeId the node ID
7239             * @param head the head
7240             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7241             * @return the previous, current, and next wiki page
7242             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
7243             */
7244            @Override
7245            public WikiPage[] findByR_N_H_PrevAndNext(long pageId,
7246                    long resourcePrimKey, long nodeId, boolean head,
7247                    OrderByComparator<WikiPage> orderByComparator)
7248                    throws NoSuchPageException {
7249                    WikiPage wikiPage = findByPrimaryKey(pageId);
7250    
7251                    Session session = null;
7252    
7253                    try {
7254                            session = openSession();
7255    
7256                            WikiPage[] array = new WikiPageImpl[3];
7257    
7258                            array[0] = getByR_N_H_PrevAndNext(session, wikiPage,
7259                                            resourcePrimKey, nodeId, head, orderByComparator, true);
7260    
7261                            array[1] = wikiPage;
7262    
7263                            array[2] = getByR_N_H_PrevAndNext(session, wikiPage,
7264                                            resourcePrimKey, nodeId, head, orderByComparator, false);
7265    
7266                            return array;
7267                    }
7268                    catch (Exception e) {
7269                            throw processException(e);
7270                    }
7271                    finally {
7272                            closeSession(session);
7273                    }
7274            }
7275    
7276            protected WikiPage getByR_N_H_PrevAndNext(Session session,
7277                    WikiPage wikiPage, long resourcePrimKey, long nodeId, boolean head,
7278                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
7279                    StringBundler query = null;
7280    
7281                    if (orderByComparator != null) {
7282                            query = new StringBundler(6 +
7283                                            (orderByComparator.getOrderByFields().length * 6));
7284                    }
7285                    else {
7286                            query = new StringBundler(3);
7287                    }
7288    
7289                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
7290    
7291                    query.append(_FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2);
7292    
7293                    query.append(_FINDER_COLUMN_R_N_H_NODEID_2);
7294    
7295                    query.append(_FINDER_COLUMN_R_N_H_HEAD_2);
7296    
7297                    if (orderByComparator != null) {
7298                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7299    
7300                            if (orderByConditionFields.length > 0) {
7301                                    query.append(WHERE_AND);
7302                            }
7303    
7304                            for (int i = 0; i < orderByConditionFields.length; i++) {
7305                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7306                                    query.append(orderByConditionFields[i]);
7307    
7308                                    if ((i + 1) < orderByConditionFields.length) {
7309                                            if (orderByComparator.isAscending() ^ previous) {
7310                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7311                                            }
7312                                            else {
7313                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7314                                            }
7315                                    }
7316                                    else {
7317                                            if (orderByComparator.isAscending() ^ previous) {
7318                                                    query.append(WHERE_GREATER_THAN);
7319                                            }
7320                                            else {
7321                                                    query.append(WHERE_LESSER_THAN);
7322                                            }
7323                                    }
7324                            }
7325    
7326                            query.append(ORDER_BY_CLAUSE);
7327    
7328                            String[] orderByFields = orderByComparator.getOrderByFields();
7329    
7330                            for (int i = 0; i < orderByFields.length; i++) {
7331                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7332                                    query.append(orderByFields[i]);
7333    
7334                                    if ((i + 1) < orderByFields.length) {
7335                                            if (orderByComparator.isAscending() ^ previous) {
7336                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7337                                            }
7338                                            else {
7339                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7340                                            }
7341                                    }
7342                                    else {
7343                                            if (orderByComparator.isAscending() ^ previous) {
7344                                                    query.append(ORDER_BY_ASC);
7345                                            }
7346                                            else {
7347                                                    query.append(ORDER_BY_DESC);
7348                                            }
7349                                    }
7350                            }
7351                    }
7352                    else {
7353                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7354                    }
7355    
7356                    String sql = query.toString();
7357    
7358                    Query q = session.createQuery(sql);
7359    
7360                    q.setFirstResult(0);
7361                    q.setMaxResults(2);
7362    
7363                    QueryPos qPos = QueryPos.getInstance(q);
7364    
7365                    qPos.add(resourcePrimKey);
7366    
7367                    qPos.add(nodeId);
7368    
7369                    qPos.add(head);
7370    
7371                    if (orderByComparator != null) {
7372                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
7373    
7374                            for (Object value : values) {
7375                                    qPos.add(value);
7376                            }
7377                    }
7378    
7379                    List<WikiPage> list = q.list();
7380    
7381                    if (list.size() == 2) {
7382                            return list.get(1);
7383                    }
7384                    else {
7385                            return null;
7386                    }
7387            }
7388    
7389            /**
7390             * Removes all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63; from the database.
7391             *
7392             * @param resourcePrimKey the resource prim key
7393             * @param nodeId the node ID
7394             * @param head the head
7395             */
7396            @Override
7397            public void removeByR_N_H(long resourcePrimKey, long nodeId, boolean head) {
7398                    for (WikiPage wikiPage : findByR_N_H(resourcePrimKey, nodeId, head,
7399                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7400                            remove(wikiPage);
7401                    }
7402            }
7403    
7404            /**
7405             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
7406             *
7407             * @param resourcePrimKey the resource prim key
7408             * @param nodeId the node ID
7409             * @param head the head
7410             * @return the number of matching wiki pages
7411             */
7412            @Override
7413            public int countByR_N_H(long resourcePrimKey, long nodeId, boolean head) {
7414                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_N_H;
7415    
7416                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, head };
7417    
7418                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7419                                    this);
7420    
7421                    if (count == null) {
7422                            StringBundler query = new StringBundler(4);
7423    
7424                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
7425    
7426                            query.append(_FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2);
7427    
7428                            query.append(_FINDER_COLUMN_R_N_H_NODEID_2);
7429    
7430                            query.append(_FINDER_COLUMN_R_N_H_HEAD_2);
7431    
7432                            String sql = query.toString();
7433    
7434                            Session session = null;
7435    
7436                            try {
7437                                    session = openSession();
7438    
7439                                    Query q = session.createQuery(sql);
7440    
7441                                    QueryPos qPos = QueryPos.getInstance(q);
7442    
7443                                    qPos.add(resourcePrimKey);
7444    
7445                                    qPos.add(nodeId);
7446    
7447                                    qPos.add(head);
7448    
7449                                    count = (Long)q.uniqueResult();
7450    
7451                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7452                            }
7453                            catch (Exception e) {
7454                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7455    
7456                                    throw processException(e);
7457                            }
7458                            finally {
7459                                    closeSession(session);
7460                            }
7461                    }
7462    
7463                    return count.intValue();
7464            }
7465    
7466            private static final String _FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
7467            private static final String _FINDER_COLUMN_R_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
7468            private static final String _FINDER_COLUMN_R_N_H_HEAD_2 = "wikiPage.head = ?";
7469            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
7470                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
7471                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_N_S",
7472                            new String[] {
7473                                    Long.class.getName(), Long.class.getName(),
7474                                    Integer.class.getName(),
7475                                    
7476                            Integer.class.getName(), Integer.class.getName(),
7477                                    OrderByComparator.class.getName()
7478                            });
7479            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
7480                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
7481                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_N_S",
7482                            new String[] {
7483                                    Long.class.getName(), Long.class.getName(),
7484                                    Integer.class.getName()
7485                            },
7486                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
7487                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
7488                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
7489                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
7490                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
7491            public static final FinderPath FINDER_PATH_COUNT_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
7492                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
7493                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N_S",
7494                            new String[] {
7495                                    Long.class.getName(), Long.class.getName(),
7496                                    Integer.class.getName()
7497                            });
7498    
7499            /**
7500             * Returns all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
7501             *
7502             * @param resourcePrimKey the resource prim key
7503             * @param nodeId the node ID
7504             * @param status the status
7505             * @return the matching wiki pages
7506             */
7507            @Override
7508            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
7509                    int status) {
7510                    return findByR_N_S(resourcePrimKey, nodeId, status, QueryUtil.ALL_POS,
7511                            QueryUtil.ALL_POS, null);
7512            }
7513    
7514            /**
7515             * Returns a range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
7516             *
7517             * <p>
7518             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
7519             * </p>
7520             *
7521             * @param resourcePrimKey the resource prim key
7522             * @param nodeId the node ID
7523             * @param status the status
7524             * @param start the lower bound of the range of wiki pages
7525             * @param end the upper bound of the range of wiki pages (not inclusive)
7526             * @return the range of matching wiki pages
7527             */
7528            @Override
7529            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
7530                    int status, int start, int end) {
7531                    return findByR_N_S(resourcePrimKey, nodeId, status, start, end, null);
7532            }
7533    
7534            /**
7535             * Returns an ordered range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
7536             *
7537             * <p>
7538             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
7539             * </p>
7540             *
7541             * @param resourcePrimKey the resource prim key
7542             * @param nodeId the node ID
7543             * @param status the status
7544             * @param start the lower bound of the range of wiki pages
7545             * @param end the upper bound of the range of wiki pages (not inclusive)
7546             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7547             * @return the ordered range of matching wiki pages
7548             */
7549            @Override
7550            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
7551                    int status, int start, int end,
7552                    OrderByComparator<WikiPage> orderByComparator) {
7553                    boolean pagination = true;
7554                    FinderPath finderPath = null;
7555                    Object[] finderArgs = null;
7556    
7557                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7558                                    (orderByComparator == null)) {
7559                            pagination = false;
7560                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S;
7561                            finderArgs = new Object[] { resourcePrimKey, nodeId, status };
7562                    }
7563                    else {
7564                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N_S;
7565                            finderArgs = new Object[] {
7566                                            resourcePrimKey, nodeId, status,
7567                                            
7568                                            start, end, orderByComparator
7569                                    };
7570                    }
7571    
7572                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
7573                                    finderArgs, this);
7574    
7575                    if ((list != null) && !list.isEmpty()) {
7576                            for (WikiPage wikiPage : list) {
7577                                    if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
7578                                                    (nodeId != wikiPage.getNodeId()) ||
7579                                                    (status != wikiPage.getStatus())) {
7580                                            list = null;
7581    
7582                                            break;
7583                                    }
7584                            }
7585                    }
7586    
7587                    if (list == null) {
7588                            StringBundler query = null;
7589    
7590                            if (orderByComparator != null) {
7591                                    query = new StringBundler(5 +
7592                                                    (orderByComparator.getOrderByFields().length * 3));
7593                            }
7594                            else {
7595                                    query = new StringBundler(5);
7596                            }
7597    
7598                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
7599    
7600                            query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
7601    
7602                            query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
7603    
7604                            query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
7605    
7606                            if (orderByComparator != null) {
7607                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7608                                            orderByComparator);
7609                            }
7610                            else
7611                             if (pagination) {
7612                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7613                            }
7614    
7615                            String sql = query.toString();
7616    
7617                            Session session = null;
7618    
7619                            try {
7620                                    session = openSession();
7621    
7622                                    Query q = session.createQuery(sql);
7623    
7624                                    QueryPos qPos = QueryPos.getInstance(q);
7625    
7626                                    qPos.add(resourcePrimKey);
7627    
7628                                    qPos.add(nodeId);
7629    
7630                                    qPos.add(status);
7631    
7632                                    if (!pagination) {
7633                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
7634                                                            start, end, false);
7635    
7636                                            Collections.sort(list);
7637    
7638                                            list = Collections.unmodifiableList(list);
7639                                    }
7640                                    else {
7641                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
7642                                                            start, end);
7643                                    }
7644    
7645                                    cacheResult(list);
7646    
7647                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7648                            }
7649                            catch (Exception e) {
7650                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7651    
7652                                    throw processException(e);
7653                            }
7654                            finally {
7655                                    closeSession(session);
7656                            }
7657                    }
7658    
7659                    return list;
7660            }
7661    
7662            /**
7663             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
7664             *
7665             * @param resourcePrimKey the resource prim key
7666             * @param nodeId the node ID
7667             * @param status the status
7668             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7669             * @return the first matching wiki page
7670             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7671             */
7672            @Override
7673            public WikiPage findByR_N_S_First(long resourcePrimKey, long nodeId,
7674                    int status, OrderByComparator<WikiPage> orderByComparator)
7675                    throws NoSuchPageException {
7676                    WikiPage wikiPage = fetchByR_N_S_First(resourcePrimKey, nodeId, status,
7677                                    orderByComparator);
7678    
7679                    if (wikiPage != null) {
7680                            return wikiPage;
7681                    }
7682    
7683                    StringBundler msg = new StringBundler(8);
7684    
7685                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7686    
7687                    msg.append("resourcePrimKey=");
7688                    msg.append(resourcePrimKey);
7689    
7690                    msg.append(", nodeId=");
7691                    msg.append(nodeId);
7692    
7693                    msg.append(", status=");
7694                    msg.append(status);
7695    
7696                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7697    
7698                    throw new NoSuchPageException(msg.toString());
7699            }
7700    
7701            /**
7702             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
7703             *
7704             * @param resourcePrimKey the resource prim key
7705             * @param nodeId the node ID
7706             * @param status the status
7707             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7708             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
7709             */
7710            @Override
7711            public WikiPage fetchByR_N_S_First(long resourcePrimKey, long nodeId,
7712                    int status, OrderByComparator<WikiPage> orderByComparator) {
7713                    List<WikiPage> list = findByR_N_S(resourcePrimKey, nodeId, status, 0,
7714                                    1, orderByComparator);
7715    
7716                    if (!list.isEmpty()) {
7717                            return list.get(0);
7718                    }
7719    
7720                    return null;
7721            }
7722    
7723            /**
7724             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
7725             *
7726             * @param resourcePrimKey the resource prim key
7727             * @param nodeId the node ID
7728             * @param status the status
7729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7730             * @return the last matching wiki page
7731             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7732             */
7733            @Override
7734            public WikiPage findByR_N_S_Last(long resourcePrimKey, long nodeId,
7735                    int status, OrderByComparator<WikiPage> orderByComparator)
7736                    throws NoSuchPageException {
7737                    WikiPage wikiPage = fetchByR_N_S_Last(resourcePrimKey, nodeId, status,
7738                                    orderByComparator);
7739    
7740                    if (wikiPage != null) {
7741                            return wikiPage;
7742                    }
7743    
7744                    StringBundler msg = new StringBundler(8);
7745    
7746                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7747    
7748                    msg.append("resourcePrimKey=");
7749                    msg.append(resourcePrimKey);
7750    
7751                    msg.append(", nodeId=");
7752                    msg.append(nodeId);
7753    
7754                    msg.append(", status=");
7755                    msg.append(status);
7756    
7757                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7758    
7759                    throw new NoSuchPageException(msg.toString());
7760            }
7761    
7762            /**
7763             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
7764             *
7765             * @param resourcePrimKey the resource prim key
7766             * @param nodeId the node ID
7767             * @param status the status
7768             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7769             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
7770             */
7771            @Override
7772            public WikiPage fetchByR_N_S_Last(long resourcePrimKey, long nodeId,
7773                    int status, OrderByComparator<WikiPage> orderByComparator) {
7774                    int count = countByR_N_S(resourcePrimKey, nodeId, status);
7775    
7776                    if (count == 0) {
7777                            return null;
7778                    }
7779    
7780                    List<WikiPage> list = findByR_N_S(resourcePrimKey, nodeId, status,
7781                                    count - 1, count, orderByComparator);
7782    
7783                    if (!list.isEmpty()) {
7784                            return list.get(0);
7785                    }
7786    
7787                    return null;
7788            }
7789    
7790            /**
7791             * Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
7792             *
7793             * @param pageId the primary key of the current wiki page
7794             * @param resourcePrimKey the resource prim key
7795             * @param nodeId the node ID
7796             * @param status the status
7797             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7798             * @return the previous, current, and next wiki page
7799             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
7800             */
7801            @Override
7802            public WikiPage[] findByR_N_S_PrevAndNext(long pageId,
7803                    long resourcePrimKey, long nodeId, int status,
7804                    OrderByComparator<WikiPage> orderByComparator)
7805                    throws NoSuchPageException {
7806                    WikiPage wikiPage = findByPrimaryKey(pageId);
7807    
7808                    Session session = null;
7809    
7810                    try {
7811                            session = openSession();
7812    
7813                            WikiPage[] array = new WikiPageImpl[3];
7814    
7815                            array[0] = getByR_N_S_PrevAndNext(session, wikiPage,
7816                                            resourcePrimKey, nodeId, status, orderByComparator, true);
7817    
7818                            array[1] = wikiPage;
7819    
7820                            array[2] = getByR_N_S_PrevAndNext(session, wikiPage,
7821                                            resourcePrimKey, nodeId, status, orderByComparator, false);
7822    
7823                            return array;
7824                    }
7825                    catch (Exception e) {
7826                            throw processException(e);
7827                    }
7828                    finally {
7829                            closeSession(session);
7830                    }
7831            }
7832    
7833            protected WikiPage getByR_N_S_PrevAndNext(Session session,
7834                    WikiPage wikiPage, long resourcePrimKey, long nodeId, int status,
7835                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
7836                    StringBundler query = null;
7837    
7838                    if (orderByComparator != null) {
7839                            query = new StringBundler(6 +
7840                                            (orderByComparator.getOrderByFields().length * 6));
7841                    }
7842                    else {
7843                            query = new StringBundler(3);
7844                    }
7845    
7846                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
7847    
7848                    query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
7849    
7850                    query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
7851    
7852                    query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
7853    
7854                    if (orderByComparator != null) {
7855                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7856    
7857                            if (orderByConditionFields.length > 0) {
7858                                    query.append(WHERE_AND);
7859                            }
7860    
7861                            for (int i = 0; i < orderByConditionFields.length; i++) {
7862                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7863                                    query.append(orderByConditionFields[i]);
7864    
7865                                    if ((i + 1) < orderByConditionFields.length) {
7866                                            if (orderByComparator.isAscending() ^ previous) {
7867                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7868                                            }
7869                                            else {
7870                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7871                                            }
7872                                    }
7873                                    else {
7874                                            if (orderByComparator.isAscending() ^ previous) {
7875                                                    query.append(WHERE_GREATER_THAN);
7876                                            }
7877                                            else {
7878                                                    query.append(WHERE_LESSER_THAN);
7879                                            }
7880                                    }
7881                            }
7882    
7883                            query.append(ORDER_BY_CLAUSE);
7884    
7885                            String[] orderByFields = orderByComparator.getOrderByFields();
7886    
7887                            for (int i = 0; i < orderByFields.length; i++) {
7888                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7889                                    query.append(orderByFields[i]);
7890    
7891                                    if ((i + 1) < orderByFields.length) {
7892                                            if (orderByComparator.isAscending() ^ previous) {
7893                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7894                                            }
7895                                            else {
7896                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7897                                            }
7898                                    }
7899                                    else {
7900                                            if (orderByComparator.isAscending() ^ previous) {
7901                                                    query.append(ORDER_BY_ASC);
7902                                            }
7903                                            else {
7904                                                    query.append(ORDER_BY_DESC);
7905                                            }
7906                                    }
7907                            }
7908                    }
7909                    else {
7910                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7911                    }
7912    
7913                    String sql = query.toString();
7914    
7915                    Query q = session.createQuery(sql);
7916    
7917                    q.setFirstResult(0);
7918                    q.setMaxResults(2);
7919    
7920                    QueryPos qPos = QueryPos.getInstance(q);
7921    
7922                    qPos.add(resourcePrimKey);
7923    
7924                    qPos.add(nodeId);
7925    
7926                    qPos.add(status);
7927    
7928                    if (orderByComparator != null) {
7929                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
7930    
7931                            for (Object value : values) {
7932                                    qPos.add(value);
7933                            }
7934                    }
7935    
7936                    List<WikiPage> list = q.list();
7937    
7938                    if (list.size() == 2) {
7939                            return list.get(1);
7940                    }
7941                    else {
7942                            return null;
7943                    }
7944            }
7945    
7946            /**
7947             * Removes all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63; from the database.
7948             *
7949             * @param resourcePrimKey the resource prim key
7950             * @param nodeId the node ID
7951             * @param status the status
7952             */
7953            @Override
7954            public void removeByR_N_S(long resourcePrimKey, long nodeId, int status) {
7955                    for (WikiPage wikiPage : findByR_N_S(resourcePrimKey, nodeId, status,
7956                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7957                            remove(wikiPage);
7958                    }
7959            }
7960    
7961            /**
7962             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
7963             *
7964             * @param resourcePrimKey the resource prim key
7965             * @param nodeId the node ID
7966             * @param status the status
7967             * @return the number of matching wiki pages
7968             */
7969            @Override
7970            public int countByR_N_S(long resourcePrimKey, long nodeId, int status) {
7971                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_N_S;
7972    
7973                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, status };
7974    
7975                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7976                                    this);
7977    
7978                    if (count == null) {
7979                            StringBundler query = new StringBundler(4);
7980    
7981                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
7982    
7983                            query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
7984    
7985                            query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
7986    
7987                            query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
7988    
7989                            String sql = query.toString();
7990    
7991                            Session session = null;
7992    
7993                            try {
7994                                    session = openSession();
7995    
7996                                    Query q = session.createQuery(sql);
7997    
7998                                    QueryPos qPos = QueryPos.getInstance(q);
7999    
8000                                    qPos.add(resourcePrimKey);
8001    
8002                                    qPos.add(nodeId);
8003    
8004                                    qPos.add(status);
8005    
8006                                    count = (Long)q.uniqueResult();
8007    
8008                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8009                            }
8010                            catch (Exception e) {
8011                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8012    
8013                                    throw processException(e);
8014                            }
8015                            finally {
8016                                    closeSession(session);
8017                            }
8018                    }
8019    
8020                    return count.intValue();
8021            }
8022    
8023            private static final String _FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
8024            private static final String _FINDER_COLUMN_R_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
8025            private static final String _FINDER_COLUMN_R_N_S_STATUS_2 = "wikiPage.status = ?";
8026            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
8027                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
8028                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_H",
8029                            new String[] {
8030                                    Long.class.getName(), Long.class.getName(),
8031                                    Boolean.class.getName(),
8032                                    
8033                            Integer.class.getName(), Integer.class.getName(),
8034                                    OrderByComparator.class.getName()
8035                            });
8036            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
8037                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
8038                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_H",
8039                            new String[] {
8040                                    Long.class.getName(), Long.class.getName(),
8041                                    Boolean.class.getName()
8042                            },
8043                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
8044                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
8045                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
8046                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
8047                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
8048            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
8049                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
8050                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_H",
8051                            new String[] {
8052                                    Long.class.getName(), Long.class.getName(),
8053                                    Boolean.class.getName()
8054                            });
8055    
8056            /**
8057             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
8058             *
8059             * @param groupId the group ID
8060             * @param nodeId the node ID
8061             * @param head the head
8062             * @return the matching wiki pages
8063             */
8064            @Override
8065            public List<WikiPage> findByG_N_H(long groupId, long nodeId, boolean head) {
8066                    return findByG_N_H(groupId, nodeId, head, QueryUtil.ALL_POS,
8067                            QueryUtil.ALL_POS, null);
8068            }
8069    
8070            /**
8071             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
8072             *
8073             * <p>
8074             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
8075             * </p>
8076             *
8077             * @param groupId the group ID
8078             * @param nodeId the node ID
8079             * @param head the head
8080             * @param start the lower bound of the range of wiki pages
8081             * @param end the upper bound of the range of wiki pages (not inclusive)
8082             * @return the range of matching wiki pages
8083             */
8084            @Override
8085            public List<WikiPage> findByG_N_H(long groupId, long nodeId, boolean head,
8086                    int start, int end) {
8087                    return findByG_N_H(groupId, nodeId, head, start, end, null);
8088            }
8089    
8090            /**
8091             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
8092             *
8093             * <p>
8094             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
8095             * </p>
8096             *
8097             * @param groupId the group ID
8098             * @param nodeId the node ID
8099             * @param head the head
8100             * @param start the lower bound of the range of wiki pages
8101             * @param end the upper bound of the range of wiki pages (not inclusive)
8102             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8103             * @return the ordered range of matching wiki pages
8104             */
8105            @Override
8106            public List<WikiPage> findByG_N_H(long groupId, long nodeId, boolean head,
8107                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
8108                    boolean pagination = true;
8109                    FinderPath finderPath = null;
8110                    Object[] finderArgs = null;
8111    
8112                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8113                                    (orderByComparator == null)) {
8114                            pagination = false;
8115                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H;
8116                            finderArgs = new Object[] { groupId, nodeId, head };
8117                    }
8118                    else {
8119                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H;
8120                            finderArgs = new Object[] {
8121                                            groupId, nodeId, head,
8122                                            
8123                                            start, end, orderByComparator
8124                                    };
8125                    }
8126    
8127                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
8128                                    finderArgs, this);
8129    
8130                    if ((list != null) && !list.isEmpty()) {
8131                            for (WikiPage wikiPage : list) {
8132                                    if ((groupId != wikiPage.getGroupId()) ||
8133                                                    (nodeId != wikiPage.getNodeId()) ||
8134                                                    (head != wikiPage.getHead())) {
8135                                            list = null;
8136    
8137                                            break;
8138                                    }
8139                            }
8140                    }
8141    
8142                    if (list == null) {
8143                            StringBundler query = null;
8144    
8145                            if (orderByComparator != null) {
8146                                    query = new StringBundler(5 +
8147                                                    (orderByComparator.getOrderByFields().length * 3));
8148                            }
8149                            else {
8150                                    query = new StringBundler(5);
8151                            }
8152    
8153                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
8154    
8155                            query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
8156    
8157                            query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
8158    
8159                            query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
8160    
8161                            if (orderByComparator != null) {
8162                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8163                                            orderByComparator);
8164                            }
8165                            else
8166                             if (pagination) {
8167                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8168                            }
8169    
8170                            String sql = query.toString();
8171    
8172                            Session session = null;
8173    
8174                            try {
8175                                    session = openSession();
8176    
8177                                    Query q = session.createQuery(sql);
8178    
8179                                    QueryPos qPos = QueryPos.getInstance(q);
8180    
8181                                    qPos.add(groupId);
8182    
8183                                    qPos.add(nodeId);
8184    
8185                                    qPos.add(head);
8186    
8187                                    if (!pagination) {
8188                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
8189                                                            start, end, false);
8190    
8191                                            Collections.sort(list);
8192    
8193                                            list = Collections.unmodifiableList(list);
8194                                    }
8195                                    else {
8196                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
8197                                                            start, end);
8198                                    }
8199    
8200                                    cacheResult(list);
8201    
8202                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8203                            }
8204                            catch (Exception e) {
8205                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8206    
8207                                    throw processException(e);
8208                            }
8209                            finally {
8210                                    closeSession(session);
8211                            }
8212                    }
8213    
8214                    return list;
8215            }
8216    
8217            /**
8218             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
8219             *
8220             * @param groupId the group ID
8221             * @param nodeId the node ID
8222             * @param head the head
8223             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8224             * @return the first matching wiki page
8225             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
8226             */
8227            @Override
8228            public WikiPage findByG_N_H_First(long groupId, long nodeId, boolean head,
8229                    OrderByComparator<WikiPage> orderByComparator)
8230                    throws NoSuchPageException {
8231                    WikiPage wikiPage = fetchByG_N_H_First(groupId, nodeId, head,
8232                                    orderByComparator);
8233    
8234                    if (wikiPage != null) {
8235                            return wikiPage;
8236                    }
8237    
8238                    StringBundler msg = new StringBundler(8);
8239    
8240                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8241    
8242                    msg.append("groupId=");
8243                    msg.append(groupId);
8244    
8245                    msg.append(", nodeId=");
8246                    msg.append(nodeId);
8247    
8248                    msg.append(", head=");
8249                    msg.append(head);
8250    
8251                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8252    
8253                    throw new NoSuchPageException(msg.toString());
8254            }
8255    
8256            /**
8257             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
8258             *
8259             * @param groupId the group ID
8260             * @param nodeId the node ID
8261             * @param head the head
8262             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8263             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
8264             */
8265            @Override
8266            public WikiPage fetchByG_N_H_First(long groupId, long nodeId, boolean head,
8267                    OrderByComparator<WikiPage> orderByComparator) {
8268                    List<WikiPage> list = findByG_N_H(groupId, nodeId, head, 0, 1,
8269                                    orderByComparator);
8270    
8271                    if (!list.isEmpty()) {
8272                            return list.get(0);
8273                    }
8274    
8275                    return null;
8276            }
8277    
8278            /**
8279             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
8280             *
8281             * @param groupId the group ID
8282             * @param nodeId the node ID
8283             * @param head the head
8284             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8285             * @return the last matching wiki page
8286             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
8287             */
8288            @Override
8289            public WikiPage findByG_N_H_Last(long groupId, long nodeId, boolean head,
8290                    OrderByComparator<WikiPage> orderByComparator)
8291                    throws NoSuchPageException {
8292                    WikiPage wikiPage = fetchByG_N_H_Last(groupId, nodeId, head,
8293                                    orderByComparator);
8294    
8295                    if (wikiPage != null) {
8296                            return wikiPage;
8297                    }
8298    
8299                    StringBundler msg = new StringBundler(8);
8300    
8301                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8302    
8303                    msg.append("groupId=");
8304                    msg.append(groupId);
8305    
8306                    msg.append(", nodeId=");
8307                    msg.append(nodeId);
8308    
8309                    msg.append(", head=");
8310                    msg.append(head);
8311    
8312                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8313    
8314                    throw new NoSuchPageException(msg.toString());
8315            }
8316    
8317            /**
8318             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
8319             *
8320             * @param groupId the group ID
8321             * @param nodeId the node ID
8322             * @param head the head
8323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8324             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
8325             */
8326            @Override
8327            public WikiPage fetchByG_N_H_Last(long groupId, long nodeId, boolean head,
8328                    OrderByComparator<WikiPage> orderByComparator) {
8329                    int count = countByG_N_H(groupId, nodeId, head);
8330    
8331                    if (count == 0) {
8332                            return null;
8333                    }
8334    
8335                    List<WikiPage> list = findByG_N_H(groupId, nodeId, head, count - 1,
8336                                    count, orderByComparator);
8337    
8338                    if (!list.isEmpty()) {
8339                            return list.get(0);
8340                    }
8341    
8342                    return null;
8343            }
8344    
8345            /**
8346             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
8347             *
8348             * @param pageId the primary key of the current wiki page
8349             * @param groupId the group ID
8350             * @param nodeId the node ID
8351             * @param head the head
8352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8353             * @return the previous, current, and next wiki page
8354             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
8355             */
8356            @Override
8357            public WikiPage[] findByG_N_H_PrevAndNext(long pageId, long groupId,
8358                    long nodeId, boolean head, OrderByComparator<WikiPage> orderByComparator)
8359                    throws NoSuchPageException {
8360                    WikiPage wikiPage = findByPrimaryKey(pageId);
8361    
8362                    Session session = null;
8363    
8364                    try {
8365                            session = openSession();
8366    
8367                            WikiPage[] array = new WikiPageImpl[3];
8368    
8369                            array[0] = getByG_N_H_PrevAndNext(session, wikiPage, groupId,
8370                                            nodeId, head, orderByComparator, true);
8371    
8372                            array[1] = wikiPage;
8373    
8374                            array[2] = getByG_N_H_PrevAndNext(session, wikiPage, groupId,
8375                                            nodeId, head, orderByComparator, false);
8376    
8377                            return array;
8378                    }
8379                    catch (Exception e) {
8380                            throw processException(e);
8381                    }
8382                    finally {
8383                            closeSession(session);
8384                    }
8385            }
8386    
8387            protected WikiPage getByG_N_H_PrevAndNext(Session session,
8388                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
8389                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
8390                    StringBundler query = null;
8391    
8392                    if (orderByComparator != null) {
8393                            query = new StringBundler(6 +
8394                                            (orderByComparator.getOrderByFields().length * 6));
8395                    }
8396                    else {
8397                            query = new StringBundler(3);
8398                    }
8399    
8400                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
8401    
8402                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
8403    
8404                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
8405    
8406                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
8407    
8408                    if (orderByComparator != null) {
8409                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8410    
8411                            if (orderByConditionFields.length > 0) {
8412                                    query.append(WHERE_AND);
8413                            }
8414    
8415                            for (int i = 0; i < orderByConditionFields.length; i++) {
8416                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8417                                    query.append(orderByConditionFields[i]);
8418    
8419                                    if ((i + 1) < orderByConditionFields.length) {
8420                                            if (orderByComparator.isAscending() ^ previous) {
8421                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8422                                            }
8423                                            else {
8424                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8425                                            }
8426                                    }
8427                                    else {
8428                                            if (orderByComparator.isAscending() ^ previous) {
8429                                                    query.append(WHERE_GREATER_THAN);
8430                                            }
8431                                            else {
8432                                                    query.append(WHERE_LESSER_THAN);
8433                                            }
8434                                    }
8435                            }
8436    
8437                            query.append(ORDER_BY_CLAUSE);
8438    
8439                            String[] orderByFields = orderByComparator.getOrderByFields();
8440    
8441                            for (int i = 0; i < orderByFields.length; i++) {
8442                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8443                                    query.append(orderByFields[i]);
8444    
8445                                    if ((i + 1) < orderByFields.length) {
8446                                            if (orderByComparator.isAscending() ^ previous) {
8447                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8448                                            }
8449                                            else {
8450                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8451                                            }
8452                                    }
8453                                    else {
8454                                            if (orderByComparator.isAscending() ^ previous) {
8455                                                    query.append(ORDER_BY_ASC);
8456                                            }
8457                                            else {
8458                                                    query.append(ORDER_BY_DESC);
8459                                            }
8460                                    }
8461                            }
8462                    }
8463                    else {
8464                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8465                    }
8466    
8467                    String sql = query.toString();
8468    
8469                    Query q = session.createQuery(sql);
8470    
8471                    q.setFirstResult(0);
8472                    q.setMaxResults(2);
8473    
8474                    QueryPos qPos = QueryPos.getInstance(q);
8475    
8476                    qPos.add(groupId);
8477    
8478                    qPos.add(nodeId);
8479    
8480                    qPos.add(head);
8481    
8482                    if (orderByComparator != null) {
8483                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
8484    
8485                            for (Object value : values) {
8486                                    qPos.add(value);
8487                            }
8488                    }
8489    
8490                    List<WikiPage> list = q.list();
8491    
8492                    if (list.size() == 2) {
8493                            return list.get(1);
8494                    }
8495                    else {
8496                            return null;
8497                    }
8498            }
8499    
8500            /**
8501             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
8502             *
8503             * @param groupId the group ID
8504             * @param nodeId the node ID
8505             * @param head the head
8506             * @return the matching wiki pages that the user has permission to view
8507             */
8508            @Override
8509            public List<WikiPage> filterFindByG_N_H(long groupId, long nodeId,
8510                    boolean head) {
8511                    return filterFindByG_N_H(groupId, nodeId, head, QueryUtil.ALL_POS,
8512                            QueryUtil.ALL_POS, null);
8513            }
8514    
8515            /**
8516             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
8517             *
8518             * <p>
8519             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
8520             * </p>
8521             *
8522             * @param groupId the group ID
8523             * @param nodeId the node ID
8524             * @param head the head
8525             * @param start the lower bound of the range of wiki pages
8526             * @param end the upper bound of the range of wiki pages (not inclusive)
8527             * @return the range of matching wiki pages that the user has permission to view
8528             */
8529            @Override
8530            public List<WikiPage> filterFindByG_N_H(long groupId, long nodeId,
8531                    boolean head, int start, int end) {
8532                    return filterFindByG_N_H(groupId, nodeId, head, start, end, null);
8533            }
8534    
8535            /**
8536             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
8537             *
8538             * <p>
8539             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
8540             * </p>
8541             *
8542             * @param groupId the group ID
8543             * @param nodeId the node ID
8544             * @param head the head
8545             * @param start the lower bound of the range of wiki pages
8546             * @param end the upper bound of the range of wiki pages (not inclusive)
8547             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8548             * @return the ordered range of matching wiki pages that the user has permission to view
8549             */
8550            @Override
8551            public List<WikiPage> filterFindByG_N_H(long groupId, long nodeId,
8552                    boolean head, int start, int end,
8553                    OrderByComparator<WikiPage> orderByComparator) {
8554                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8555                            return findByG_N_H(groupId, nodeId, head, start, end,
8556                                    orderByComparator);
8557                    }
8558    
8559                    StringBundler query = null;
8560    
8561                    if (orderByComparator != null) {
8562                            query = new StringBundler(5 +
8563                                            (orderByComparator.getOrderByFields().length * 3));
8564                    }
8565                    else {
8566                            query = new StringBundler(5);
8567                    }
8568    
8569                    if (getDB().isSupportsInlineDistinct()) {
8570                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
8571                    }
8572                    else {
8573                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
8574                    }
8575    
8576                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
8577    
8578                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
8579    
8580                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
8581    
8582                    if (!getDB().isSupportsInlineDistinct()) {
8583                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
8584                    }
8585    
8586                    if (orderByComparator != null) {
8587                            if (getDB().isSupportsInlineDistinct()) {
8588                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8589                                            orderByComparator, true);
8590                            }
8591                            else {
8592                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8593                                            orderByComparator, true);
8594                            }
8595                    }
8596                    else {
8597                            if (getDB().isSupportsInlineDistinct()) {
8598                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8599                            }
8600                            else {
8601                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
8602                            }
8603                    }
8604    
8605                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8606                                    WikiPage.class.getName(),
8607                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8608    
8609                    Session session = null;
8610    
8611                    try {
8612                            session = openSession();
8613    
8614                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8615    
8616                            if (getDB().isSupportsInlineDistinct()) {
8617                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
8618                            }
8619                            else {
8620                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
8621                            }
8622    
8623                            QueryPos qPos = QueryPos.getInstance(q);
8624    
8625                            qPos.add(groupId);
8626    
8627                            qPos.add(nodeId);
8628    
8629                            qPos.add(head);
8630    
8631                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
8632                    }
8633                    catch (Exception e) {
8634                            throw processException(e);
8635                    }
8636                    finally {
8637                            closeSession(session);
8638                    }
8639            }
8640    
8641            /**
8642             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
8643             *
8644             * @param pageId the primary key of the current wiki page
8645             * @param groupId the group ID
8646             * @param nodeId the node ID
8647             * @param head the head
8648             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8649             * @return the previous, current, and next wiki page
8650             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
8651             */
8652            @Override
8653            public WikiPage[] filterFindByG_N_H_PrevAndNext(long pageId, long groupId,
8654                    long nodeId, boolean head, OrderByComparator<WikiPage> orderByComparator)
8655                    throws NoSuchPageException {
8656                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8657                            return findByG_N_H_PrevAndNext(pageId, groupId, nodeId, head,
8658                                    orderByComparator);
8659                    }
8660    
8661                    WikiPage wikiPage = findByPrimaryKey(pageId);
8662    
8663                    Session session = null;
8664    
8665                    try {
8666                            session = openSession();
8667    
8668                            WikiPage[] array = new WikiPageImpl[3];
8669    
8670                            array[0] = filterGetByG_N_H_PrevAndNext(session, wikiPage, groupId,
8671                                            nodeId, head, orderByComparator, true);
8672    
8673                            array[1] = wikiPage;
8674    
8675                            array[2] = filterGetByG_N_H_PrevAndNext(session, wikiPage, groupId,
8676                                            nodeId, head, orderByComparator, false);
8677    
8678                            return array;
8679                    }
8680                    catch (Exception e) {
8681                            throw processException(e);
8682                    }
8683                    finally {
8684                            closeSession(session);
8685                    }
8686            }
8687    
8688            protected WikiPage filterGetByG_N_H_PrevAndNext(Session session,
8689                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
8690                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
8691                    StringBundler query = null;
8692    
8693                    if (orderByComparator != null) {
8694                            query = new StringBundler(6 +
8695                                            (orderByComparator.getOrderByFields().length * 6));
8696                    }
8697                    else {
8698                            query = new StringBundler(3);
8699                    }
8700    
8701                    if (getDB().isSupportsInlineDistinct()) {
8702                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
8703                    }
8704                    else {
8705                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
8706                    }
8707    
8708                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
8709    
8710                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
8711    
8712                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
8713    
8714                    if (!getDB().isSupportsInlineDistinct()) {
8715                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
8716                    }
8717    
8718                    if (orderByComparator != null) {
8719                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8720    
8721                            if (orderByConditionFields.length > 0) {
8722                                    query.append(WHERE_AND);
8723                            }
8724    
8725                            for (int i = 0; i < orderByConditionFields.length; i++) {
8726                                    if (getDB().isSupportsInlineDistinct()) {
8727                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8728                                    }
8729                                    else {
8730                                            query.append(_ORDER_BY_ENTITY_TABLE);
8731                                    }
8732    
8733                                    query.append(orderByConditionFields[i]);
8734    
8735                                    if ((i + 1) < orderByConditionFields.length) {
8736                                            if (orderByComparator.isAscending() ^ previous) {
8737                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8738                                            }
8739                                            else {
8740                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8741                                            }
8742                                    }
8743                                    else {
8744                                            if (orderByComparator.isAscending() ^ previous) {
8745                                                    query.append(WHERE_GREATER_THAN);
8746                                            }
8747                                            else {
8748                                                    query.append(WHERE_LESSER_THAN);
8749                                            }
8750                                    }
8751                            }
8752    
8753                            query.append(ORDER_BY_CLAUSE);
8754    
8755                            String[] orderByFields = orderByComparator.getOrderByFields();
8756    
8757                            for (int i = 0; i < orderByFields.length; i++) {
8758                                    if (getDB().isSupportsInlineDistinct()) {
8759                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8760                                    }
8761                                    else {
8762                                            query.append(_ORDER_BY_ENTITY_TABLE);
8763                                    }
8764    
8765                                    query.append(orderByFields[i]);
8766    
8767                                    if ((i + 1) < orderByFields.length) {
8768                                            if (orderByComparator.isAscending() ^ previous) {
8769                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8770                                            }
8771                                            else {
8772                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8773                                            }
8774                                    }
8775                                    else {
8776                                            if (orderByComparator.isAscending() ^ previous) {
8777                                                    query.append(ORDER_BY_ASC);
8778                                            }
8779                                            else {
8780                                                    query.append(ORDER_BY_DESC);
8781                                            }
8782                                    }
8783                            }
8784                    }
8785                    else {
8786                            if (getDB().isSupportsInlineDistinct()) {
8787                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8788                            }
8789                            else {
8790                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
8791                            }
8792                    }
8793    
8794                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8795                                    WikiPage.class.getName(),
8796                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8797    
8798                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
8799    
8800                    q.setFirstResult(0);
8801                    q.setMaxResults(2);
8802    
8803                    if (getDB().isSupportsInlineDistinct()) {
8804                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
8805                    }
8806                    else {
8807                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
8808                    }
8809    
8810                    QueryPos qPos = QueryPos.getInstance(q);
8811    
8812                    qPos.add(groupId);
8813    
8814                    qPos.add(nodeId);
8815    
8816                    qPos.add(head);
8817    
8818                    if (orderByComparator != null) {
8819                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
8820    
8821                            for (Object value : values) {
8822                                    qPos.add(value);
8823                            }
8824                    }
8825    
8826                    List<WikiPage> list = q.list();
8827    
8828                    if (list.size() == 2) {
8829                            return list.get(1);
8830                    }
8831                    else {
8832                            return null;
8833                    }
8834            }
8835    
8836            /**
8837             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; from the database.
8838             *
8839             * @param groupId the group ID
8840             * @param nodeId the node ID
8841             * @param head the head
8842             */
8843            @Override
8844            public void removeByG_N_H(long groupId, long nodeId, boolean head) {
8845                    for (WikiPage wikiPage : findByG_N_H(groupId, nodeId, head,
8846                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8847                            remove(wikiPage);
8848                    }
8849            }
8850    
8851            /**
8852             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
8853             *
8854             * @param groupId the group ID
8855             * @param nodeId the node ID
8856             * @param head the head
8857             * @return the number of matching wiki pages
8858             */
8859            @Override
8860            public int countByG_N_H(long groupId, long nodeId, boolean head) {
8861                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_H;
8862    
8863                    Object[] finderArgs = new Object[] { groupId, nodeId, head };
8864    
8865                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8866                                    this);
8867    
8868                    if (count == null) {
8869                            StringBundler query = new StringBundler(4);
8870    
8871                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8872    
8873                            query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
8874    
8875                            query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
8876    
8877                            query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
8878    
8879                            String sql = query.toString();
8880    
8881                            Session session = null;
8882    
8883                            try {
8884                                    session = openSession();
8885    
8886                                    Query q = session.createQuery(sql);
8887    
8888                                    QueryPos qPos = QueryPos.getInstance(q);
8889    
8890                                    qPos.add(groupId);
8891    
8892                                    qPos.add(nodeId);
8893    
8894                                    qPos.add(head);
8895    
8896                                    count = (Long)q.uniqueResult();
8897    
8898                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8899                            }
8900                            catch (Exception e) {
8901                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8902    
8903                                    throw processException(e);
8904                            }
8905                            finally {
8906                                    closeSession(session);
8907                            }
8908                    }
8909    
8910                    return count.intValue();
8911            }
8912    
8913            /**
8914             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
8915             *
8916             * @param groupId the group ID
8917             * @param nodeId the node ID
8918             * @param head the head
8919             * @return the number of matching wiki pages that the user has permission to view
8920             */
8921            @Override
8922            public int filterCountByG_N_H(long groupId, long nodeId, boolean head) {
8923                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8924                            return countByG_N_H(groupId, nodeId, head);
8925                    }
8926    
8927                    StringBundler query = new StringBundler(4);
8928    
8929                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
8930    
8931                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
8932    
8933                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
8934    
8935                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
8936    
8937                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8938                                    WikiPage.class.getName(),
8939                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8940    
8941                    Session session = null;
8942    
8943                    try {
8944                            session = openSession();
8945    
8946                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8947    
8948                            q.addScalar(COUNT_COLUMN_NAME,
8949                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8950    
8951                            QueryPos qPos = QueryPos.getInstance(q);
8952    
8953                            qPos.add(groupId);
8954    
8955                            qPos.add(nodeId);
8956    
8957                            qPos.add(head);
8958    
8959                            Long count = (Long)q.uniqueResult();
8960    
8961                            return count.intValue();
8962                    }
8963                    catch (Exception e) {
8964                            throw processException(e);
8965                    }
8966                    finally {
8967                            closeSession(session);
8968                    }
8969            }
8970    
8971            private static final String _FINDER_COLUMN_G_N_H_GROUPID_2 = "wikiPage.groupId = ? AND ";
8972            private static final String _FINDER_COLUMN_G_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
8973            private static final String _FINDER_COLUMN_G_N_H_HEAD_2 = "wikiPage.head = ?";
8974            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
8975                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
8976                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_S",
8977                            new String[] {
8978                                    Long.class.getName(), Long.class.getName(),
8979                                    Integer.class.getName(),
8980                                    
8981                            Integer.class.getName(), Integer.class.getName(),
8982                                    OrderByComparator.class.getName()
8983                            });
8984            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
8985                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
8986                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_S",
8987                            new String[] {
8988                                    Long.class.getName(), Long.class.getName(),
8989                                    Integer.class.getName()
8990                            },
8991                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
8992                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
8993                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
8994                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
8995                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
8996            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
8997                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
8998                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_S",
8999                            new String[] {
9000                                    Long.class.getName(), Long.class.getName(),
9001                                    Integer.class.getName()
9002                            });
9003    
9004            /**
9005             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
9006             *
9007             * @param groupId the group ID
9008             * @param nodeId the node ID
9009             * @param status the status
9010             * @return the matching wiki pages
9011             */
9012            @Override
9013            public List<WikiPage> findByG_N_S(long groupId, long nodeId, int status) {
9014                    return findByG_N_S(groupId, nodeId, status, QueryUtil.ALL_POS,
9015                            QueryUtil.ALL_POS, null);
9016            }
9017    
9018            /**
9019             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
9020             *
9021             * <p>
9022             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
9023             * </p>
9024             *
9025             * @param groupId the group ID
9026             * @param nodeId the node ID
9027             * @param status the status
9028             * @param start the lower bound of the range of wiki pages
9029             * @param end the upper bound of the range of wiki pages (not inclusive)
9030             * @return the range of matching wiki pages
9031             */
9032            @Override
9033            public List<WikiPage> findByG_N_S(long groupId, long nodeId, int status,
9034                    int start, int end) {
9035                    return findByG_N_S(groupId, nodeId, status, start, end, null);
9036            }
9037    
9038            /**
9039             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
9040             *
9041             * <p>
9042             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
9043             * </p>
9044             *
9045             * @param groupId the group ID
9046             * @param nodeId the node ID
9047             * @param status the status
9048             * @param start the lower bound of the range of wiki pages
9049             * @param end the upper bound of the range of wiki pages (not inclusive)
9050             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9051             * @return the ordered range of matching wiki pages
9052             */
9053            @Override
9054            public List<WikiPage> findByG_N_S(long groupId, long nodeId, int status,
9055                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
9056                    boolean pagination = true;
9057                    FinderPath finderPath = null;
9058                    Object[] finderArgs = null;
9059    
9060                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9061                                    (orderByComparator == null)) {
9062                            pagination = false;
9063                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S;
9064                            finderArgs = new Object[] { groupId, nodeId, status };
9065                    }
9066                    else {
9067                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_S;
9068                            finderArgs = new Object[] {
9069                                            groupId, nodeId, status,
9070                                            
9071                                            start, end, orderByComparator
9072                                    };
9073                    }
9074    
9075                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
9076                                    finderArgs, this);
9077    
9078                    if ((list != null) && !list.isEmpty()) {
9079                            for (WikiPage wikiPage : list) {
9080                                    if ((groupId != wikiPage.getGroupId()) ||
9081                                                    (nodeId != wikiPage.getNodeId()) ||
9082                                                    (status != wikiPage.getStatus())) {
9083                                            list = null;
9084    
9085                                            break;
9086                                    }
9087                            }
9088                    }
9089    
9090                    if (list == null) {
9091                            StringBundler query = null;
9092    
9093                            if (orderByComparator != null) {
9094                                    query = new StringBundler(5 +
9095                                                    (orderByComparator.getOrderByFields().length * 3));
9096                            }
9097                            else {
9098                                    query = new StringBundler(5);
9099                            }
9100    
9101                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
9102    
9103                            query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
9104    
9105                            query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
9106    
9107                            query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
9108    
9109                            if (orderByComparator != null) {
9110                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9111                                            orderByComparator);
9112                            }
9113                            else
9114                             if (pagination) {
9115                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9116                            }
9117    
9118                            String sql = query.toString();
9119    
9120                            Session session = null;
9121    
9122                            try {
9123                                    session = openSession();
9124    
9125                                    Query q = session.createQuery(sql);
9126    
9127                                    QueryPos qPos = QueryPos.getInstance(q);
9128    
9129                                    qPos.add(groupId);
9130    
9131                                    qPos.add(nodeId);
9132    
9133                                    qPos.add(status);
9134    
9135                                    if (!pagination) {
9136                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
9137                                                            start, end, false);
9138    
9139                                            Collections.sort(list);
9140    
9141                                            list = Collections.unmodifiableList(list);
9142                                    }
9143                                    else {
9144                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
9145                                                            start, end);
9146                                    }
9147    
9148                                    cacheResult(list);
9149    
9150                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9151                            }
9152                            catch (Exception e) {
9153                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9154    
9155                                    throw processException(e);
9156                            }
9157                            finally {
9158                                    closeSession(session);
9159                            }
9160                    }
9161    
9162                    return list;
9163            }
9164    
9165            /**
9166             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
9167             *
9168             * @param groupId the group ID
9169             * @param nodeId the node ID
9170             * @param status the status
9171             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9172             * @return the first matching wiki page
9173             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9174             */
9175            @Override
9176            public WikiPage findByG_N_S_First(long groupId, long nodeId, int status,
9177                    OrderByComparator<WikiPage> orderByComparator)
9178                    throws NoSuchPageException {
9179                    WikiPage wikiPage = fetchByG_N_S_First(groupId, nodeId, status,
9180                                    orderByComparator);
9181    
9182                    if (wikiPage != null) {
9183                            return wikiPage;
9184                    }
9185    
9186                    StringBundler msg = new StringBundler(8);
9187    
9188                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9189    
9190                    msg.append("groupId=");
9191                    msg.append(groupId);
9192    
9193                    msg.append(", nodeId=");
9194                    msg.append(nodeId);
9195    
9196                    msg.append(", status=");
9197                    msg.append(status);
9198    
9199                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9200    
9201                    throw new NoSuchPageException(msg.toString());
9202            }
9203    
9204            /**
9205             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
9206             *
9207             * @param groupId the group ID
9208             * @param nodeId the node ID
9209             * @param status the status
9210             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9211             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
9212             */
9213            @Override
9214            public WikiPage fetchByG_N_S_First(long groupId, long nodeId, int status,
9215                    OrderByComparator<WikiPage> orderByComparator) {
9216                    List<WikiPage> list = findByG_N_S(groupId, nodeId, status, 0, 1,
9217                                    orderByComparator);
9218    
9219                    if (!list.isEmpty()) {
9220                            return list.get(0);
9221                    }
9222    
9223                    return null;
9224            }
9225    
9226            /**
9227             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
9228             *
9229             * @param groupId the group ID
9230             * @param nodeId the node ID
9231             * @param status the status
9232             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9233             * @return the last matching wiki page
9234             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9235             */
9236            @Override
9237            public WikiPage findByG_N_S_Last(long groupId, long nodeId, int status,
9238                    OrderByComparator<WikiPage> orderByComparator)
9239                    throws NoSuchPageException {
9240                    WikiPage wikiPage = fetchByG_N_S_Last(groupId, nodeId, status,
9241                                    orderByComparator);
9242    
9243                    if (wikiPage != null) {
9244                            return wikiPage;
9245                    }
9246    
9247                    StringBundler msg = new StringBundler(8);
9248    
9249                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9250    
9251                    msg.append("groupId=");
9252                    msg.append(groupId);
9253    
9254                    msg.append(", nodeId=");
9255                    msg.append(nodeId);
9256    
9257                    msg.append(", status=");
9258                    msg.append(status);
9259    
9260                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9261    
9262                    throw new NoSuchPageException(msg.toString());
9263            }
9264    
9265            /**
9266             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
9267             *
9268             * @param groupId the group ID
9269             * @param nodeId the node ID
9270             * @param status the status
9271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9272             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
9273             */
9274            @Override
9275            public WikiPage fetchByG_N_S_Last(long groupId, long nodeId, int status,
9276                    OrderByComparator<WikiPage> orderByComparator) {
9277                    int count = countByG_N_S(groupId, nodeId, status);
9278    
9279                    if (count == 0) {
9280                            return null;
9281                    }
9282    
9283                    List<WikiPage> list = findByG_N_S(groupId, nodeId, status, count - 1,
9284                                    count, orderByComparator);
9285    
9286                    if (!list.isEmpty()) {
9287                            return list.get(0);
9288                    }
9289    
9290                    return null;
9291            }
9292    
9293            /**
9294             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
9295             *
9296             * @param pageId the primary key of the current wiki page
9297             * @param groupId the group ID
9298             * @param nodeId the node ID
9299             * @param status the status
9300             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9301             * @return the previous, current, and next wiki page
9302             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
9303             */
9304            @Override
9305            public WikiPage[] findByG_N_S_PrevAndNext(long pageId, long groupId,
9306                    long nodeId, int status, OrderByComparator<WikiPage> orderByComparator)
9307                    throws NoSuchPageException {
9308                    WikiPage wikiPage = findByPrimaryKey(pageId);
9309    
9310                    Session session = null;
9311    
9312                    try {
9313                            session = openSession();
9314    
9315                            WikiPage[] array = new WikiPageImpl[3];
9316    
9317                            array[0] = getByG_N_S_PrevAndNext(session, wikiPage, groupId,
9318                                            nodeId, status, orderByComparator, true);
9319    
9320                            array[1] = wikiPage;
9321    
9322                            array[2] = getByG_N_S_PrevAndNext(session, wikiPage, groupId,
9323                                            nodeId, status, orderByComparator, false);
9324    
9325                            return array;
9326                    }
9327                    catch (Exception e) {
9328                            throw processException(e);
9329                    }
9330                    finally {
9331                            closeSession(session);
9332                    }
9333            }
9334    
9335            protected WikiPage getByG_N_S_PrevAndNext(Session session,
9336                    WikiPage wikiPage, long groupId, long nodeId, int status,
9337                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
9338                    StringBundler query = null;
9339    
9340                    if (orderByComparator != null) {
9341                            query = new StringBundler(6 +
9342                                            (orderByComparator.getOrderByFields().length * 6));
9343                    }
9344                    else {
9345                            query = new StringBundler(3);
9346                    }
9347    
9348                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
9349    
9350                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
9351    
9352                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
9353    
9354                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
9355    
9356                    if (orderByComparator != null) {
9357                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9358    
9359                            if (orderByConditionFields.length > 0) {
9360                                    query.append(WHERE_AND);
9361                            }
9362    
9363                            for (int i = 0; i < orderByConditionFields.length; i++) {
9364                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9365                                    query.append(orderByConditionFields[i]);
9366    
9367                                    if ((i + 1) < orderByConditionFields.length) {
9368                                            if (orderByComparator.isAscending() ^ previous) {
9369                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9370                                            }
9371                                            else {
9372                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9373                                            }
9374                                    }
9375                                    else {
9376                                            if (orderByComparator.isAscending() ^ previous) {
9377                                                    query.append(WHERE_GREATER_THAN);
9378                                            }
9379                                            else {
9380                                                    query.append(WHERE_LESSER_THAN);
9381                                            }
9382                                    }
9383                            }
9384    
9385                            query.append(ORDER_BY_CLAUSE);
9386    
9387                            String[] orderByFields = orderByComparator.getOrderByFields();
9388    
9389                            for (int i = 0; i < orderByFields.length; i++) {
9390                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9391                                    query.append(orderByFields[i]);
9392    
9393                                    if ((i + 1) < orderByFields.length) {
9394                                            if (orderByComparator.isAscending() ^ previous) {
9395                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9396                                            }
9397                                            else {
9398                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9399                                            }
9400                                    }
9401                                    else {
9402                                            if (orderByComparator.isAscending() ^ previous) {
9403                                                    query.append(ORDER_BY_ASC);
9404                                            }
9405                                            else {
9406                                                    query.append(ORDER_BY_DESC);
9407                                            }
9408                                    }
9409                            }
9410                    }
9411                    else {
9412                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9413                    }
9414    
9415                    String sql = query.toString();
9416    
9417                    Query q = session.createQuery(sql);
9418    
9419                    q.setFirstResult(0);
9420                    q.setMaxResults(2);
9421    
9422                    QueryPos qPos = QueryPos.getInstance(q);
9423    
9424                    qPos.add(groupId);
9425    
9426                    qPos.add(nodeId);
9427    
9428                    qPos.add(status);
9429    
9430                    if (orderByComparator != null) {
9431                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
9432    
9433                            for (Object value : values) {
9434                                    qPos.add(value);
9435                            }
9436                    }
9437    
9438                    List<WikiPage> list = q.list();
9439    
9440                    if (list.size() == 2) {
9441                            return list.get(1);
9442                    }
9443                    else {
9444                            return null;
9445                    }
9446            }
9447    
9448            /**
9449             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
9450             *
9451             * @param groupId the group ID
9452             * @param nodeId the node ID
9453             * @param status the status
9454             * @return the matching wiki pages that the user has permission to view
9455             */
9456            @Override
9457            public List<WikiPage> filterFindByG_N_S(long groupId, long nodeId,
9458                    int status) {
9459                    return filterFindByG_N_S(groupId, nodeId, status, QueryUtil.ALL_POS,
9460                            QueryUtil.ALL_POS, null);
9461            }
9462    
9463            /**
9464             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
9465             *
9466             * <p>
9467             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
9468             * </p>
9469             *
9470             * @param groupId the group ID
9471             * @param nodeId the node ID
9472             * @param status the status
9473             * @param start the lower bound of the range of wiki pages
9474             * @param end the upper bound of the range of wiki pages (not inclusive)
9475             * @return the range of matching wiki pages that the user has permission to view
9476             */
9477            @Override
9478            public List<WikiPage> filterFindByG_N_S(long groupId, long nodeId,
9479                    int status, int start, int end) {
9480                    return filterFindByG_N_S(groupId, nodeId, status, start, end, null);
9481            }
9482    
9483            /**
9484             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
9485             *
9486             * <p>
9487             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
9488             * </p>
9489             *
9490             * @param groupId the group ID
9491             * @param nodeId the node ID
9492             * @param status the status
9493             * @param start the lower bound of the range of wiki pages
9494             * @param end the upper bound of the range of wiki pages (not inclusive)
9495             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9496             * @return the ordered range of matching wiki pages that the user has permission to view
9497             */
9498            @Override
9499            public List<WikiPage> filterFindByG_N_S(long groupId, long nodeId,
9500                    int status, int start, int end,
9501                    OrderByComparator<WikiPage> orderByComparator) {
9502                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9503                            return findByG_N_S(groupId, nodeId, status, start, end,
9504                                    orderByComparator);
9505                    }
9506    
9507                    StringBundler query = null;
9508    
9509                    if (orderByComparator != null) {
9510                            query = new StringBundler(5 +
9511                                            (orderByComparator.getOrderByFields().length * 3));
9512                    }
9513                    else {
9514                            query = new StringBundler(5);
9515                    }
9516    
9517                    if (getDB().isSupportsInlineDistinct()) {
9518                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
9519                    }
9520                    else {
9521                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
9522                    }
9523    
9524                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
9525    
9526                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
9527    
9528                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
9529    
9530                    if (!getDB().isSupportsInlineDistinct()) {
9531                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
9532                    }
9533    
9534                    if (orderByComparator != null) {
9535                            if (getDB().isSupportsInlineDistinct()) {
9536                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9537                                            orderByComparator, true);
9538                            }
9539                            else {
9540                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9541                                            orderByComparator, true);
9542                            }
9543                    }
9544                    else {
9545                            if (getDB().isSupportsInlineDistinct()) {
9546                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9547                            }
9548                            else {
9549                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
9550                            }
9551                    }
9552    
9553                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9554                                    WikiPage.class.getName(),
9555                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9556    
9557                    Session session = null;
9558    
9559                    try {
9560                            session = openSession();
9561    
9562                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9563    
9564                            if (getDB().isSupportsInlineDistinct()) {
9565                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
9566                            }
9567                            else {
9568                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
9569                            }
9570    
9571                            QueryPos qPos = QueryPos.getInstance(q);
9572    
9573                            qPos.add(groupId);
9574    
9575                            qPos.add(nodeId);
9576    
9577                            qPos.add(status);
9578    
9579                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
9580                    }
9581                    catch (Exception e) {
9582                            throw processException(e);
9583                    }
9584                    finally {
9585                            closeSession(session);
9586                    }
9587            }
9588    
9589            /**
9590             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
9591             *
9592             * @param pageId the primary key of the current wiki page
9593             * @param groupId the group ID
9594             * @param nodeId the node ID
9595             * @param status the status
9596             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9597             * @return the previous, current, and next wiki page
9598             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
9599             */
9600            @Override
9601            public WikiPage[] filterFindByG_N_S_PrevAndNext(long pageId, long groupId,
9602                    long nodeId, int status, OrderByComparator<WikiPage> orderByComparator)
9603                    throws NoSuchPageException {
9604                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9605                            return findByG_N_S_PrevAndNext(pageId, groupId, nodeId, status,
9606                                    orderByComparator);
9607                    }
9608    
9609                    WikiPage wikiPage = findByPrimaryKey(pageId);
9610    
9611                    Session session = null;
9612    
9613                    try {
9614                            session = openSession();
9615    
9616                            WikiPage[] array = new WikiPageImpl[3];
9617    
9618                            array[0] = filterGetByG_N_S_PrevAndNext(session, wikiPage, groupId,
9619                                            nodeId, status, orderByComparator, true);
9620    
9621                            array[1] = wikiPage;
9622    
9623                            array[2] = filterGetByG_N_S_PrevAndNext(session, wikiPage, groupId,
9624                                            nodeId, status, orderByComparator, false);
9625    
9626                            return array;
9627                    }
9628                    catch (Exception e) {
9629                            throw processException(e);
9630                    }
9631                    finally {
9632                            closeSession(session);
9633                    }
9634            }
9635    
9636            protected WikiPage filterGetByG_N_S_PrevAndNext(Session session,
9637                    WikiPage wikiPage, long groupId, long nodeId, int status,
9638                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
9639                    StringBundler query = null;
9640    
9641                    if (orderByComparator != null) {
9642                            query = new StringBundler(6 +
9643                                            (orderByComparator.getOrderByFields().length * 6));
9644                    }
9645                    else {
9646                            query = new StringBundler(3);
9647                    }
9648    
9649                    if (getDB().isSupportsInlineDistinct()) {
9650                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
9651                    }
9652                    else {
9653                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
9654                    }
9655    
9656                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
9657    
9658                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
9659    
9660                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
9661    
9662                    if (!getDB().isSupportsInlineDistinct()) {
9663                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
9664                    }
9665    
9666                    if (orderByComparator != null) {
9667                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9668    
9669                            if (orderByConditionFields.length > 0) {
9670                                    query.append(WHERE_AND);
9671                            }
9672    
9673                            for (int i = 0; i < orderByConditionFields.length; i++) {
9674                                    if (getDB().isSupportsInlineDistinct()) {
9675                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9676                                    }
9677                                    else {
9678                                            query.append(_ORDER_BY_ENTITY_TABLE);
9679                                    }
9680    
9681                                    query.append(orderByConditionFields[i]);
9682    
9683                                    if ((i + 1) < orderByConditionFields.length) {
9684                                            if (orderByComparator.isAscending() ^ previous) {
9685                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9686                                            }
9687                                            else {
9688                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9689                                            }
9690                                    }
9691                                    else {
9692                                            if (orderByComparator.isAscending() ^ previous) {
9693                                                    query.append(WHERE_GREATER_THAN);
9694                                            }
9695                                            else {
9696                                                    query.append(WHERE_LESSER_THAN);
9697                                            }
9698                                    }
9699                            }
9700    
9701                            query.append(ORDER_BY_CLAUSE);
9702    
9703                            String[] orderByFields = orderByComparator.getOrderByFields();
9704    
9705                            for (int i = 0; i < orderByFields.length; i++) {
9706                                    if (getDB().isSupportsInlineDistinct()) {
9707                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9708                                    }
9709                                    else {
9710                                            query.append(_ORDER_BY_ENTITY_TABLE);
9711                                    }
9712    
9713                                    query.append(orderByFields[i]);
9714    
9715                                    if ((i + 1) < orderByFields.length) {
9716                                            if (orderByComparator.isAscending() ^ previous) {
9717                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9718                                            }
9719                                            else {
9720                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9721                                            }
9722                                    }
9723                                    else {
9724                                            if (orderByComparator.isAscending() ^ previous) {
9725                                                    query.append(ORDER_BY_ASC);
9726                                            }
9727                                            else {
9728                                                    query.append(ORDER_BY_DESC);
9729                                            }
9730                                    }
9731                            }
9732                    }
9733                    else {
9734                            if (getDB().isSupportsInlineDistinct()) {
9735                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9736                            }
9737                            else {
9738                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
9739                            }
9740                    }
9741    
9742                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9743                                    WikiPage.class.getName(),
9744                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9745    
9746                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9747    
9748                    q.setFirstResult(0);
9749                    q.setMaxResults(2);
9750    
9751                    if (getDB().isSupportsInlineDistinct()) {
9752                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
9753                    }
9754                    else {
9755                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
9756                    }
9757    
9758                    QueryPos qPos = QueryPos.getInstance(q);
9759    
9760                    qPos.add(groupId);
9761    
9762                    qPos.add(nodeId);
9763    
9764                    qPos.add(status);
9765    
9766                    if (orderByComparator != null) {
9767                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
9768    
9769                            for (Object value : values) {
9770                                    qPos.add(value);
9771                            }
9772                    }
9773    
9774                    List<WikiPage> list = q.list();
9775    
9776                    if (list.size() == 2) {
9777                            return list.get(1);
9778                    }
9779                    else {
9780                            return null;
9781                    }
9782            }
9783    
9784            /**
9785             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63; from the database.
9786             *
9787             * @param groupId the group ID
9788             * @param nodeId the node ID
9789             * @param status the status
9790             */
9791            @Override
9792            public void removeByG_N_S(long groupId, long nodeId, int status) {
9793                    for (WikiPage wikiPage : findByG_N_S(groupId, nodeId, status,
9794                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9795                            remove(wikiPage);
9796                    }
9797            }
9798    
9799            /**
9800             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
9801             *
9802             * @param groupId the group ID
9803             * @param nodeId the node ID
9804             * @param status the status
9805             * @return the number of matching wiki pages
9806             */
9807            @Override
9808            public int countByG_N_S(long groupId, long nodeId, int status) {
9809                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_S;
9810    
9811                    Object[] finderArgs = new Object[] { groupId, nodeId, status };
9812    
9813                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9814                                    this);
9815    
9816                    if (count == null) {
9817                            StringBundler query = new StringBundler(4);
9818    
9819                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
9820    
9821                            query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
9822    
9823                            query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
9824    
9825                            query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
9826    
9827                            String sql = query.toString();
9828    
9829                            Session session = null;
9830    
9831                            try {
9832                                    session = openSession();
9833    
9834                                    Query q = session.createQuery(sql);
9835    
9836                                    QueryPos qPos = QueryPos.getInstance(q);
9837    
9838                                    qPos.add(groupId);
9839    
9840                                    qPos.add(nodeId);
9841    
9842                                    qPos.add(status);
9843    
9844                                    count = (Long)q.uniqueResult();
9845    
9846                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9847                            }
9848                            catch (Exception e) {
9849                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9850    
9851                                    throw processException(e);
9852                            }
9853                            finally {
9854                                    closeSession(session);
9855                            }
9856                    }
9857    
9858                    return count.intValue();
9859            }
9860    
9861            /**
9862             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
9863             *
9864             * @param groupId the group ID
9865             * @param nodeId the node ID
9866             * @param status the status
9867             * @return the number of matching wiki pages that the user has permission to view
9868             */
9869            @Override
9870            public int filterCountByG_N_S(long groupId, long nodeId, int status) {
9871                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9872                            return countByG_N_S(groupId, nodeId, status);
9873                    }
9874    
9875                    StringBundler query = new StringBundler(4);
9876    
9877                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
9878    
9879                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
9880    
9881                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
9882    
9883                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
9884    
9885                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9886                                    WikiPage.class.getName(),
9887                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9888    
9889                    Session session = null;
9890    
9891                    try {
9892                            session = openSession();
9893    
9894                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9895    
9896                            q.addScalar(COUNT_COLUMN_NAME,
9897                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9898    
9899                            QueryPos qPos = QueryPos.getInstance(q);
9900    
9901                            qPos.add(groupId);
9902    
9903                            qPos.add(nodeId);
9904    
9905                            qPos.add(status);
9906    
9907                            Long count = (Long)q.uniqueResult();
9908    
9909                            return count.intValue();
9910                    }
9911                    catch (Exception e) {
9912                            throw processException(e);
9913                    }
9914                    finally {
9915                            closeSession(session);
9916                    }
9917            }
9918    
9919            private static final String _FINDER_COLUMN_G_N_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
9920            private static final String _FINDER_COLUMN_G_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
9921            private static final String _FINDER_COLUMN_G_N_S_STATUS_2 = "wikiPage.status = ?";
9922            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
9923                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
9924                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_N_S",
9925                            new String[] {
9926                                    Long.class.getName(), Long.class.getName(),
9927                                    Integer.class.getName(),
9928                                    
9929                            Integer.class.getName(), Integer.class.getName(),
9930                                    OrderByComparator.class.getName()
9931                            });
9932            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
9933                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
9934                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_N_S",
9935                            new String[] {
9936                                    Long.class.getName(), Long.class.getName(),
9937                                    Integer.class.getName()
9938                            },
9939                            WikiPageModelImpl.USERID_COLUMN_BITMASK |
9940                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
9941                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
9942                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
9943                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
9944            public static final FinderPath FINDER_PATH_COUNT_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
9945                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
9946                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_N_S",
9947                            new String[] {
9948                                    Long.class.getName(), Long.class.getName(),
9949                                    Integer.class.getName()
9950                            });
9951    
9952            /**
9953             * Returns all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
9954             *
9955             * @param userId the user ID
9956             * @param nodeId the node ID
9957             * @param status the status
9958             * @return the matching wiki pages
9959             */
9960            @Override
9961            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status) {
9962                    return findByU_N_S(userId, nodeId, status, QueryUtil.ALL_POS,
9963                            QueryUtil.ALL_POS, null);
9964            }
9965    
9966            /**
9967             * Returns a range of all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
9968             *
9969             * <p>
9970             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
9971             * </p>
9972             *
9973             * @param userId the user ID
9974             * @param nodeId the node ID
9975             * @param status the status
9976             * @param start the lower bound of the range of wiki pages
9977             * @param end the upper bound of the range of wiki pages (not inclusive)
9978             * @return the range of matching wiki pages
9979             */
9980            @Override
9981            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status,
9982                    int start, int end) {
9983                    return findByU_N_S(userId, nodeId, status, start, end, null);
9984            }
9985    
9986            /**
9987             * Returns an ordered range of all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
9988             *
9989             * <p>
9990             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
9991             * </p>
9992             *
9993             * @param userId the user ID
9994             * @param nodeId the node ID
9995             * @param status the status
9996             * @param start the lower bound of the range of wiki pages
9997             * @param end the upper bound of the range of wiki pages (not inclusive)
9998             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9999             * @return the ordered range of matching wiki pages
10000             */
10001            @Override
10002            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status,
10003                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
10004                    boolean pagination = true;
10005                    FinderPath finderPath = null;
10006                    Object[] finderArgs = null;
10007    
10008                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10009                                    (orderByComparator == null)) {
10010                            pagination = false;
10011                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S;
10012                            finderArgs = new Object[] { userId, nodeId, status };
10013                    }
10014                    else {
10015                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_N_S;
10016                            finderArgs = new Object[] {
10017                                            userId, nodeId, status,
10018                                            
10019                                            start, end, orderByComparator
10020                                    };
10021                    }
10022    
10023                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
10024                                    finderArgs, this);
10025    
10026                    if ((list != null) && !list.isEmpty()) {
10027                            for (WikiPage wikiPage : list) {
10028                                    if ((userId != wikiPage.getUserId()) ||
10029                                                    (nodeId != wikiPage.getNodeId()) ||
10030                                                    (status != wikiPage.getStatus())) {
10031                                            list = null;
10032    
10033                                            break;
10034                                    }
10035                            }
10036                    }
10037    
10038                    if (list == null) {
10039                            StringBundler query = null;
10040    
10041                            if (orderByComparator != null) {
10042                                    query = new StringBundler(5 +
10043                                                    (orderByComparator.getOrderByFields().length * 3));
10044                            }
10045                            else {
10046                                    query = new StringBundler(5);
10047                            }
10048    
10049                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
10050    
10051                            query.append(_FINDER_COLUMN_U_N_S_USERID_2);
10052    
10053                            query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
10054    
10055                            query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
10056    
10057                            if (orderByComparator != null) {
10058                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10059                                            orderByComparator);
10060                            }
10061                            else
10062                             if (pagination) {
10063                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10064                            }
10065    
10066                            String sql = query.toString();
10067    
10068                            Session session = null;
10069    
10070                            try {
10071                                    session = openSession();
10072    
10073                                    Query q = session.createQuery(sql);
10074    
10075                                    QueryPos qPos = QueryPos.getInstance(q);
10076    
10077                                    qPos.add(userId);
10078    
10079                                    qPos.add(nodeId);
10080    
10081                                    qPos.add(status);
10082    
10083                                    if (!pagination) {
10084                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
10085                                                            start, end, false);
10086    
10087                                            Collections.sort(list);
10088    
10089                                            list = Collections.unmodifiableList(list);
10090                                    }
10091                                    else {
10092                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
10093                                                            start, end);
10094                                    }
10095    
10096                                    cacheResult(list);
10097    
10098                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10099                            }
10100                            catch (Exception e) {
10101                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10102    
10103                                    throw processException(e);
10104                            }
10105                            finally {
10106                                    closeSession(session);
10107                            }
10108                    }
10109    
10110                    return list;
10111            }
10112    
10113            /**
10114             * Returns the first wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
10115             *
10116             * @param userId the user ID
10117             * @param nodeId the node ID
10118             * @param status the status
10119             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10120             * @return the first matching wiki page
10121             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
10122             */
10123            @Override
10124            public WikiPage findByU_N_S_First(long userId, long nodeId, int status,
10125                    OrderByComparator<WikiPage> orderByComparator)
10126                    throws NoSuchPageException {
10127                    WikiPage wikiPage = fetchByU_N_S_First(userId, nodeId, status,
10128                                    orderByComparator);
10129    
10130                    if (wikiPage != null) {
10131                            return wikiPage;
10132                    }
10133    
10134                    StringBundler msg = new StringBundler(8);
10135    
10136                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10137    
10138                    msg.append("userId=");
10139                    msg.append(userId);
10140    
10141                    msg.append(", nodeId=");
10142                    msg.append(nodeId);
10143    
10144                    msg.append(", status=");
10145                    msg.append(status);
10146    
10147                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10148    
10149                    throw new NoSuchPageException(msg.toString());
10150            }
10151    
10152            /**
10153             * Returns the first wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
10154             *
10155             * @param userId the user ID
10156             * @param nodeId the node ID
10157             * @param status the status
10158             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10159             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
10160             */
10161            @Override
10162            public WikiPage fetchByU_N_S_First(long userId, long nodeId, int status,
10163                    OrderByComparator<WikiPage> orderByComparator) {
10164                    List<WikiPage> list = findByU_N_S(userId, nodeId, status, 0, 1,
10165                                    orderByComparator);
10166    
10167                    if (!list.isEmpty()) {
10168                            return list.get(0);
10169                    }
10170    
10171                    return null;
10172            }
10173    
10174            /**
10175             * Returns the last wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
10176             *
10177             * @param userId the user ID
10178             * @param nodeId the node ID
10179             * @param status the status
10180             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10181             * @return the last matching wiki page
10182             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
10183             */
10184            @Override
10185            public WikiPage findByU_N_S_Last(long userId, long nodeId, int status,
10186                    OrderByComparator<WikiPage> orderByComparator)
10187                    throws NoSuchPageException {
10188                    WikiPage wikiPage = fetchByU_N_S_Last(userId, nodeId, status,
10189                                    orderByComparator);
10190    
10191                    if (wikiPage != null) {
10192                            return wikiPage;
10193                    }
10194    
10195                    StringBundler msg = new StringBundler(8);
10196    
10197                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10198    
10199                    msg.append("userId=");
10200                    msg.append(userId);
10201    
10202                    msg.append(", nodeId=");
10203                    msg.append(nodeId);
10204    
10205                    msg.append(", status=");
10206                    msg.append(status);
10207    
10208                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10209    
10210                    throw new NoSuchPageException(msg.toString());
10211            }
10212    
10213            /**
10214             * Returns the last wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
10215             *
10216             * @param userId the user ID
10217             * @param nodeId the node ID
10218             * @param status the status
10219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10220             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
10221             */
10222            @Override
10223            public WikiPage fetchByU_N_S_Last(long userId, long nodeId, int status,
10224                    OrderByComparator<WikiPage> orderByComparator) {
10225                    int count = countByU_N_S(userId, nodeId, status);
10226    
10227                    if (count == 0) {
10228                            return null;
10229                    }
10230    
10231                    List<WikiPage> list = findByU_N_S(userId, nodeId, status, count - 1,
10232                                    count, orderByComparator);
10233    
10234                    if (!list.isEmpty()) {
10235                            return list.get(0);
10236                    }
10237    
10238                    return null;
10239            }
10240    
10241            /**
10242             * Returns the wiki pages before and after the current wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
10243             *
10244             * @param pageId the primary key of the current wiki page
10245             * @param userId the user ID
10246             * @param nodeId the node ID
10247             * @param status the status
10248             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10249             * @return the previous, current, and next wiki page
10250             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
10251             */
10252            @Override
10253            public WikiPage[] findByU_N_S_PrevAndNext(long pageId, long userId,
10254                    long nodeId, int status, OrderByComparator<WikiPage> orderByComparator)
10255                    throws NoSuchPageException {
10256                    WikiPage wikiPage = findByPrimaryKey(pageId);
10257    
10258                    Session session = null;
10259    
10260                    try {
10261                            session = openSession();
10262    
10263                            WikiPage[] array = new WikiPageImpl[3];
10264    
10265                            array[0] = getByU_N_S_PrevAndNext(session, wikiPage, userId,
10266                                            nodeId, status, orderByComparator, true);
10267    
10268                            array[1] = wikiPage;
10269    
10270                            array[2] = getByU_N_S_PrevAndNext(session, wikiPage, userId,
10271                                            nodeId, status, orderByComparator, false);
10272    
10273                            return array;
10274                    }
10275                    catch (Exception e) {
10276                            throw processException(e);
10277                    }
10278                    finally {
10279                            closeSession(session);
10280                    }
10281            }
10282    
10283            protected WikiPage getByU_N_S_PrevAndNext(Session session,
10284                    WikiPage wikiPage, long userId, long nodeId, int status,
10285                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
10286                    StringBundler query = null;
10287    
10288                    if (orderByComparator != null) {
10289                            query = new StringBundler(6 +
10290                                            (orderByComparator.getOrderByFields().length * 6));
10291                    }
10292                    else {
10293                            query = new StringBundler(3);
10294                    }
10295    
10296                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
10297    
10298                    query.append(_FINDER_COLUMN_U_N_S_USERID_2);
10299    
10300                    query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
10301    
10302                    query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
10303    
10304                    if (orderByComparator != null) {
10305                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10306    
10307                            if (orderByConditionFields.length > 0) {
10308                                    query.append(WHERE_AND);
10309                            }
10310    
10311                            for (int i = 0; i < orderByConditionFields.length; i++) {
10312                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10313                                    query.append(orderByConditionFields[i]);
10314    
10315                                    if ((i + 1) < orderByConditionFields.length) {
10316                                            if (orderByComparator.isAscending() ^ previous) {
10317                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10318                                            }
10319                                            else {
10320                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10321                                            }
10322                                    }
10323                                    else {
10324                                            if (orderByComparator.isAscending() ^ previous) {
10325                                                    query.append(WHERE_GREATER_THAN);
10326                                            }
10327                                            else {
10328                                                    query.append(WHERE_LESSER_THAN);
10329                                            }
10330                                    }
10331                            }
10332    
10333                            query.append(ORDER_BY_CLAUSE);
10334    
10335                            String[] orderByFields = orderByComparator.getOrderByFields();
10336    
10337                            for (int i = 0; i < orderByFields.length; i++) {
10338                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10339                                    query.append(orderByFields[i]);
10340    
10341                                    if ((i + 1) < orderByFields.length) {
10342                                            if (orderByComparator.isAscending() ^ previous) {
10343                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10344                                            }
10345                                            else {
10346                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10347                                            }
10348                                    }
10349                                    else {
10350                                            if (orderByComparator.isAscending() ^ previous) {
10351                                                    query.append(ORDER_BY_ASC);
10352                                            }
10353                                            else {
10354                                                    query.append(ORDER_BY_DESC);
10355                                            }
10356                                    }
10357                            }
10358                    }
10359                    else {
10360                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10361                    }
10362    
10363                    String sql = query.toString();
10364    
10365                    Query q = session.createQuery(sql);
10366    
10367                    q.setFirstResult(0);
10368                    q.setMaxResults(2);
10369    
10370                    QueryPos qPos = QueryPos.getInstance(q);
10371    
10372                    qPos.add(userId);
10373    
10374                    qPos.add(nodeId);
10375    
10376                    qPos.add(status);
10377    
10378                    if (orderByComparator != null) {
10379                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
10380    
10381                            for (Object value : values) {
10382                                    qPos.add(value);
10383                            }
10384                    }
10385    
10386                    List<WikiPage> list = q.list();
10387    
10388                    if (list.size() == 2) {
10389                            return list.get(1);
10390                    }
10391                    else {
10392                            return null;
10393                    }
10394            }
10395    
10396            /**
10397             * Removes all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63; from the database.
10398             *
10399             * @param userId the user ID
10400             * @param nodeId the node ID
10401             * @param status the status
10402             */
10403            @Override
10404            public void removeByU_N_S(long userId, long nodeId, int status) {
10405                    for (WikiPage wikiPage : findByU_N_S(userId, nodeId, status,
10406                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10407                            remove(wikiPage);
10408                    }
10409            }
10410    
10411            /**
10412             * Returns the number of wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
10413             *
10414             * @param userId the user ID
10415             * @param nodeId the node ID
10416             * @param status the status
10417             * @return the number of matching wiki pages
10418             */
10419            @Override
10420            public int countByU_N_S(long userId, long nodeId, int status) {
10421                    FinderPath finderPath = FINDER_PATH_COUNT_BY_U_N_S;
10422    
10423                    Object[] finderArgs = new Object[] { userId, nodeId, status };
10424    
10425                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10426                                    this);
10427    
10428                    if (count == null) {
10429                            StringBundler query = new StringBundler(4);
10430    
10431                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
10432    
10433                            query.append(_FINDER_COLUMN_U_N_S_USERID_2);
10434    
10435                            query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
10436    
10437                            query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
10438    
10439                            String sql = query.toString();
10440    
10441                            Session session = null;
10442    
10443                            try {
10444                                    session = openSession();
10445    
10446                                    Query q = session.createQuery(sql);
10447    
10448                                    QueryPos qPos = QueryPos.getInstance(q);
10449    
10450                                    qPos.add(userId);
10451    
10452                                    qPos.add(nodeId);
10453    
10454                                    qPos.add(status);
10455    
10456                                    count = (Long)q.uniqueResult();
10457    
10458                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10459                            }
10460                            catch (Exception e) {
10461                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10462    
10463                                    throw processException(e);
10464                            }
10465                            finally {
10466                                    closeSession(session);
10467                            }
10468                    }
10469    
10470                    return count.intValue();
10471            }
10472    
10473            private static final String _FINDER_COLUMN_U_N_S_USERID_2 = "wikiPage.userId = ? AND ";
10474            private static final String _FINDER_COLUMN_U_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
10475            private static final String _FINDER_COLUMN_U_N_S_STATUS_2 = "wikiPage.status = ?";
10476            public static final FinderPath FINDER_PATH_FETCH_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10477                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
10478                            FINDER_CLASS_NAME_ENTITY, "fetchByN_T_V",
10479                            new String[] {
10480                                    Long.class.getName(), String.class.getName(),
10481                                    Double.class.getName()
10482                            },
10483                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
10484                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
10485                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
10486            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10487                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
10488                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T_V",
10489                            new String[] {
10490                                    Long.class.getName(), String.class.getName(),
10491                                    Double.class.getName()
10492                            });
10493    
10494            /**
10495             * Returns the wiki page where nodeId = &#63; and title = &#63; and version = &#63; or throws a {@link com.liferay.portlet.wiki.NoSuchPageException} if it could not be found.
10496             *
10497             * @param nodeId the node ID
10498             * @param title the title
10499             * @param version the version
10500             * @return the matching wiki page
10501             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
10502             */
10503            @Override
10504            public WikiPage findByN_T_V(long nodeId, String title, double version)
10505                    throws NoSuchPageException {
10506                    WikiPage wikiPage = fetchByN_T_V(nodeId, title, version);
10507    
10508                    if (wikiPage == null) {
10509                            StringBundler msg = new StringBundler(8);
10510    
10511                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10512    
10513                            msg.append("nodeId=");
10514                            msg.append(nodeId);
10515    
10516                            msg.append(", title=");
10517                            msg.append(title);
10518    
10519                            msg.append(", version=");
10520                            msg.append(version);
10521    
10522                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10523    
10524                            if (_log.isWarnEnabled()) {
10525                                    _log.warn(msg.toString());
10526                            }
10527    
10528                            throw new NoSuchPageException(msg.toString());
10529                    }
10530    
10531                    return wikiPage;
10532            }
10533    
10534            /**
10535             * Returns the wiki page where nodeId = &#63; and title = &#63; and version = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
10536             *
10537             * @param nodeId the node ID
10538             * @param title the title
10539             * @param version the version
10540             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
10541             */
10542            @Override
10543            public WikiPage fetchByN_T_V(long nodeId, String title, double version) {
10544                    return fetchByN_T_V(nodeId, title, version, true);
10545            }
10546    
10547            /**
10548             * Returns the wiki page where nodeId = &#63; and title = &#63; and version = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
10549             *
10550             * @param nodeId the node ID
10551             * @param title the title
10552             * @param version the version
10553             * @param retrieveFromCache whether to use the finder cache
10554             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
10555             */
10556            @Override
10557            public WikiPage fetchByN_T_V(long nodeId, String title, double version,
10558                    boolean retrieveFromCache) {
10559                    Object[] finderArgs = new Object[] { nodeId, title, version };
10560    
10561                    Object result = null;
10562    
10563                    if (retrieveFromCache) {
10564                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_N_T_V,
10565                                            finderArgs, this);
10566                    }
10567    
10568                    if (result instanceof WikiPage) {
10569                            WikiPage wikiPage = (WikiPage)result;
10570    
10571                            if ((nodeId != wikiPage.getNodeId()) ||
10572                                            !Validator.equals(title, wikiPage.getTitle()) ||
10573                                            (version != wikiPage.getVersion())) {
10574                                    result = null;
10575                            }
10576                    }
10577    
10578                    if (result == null) {
10579                            StringBundler query = new StringBundler(5);
10580    
10581                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
10582    
10583                            query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
10584    
10585                            boolean bindTitle = false;
10586    
10587                            if (title == null) {
10588                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
10589                            }
10590                            else if (title.equals(StringPool.BLANK)) {
10591                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
10592                            }
10593                            else {
10594                                    bindTitle = true;
10595    
10596                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
10597                            }
10598    
10599                            query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
10600    
10601                            String sql = query.toString();
10602    
10603                            Session session = null;
10604    
10605                            try {
10606                                    session = openSession();
10607    
10608                                    Query q = session.createQuery(sql);
10609    
10610                                    QueryPos qPos = QueryPos.getInstance(q);
10611    
10612                                    qPos.add(nodeId);
10613    
10614                                    if (bindTitle) {
10615                                            qPos.add(StringUtil.toLowerCase(title));
10616                                    }
10617    
10618                                    qPos.add(version);
10619    
10620                                    List<WikiPage> list = q.list();
10621    
10622                                    if (list.isEmpty()) {
10623                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
10624                                                    finderArgs, list);
10625                                    }
10626                                    else {
10627                                            WikiPage wikiPage = list.get(0);
10628    
10629                                            result = wikiPage;
10630    
10631                                            cacheResult(wikiPage);
10632    
10633                                            if ((wikiPage.getNodeId() != nodeId) ||
10634                                                            (wikiPage.getTitle() == null) ||
10635                                                            !wikiPage.getTitle().equals(title) ||
10636                                                            (wikiPage.getVersion() != version)) {
10637                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
10638                                                            finderArgs, wikiPage);
10639                                            }
10640                                    }
10641                            }
10642                            catch (Exception e) {
10643                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V,
10644                                            finderArgs);
10645    
10646                                    throw processException(e);
10647                            }
10648                            finally {
10649                                    closeSession(session);
10650                            }
10651                    }
10652    
10653                    if (result instanceof List<?>) {
10654                            return null;
10655                    }
10656                    else {
10657                            return (WikiPage)result;
10658                    }
10659            }
10660    
10661            /**
10662             * Removes the wiki page where nodeId = &#63; and title = &#63; and version = &#63; from the database.
10663             *
10664             * @param nodeId the node ID
10665             * @param title the title
10666             * @param version the version
10667             * @return the wiki page that was removed
10668             */
10669            @Override
10670            public WikiPage removeByN_T_V(long nodeId, String title, double version)
10671                    throws NoSuchPageException {
10672                    WikiPage wikiPage = findByN_T_V(nodeId, title, version);
10673    
10674                    return remove(wikiPage);
10675            }
10676    
10677            /**
10678             * Returns the number of wiki pages where nodeId = &#63; and title = &#63; and version = &#63;.
10679             *
10680             * @param nodeId the node ID
10681             * @param title the title
10682             * @param version the version
10683             * @return the number of matching wiki pages
10684             */
10685            @Override
10686            public int countByN_T_V(long nodeId, String title, double version) {
10687                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_T_V;
10688    
10689                    Object[] finderArgs = new Object[] { nodeId, title, version };
10690    
10691                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10692                                    this);
10693    
10694                    if (count == null) {
10695                            StringBundler query = new StringBundler(4);
10696    
10697                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
10698    
10699                            query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
10700    
10701                            boolean bindTitle = false;
10702    
10703                            if (title == null) {
10704                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
10705                            }
10706                            else if (title.equals(StringPool.BLANK)) {
10707                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
10708                            }
10709                            else {
10710                                    bindTitle = true;
10711    
10712                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
10713                            }
10714    
10715                            query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
10716    
10717                            String sql = query.toString();
10718    
10719                            Session session = null;
10720    
10721                            try {
10722                                    session = openSession();
10723    
10724                                    Query q = session.createQuery(sql);
10725    
10726                                    QueryPos qPos = QueryPos.getInstance(q);
10727    
10728                                    qPos.add(nodeId);
10729    
10730                                    if (bindTitle) {
10731                                            qPos.add(StringUtil.toLowerCase(title));
10732                                    }
10733    
10734                                    qPos.add(version);
10735    
10736                                    count = (Long)q.uniqueResult();
10737    
10738                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10739                            }
10740                            catch (Exception e) {
10741                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10742    
10743                                    throw processException(e);
10744                            }
10745                            finally {
10746                                    closeSession(session);
10747                            }
10748                    }
10749    
10750                    return count.intValue();
10751            }
10752    
10753            private static final String _FINDER_COLUMN_N_T_V_NODEID_2 = "wikiPage.nodeId = ? AND ";
10754            private static final String _FINDER_COLUMN_N_T_V_TITLE_1 = "wikiPage.title IS NULL AND ";
10755            private static final String _FINDER_COLUMN_N_T_V_TITLE_2 = "lower(wikiPage.title) = ? AND ";
10756            private static final String _FINDER_COLUMN_N_T_V_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = '') AND ";
10757            private static final String _FINDER_COLUMN_N_T_V_VERSION_2 = "wikiPage.version = ?";
10758            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10759                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
10760                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_T_H",
10761                            new String[] {
10762                                    Long.class.getName(), String.class.getName(),
10763                                    Boolean.class.getName(),
10764                                    
10765                            Integer.class.getName(), Integer.class.getName(),
10766                                    OrderByComparator.class.getName()
10767                            });
10768            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10769                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
10770                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_T_H",
10771                            new String[] {
10772                                    Long.class.getName(), String.class.getName(),
10773                                    Boolean.class.getName()
10774                            },
10775                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
10776                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
10777                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
10778                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
10779            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10780                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
10781                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T_H",
10782                            new String[] {
10783                                    Long.class.getName(), String.class.getName(),
10784                                    Boolean.class.getName()
10785                            });
10786    
10787            /**
10788             * Returns all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
10789             *
10790             * @param nodeId the node ID
10791             * @param title the title
10792             * @param head the head
10793             * @return the matching wiki pages
10794             */
10795            @Override
10796            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head) {
10797                    return findByN_T_H(nodeId, title, head, QueryUtil.ALL_POS,
10798                            QueryUtil.ALL_POS, null);
10799            }
10800    
10801            /**
10802             * Returns a range of all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
10803             *
10804             * <p>
10805             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
10806             * </p>
10807             *
10808             * @param nodeId the node ID
10809             * @param title the title
10810             * @param head the head
10811             * @param start the lower bound of the range of wiki pages
10812             * @param end the upper bound of the range of wiki pages (not inclusive)
10813             * @return the range of matching wiki pages
10814             */
10815            @Override
10816            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
10817                    int start, int end) {
10818                    return findByN_T_H(nodeId, title, head, start, end, null);
10819            }
10820    
10821            /**
10822             * Returns an ordered range of all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
10823             *
10824             * <p>
10825             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
10826             * </p>
10827             *
10828             * @param nodeId the node ID
10829             * @param title the title
10830             * @param head the head
10831             * @param start the lower bound of the range of wiki pages
10832             * @param end the upper bound of the range of wiki pages (not inclusive)
10833             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10834             * @return the ordered range of matching wiki pages
10835             */
10836            @Override
10837            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
10838                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
10839                    boolean pagination = true;
10840                    FinderPath finderPath = null;
10841                    Object[] finderArgs = null;
10842    
10843                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10844                                    (orderByComparator == null)) {
10845                            pagination = false;
10846                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H;
10847                            finderArgs = new Object[] { nodeId, title, head };
10848                    }
10849                    else {
10850                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_H;
10851                            finderArgs = new Object[] {
10852                                            nodeId, title, head,
10853                                            
10854                                            start, end, orderByComparator
10855                                    };
10856                    }
10857    
10858                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
10859                                    finderArgs, this);
10860    
10861                    if ((list != null) && !list.isEmpty()) {
10862                            for (WikiPage wikiPage : list) {
10863                                    if ((nodeId != wikiPage.getNodeId()) ||
10864                                                    !Validator.equals(title, wikiPage.getTitle()) ||
10865                                                    (head != wikiPage.getHead())) {
10866                                            list = null;
10867    
10868                                            break;
10869                                    }
10870                            }
10871                    }
10872    
10873                    if (list == null) {
10874                            StringBundler query = null;
10875    
10876                            if (orderByComparator != null) {
10877                                    query = new StringBundler(5 +
10878                                                    (orderByComparator.getOrderByFields().length * 3));
10879                            }
10880                            else {
10881                                    query = new StringBundler(5);
10882                            }
10883    
10884                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
10885    
10886                            query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
10887    
10888                            boolean bindTitle = false;
10889    
10890                            if (title == null) {
10891                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
10892                            }
10893                            else if (title.equals(StringPool.BLANK)) {
10894                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
10895                            }
10896                            else {
10897                                    bindTitle = true;
10898    
10899                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
10900                            }
10901    
10902                            query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
10903    
10904                            if (orderByComparator != null) {
10905                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10906                                            orderByComparator);
10907                            }
10908                            else
10909                             if (pagination) {
10910                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10911                            }
10912    
10913                            String sql = query.toString();
10914    
10915                            Session session = null;
10916    
10917                            try {
10918                                    session = openSession();
10919    
10920                                    Query q = session.createQuery(sql);
10921    
10922                                    QueryPos qPos = QueryPos.getInstance(q);
10923    
10924                                    qPos.add(nodeId);
10925    
10926                                    if (bindTitle) {
10927                                            qPos.add(StringUtil.toLowerCase(title));
10928                                    }
10929    
10930                                    qPos.add(head);
10931    
10932                                    if (!pagination) {
10933                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
10934                                                            start, end, false);
10935    
10936                                            Collections.sort(list);
10937    
10938                                            list = Collections.unmodifiableList(list);
10939                                    }
10940                                    else {
10941                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
10942                                                            start, end);
10943                                    }
10944    
10945                                    cacheResult(list);
10946    
10947                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10948                            }
10949                            catch (Exception e) {
10950                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10951    
10952                                    throw processException(e);
10953                            }
10954                            finally {
10955                                    closeSession(session);
10956                            }
10957                    }
10958    
10959                    return list;
10960            }
10961    
10962            /**
10963             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
10964             *
10965             * @param nodeId the node ID
10966             * @param title the title
10967             * @param head the head
10968             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10969             * @return the first matching wiki page
10970             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
10971             */
10972            @Override
10973            public WikiPage findByN_T_H_First(long nodeId, String title, boolean head,
10974                    OrderByComparator<WikiPage> orderByComparator)
10975                    throws NoSuchPageException {
10976                    WikiPage wikiPage = fetchByN_T_H_First(nodeId, title, head,
10977                                    orderByComparator);
10978    
10979                    if (wikiPage != null) {
10980                            return wikiPage;
10981                    }
10982    
10983                    StringBundler msg = new StringBundler(8);
10984    
10985                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10986    
10987                    msg.append("nodeId=");
10988                    msg.append(nodeId);
10989    
10990                    msg.append(", title=");
10991                    msg.append(title);
10992    
10993                    msg.append(", head=");
10994                    msg.append(head);
10995    
10996                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10997    
10998                    throw new NoSuchPageException(msg.toString());
10999            }
11000    
11001            /**
11002             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
11003             *
11004             * @param nodeId the node ID
11005             * @param title the title
11006             * @param head the head
11007             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11008             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
11009             */
11010            @Override
11011            public WikiPage fetchByN_T_H_First(long nodeId, String title, boolean head,
11012                    OrderByComparator<WikiPage> orderByComparator) {
11013                    List<WikiPage> list = findByN_T_H(nodeId, title, head, 0, 1,
11014                                    orderByComparator);
11015    
11016                    if (!list.isEmpty()) {
11017                            return list.get(0);
11018                    }
11019    
11020                    return null;
11021            }
11022    
11023            /**
11024             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
11025             *
11026             * @param nodeId the node ID
11027             * @param title the title
11028             * @param head the head
11029             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11030             * @return the last matching wiki page
11031             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
11032             */
11033            @Override
11034            public WikiPage findByN_T_H_Last(long nodeId, String title, boolean head,
11035                    OrderByComparator<WikiPage> orderByComparator)
11036                    throws NoSuchPageException {
11037                    WikiPage wikiPage = fetchByN_T_H_Last(nodeId, title, head,
11038                                    orderByComparator);
11039    
11040                    if (wikiPage != null) {
11041                            return wikiPage;
11042                    }
11043    
11044                    StringBundler msg = new StringBundler(8);
11045    
11046                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11047    
11048                    msg.append("nodeId=");
11049                    msg.append(nodeId);
11050    
11051                    msg.append(", title=");
11052                    msg.append(title);
11053    
11054                    msg.append(", head=");
11055                    msg.append(head);
11056    
11057                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11058    
11059                    throw new NoSuchPageException(msg.toString());
11060            }
11061    
11062            /**
11063             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
11064             *
11065             * @param nodeId the node ID
11066             * @param title the title
11067             * @param head the head
11068             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11069             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
11070             */
11071            @Override
11072            public WikiPage fetchByN_T_H_Last(long nodeId, String title, boolean head,
11073                    OrderByComparator<WikiPage> orderByComparator) {
11074                    int count = countByN_T_H(nodeId, title, head);
11075    
11076                    if (count == 0) {
11077                            return null;
11078                    }
11079    
11080                    List<WikiPage> list = findByN_T_H(nodeId, title, head, count - 1,
11081                                    count, orderByComparator);
11082    
11083                    if (!list.isEmpty()) {
11084                            return list.get(0);
11085                    }
11086    
11087                    return null;
11088            }
11089    
11090            /**
11091             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
11092             *
11093             * @param pageId the primary key of the current wiki page
11094             * @param nodeId the node ID
11095             * @param title the title
11096             * @param head the head
11097             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11098             * @return the previous, current, and next wiki page
11099             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
11100             */
11101            @Override
11102            public WikiPage[] findByN_T_H_PrevAndNext(long pageId, long nodeId,
11103                    String title, boolean head,
11104                    OrderByComparator<WikiPage> orderByComparator)
11105                    throws NoSuchPageException {
11106                    WikiPage wikiPage = findByPrimaryKey(pageId);
11107    
11108                    Session session = null;
11109    
11110                    try {
11111                            session = openSession();
11112    
11113                            WikiPage[] array = new WikiPageImpl[3];
11114    
11115                            array[0] = getByN_T_H_PrevAndNext(session, wikiPage, nodeId, title,
11116                                            head, orderByComparator, true);
11117    
11118                            array[1] = wikiPage;
11119    
11120                            array[2] = getByN_T_H_PrevAndNext(session, wikiPage, nodeId, title,
11121                                            head, orderByComparator, false);
11122    
11123                            return array;
11124                    }
11125                    catch (Exception e) {
11126                            throw processException(e);
11127                    }
11128                    finally {
11129                            closeSession(session);
11130                    }
11131            }
11132    
11133            protected WikiPage getByN_T_H_PrevAndNext(Session session,
11134                    WikiPage wikiPage, long nodeId, String title, boolean head,
11135                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
11136                    StringBundler query = null;
11137    
11138                    if (orderByComparator != null) {
11139                            query = new StringBundler(6 +
11140                                            (orderByComparator.getOrderByFields().length * 6));
11141                    }
11142                    else {
11143                            query = new StringBundler(3);
11144                    }
11145    
11146                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
11147    
11148                    query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
11149    
11150                    boolean bindTitle = false;
11151    
11152                    if (title == null) {
11153                            query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
11154                    }
11155                    else if (title.equals(StringPool.BLANK)) {
11156                            query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
11157                    }
11158                    else {
11159                            bindTitle = true;
11160    
11161                            query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
11162                    }
11163    
11164                    query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
11165    
11166                    if (orderByComparator != null) {
11167                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11168    
11169                            if (orderByConditionFields.length > 0) {
11170                                    query.append(WHERE_AND);
11171                            }
11172    
11173                            for (int i = 0; i < orderByConditionFields.length; i++) {
11174                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11175                                    query.append(orderByConditionFields[i]);
11176    
11177                                    if ((i + 1) < orderByConditionFields.length) {
11178                                            if (orderByComparator.isAscending() ^ previous) {
11179                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11180                                            }
11181                                            else {
11182                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11183                                            }
11184                                    }
11185                                    else {
11186                                            if (orderByComparator.isAscending() ^ previous) {
11187                                                    query.append(WHERE_GREATER_THAN);
11188                                            }
11189                                            else {
11190                                                    query.append(WHERE_LESSER_THAN);
11191                                            }
11192                                    }
11193                            }
11194    
11195                            query.append(ORDER_BY_CLAUSE);
11196    
11197                            String[] orderByFields = orderByComparator.getOrderByFields();
11198    
11199                            for (int i = 0; i < orderByFields.length; i++) {
11200                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11201                                    query.append(orderByFields[i]);
11202    
11203                                    if ((i + 1) < orderByFields.length) {
11204                                            if (orderByComparator.isAscending() ^ previous) {
11205                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11206                                            }
11207                                            else {
11208                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11209                                            }
11210                                    }
11211                                    else {
11212                                            if (orderByComparator.isAscending() ^ previous) {
11213                                                    query.append(ORDER_BY_ASC);
11214                                            }
11215                                            else {
11216                                                    query.append(ORDER_BY_DESC);
11217                                            }
11218                                    }
11219                            }
11220                    }
11221                    else {
11222                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11223                    }
11224    
11225                    String sql = query.toString();
11226    
11227                    Query q = session.createQuery(sql);
11228    
11229                    q.setFirstResult(0);
11230                    q.setMaxResults(2);
11231    
11232                    QueryPos qPos = QueryPos.getInstance(q);
11233    
11234                    qPos.add(nodeId);
11235    
11236                    if (bindTitle) {
11237                            qPos.add(StringUtil.toLowerCase(title));
11238                    }
11239    
11240                    qPos.add(head);
11241    
11242                    if (orderByComparator != null) {
11243                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
11244    
11245                            for (Object value : values) {
11246                                    qPos.add(value);
11247                            }
11248                    }
11249    
11250                    List<WikiPage> list = q.list();
11251    
11252                    if (list.size() == 2) {
11253                            return list.get(1);
11254                    }
11255                    else {
11256                            return null;
11257                    }
11258            }
11259    
11260            /**
11261             * Removes all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63; from the database.
11262             *
11263             * @param nodeId the node ID
11264             * @param title the title
11265             * @param head the head
11266             */
11267            @Override
11268            public void removeByN_T_H(long nodeId, String title, boolean head) {
11269                    for (WikiPage wikiPage : findByN_T_H(nodeId, title, head,
11270                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11271                            remove(wikiPage);
11272                    }
11273            }
11274    
11275            /**
11276             * Returns the number of wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
11277             *
11278             * @param nodeId the node ID
11279             * @param title the title
11280             * @param head the head
11281             * @return the number of matching wiki pages
11282             */
11283            @Override
11284            public int countByN_T_H(long nodeId, String title, boolean head) {
11285                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_T_H;
11286    
11287                    Object[] finderArgs = new Object[] { nodeId, title, head };
11288    
11289                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11290                                    this);
11291    
11292                    if (count == null) {
11293                            StringBundler query = new StringBundler(4);
11294    
11295                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
11296    
11297                            query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
11298    
11299                            boolean bindTitle = false;
11300    
11301                            if (title == null) {
11302                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
11303                            }
11304                            else if (title.equals(StringPool.BLANK)) {
11305                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
11306                            }
11307                            else {
11308                                    bindTitle = true;
11309    
11310                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
11311                            }
11312    
11313                            query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
11314    
11315                            String sql = query.toString();
11316    
11317                            Session session = null;
11318    
11319                            try {
11320                                    session = openSession();
11321    
11322                                    Query q = session.createQuery(sql);
11323    
11324                                    QueryPos qPos = QueryPos.getInstance(q);
11325    
11326                                    qPos.add(nodeId);
11327    
11328                                    if (bindTitle) {
11329                                            qPos.add(StringUtil.toLowerCase(title));
11330                                    }
11331    
11332                                    qPos.add(head);
11333    
11334                                    count = (Long)q.uniqueResult();
11335    
11336                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11337                            }
11338                            catch (Exception e) {
11339                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11340    
11341                                    throw processException(e);
11342                            }
11343                            finally {
11344                                    closeSession(session);
11345                            }
11346                    }
11347    
11348                    return count.intValue();
11349            }
11350    
11351            private static final String _FINDER_COLUMN_N_T_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
11352            private static final String _FINDER_COLUMN_N_T_H_TITLE_1 = "wikiPage.title IS NULL AND ";
11353            private static final String _FINDER_COLUMN_N_T_H_TITLE_2 = "lower(wikiPage.title) = ? AND ";
11354            private static final String _FINDER_COLUMN_N_T_H_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = '') AND ";
11355            private static final String _FINDER_COLUMN_N_T_H_HEAD_2 = "wikiPage.head = ?";
11356            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
11357                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
11358                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_T_S",
11359                            new String[] {
11360                                    Long.class.getName(), String.class.getName(),
11361                                    Integer.class.getName(),
11362                                    
11363                            Integer.class.getName(), Integer.class.getName(),
11364                                    OrderByComparator.class.getName()
11365                            });
11366            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
11367                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
11368                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_T_S",
11369                            new String[] {
11370                                    Long.class.getName(), String.class.getName(),
11371                                    Integer.class.getName()
11372                            },
11373                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
11374                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
11375                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
11376                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
11377            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
11378                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
11379                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T_S",
11380                            new String[] {
11381                                    Long.class.getName(), String.class.getName(),
11382                                    Integer.class.getName()
11383                            });
11384    
11385            /**
11386             * Returns all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
11387             *
11388             * @param nodeId the node ID
11389             * @param title the title
11390             * @param status the status
11391             * @return the matching wiki pages
11392             */
11393            @Override
11394            public List<WikiPage> findByN_T_S(long nodeId, String title, int status) {
11395                    return findByN_T_S(nodeId, title, status, QueryUtil.ALL_POS,
11396                            QueryUtil.ALL_POS, null);
11397            }
11398    
11399            /**
11400             * Returns a range of all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
11401             *
11402             * <p>
11403             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
11404             * </p>
11405             *
11406             * @param nodeId the node ID
11407             * @param title the title
11408             * @param status the status
11409             * @param start the lower bound of the range of wiki pages
11410             * @param end the upper bound of the range of wiki pages (not inclusive)
11411             * @return the range of matching wiki pages
11412             */
11413            @Override
11414            public List<WikiPage> findByN_T_S(long nodeId, String title, int status,
11415                    int start, int end) {
11416                    return findByN_T_S(nodeId, title, status, start, end, null);
11417            }
11418    
11419            /**
11420             * Returns an ordered range of all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
11421             *
11422             * <p>
11423             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
11424             * </p>
11425             *
11426             * @param nodeId the node ID
11427             * @param title the title
11428             * @param status the status
11429             * @param start the lower bound of the range of wiki pages
11430             * @param end the upper bound of the range of wiki pages (not inclusive)
11431             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11432             * @return the ordered range of matching wiki pages
11433             */
11434            @Override
11435            public List<WikiPage> findByN_T_S(long nodeId, String title, int status,
11436                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
11437                    boolean pagination = true;
11438                    FinderPath finderPath = null;
11439                    Object[] finderArgs = null;
11440    
11441                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11442                                    (orderByComparator == null)) {
11443                            pagination = false;
11444                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S;
11445                            finderArgs = new Object[] { nodeId, title, status };
11446                    }
11447                    else {
11448                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_S;
11449                            finderArgs = new Object[] {
11450                                            nodeId, title, status,
11451                                            
11452                                            start, end, orderByComparator
11453                                    };
11454                    }
11455    
11456                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
11457                                    finderArgs, this);
11458    
11459                    if ((list != null) && !list.isEmpty()) {
11460                            for (WikiPage wikiPage : list) {
11461                                    if ((nodeId != wikiPage.getNodeId()) ||
11462                                                    !Validator.equals(title, wikiPage.getTitle()) ||
11463                                                    (status != wikiPage.getStatus())) {
11464                                            list = null;
11465    
11466                                            break;
11467                                    }
11468                            }
11469                    }
11470    
11471                    if (list == null) {
11472                            StringBundler query = null;
11473    
11474                            if (orderByComparator != null) {
11475                                    query = new StringBundler(5 +
11476                                                    (orderByComparator.getOrderByFields().length * 3));
11477                            }
11478                            else {
11479                                    query = new StringBundler(5);
11480                            }
11481    
11482                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
11483    
11484                            query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
11485    
11486                            boolean bindTitle = false;
11487    
11488                            if (title == null) {
11489                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
11490                            }
11491                            else if (title.equals(StringPool.BLANK)) {
11492                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
11493                            }
11494                            else {
11495                                    bindTitle = true;
11496    
11497                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
11498                            }
11499    
11500                            query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
11501    
11502                            if (orderByComparator != null) {
11503                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11504                                            orderByComparator);
11505                            }
11506                            else
11507                             if (pagination) {
11508                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11509                            }
11510    
11511                            String sql = query.toString();
11512    
11513                            Session session = null;
11514    
11515                            try {
11516                                    session = openSession();
11517    
11518                                    Query q = session.createQuery(sql);
11519    
11520                                    QueryPos qPos = QueryPos.getInstance(q);
11521    
11522                                    qPos.add(nodeId);
11523    
11524                                    if (bindTitle) {
11525                                            qPos.add(StringUtil.toLowerCase(title));
11526                                    }
11527    
11528                                    qPos.add(status);
11529    
11530                                    if (!pagination) {
11531                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
11532                                                            start, end, false);
11533    
11534                                            Collections.sort(list);
11535    
11536                                            list = Collections.unmodifiableList(list);
11537                                    }
11538                                    else {
11539                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
11540                                                            start, end);
11541                                    }
11542    
11543                                    cacheResult(list);
11544    
11545                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11546                            }
11547                            catch (Exception e) {
11548                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11549    
11550                                    throw processException(e);
11551                            }
11552                            finally {
11553                                    closeSession(session);
11554                            }
11555                    }
11556    
11557                    return list;
11558            }
11559    
11560            /**
11561             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
11562             *
11563             * @param nodeId the node ID
11564             * @param title the title
11565             * @param status the status
11566             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11567             * @return the first matching wiki page
11568             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
11569             */
11570            @Override
11571            public WikiPage findByN_T_S_First(long nodeId, String title, int status,
11572                    OrderByComparator<WikiPage> orderByComparator)
11573                    throws NoSuchPageException {
11574                    WikiPage wikiPage = fetchByN_T_S_First(nodeId, title, status,
11575                                    orderByComparator);
11576    
11577                    if (wikiPage != null) {
11578                            return wikiPage;
11579                    }
11580    
11581                    StringBundler msg = new StringBundler(8);
11582    
11583                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11584    
11585                    msg.append("nodeId=");
11586                    msg.append(nodeId);
11587    
11588                    msg.append(", title=");
11589                    msg.append(title);
11590    
11591                    msg.append(", status=");
11592                    msg.append(status);
11593    
11594                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11595    
11596                    throw new NoSuchPageException(msg.toString());
11597            }
11598    
11599            /**
11600             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
11601             *
11602             * @param nodeId the node ID
11603             * @param title the title
11604             * @param status the status
11605             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11606             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
11607             */
11608            @Override
11609            public WikiPage fetchByN_T_S_First(long nodeId, String title, int status,
11610                    OrderByComparator<WikiPage> orderByComparator) {
11611                    List<WikiPage> list = findByN_T_S(nodeId, title, status, 0, 1,
11612                                    orderByComparator);
11613    
11614                    if (!list.isEmpty()) {
11615                            return list.get(0);
11616                    }
11617    
11618                    return null;
11619            }
11620    
11621            /**
11622             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
11623             *
11624             * @param nodeId the node ID
11625             * @param title the title
11626             * @param status the status
11627             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11628             * @return the last matching wiki page
11629             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
11630             */
11631            @Override
11632            public WikiPage findByN_T_S_Last(long nodeId, String title, int status,
11633                    OrderByComparator<WikiPage> orderByComparator)
11634                    throws NoSuchPageException {
11635                    WikiPage wikiPage = fetchByN_T_S_Last(nodeId, title, status,
11636                                    orderByComparator);
11637    
11638                    if (wikiPage != null) {
11639                            return wikiPage;
11640                    }
11641    
11642                    StringBundler msg = new StringBundler(8);
11643    
11644                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11645    
11646                    msg.append("nodeId=");
11647                    msg.append(nodeId);
11648    
11649                    msg.append(", title=");
11650                    msg.append(title);
11651    
11652                    msg.append(", status=");
11653                    msg.append(status);
11654    
11655                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11656    
11657                    throw new NoSuchPageException(msg.toString());
11658            }
11659    
11660            /**
11661             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
11662             *
11663             * @param nodeId the node ID
11664             * @param title the title
11665             * @param status the status
11666             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11667             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
11668             */
11669            @Override
11670            public WikiPage fetchByN_T_S_Last(long nodeId, String title, int status,
11671                    OrderByComparator<WikiPage> orderByComparator) {
11672                    int count = countByN_T_S(nodeId, title, status);
11673    
11674                    if (count == 0) {
11675                            return null;
11676                    }
11677    
11678                    List<WikiPage> list = findByN_T_S(nodeId, title, status, count - 1,
11679                                    count, orderByComparator);
11680    
11681                    if (!list.isEmpty()) {
11682                            return list.get(0);
11683                    }
11684    
11685                    return null;
11686            }
11687    
11688            /**
11689             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
11690             *
11691             * @param pageId the primary key of the current wiki page
11692             * @param nodeId the node ID
11693             * @param title the title
11694             * @param status the status
11695             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11696             * @return the previous, current, and next wiki page
11697             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
11698             */
11699            @Override
11700            public WikiPage[] findByN_T_S_PrevAndNext(long pageId, long nodeId,
11701                    String title, int status, OrderByComparator<WikiPage> orderByComparator)
11702                    throws NoSuchPageException {
11703                    WikiPage wikiPage = findByPrimaryKey(pageId);
11704    
11705                    Session session = null;
11706    
11707                    try {
11708                            session = openSession();
11709    
11710                            WikiPage[] array = new WikiPageImpl[3];
11711    
11712                            array[0] = getByN_T_S_PrevAndNext(session, wikiPage, nodeId, title,
11713                                            status, orderByComparator, true);
11714    
11715                            array[1] = wikiPage;
11716    
11717                            array[2] = getByN_T_S_PrevAndNext(session, wikiPage, nodeId, title,
11718                                            status, orderByComparator, false);
11719    
11720                            return array;
11721                    }
11722                    catch (Exception e) {
11723                            throw processException(e);
11724                    }
11725                    finally {
11726                            closeSession(session);
11727                    }
11728            }
11729    
11730            protected WikiPage getByN_T_S_PrevAndNext(Session session,
11731                    WikiPage wikiPage, long nodeId, String title, int status,
11732                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
11733                    StringBundler query = null;
11734    
11735                    if (orderByComparator != null) {
11736                            query = new StringBundler(6 +
11737                                            (orderByComparator.getOrderByFields().length * 6));
11738                    }
11739                    else {
11740                            query = new StringBundler(3);
11741                    }
11742    
11743                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
11744    
11745                    query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
11746    
11747                    boolean bindTitle = false;
11748    
11749                    if (title == null) {
11750                            query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
11751                    }
11752                    else if (title.equals(StringPool.BLANK)) {
11753                            query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
11754                    }
11755                    else {
11756                            bindTitle = true;
11757    
11758                            query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
11759                    }
11760    
11761                    query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
11762    
11763                    if (orderByComparator != null) {
11764                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11765    
11766                            if (orderByConditionFields.length > 0) {
11767                                    query.append(WHERE_AND);
11768                            }
11769    
11770                            for (int i = 0; i < orderByConditionFields.length; i++) {
11771                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11772                                    query.append(orderByConditionFields[i]);
11773    
11774                                    if ((i + 1) < orderByConditionFields.length) {
11775                                            if (orderByComparator.isAscending() ^ previous) {
11776                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11777                                            }
11778                                            else {
11779                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11780                                            }
11781                                    }
11782                                    else {
11783                                            if (orderByComparator.isAscending() ^ previous) {
11784                                                    query.append(WHERE_GREATER_THAN);
11785                                            }
11786                                            else {
11787                                                    query.append(WHERE_LESSER_THAN);
11788                                            }
11789                                    }
11790                            }
11791    
11792                            query.append(ORDER_BY_CLAUSE);
11793    
11794                            String[] orderByFields = orderByComparator.getOrderByFields();
11795    
11796                            for (int i = 0; i < orderByFields.length; i++) {
11797                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11798                                    query.append(orderByFields[i]);
11799    
11800                                    if ((i + 1) < orderByFields.length) {
11801                                            if (orderByComparator.isAscending() ^ previous) {
11802                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11803                                            }
11804                                            else {
11805                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11806                                            }
11807                                    }
11808                                    else {
11809                                            if (orderByComparator.isAscending() ^ previous) {
11810                                                    query.append(ORDER_BY_ASC);
11811                                            }
11812                                            else {
11813                                                    query.append(ORDER_BY_DESC);
11814                                            }
11815                                    }
11816                            }
11817                    }
11818                    else {
11819                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11820                    }
11821    
11822                    String sql = query.toString();
11823    
11824                    Query q = session.createQuery(sql);
11825    
11826                    q.setFirstResult(0);
11827                    q.setMaxResults(2);
11828    
11829                    QueryPos qPos = QueryPos.getInstance(q);
11830    
11831                    qPos.add(nodeId);
11832    
11833                    if (bindTitle) {
11834                            qPos.add(StringUtil.toLowerCase(title));
11835                    }
11836    
11837                    qPos.add(status);
11838    
11839                    if (orderByComparator != null) {
11840                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
11841    
11842                            for (Object value : values) {
11843                                    qPos.add(value);
11844                            }
11845                    }
11846    
11847                    List<WikiPage> list = q.list();
11848    
11849                    if (list.size() == 2) {
11850                            return list.get(1);
11851                    }
11852                    else {
11853                            return null;
11854                    }
11855            }
11856    
11857            /**
11858             * Removes all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63; from the database.
11859             *
11860             * @param nodeId the node ID
11861             * @param title the title
11862             * @param status the status
11863             */
11864            @Override
11865            public void removeByN_T_S(long nodeId, String title, int status) {
11866                    for (WikiPage wikiPage : findByN_T_S(nodeId, title, status,
11867                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11868                            remove(wikiPage);
11869                    }
11870            }
11871    
11872            /**
11873             * Returns the number of wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
11874             *
11875             * @param nodeId the node ID
11876             * @param title the title
11877             * @param status the status
11878             * @return the number of matching wiki pages
11879             */
11880            @Override
11881            public int countByN_T_S(long nodeId, String title, int status) {
11882                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_T_S;
11883    
11884                    Object[] finderArgs = new Object[] { nodeId, title, status };
11885    
11886                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11887                                    this);
11888    
11889                    if (count == null) {
11890                            StringBundler query = new StringBundler(4);
11891    
11892                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
11893    
11894                            query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
11895    
11896                            boolean bindTitle = false;
11897    
11898                            if (title == null) {
11899                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
11900                            }
11901                            else if (title.equals(StringPool.BLANK)) {
11902                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
11903                            }
11904                            else {
11905                                    bindTitle = true;
11906    
11907                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
11908                            }
11909    
11910                            query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
11911    
11912                            String sql = query.toString();
11913    
11914                            Session session = null;
11915    
11916                            try {
11917                                    session = openSession();
11918    
11919                                    Query q = session.createQuery(sql);
11920    
11921                                    QueryPos qPos = QueryPos.getInstance(q);
11922    
11923                                    qPos.add(nodeId);
11924    
11925                                    if (bindTitle) {
11926                                            qPos.add(StringUtil.toLowerCase(title));
11927                                    }
11928    
11929                                    qPos.add(status);
11930    
11931                                    count = (Long)q.uniqueResult();
11932    
11933                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11934                            }
11935                            catch (Exception e) {
11936                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11937    
11938                                    throw processException(e);
11939                            }
11940                            finally {
11941                                    closeSession(session);
11942                            }
11943                    }
11944    
11945                    return count.intValue();
11946            }
11947    
11948            private static final String _FINDER_COLUMN_N_T_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
11949            private static final String _FINDER_COLUMN_N_T_S_TITLE_1 = "wikiPage.title IS NULL AND ";
11950            private static final String _FINDER_COLUMN_N_T_S_TITLE_2 = "lower(wikiPage.title) = ? AND ";
11951            private static final String _FINDER_COLUMN_N_T_S_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = '') AND ";
11952            private static final String _FINDER_COLUMN_N_T_S_STATUS_2 = "wikiPage.status = ?";
11953            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
11954                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
11955                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_P",
11956                            new String[] {
11957                                    Long.class.getName(), Boolean.class.getName(),
11958                                    String.class.getName(),
11959                                    
11960                            Integer.class.getName(), Integer.class.getName(),
11961                                    OrderByComparator.class.getName()
11962                            });
11963            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
11964                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
11965                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_P",
11966                            new String[] {
11967                                    Long.class.getName(), Boolean.class.getName(),
11968                                    String.class.getName()
11969                            },
11970                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
11971                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
11972                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK |
11973                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
11974                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
11975            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
11976                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
11977                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_P",
11978                            new String[] {
11979                                    Long.class.getName(), Boolean.class.getName(),
11980                                    String.class.getName()
11981                            });
11982    
11983            /**
11984             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
11985             *
11986             * @param nodeId the node ID
11987             * @param head the head
11988             * @param parentTitle the parent title
11989             * @return the matching wiki pages
11990             */
11991            @Override
11992            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
11993                    String parentTitle) {
11994                    return findByN_H_P(nodeId, head, parentTitle, QueryUtil.ALL_POS,
11995                            QueryUtil.ALL_POS, null);
11996            }
11997    
11998            /**
11999             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
12000             *
12001             * <p>
12002             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
12003             * </p>
12004             *
12005             * @param nodeId the node ID
12006             * @param head the head
12007             * @param parentTitle the parent title
12008             * @param start the lower bound of the range of wiki pages
12009             * @param end the upper bound of the range of wiki pages (not inclusive)
12010             * @return the range of matching wiki pages
12011             */
12012            @Override
12013            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
12014                    String parentTitle, int start, int end) {
12015                    return findByN_H_P(nodeId, head, parentTitle, start, end, null);
12016            }
12017    
12018            /**
12019             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
12020             *
12021             * <p>
12022             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
12023             * </p>
12024             *
12025             * @param nodeId the node ID
12026             * @param head the head
12027             * @param parentTitle the parent title
12028             * @param start the lower bound of the range of wiki pages
12029             * @param end the upper bound of the range of wiki pages (not inclusive)
12030             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12031             * @return the ordered range of matching wiki pages
12032             */
12033            @Override
12034            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
12035                    String parentTitle, int start, int end,
12036                    OrderByComparator<WikiPage> orderByComparator) {
12037                    boolean pagination = true;
12038                    FinderPath finderPath = null;
12039                    Object[] finderArgs = null;
12040    
12041                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12042                                    (orderByComparator == null)) {
12043                            pagination = false;
12044                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P;
12045                            finderArgs = new Object[] { nodeId, head, parentTitle };
12046                    }
12047                    else {
12048                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P;
12049                            finderArgs = new Object[] {
12050                                            nodeId, head, parentTitle,
12051                                            
12052                                            start, end, orderByComparator
12053                                    };
12054                    }
12055    
12056                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
12057                                    finderArgs, this);
12058    
12059                    if ((list != null) && !list.isEmpty()) {
12060                            for (WikiPage wikiPage : list) {
12061                                    if ((nodeId != wikiPage.getNodeId()) ||
12062                                                    (head != wikiPage.getHead()) ||
12063                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle())) {
12064                                            list = null;
12065    
12066                                            break;
12067                                    }
12068                            }
12069                    }
12070    
12071                    if (list == null) {
12072                            StringBundler query = null;
12073    
12074                            if (orderByComparator != null) {
12075                                    query = new StringBundler(5 +
12076                                                    (orderByComparator.getOrderByFields().length * 3));
12077                            }
12078                            else {
12079                                    query = new StringBundler(5);
12080                            }
12081    
12082                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
12083    
12084                            query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
12085    
12086                            query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
12087    
12088                            boolean bindParentTitle = false;
12089    
12090                            if (parentTitle == null) {
12091                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
12092                            }
12093                            else if (parentTitle.equals(StringPool.BLANK)) {
12094                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
12095                            }
12096                            else {
12097                                    bindParentTitle = true;
12098    
12099                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
12100                            }
12101    
12102                            if (orderByComparator != null) {
12103                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12104                                            orderByComparator);
12105                            }
12106                            else
12107                             if (pagination) {
12108                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12109                            }
12110    
12111                            String sql = query.toString();
12112    
12113                            Session session = null;
12114    
12115                            try {
12116                                    session = openSession();
12117    
12118                                    Query q = session.createQuery(sql);
12119    
12120                                    QueryPos qPos = QueryPos.getInstance(q);
12121    
12122                                    qPos.add(nodeId);
12123    
12124                                    qPos.add(head);
12125    
12126                                    if (bindParentTitle) {
12127                                            qPos.add(StringUtil.toLowerCase(parentTitle));
12128                                    }
12129    
12130                                    if (!pagination) {
12131                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
12132                                                            start, end, false);
12133    
12134                                            Collections.sort(list);
12135    
12136                                            list = Collections.unmodifiableList(list);
12137                                    }
12138                                    else {
12139                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
12140                                                            start, end);
12141                                    }
12142    
12143                                    cacheResult(list);
12144    
12145                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12146                            }
12147                            catch (Exception e) {
12148                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12149    
12150                                    throw processException(e);
12151                            }
12152                            finally {
12153                                    closeSession(session);
12154                            }
12155                    }
12156    
12157                    return list;
12158            }
12159    
12160            /**
12161             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
12162             *
12163             * @param nodeId the node ID
12164             * @param head the head
12165             * @param parentTitle the parent title
12166             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12167             * @return the first matching wiki page
12168             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
12169             */
12170            @Override
12171            public WikiPage findByN_H_P_First(long nodeId, boolean head,
12172                    String parentTitle, OrderByComparator<WikiPage> orderByComparator)
12173                    throws NoSuchPageException {
12174                    WikiPage wikiPage = fetchByN_H_P_First(nodeId, head, parentTitle,
12175                                    orderByComparator);
12176    
12177                    if (wikiPage != null) {
12178                            return wikiPage;
12179                    }
12180    
12181                    StringBundler msg = new StringBundler(8);
12182    
12183                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12184    
12185                    msg.append("nodeId=");
12186                    msg.append(nodeId);
12187    
12188                    msg.append(", head=");
12189                    msg.append(head);
12190    
12191                    msg.append(", parentTitle=");
12192                    msg.append(parentTitle);
12193    
12194                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12195    
12196                    throw new NoSuchPageException(msg.toString());
12197            }
12198    
12199            /**
12200             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
12201             *
12202             * @param nodeId the node ID
12203             * @param head the head
12204             * @param parentTitle the parent title
12205             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12206             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
12207             */
12208            @Override
12209            public WikiPage fetchByN_H_P_First(long nodeId, boolean head,
12210                    String parentTitle, OrderByComparator<WikiPage> orderByComparator) {
12211                    List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, 0, 1,
12212                                    orderByComparator);
12213    
12214                    if (!list.isEmpty()) {
12215                            return list.get(0);
12216                    }
12217    
12218                    return null;
12219            }
12220    
12221            /**
12222             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
12223             *
12224             * @param nodeId the node ID
12225             * @param head the head
12226             * @param parentTitle the parent title
12227             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12228             * @return the last matching wiki page
12229             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
12230             */
12231            @Override
12232            public WikiPage findByN_H_P_Last(long nodeId, boolean head,
12233                    String parentTitle, OrderByComparator<WikiPage> orderByComparator)
12234                    throws NoSuchPageException {
12235                    WikiPage wikiPage = fetchByN_H_P_Last(nodeId, head, parentTitle,
12236                                    orderByComparator);
12237    
12238                    if (wikiPage != null) {
12239                            return wikiPage;
12240                    }
12241    
12242                    StringBundler msg = new StringBundler(8);
12243    
12244                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12245    
12246                    msg.append("nodeId=");
12247                    msg.append(nodeId);
12248    
12249                    msg.append(", head=");
12250                    msg.append(head);
12251    
12252                    msg.append(", parentTitle=");
12253                    msg.append(parentTitle);
12254    
12255                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12256    
12257                    throw new NoSuchPageException(msg.toString());
12258            }
12259    
12260            /**
12261             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
12262             *
12263             * @param nodeId the node ID
12264             * @param head the head
12265             * @param parentTitle the parent title
12266             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12267             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
12268             */
12269            @Override
12270            public WikiPage fetchByN_H_P_Last(long nodeId, boolean head,
12271                    String parentTitle, OrderByComparator<WikiPage> orderByComparator) {
12272                    int count = countByN_H_P(nodeId, head, parentTitle);
12273    
12274                    if (count == 0) {
12275                            return null;
12276                    }
12277    
12278                    List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, count - 1,
12279                                    count, orderByComparator);
12280    
12281                    if (!list.isEmpty()) {
12282                            return list.get(0);
12283                    }
12284    
12285                    return null;
12286            }
12287    
12288            /**
12289             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
12290             *
12291             * @param pageId the primary key of the current wiki page
12292             * @param nodeId the node ID
12293             * @param head the head
12294             * @param parentTitle the parent title
12295             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12296             * @return the previous, current, and next wiki page
12297             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
12298             */
12299            @Override
12300            public WikiPage[] findByN_H_P_PrevAndNext(long pageId, long nodeId,
12301                    boolean head, String parentTitle,
12302                    OrderByComparator<WikiPage> orderByComparator)
12303                    throws NoSuchPageException {
12304                    WikiPage wikiPage = findByPrimaryKey(pageId);
12305    
12306                    Session session = null;
12307    
12308                    try {
12309                            session = openSession();
12310    
12311                            WikiPage[] array = new WikiPageImpl[3];
12312    
12313                            array[0] = getByN_H_P_PrevAndNext(session, wikiPage, nodeId, head,
12314                                            parentTitle, orderByComparator, true);
12315    
12316                            array[1] = wikiPage;
12317    
12318                            array[2] = getByN_H_P_PrevAndNext(session, wikiPage, nodeId, head,
12319                                            parentTitle, orderByComparator, false);
12320    
12321                            return array;
12322                    }
12323                    catch (Exception e) {
12324                            throw processException(e);
12325                    }
12326                    finally {
12327                            closeSession(session);
12328                    }
12329            }
12330    
12331            protected WikiPage getByN_H_P_PrevAndNext(Session session,
12332                    WikiPage wikiPage, long nodeId, boolean head, String parentTitle,
12333                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
12334                    StringBundler query = null;
12335    
12336                    if (orderByComparator != null) {
12337                            query = new StringBundler(6 +
12338                                            (orderByComparator.getOrderByFields().length * 6));
12339                    }
12340                    else {
12341                            query = new StringBundler(3);
12342                    }
12343    
12344                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
12345    
12346                    query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
12347    
12348                    query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
12349    
12350                    boolean bindParentTitle = false;
12351    
12352                    if (parentTitle == null) {
12353                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
12354                    }
12355                    else if (parentTitle.equals(StringPool.BLANK)) {
12356                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
12357                    }
12358                    else {
12359                            bindParentTitle = true;
12360    
12361                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
12362                    }
12363    
12364                    if (orderByComparator != null) {
12365                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12366    
12367                            if (orderByConditionFields.length > 0) {
12368                                    query.append(WHERE_AND);
12369                            }
12370    
12371                            for (int i = 0; i < orderByConditionFields.length; i++) {
12372                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12373                                    query.append(orderByConditionFields[i]);
12374    
12375                                    if ((i + 1) < orderByConditionFields.length) {
12376                                            if (orderByComparator.isAscending() ^ previous) {
12377                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12378                                            }
12379                                            else {
12380                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12381                                            }
12382                                    }
12383                                    else {
12384                                            if (orderByComparator.isAscending() ^ previous) {
12385                                                    query.append(WHERE_GREATER_THAN);
12386                                            }
12387                                            else {
12388                                                    query.append(WHERE_LESSER_THAN);
12389                                            }
12390                                    }
12391                            }
12392    
12393                            query.append(ORDER_BY_CLAUSE);
12394    
12395                            String[] orderByFields = orderByComparator.getOrderByFields();
12396    
12397                            for (int i = 0; i < orderByFields.length; i++) {
12398                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12399                                    query.append(orderByFields[i]);
12400    
12401                                    if ((i + 1) < orderByFields.length) {
12402                                            if (orderByComparator.isAscending() ^ previous) {
12403                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12404                                            }
12405                                            else {
12406                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12407                                            }
12408                                    }
12409                                    else {
12410                                            if (orderByComparator.isAscending() ^ previous) {
12411                                                    query.append(ORDER_BY_ASC);
12412                                            }
12413                                            else {
12414                                                    query.append(ORDER_BY_DESC);
12415                                            }
12416                                    }
12417                            }
12418                    }
12419                    else {
12420                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12421                    }
12422    
12423                    String sql = query.toString();
12424    
12425                    Query q = session.createQuery(sql);
12426    
12427                    q.setFirstResult(0);
12428                    q.setMaxResults(2);
12429    
12430                    QueryPos qPos = QueryPos.getInstance(q);
12431    
12432                    qPos.add(nodeId);
12433    
12434                    qPos.add(head);
12435    
12436                    if (bindParentTitle) {
12437                            qPos.add(StringUtil.toLowerCase(parentTitle));
12438                    }
12439    
12440                    if (orderByComparator != null) {
12441                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
12442    
12443                            for (Object value : values) {
12444                                    qPos.add(value);
12445                            }
12446                    }
12447    
12448                    List<WikiPage> list = q.list();
12449    
12450                    if (list.size() == 2) {
12451                            return list.get(1);
12452                    }
12453                    else {
12454                            return null;
12455                    }
12456            }
12457    
12458            /**
12459             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; from the database.
12460             *
12461             * @param nodeId the node ID
12462             * @param head the head
12463             * @param parentTitle the parent title
12464             */
12465            @Override
12466            public void removeByN_H_P(long nodeId, boolean head, String parentTitle) {
12467                    for (WikiPage wikiPage : findByN_H_P(nodeId, head, parentTitle,
12468                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12469                            remove(wikiPage);
12470                    }
12471            }
12472    
12473            /**
12474             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
12475             *
12476             * @param nodeId the node ID
12477             * @param head the head
12478             * @param parentTitle the parent title
12479             * @return the number of matching wiki pages
12480             */
12481            @Override
12482            public int countByN_H_P(long nodeId, boolean head, String parentTitle) {
12483                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_H_P;
12484    
12485                    Object[] finderArgs = new Object[] { nodeId, head, parentTitle };
12486    
12487                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12488                                    this);
12489    
12490                    if (count == null) {
12491                            StringBundler query = new StringBundler(4);
12492    
12493                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
12494    
12495                            query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
12496    
12497                            query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
12498    
12499                            boolean bindParentTitle = false;
12500    
12501                            if (parentTitle == null) {
12502                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
12503                            }
12504                            else if (parentTitle.equals(StringPool.BLANK)) {
12505                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
12506                            }
12507                            else {
12508                                    bindParentTitle = true;
12509    
12510                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
12511                            }
12512    
12513                            String sql = query.toString();
12514    
12515                            Session session = null;
12516    
12517                            try {
12518                                    session = openSession();
12519    
12520                                    Query q = session.createQuery(sql);
12521    
12522                                    QueryPos qPos = QueryPos.getInstance(q);
12523    
12524                                    qPos.add(nodeId);
12525    
12526                                    qPos.add(head);
12527    
12528                                    if (bindParentTitle) {
12529                                            qPos.add(StringUtil.toLowerCase(parentTitle));
12530                                    }
12531    
12532                                    count = (Long)q.uniqueResult();
12533    
12534                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12535                            }
12536                            catch (Exception e) {
12537                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12538    
12539                                    throw processException(e);
12540                            }
12541                            finally {
12542                                    closeSession(session);
12543                            }
12544                    }
12545    
12546                    return count.intValue();
12547            }
12548    
12549            private static final String _FINDER_COLUMN_N_H_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
12550            private static final String _FINDER_COLUMN_N_H_P_HEAD_2 = "wikiPage.head = ? AND ";
12551            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
12552            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = ?";
12553            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = '')";
12554            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
12555                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
12556                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_R",
12557                            new String[] {
12558                                    Long.class.getName(), Boolean.class.getName(),
12559                                    String.class.getName(),
12560                                    
12561                            Integer.class.getName(), Integer.class.getName(),
12562                                    OrderByComparator.class.getName()
12563                            });
12564            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
12565                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
12566                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_R",
12567                            new String[] {
12568                                    Long.class.getName(), Boolean.class.getName(),
12569                                    String.class.getName()
12570                            },
12571                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
12572                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
12573                            WikiPageModelImpl.REDIRECTTITLE_COLUMN_BITMASK |
12574                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
12575                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
12576            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
12577                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
12578                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_R",
12579                            new String[] {
12580                                    Long.class.getName(), Boolean.class.getName(),
12581                                    String.class.getName()
12582                            });
12583    
12584            /**
12585             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63;.
12586             *
12587             * @param nodeId the node ID
12588             * @param head the head
12589             * @param redirectTitle the redirect title
12590             * @return the matching wiki pages
12591             */
12592            @Override
12593            public List<WikiPage> findByN_H_R(long nodeId, boolean head,
12594                    String redirectTitle) {
12595                    return findByN_H_R(nodeId, head, redirectTitle, QueryUtil.ALL_POS,
12596                            QueryUtil.ALL_POS, null);
12597            }
12598    
12599            /**
12600             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63;.
12601             *
12602             * <p>
12603             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
12604             * </p>
12605             *
12606             * @param nodeId the node ID
12607             * @param head the head
12608             * @param redirectTitle the redirect title
12609             * @param start the lower bound of the range of wiki pages
12610             * @param end the upper bound of the range of wiki pages (not inclusive)
12611             * @return the range of matching wiki pages
12612             */
12613            @Override
12614            public List<WikiPage> findByN_H_R(long nodeId, boolean head,
12615                    String redirectTitle, int start, int end) {
12616                    return findByN_H_R(nodeId, head, redirectTitle, start, end, null);
12617            }
12618    
12619            /**
12620             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63;.
12621             *
12622             * <p>
12623             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
12624             * </p>
12625             *
12626             * @param nodeId the node ID
12627             * @param head the head
12628             * @param redirectTitle the redirect title
12629             * @param start the lower bound of the range of wiki pages
12630             * @param end the upper bound of the range of wiki pages (not inclusive)
12631             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12632             * @return the ordered range of matching wiki pages
12633             */
12634            @Override
12635            public List<WikiPage> findByN_H_R(long nodeId, boolean head,
12636                    String redirectTitle, int start, int end,
12637                    OrderByComparator<WikiPage> orderByComparator) {
12638                    boolean pagination = true;
12639                    FinderPath finderPath = null;
12640                    Object[] finderArgs = null;
12641    
12642                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12643                                    (orderByComparator == null)) {
12644                            pagination = false;
12645                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_R;
12646                            finderArgs = new Object[] { nodeId, head, redirectTitle };
12647                    }
12648                    else {
12649                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_R;
12650                            finderArgs = new Object[] {
12651                                            nodeId, head, redirectTitle,
12652                                            
12653                                            start, end, orderByComparator
12654                                    };
12655                    }
12656    
12657                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
12658                                    finderArgs, this);
12659    
12660                    if ((list != null) && !list.isEmpty()) {
12661                            for (WikiPage wikiPage : list) {
12662                                    if ((nodeId != wikiPage.getNodeId()) ||
12663                                                    (head != wikiPage.getHead()) ||
12664                                                    !Validator.equals(redirectTitle,
12665                                                            wikiPage.getRedirectTitle())) {
12666                                            list = null;
12667    
12668                                            break;
12669                                    }
12670                            }
12671                    }
12672    
12673                    if (list == null) {
12674                            StringBundler query = null;
12675    
12676                            if (orderByComparator != null) {
12677                                    query = new StringBundler(5 +
12678                                                    (orderByComparator.getOrderByFields().length * 3));
12679                            }
12680                            else {
12681                                    query = new StringBundler(5);
12682                            }
12683    
12684                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
12685    
12686                            query.append(_FINDER_COLUMN_N_H_R_NODEID_2);
12687    
12688                            query.append(_FINDER_COLUMN_N_H_R_HEAD_2);
12689    
12690                            boolean bindRedirectTitle = false;
12691    
12692                            if (redirectTitle == null) {
12693                                    query.append(_FINDER_COLUMN_N_H_R_REDIRECTTITLE_1);
12694                            }
12695                            else if (redirectTitle.equals(StringPool.BLANK)) {
12696                                    query.append(_FINDER_COLUMN_N_H_R_REDIRECTTITLE_3);
12697                            }
12698                            else {
12699                                    bindRedirectTitle = true;
12700    
12701                                    query.append(_FINDER_COLUMN_N_H_R_REDIRECTTITLE_2);
12702                            }
12703    
12704                            if (orderByComparator != null) {
12705                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12706                                            orderByComparator);
12707                            }
12708                            else
12709                             if (pagination) {
12710                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12711                            }
12712    
12713                            String sql = query.toString();
12714    
12715                            Session session = null;
12716    
12717                            try {
12718                                    session = openSession();
12719    
12720                                    Query q = session.createQuery(sql);
12721    
12722                                    QueryPos qPos = QueryPos.getInstance(q);
12723    
12724                                    qPos.add(nodeId);
12725    
12726                                    qPos.add(head);
12727    
12728                                    if (bindRedirectTitle) {
12729                                            qPos.add(StringUtil.toLowerCase(redirectTitle));
12730                                    }
12731    
12732                                    if (!pagination) {
12733                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
12734                                                            start, end, false);
12735    
12736                                            Collections.sort(list);
12737    
12738                                            list = Collections.unmodifiableList(list);
12739                                    }
12740                                    else {
12741                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
12742                                                            start, end);
12743                                    }
12744    
12745                                    cacheResult(list);
12746    
12747                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12748                            }
12749                            catch (Exception e) {
12750                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12751    
12752                                    throw processException(e);
12753                            }
12754                            finally {
12755                                    closeSession(session);
12756                            }
12757                    }
12758    
12759                    return list;
12760            }
12761    
12762            /**
12763             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63;.
12764             *
12765             * @param nodeId the node ID
12766             * @param head the head
12767             * @param redirectTitle the redirect title
12768             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12769             * @return the first matching wiki page
12770             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
12771             */
12772            @Override
12773            public WikiPage findByN_H_R_First(long nodeId, boolean head,
12774                    String redirectTitle, OrderByComparator<WikiPage> orderByComparator)
12775                    throws NoSuchPageException {
12776                    WikiPage wikiPage = fetchByN_H_R_First(nodeId, head, redirectTitle,
12777                                    orderByComparator);
12778    
12779                    if (wikiPage != null) {
12780                            return wikiPage;
12781                    }
12782    
12783                    StringBundler msg = new StringBundler(8);
12784    
12785                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12786    
12787                    msg.append("nodeId=");
12788                    msg.append(nodeId);
12789    
12790                    msg.append(", head=");
12791                    msg.append(head);
12792    
12793                    msg.append(", redirectTitle=");
12794                    msg.append(redirectTitle);
12795    
12796                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12797    
12798                    throw new NoSuchPageException(msg.toString());
12799            }
12800    
12801            /**
12802             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63;.
12803             *
12804             * @param nodeId the node ID
12805             * @param head the head
12806             * @param redirectTitle the redirect title
12807             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12808             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
12809             */
12810            @Override
12811            public WikiPage fetchByN_H_R_First(long nodeId, boolean head,
12812                    String redirectTitle, OrderByComparator<WikiPage> orderByComparator) {
12813                    List<WikiPage> list = findByN_H_R(nodeId, head, redirectTitle, 0, 1,
12814                                    orderByComparator);
12815    
12816                    if (!list.isEmpty()) {
12817                            return list.get(0);
12818                    }
12819    
12820                    return null;
12821            }
12822    
12823            /**
12824             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63;.
12825             *
12826             * @param nodeId the node ID
12827             * @param head the head
12828             * @param redirectTitle the redirect title
12829             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12830             * @return the last matching wiki page
12831             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
12832             */
12833            @Override
12834            public WikiPage findByN_H_R_Last(long nodeId, boolean head,
12835                    String redirectTitle, OrderByComparator<WikiPage> orderByComparator)
12836                    throws NoSuchPageException {
12837                    WikiPage wikiPage = fetchByN_H_R_Last(nodeId, head, redirectTitle,
12838                                    orderByComparator);
12839    
12840                    if (wikiPage != null) {
12841                            return wikiPage;
12842                    }
12843    
12844                    StringBundler msg = new StringBundler(8);
12845    
12846                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12847    
12848                    msg.append("nodeId=");
12849                    msg.append(nodeId);
12850    
12851                    msg.append(", head=");
12852                    msg.append(head);
12853    
12854                    msg.append(", redirectTitle=");
12855                    msg.append(redirectTitle);
12856    
12857                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12858    
12859                    throw new NoSuchPageException(msg.toString());
12860            }
12861    
12862            /**
12863             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63;.
12864             *
12865             * @param nodeId the node ID
12866             * @param head the head
12867             * @param redirectTitle the redirect title
12868             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12869             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
12870             */
12871            @Override
12872            public WikiPage fetchByN_H_R_Last(long nodeId, boolean head,
12873                    String redirectTitle, OrderByComparator<WikiPage> orderByComparator) {
12874                    int count = countByN_H_R(nodeId, head, redirectTitle);
12875    
12876                    if (count == 0) {
12877                            return null;
12878                    }
12879    
12880                    List<WikiPage> list = findByN_H_R(nodeId, head, redirectTitle,
12881                                    count - 1, count, orderByComparator);
12882    
12883                    if (!list.isEmpty()) {
12884                            return list.get(0);
12885                    }
12886    
12887                    return null;
12888            }
12889    
12890            /**
12891             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63;.
12892             *
12893             * @param pageId the primary key of the current wiki page
12894             * @param nodeId the node ID
12895             * @param head the head
12896             * @param redirectTitle the redirect title
12897             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12898             * @return the previous, current, and next wiki page
12899             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
12900             */
12901            @Override
12902            public WikiPage[] findByN_H_R_PrevAndNext(long pageId, long nodeId,
12903                    boolean head, String redirectTitle,
12904                    OrderByComparator<WikiPage> orderByComparator)
12905                    throws NoSuchPageException {
12906                    WikiPage wikiPage = findByPrimaryKey(pageId);
12907    
12908                    Session session = null;
12909    
12910                    try {
12911                            session = openSession();
12912    
12913                            WikiPage[] array = new WikiPageImpl[3];
12914    
12915                            array[0] = getByN_H_R_PrevAndNext(session, wikiPage, nodeId, head,
12916                                            redirectTitle, orderByComparator, true);
12917    
12918                            array[1] = wikiPage;
12919    
12920                            array[2] = getByN_H_R_PrevAndNext(session, wikiPage, nodeId, head,
12921                                            redirectTitle, orderByComparator, false);
12922    
12923                            return array;
12924                    }
12925                    catch (Exception e) {
12926                            throw processException(e);
12927                    }
12928                    finally {
12929                            closeSession(session);
12930                    }
12931            }
12932    
12933            protected WikiPage getByN_H_R_PrevAndNext(Session session,
12934                    WikiPage wikiPage, long nodeId, boolean head, String redirectTitle,
12935                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
12936                    StringBundler query = null;
12937    
12938                    if (orderByComparator != null) {
12939                            query = new StringBundler(6 +
12940                                            (orderByComparator.getOrderByFields().length * 6));
12941                    }
12942                    else {
12943                            query = new StringBundler(3);
12944                    }
12945    
12946                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
12947    
12948                    query.append(_FINDER_COLUMN_N_H_R_NODEID_2);
12949    
12950                    query.append(_FINDER_COLUMN_N_H_R_HEAD_2);
12951    
12952                    boolean bindRedirectTitle = false;
12953    
12954                    if (redirectTitle == null) {
12955                            query.append(_FINDER_COLUMN_N_H_R_REDIRECTTITLE_1);
12956                    }
12957                    else if (redirectTitle.equals(StringPool.BLANK)) {
12958                            query.append(_FINDER_COLUMN_N_H_R_REDIRECTTITLE_3);
12959                    }
12960                    else {
12961                            bindRedirectTitle = true;
12962    
12963                            query.append(_FINDER_COLUMN_N_H_R_REDIRECTTITLE_2);
12964                    }
12965    
12966                    if (orderByComparator != null) {
12967                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12968    
12969                            if (orderByConditionFields.length > 0) {
12970                                    query.append(WHERE_AND);
12971                            }
12972    
12973                            for (int i = 0; i < orderByConditionFields.length; i++) {
12974                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12975                                    query.append(orderByConditionFields[i]);
12976    
12977                                    if ((i + 1) < orderByConditionFields.length) {
12978                                            if (orderByComparator.isAscending() ^ previous) {
12979                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12980                                            }
12981                                            else {
12982                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12983                                            }
12984                                    }
12985                                    else {
12986                                            if (orderByComparator.isAscending() ^ previous) {
12987                                                    query.append(WHERE_GREATER_THAN);
12988                                            }
12989                                            else {
12990                                                    query.append(WHERE_LESSER_THAN);
12991                                            }
12992                                    }
12993                            }
12994    
12995                            query.append(ORDER_BY_CLAUSE);
12996    
12997                            String[] orderByFields = orderByComparator.getOrderByFields();
12998    
12999                            for (int i = 0; i < orderByFields.length; i++) {
13000                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13001                                    query.append(orderByFields[i]);
13002    
13003                                    if ((i + 1) < orderByFields.length) {
13004                                            if (orderByComparator.isAscending() ^ previous) {
13005                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13006                                            }
13007                                            else {
13008                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13009                                            }
13010                                    }
13011                                    else {
13012                                            if (orderByComparator.isAscending() ^ previous) {
13013                                                    query.append(ORDER_BY_ASC);
13014                                            }
13015                                            else {
13016                                                    query.append(ORDER_BY_DESC);
13017                                            }
13018                                    }
13019                            }
13020                    }
13021                    else {
13022                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13023                    }
13024    
13025                    String sql = query.toString();
13026    
13027                    Query q = session.createQuery(sql);
13028    
13029                    q.setFirstResult(0);
13030                    q.setMaxResults(2);
13031    
13032                    QueryPos qPos = QueryPos.getInstance(q);
13033    
13034                    qPos.add(nodeId);
13035    
13036                    qPos.add(head);
13037    
13038                    if (bindRedirectTitle) {
13039                            qPos.add(StringUtil.toLowerCase(redirectTitle));
13040                    }
13041    
13042                    if (orderByComparator != null) {
13043                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
13044    
13045                            for (Object value : values) {
13046                                    qPos.add(value);
13047                            }
13048                    }
13049    
13050                    List<WikiPage> list = q.list();
13051    
13052                    if (list.size() == 2) {
13053                            return list.get(1);
13054                    }
13055                    else {
13056                            return null;
13057                    }
13058            }
13059    
13060            /**
13061             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; from the database.
13062             *
13063             * @param nodeId the node ID
13064             * @param head the head
13065             * @param redirectTitle the redirect title
13066             */
13067            @Override
13068            public void removeByN_H_R(long nodeId, boolean head, String redirectTitle) {
13069                    for (WikiPage wikiPage : findByN_H_R(nodeId, head, redirectTitle,
13070                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13071                            remove(wikiPage);
13072                    }
13073            }
13074    
13075            /**
13076             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63;.
13077             *
13078             * @param nodeId the node ID
13079             * @param head the head
13080             * @param redirectTitle the redirect title
13081             * @return the number of matching wiki pages
13082             */
13083            @Override
13084            public int countByN_H_R(long nodeId, boolean head, String redirectTitle) {
13085                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_H_R;
13086    
13087                    Object[] finderArgs = new Object[] { nodeId, head, redirectTitle };
13088    
13089                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13090                                    this);
13091    
13092                    if (count == null) {
13093                            StringBundler query = new StringBundler(4);
13094    
13095                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
13096    
13097                            query.append(_FINDER_COLUMN_N_H_R_NODEID_2);
13098    
13099                            query.append(_FINDER_COLUMN_N_H_R_HEAD_2);
13100    
13101                            boolean bindRedirectTitle = false;
13102    
13103                            if (redirectTitle == null) {
13104                                    query.append(_FINDER_COLUMN_N_H_R_REDIRECTTITLE_1);
13105                            }
13106                            else if (redirectTitle.equals(StringPool.BLANK)) {
13107                                    query.append(_FINDER_COLUMN_N_H_R_REDIRECTTITLE_3);
13108                            }
13109                            else {
13110                                    bindRedirectTitle = true;
13111    
13112                                    query.append(_FINDER_COLUMN_N_H_R_REDIRECTTITLE_2);
13113                            }
13114    
13115                            String sql = query.toString();
13116    
13117                            Session session = null;
13118    
13119                            try {
13120                                    session = openSession();
13121    
13122                                    Query q = session.createQuery(sql);
13123    
13124                                    QueryPos qPos = QueryPos.getInstance(q);
13125    
13126                                    qPos.add(nodeId);
13127    
13128                                    qPos.add(head);
13129    
13130                                    if (bindRedirectTitle) {
13131                                            qPos.add(StringUtil.toLowerCase(redirectTitle));
13132                                    }
13133    
13134                                    count = (Long)q.uniqueResult();
13135    
13136                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13137                            }
13138                            catch (Exception e) {
13139                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13140    
13141                                    throw processException(e);
13142                            }
13143                            finally {
13144                                    closeSession(session);
13145                            }
13146                    }
13147    
13148                    return count.intValue();
13149            }
13150    
13151            private static final String _FINDER_COLUMN_N_H_R_NODEID_2 = "wikiPage.nodeId = ? AND ";
13152            private static final String _FINDER_COLUMN_N_H_R_HEAD_2 = "wikiPage.head = ? AND ";
13153            private static final String _FINDER_COLUMN_N_H_R_REDIRECTTITLE_1 = "wikiPage.redirectTitle IS NULL";
13154            private static final String _FINDER_COLUMN_N_H_R_REDIRECTTITLE_2 = "lower(wikiPage.redirectTitle) = ?";
13155            private static final String _FINDER_COLUMN_N_H_R_REDIRECTTITLE_3 = "(wikiPage.redirectTitle IS NULL OR wikiPage.redirectTitle = '')";
13156            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
13157                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
13158                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_S",
13159                            new String[] {
13160                                    Long.class.getName(), Boolean.class.getName(),
13161                                    Integer.class.getName(),
13162                                    
13163                            Integer.class.getName(), Integer.class.getName(),
13164                                    OrderByComparator.class.getName()
13165                            });
13166            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
13167                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
13168                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_S",
13169                            new String[] {
13170                                    Long.class.getName(), Boolean.class.getName(),
13171                                    Integer.class.getName()
13172                            },
13173                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
13174                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
13175                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
13176                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
13177                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
13178            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
13179                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
13180                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_S",
13181                            new String[] {
13182                                    Long.class.getName(), Boolean.class.getName(),
13183                                    Integer.class.getName()
13184                            });
13185    
13186            /**
13187             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
13188             *
13189             * @param nodeId the node ID
13190             * @param head the head
13191             * @param status the status
13192             * @return the matching wiki pages
13193             */
13194            @Override
13195            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status) {
13196                    return findByN_H_S(nodeId, head, status, QueryUtil.ALL_POS,
13197                            QueryUtil.ALL_POS, null);
13198            }
13199    
13200            /**
13201             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
13202             *
13203             * <p>
13204             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
13205             * </p>
13206             *
13207             * @param nodeId the node ID
13208             * @param head the head
13209             * @param status the status
13210             * @param start the lower bound of the range of wiki pages
13211             * @param end the upper bound of the range of wiki pages (not inclusive)
13212             * @return the range of matching wiki pages
13213             */
13214            @Override
13215            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status,
13216                    int start, int end) {
13217                    return findByN_H_S(nodeId, head, status, start, end, null);
13218            }
13219    
13220            /**
13221             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
13222             *
13223             * <p>
13224             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
13225             * </p>
13226             *
13227             * @param nodeId the node ID
13228             * @param head the head
13229             * @param status the status
13230             * @param start the lower bound of the range of wiki pages
13231             * @param end the upper bound of the range of wiki pages (not inclusive)
13232             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13233             * @return the ordered range of matching wiki pages
13234             */
13235            @Override
13236            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status,
13237                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
13238                    boolean pagination = true;
13239                    FinderPath finderPath = null;
13240                    Object[] finderArgs = null;
13241    
13242                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13243                                    (orderByComparator == null)) {
13244                            pagination = false;
13245                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S;
13246                            finderArgs = new Object[] { nodeId, head, status };
13247                    }
13248                    else {
13249                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_S;
13250                            finderArgs = new Object[] {
13251                                            nodeId, head, status,
13252                                            
13253                                            start, end, orderByComparator
13254                                    };
13255                    }
13256    
13257                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
13258                                    finderArgs, this);
13259    
13260                    if ((list != null) && !list.isEmpty()) {
13261                            for (WikiPage wikiPage : list) {
13262                                    if ((nodeId != wikiPage.getNodeId()) ||
13263                                                    (head != wikiPage.getHead()) ||
13264                                                    (status != wikiPage.getStatus())) {
13265                                            list = null;
13266    
13267                                            break;
13268                                    }
13269                            }
13270                    }
13271    
13272                    if (list == null) {
13273                            StringBundler query = null;
13274    
13275                            if (orderByComparator != null) {
13276                                    query = new StringBundler(5 +
13277                                                    (orderByComparator.getOrderByFields().length * 3));
13278                            }
13279                            else {
13280                                    query = new StringBundler(5);
13281                            }
13282    
13283                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
13284    
13285                            query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
13286    
13287                            query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
13288    
13289                            query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
13290    
13291                            if (orderByComparator != null) {
13292                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13293                                            orderByComparator);
13294                            }
13295                            else
13296                             if (pagination) {
13297                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13298                            }
13299    
13300                            String sql = query.toString();
13301    
13302                            Session session = null;
13303    
13304                            try {
13305                                    session = openSession();
13306    
13307                                    Query q = session.createQuery(sql);
13308    
13309                                    QueryPos qPos = QueryPos.getInstance(q);
13310    
13311                                    qPos.add(nodeId);
13312    
13313                                    qPos.add(head);
13314    
13315                                    qPos.add(status);
13316    
13317                                    if (!pagination) {
13318                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
13319                                                            start, end, false);
13320    
13321                                            Collections.sort(list);
13322    
13323                                            list = Collections.unmodifiableList(list);
13324                                    }
13325                                    else {
13326                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
13327                                                            start, end);
13328                                    }
13329    
13330                                    cacheResult(list);
13331    
13332                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13333                            }
13334                            catch (Exception e) {
13335                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13336    
13337                                    throw processException(e);
13338                            }
13339                            finally {
13340                                    closeSession(session);
13341                            }
13342                    }
13343    
13344                    return list;
13345            }
13346    
13347            /**
13348             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
13349             *
13350             * @param nodeId the node ID
13351             * @param head the head
13352             * @param status the status
13353             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13354             * @return the first matching wiki page
13355             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
13356             */
13357            @Override
13358            public WikiPage findByN_H_S_First(long nodeId, boolean head, int status,
13359                    OrderByComparator<WikiPage> orderByComparator)
13360                    throws NoSuchPageException {
13361                    WikiPage wikiPage = fetchByN_H_S_First(nodeId, head, status,
13362                                    orderByComparator);
13363    
13364                    if (wikiPage != null) {
13365                            return wikiPage;
13366                    }
13367    
13368                    StringBundler msg = new StringBundler(8);
13369    
13370                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13371    
13372                    msg.append("nodeId=");
13373                    msg.append(nodeId);
13374    
13375                    msg.append(", head=");
13376                    msg.append(head);
13377    
13378                    msg.append(", status=");
13379                    msg.append(status);
13380    
13381                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13382    
13383                    throw new NoSuchPageException(msg.toString());
13384            }
13385    
13386            /**
13387             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
13388             *
13389             * @param nodeId the node ID
13390             * @param head the head
13391             * @param status the status
13392             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13393             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
13394             */
13395            @Override
13396            public WikiPage fetchByN_H_S_First(long nodeId, boolean head, int status,
13397                    OrderByComparator<WikiPage> orderByComparator) {
13398                    List<WikiPage> list = findByN_H_S(nodeId, head, status, 0, 1,
13399                                    orderByComparator);
13400    
13401                    if (!list.isEmpty()) {
13402                            return list.get(0);
13403                    }
13404    
13405                    return null;
13406            }
13407    
13408            /**
13409             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
13410             *
13411             * @param nodeId the node ID
13412             * @param head the head
13413             * @param status the status
13414             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13415             * @return the last matching wiki page
13416             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
13417             */
13418            @Override
13419            public WikiPage findByN_H_S_Last(long nodeId, boolean head, int status,
13420                    OrderByComparator<WikiPage> orderByComparator)
13421                    throws NoSuchPageException {
13422                    WikiPage wikiPage = fetchByN_H_S_Last(nodeId, head, status,
13423                                    orderByComparator);
13424    
13425                    if (wikiPage != null) {
13426                            return wikiPage;
13427                    }
13428    
13429                    StringBundler msg = new StringBundler(8);
13430    
13431                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13432    
13433                    msg.append("nodeId=");
13434                    msg.append(nodeId);
13435    
13436                    msg.append(", head=");
13437                    msg.append(head);
13438    
13439                    msg.append(", status=");
13440                    msg.append(status);
13441    
13442                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13443    
13444                    throw new NoSuchPageException(msg.toString());
13445            }
13446    
13447            /**
13448             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
13449             *
13450             * @param nodeId the node ID
13451             * @param head the head
13452             * @param status the status
13453             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13454             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
13455             */
13456            @Override
13457            public WikiPage fetchByN_H_S_Last(long nodeId, boolean head, int status,
13458                    OrderByComparator<WikiPage> orderByComparator) {
13459                    int count = countByN_H_S(nodeId, head, status);
13460    
13461                    if (count == 0) {
13462                            return null;
13463                    }
13464    
13465                    List<WikiPage> list = findByN_H_S(nodeId, head, status, count - 1,
13466                                    count, orderByComparator);
13467    
13468                    if (!list.isEmpty()) {
13469                            return list.get(0);
13470                    }
13471    
13472                    return null;
13473            }
13474    
13475            /**
13476             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
13477             *
13478             * @param pageId the primary key of the current wiki page
13479             * @param nodeId the node ID
13480             * @param head the head
13481             * @param status the status
13482             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13483             * @return the previous, current, and next wiki page
13484             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
13485             */
13486            @Override
13487            public WikiPage[] findByN_H_S_PrevAndNext(long pageId, long nodeId,
13488                    boolean head, int status, OrderByComparator<WikiPage> orderByComparator)
13489                    throws NoSuchPageException {
13490                    WikiPage wikiPage = findByPrimaryKey(pageId);
13491    
13492                    Session session = null;
13493    
13494                    try {
13495                            session = openSession();
13496    
13497                            WikiPage[] array = new WikiPageImpl[3];
13498    
13499                            array[0] = getByN_H_S_PrevAndNext(session, wikiPage, nodeId, head,
13500                                            status, orderByComparator, true);
13501    
13502                            array[1] = wikiPage;
13503    
13504                            array[2] = getByN_H_S_PrevAndNext(session, wikiPage, nodeId, head,
13505                                            status, orderByComparator, false);
13506    
13507                            return array;
13508                    }
13509                    catch (Exception e) {
13510                            throw processException(e);
13511                    }
13512                    finally {
13513                            closeSession(session);
13514                    }
13515            }
13516    
13517            protected WikiPage getByN_H_S_PrevAndNext(Session session,
13518                    WikiPage wikiPage, long nodeId, boolean head, int status,
13519                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
13520                    StringBundler query = null;
13521    
13522                    if (orderByComparator != null) {
13523                            query = new StringBundler(6 +
13524                                            (orderByComparator.getOrderByFields().length * 6));
13525                    }
13526                    else {
13527                            query = new StringBundler(3);
13528                    }
13529    
13530                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
13531    
13532                    query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
13533    
13534                    query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
13535    
13536                    query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
13537    
13538                    if (orderByComparator != null) {
13539                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13540    
13541                            if (orderByConditionFields.length > 0) {
13542                                    query.append(WHERE_AND);
13543                            }
13544    
13545                            for (int i = 0; i < orderByConditionFields.length; i++) {
13546                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13547                                    query.append(orderByConditionFields[i]);
13548    
13549                                    if ((i + 1) < orderByConditionFields.length) {
13550                                            if (orderByComparator.isAscending() ^ previous) {
13551                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13552                                            }
13553                                            else {
13554                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13555                                            }
13556                                    }
13557                                    else {
13558                                            if (orderByComparator.isAscending() ^ previous) {
13559                                                    query.append(WHERE_GREATER_THAN);
13560                                            }
13561                                            else {
13562                                                    query.append(WHERE_LESSER_THAN);
13563                                            }
13564                                    }
13565                            }
13566    
13567                            query.append(ORDER_BY_CLAUSE);
13568    
13569                            String[] orderByFields = orderByComparator.getOrderByFields();
13570    
13571                            for (int i = 0; i < orderByFields.length; i++) {
13572                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13573                                    query.append(orderByFields[i]);
13574    
13575                                    if ((i + 1) < orderByFields.length) {
13576                                            if (orderByComparator.isAscending() ^ previous) {
13577                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13578                                            }
13579                                            else {
13580                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13581                                            }
13582                                    }
13583                                    else {
13584                                            if (orderByComparator.isAscending() ^ previous) {
13585                                                    query.append(ORDER_BY_ASC);
13586                                            }
13587                                            else {
13588                                                    query.append(ORDER_BY_DESC);
13589                                            }
13590                                    }
13591                            }
13592                    }
13593                    else {
13594                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13595                    }
13596    
13597                    String sql = query.toString();
13598    
13599                    Query q = session.createQuery(sql);
13600    
13601                    q.setFirstResult(0);
13602                    q.setMaxResults(2);
13603    
13604                    QueryPos qPos = QueryPos.getInstance(q);
13605    
13606                    qPos.add(nodeId);
13607    
13608                    qPos.add(head);
13609    
13610                    qPos.add(status);
13611    
13612                    if (orderByComparator != null) {
13613                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
13614    
13615                            for (Object value : values) {
13616                                    qPos.add(value);
13617                            }
13618                    }
13619    
13620                    List<WikiPage> list = q.list();
13621    
13622                    if (list.size() == 2) {
13623                            return list.get(1);
13624                    }
13625                    else {
13626                            return null;
13627                    }
13628            }
13629    
13630            /**
13631             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63; from the database.
13632             *
13633             * @param nodeId the node ID
13634             * @param head the head
13635             * @param status the status
13636             */
13637            @Override
13638            public void removeByN_H_S(long nodeId, boolean head, int status) {
13639                    for (WikiPage wikiPage : findByN_H_S(nodeId, head, status,
13640                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13641                            remove(wikiPage);
13642                    }
13643            }
13644    
13645            /**
13646             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
13647             *
13648             * @param nodeId the node ID
13649             * @param head the head
13650             * @param status the status
13651             * @return the number of matching wiki pages
13652             */
13653            @Override
13654            public int countByN_H_S(long nodeId, boolean head, int status) {
13655                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_H_S;
13656    
13657                    Object[] finderArgs = new Object[] { nodeId, head, status };
13658    
13659                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13660                                    this);
13661    
13662                    if (count == null) {
13663                            StringBundler query = new StringBundler(4);
13664    
13665                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
13666    
13667                            query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
13668    
13669                            query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
13670    
13671                            query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
13672    
13673                            String sql = query.toString();
13674    
13675                            Session session = null;
13676    
13677                            try {
13678                                    session = openSession();
13679    
13680                                    Query q = session.createQuery(sql);
13681    
13682                                    QueryPos qPos = QueryPos.getInstance(q);
13683    
13684                                    qPos.add(nodeId);
13685    
13686                                    qPos.add(head);
13687    
13688                                    qPos.add(status);
13689    
13690                                    count = (Long)q.uniqueResult();
13691    
13692                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13693                            }
13694                            catch (Exception e) {
13695                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13696    
13697                                    throw processException(e);
13698                            }
13699                            finally {
13700                                    closeSession(session);
13701                            }
13702                    }
13703    
13704                    return count.intValue();
13705            }
13706    
13707            private static final String _FINDER_COLUMN_N_H_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
13708            private static final String _FINDER_COLUMN_N_H_S_HEAD_2 = "wikiPage.head = ? AND ";
13709            private static final String _FINDER_COLUMN_N_H_S_STATUS_2 = "wikiPage.status = ?";
13710            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_NOTS = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
13711                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
13712                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_NotS",
13713                            new String[] {
13714                                    Long.class.getName(), Boolean.class.getName(),
13715                                    Integer.class.getName(),
13716                                    
13717                            Integer.class.getName(), Integer.class.getName(),
13718                                    OrderByComparator.class.getName()
13719                            });
13720            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_N_H_NOTS =
13721                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
13722                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
13723                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByN_H_NotS",
13724                            new String[] {
13725                                    Long.class.getName(), Boolean.class.getName(),
13726                                    Integer.class.getName()
13727                            });
13728    
13729            /**
13730             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and status &ne; &#63;.
13731             *
13732             * @param nodeId the node ID
13733             * @param head the head
13734             * @param status the status
13735             * @return the matching wiki pages
13736             */
13737            @Override
13738            public List<WikiPage> findByN_H_NotS(long nodeId, boolean head, int status) {
13739                    return findByN_H_NotS(nodeId, head, status, QueryUtil.ALL_POS,
13740                            QueryUtil.ALL_POS, null);
13741            }
13742    
13743            /**
13744             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and status &ne; &#63;.
13745             *
13746             * <p>
13747             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
13748             * </p>
13749             *
13750             * @param nodeId the node ID
13751             * @param head the head
13752             * @param status the status
13753             * @param start the lower bound of the range of wiki pages
13754             * @param end the upper bound of the range of wiki pages (not inclusive)
13755             * @return the range of matching wiki pages
13756             */
13757            @Override
13758            public List<WikiPage> findByN_H_NotS(long nodeId, boolean head, int status,
13759                    int start, int end) {
13760                    return findByN_H_NotS(nodeId, head, status, start, end, null);
13761            }
13762    
13763            /**
13764             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and status &ne; &#63;.
13765             *
13766             * <p>
13767             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
13768             * </p>
13769             *
13770             * @param nodeId the node ID
13771             * @param head the head
13772             * @param status the status
13773             * @param start the lower bound of the range of wiki pages
13774             * @param end the upper bound of the range of wiki pages (not inclusive)
13775             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13776             * @return the ordered range of matching wiki pages
13777             */
13778            @Override
13779            public List<WikiPage> findByN_H_NotS(long nodeId, boolean head, int status,
13780                    int start, int end, OrderByComparator<WikiPage> orderByComparator) {
13781                    boolean pagination = true;
13782                    FinderPath finderPath = null;
13783                    Object[] finderArgs = null;
13784    
13785                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_NOTS;
13786                    finderArgs = new Object[] {
13787                                    nodeId, head, status,
13788                                    
13789                                    start, end, orderByComparator
13790                            };
13791    
13792                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
13793                                    finderArgs, this);
13794    
13795                    if ((list != null) && !list.isEmpty()) {
13796                            for (WikiPage wikiPage : list) {
13797                                    if ((nodeId != wikiPage.getNodeId()) ||
13798                                                    (head != wikiPage.getHead()) ||
13799                                                    (status == wikiPage.getStatus())) {
13800                                            list = null;
13801    
13802                                            break;
13803                                    }
13804                            }
13805                    }
13806    
13807                    if (list == null) {
13808                            StringBundler query = null;
13809    
13810                            if (orderByComparator != null) {
13811                                    query = new StringBundler(5 +
13812                                                    (orderByComparator.getOrderByFields().length * 3));
13813                            }
13814                            else {
13815                                    query = new StringBundler(5);
13816                            }
13817    
13818                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
13819    
13820                            query.append(_FINDER_COLUMN_N_H_NOTS_NODEID_2);
13821    
13822                            query.append(_FINDER_COLUMN_N_H_NOTS_HEAD_2);
13823    
13824                            query.append(_FINDER_COLUMN_N_H_NOTS_STATUS_2);
13825    
13826                            if (orderByComparator != null) {
13827                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13828                                            orderByComparator);
13829                            }
13830                            else
13831                             if (pagination) {
13832                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13833                            }
13834    
13835                            String sql = query.toString();
13836    
13837                            Session session = null;
13838    
13839                            try {
13840                                    session = openSession();
13841    
13842                                    Query q = session.createQuery(sql);
13843    
13844                                    QueryPos qPos = QueryPos.getInstance(q);
13845    
13846                                    qPos.add(nodeId);
13847    
13848                                    qPos.add(head);
13849    
13850                                    qPos.add(status);
13851    
13852                                    if (!pagination) {
13853                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
13854                                                            start, end, false);
13855    
13856                                            Collections.sort(list);
13857    
13858                                            list = Collections.unmodifiableList(list);
13859                                    }
13860                                    else {
13861                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
13862                                                            start, end);
13863                                    }
13864    
13865                                    cacheResult(list);
13866    
13867                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13868                            }
13869                            catch (Exception e) {
13870                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13871    
13872                                    throw processException(e);
13873                            }
13874                            finally {
13875                                    closeSession(session);
13876                            }
13877                    }
13878    
13879                    return list;
13880            }
13881    
13882            /**
13883             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and status &ne; &#63;.
13884             *
13885             * @param nodeId the node ID
13886             * @param head the head
13887             * @param status the status
13888             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13889             * @return the first matching wiki page
13890             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
13891             */
13892            @Override
13893            public WikiPage findByN_H_NotS_First(long nodeId, boolean head, int status,
13894                    OrderByComparator<WikiPage> orderByComparator)
13895                    throws NoSuchPageException {
13896                    WikiPage wikiPage = fetchByN_H_NotS_First(nodeId, head, status,
13897                                    orderByComparator);
13898    
13899                    if (wikiPage != null) {
13900                            return wikiPage;
13901                    }
13902    
13903                    StringBundler msg = new StringBundler(8);
13904    
13905                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13906    
13907                    msg.append("nodeId=");
13908                    msg.append(nodeId);
13909    
13910                    msg.append(", head=");
13911                    msg.append(head);
13912    
13913                    msg.append(", status=");
13914                    msg.append(status);
13915    
13916                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13917    
13918                    throw new NoSuchPageException(msg.toString());
13919            }
13920    
13921            /**
13922             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and status &ne; &#63;.
13923             *
13924             * @param nodeId the node ID
13925             * @param head the head
13926             * @param status the status
13927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13928             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
13929             */
13930            @Override
13931            public WikiPage fetchByN_H_NotS_First(long nodeId, boolean head,
13932                    int status, OrderByComparator<WikiPage> orderByComparator) {
13933                    List<WikiPage> list = findByN_H_NotS(nodeId, head, status, 0, 1,
13934                                    orderByComparator);
13935    
13936                    if (!list.isEmpty()) {
13937                            return list.get(0);
13938                    }
13939    
13940                    return null;
13941            }
13942    
13943            /**
13944             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and status &ne; &#63;.
13945             *
13946             * @param nodeId the node ID
13947             * @param head the head
13948             * @param status the status
13949             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13950             * @return the last matching wiki page
13951             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
13952             */
13953            @Override
13954            public WikiPage findByN_H_NotS_Last(long nodeId, boolean head, int status,
13955                    OrderByComparator<WikiPage> orderByComparator)
13956                    throws NoSuchPageException {
13957                    WikiPage wikiPage = fetchByN_H_NotS_Last(nodeId, head, status,
13958                                    orderByComparator);
13959    
13960                    if (wikiPage != null) {
13961                            return wikiPage;
13962                    }
13963    
13964                    StringBundler msg = new StringBundler(8);
13965    
13966                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13967    
13968                    msg.append("nodeId=");
13969                    msg.append(nodeId);
13970    
13971                    msg.append(", head=");
13972                    msg.append(head);
13973    
13974                    msg.append(", status=");
13975                    msg.append(status);
13976    
13977                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13978    
13979                    throw new NoSuchPageException(msg.toString());
13980            }
13981    
13982            /**
13983             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and status &ne; &#63;.
13984             *
13985             * @param nodeId the node ID
13986             * @param head the head
13987             * @param status the status
13988             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13989             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
13990             */
13991            @Override
13992            public WikiPage fetchByN_H_NotS_Last(long nodeId, boolean head, int status,
13993                    OrderByComparator<WikiPage> orderByComparator) {
13994                    int count = countByN_H_NotS(nodeId, head, status);
13995    
13996                    if (count == 0) {
13997                            return null;
13998                    }
13999    
14000                    List<WikiPage> list = findByN_H_NotS(nodeId, head, status, count - 1,
14001                                    count, orderByComparator);
14002    
14003                    if (!list.isEmpty()) {
14004                            return list.get(0);
14005                    }
14006    
14007                    return null;
14008            }
14009    
14010            /**
14011             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and status &ne; &#63;.
14012             *
14013             * @param pageId the primary key of the current wiki page
14014             * @param nodeId the node ID
14015             * @param head the head
14016             * @param status the status
14017             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14018             * @return the previous, current, and next wiki page
14019             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
14020             */
14021            @Override
14022            public WikiPage[] findByN_H_NotS_PrevAndNext(long pageId, long nodeId,
14023                    boolean head, int status, OrderByComparator<WikiPage> orderByComparator)
14024                    throws NoSuchPageException {
14025                    WikiPage wikiPage = findByPrimaryKey(pageId);
14026    
14027                    Session session = null;
14028    
14029                    try {
14030                            session = openSession();
14031    
14032                            WikiPage[] array = new WikiPageImpl[3];
14033    
14034                            array[0] = getByN_H_NotS_PrevAndNext(session, wikiPage, nodeId,
14035                                            head, status, orderByComparator, true);
14036    
14037                            array[1] = wikiPage;
14038    
14039                            array[2] = getByN_H_NotS_PrevAndNext(session, wikiPage, nodeId,
14040                                            head, status, orderByComparator, false);
14041    
14042                            return array;
14043                    }
14044                    catch (Exception e) {
14045                            throw processException(e);
14046                    }
14047                    finally {
14048                            closeSession(session);
14049                    }
14050            }
14051    
14052            protected WikiPage getByN_H_NotS_PrevAndNext(Session session,
14053                    WikiPage wikiPage, long nodeId, boolean head, int status,
14054                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
14055                    StringBundler query = null;
14056    
14057                    if (orderByComparator != null) {
14058                            query = new StringBundler(6 +
14059                                            (orderByComparator.getOrderByFields().length * 6));
14060                    }
14061                    else {
14062                            query = new StringBundler(3);
14063                    }
14064    
14065                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
14066    
14067                    query.append(_FINDER_COLUMN_N_H_NOTS_NODEID_2);
14068    
14069                    query.append(_FINDER_COLUMN_N_H_NOTS_HEAD_2);
14070    
14071                    query.append(_FINDER_COLUMN_N_H_NOTS_STATUS_2);
14072    
14073                    if (orderByComparator != null) {
14074                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14075    
14076                            if (orderByConditionFields.length > 0) {
14077                                    query.append(WHERE_AND);
14078                            }
14079    
14080                            for (int i = 0; i < orderByConditionFields.length; i++) {
14081                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14082                                    query.append(orderByConditionFields[i]);
14083    
14084                                    if ((i + 1) < orderByConditionFields.length) {
14085                                            if (orderByComparator.isAscending() ^ previous) {
14086                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14087                                            }
14088                                            else {
14089                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14090                                            }
14091                                    }
14092                                    else {
14093                                            if (orderByComparator.isAscending() ^ previous) {
14094                                                    query.append(WHERE_GREATER_THAN);
14095                                            }
14096                                            else {
14097                                                    query.append(WHERE_LESSER_THAN);
14098                                            }
14099                                    }
14100                            }
14101    
14102                            query.append(ORDER_BY_CLAUSE);
14103    
14104                            String[] orderByFields = orderByComparator.getOrderByFields();
14105    
14106                            for (int i = 0; i < orderByFields.length; i++) {
14107                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14108                                    query.append(orderByFields[i]);
14109    
14110                                    if ((i + 1) < orderByFields.length) {
14111                                            if (orderByComparator.isAscending() ^ previous) {
14112                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14113                                            }
14114                                            else {
14115                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14116                                            }
14117                                    }
14118                                    else {
14119                                            if (orderByComparator.isAscending() ^ previous) {
14120                                                    query.append(ORDER_BY_ASC);
14121                                            }
14122                                            else {
14123                                                    query.append(ORDER_BY_DESC);
14124                                            }
14125                                    }
14126                            }
14127                    }
14128                    else {
14129                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
14130                    }
14131    
14132                    String sql = query.toString();
14133    
14134                    Query q = session.createQuery(sql);
14135    
14136                    q.setFirstResult(0);
14137                    q.setMaxResults(2);
14138    
14139                    QueryPos qPos = QueryPos.getInstance(q);
14140    
14141                    qPos.add(nodeId);
14142    
14143                    qPos.add(head);
14144    
14145                    qPos.add(status);
14146    
14147                    if (orderByComparator != null) {
14148                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
14149    
14150                            for (Object value : values) {
14151                                    qPos.add(value);
14152                            }
14153                    }
14154    
14155                    List<WikiPage> list = q.list();
14156    
14157                    if (list.size() == 2) {
14158                            return list.get(1);
14159                    }
14160                    else {
14161                            return null;
14162                    }
14163            }
14164    
14165            /**
14166             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and status &ne; &#63; from the database.
14167             *
14168             * @param nodeId the node ID
14169             * @param head the head
14170             * @param status the status
14171             */
14172            @Override
14173            public void removeByN_H_NotS(long nodeId, boolean head, int status) {
14174                    for (WikiPage wikiPage : findByN_H_NotS(nodeId, head, status,
14175                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14176                            remove(wikiPage);
14177                    }
14178            }
14179    
14180            /**
14181             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and status &ne; &#63;.
14182             *
14183             * @param nodeId the node ID
14184             * @param head the head
14185             * @param status the status
14186             * @return the number of matching wiki pages
14187             */
14188            @Override
14189            public int countByN_H_NotS(long nodeId, boolean head, int status) {
14190                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_N_H_NOTS;
14191    
14192                    Object[] finderArgs = new Object[] { nodeId, head, status };
14193    
14194                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14195                                    this);
14196    
14197                    if (count == null) {
14198                            StringBundler query = new StringBundler(4);
14199    
14200                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
14201    
14202                            query.append(_FINDER_COLUMN_N_H_NOTS_NODEID_2);
14203    
14204                            query.append(_FINDER_COLUMN_N_H_NOTS_HEAD_2);
14205    
14206                            query.append(_FINDER_COLUMN_N_H_NOTS_STATUS_2);
14207    
14208                            String sql = query.toString();
14209    
14210                            Session session = null;
14211    
14212                            try {
14213                                    session = openSession();
14214    
14215                                    Query q = session.createQuery(sql);
14216    
14217                                    QueryPos qPos = QueryPos.getInstance(q);
14218    
14219                                    qPos.add(nodeId);
14220    
14221                                    qPos.add(head);
14222    
14223                                    qPos.add(status);
14224    
14225                                    count = (Long)q.uniqueResult();
14226    
14227                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14228                            }
14229                            catch (Exception e) {
14230                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14231    
14232                                    throw processException(e);
14233                            }
14234                            finally {
14235                                    closeSession(session);
14236                            }
14237                    }
14238    
14239                    return count.intValue();
14240            }
14241    
14242            private static final String _FINDER_COLUMN_N_H_NOTS_NODEID_2 = "wikiPage.nodeId = ? AND ";
14243            private static final String _FINDER_COLUMN_N_H_NOTS_HEAD_2 = "wikiPage.head = ? AND ";
14244            private static final String _FINDER_COLUMN_N_H_NOTS_STATUS_2 = "wikiPage.status != ?";
14245            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
14246                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
14247                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_N_S",
14248                            new String[] {
14249                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
14250                                    Integer.class.getName(),
14251                                    
14252                            Integer.class.getName(), Integer.class.getName(),
14253                                    OrderByComparator.class.getName()
14254                            });
14255            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S =
14256                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
14257                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
14258                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_N_S",
14259                            new String[] {
14260                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
14261                                    Integer.class.getName()
14262                            },
14263                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
14264                            WikiPageModelImpl.USERID_COLUMN_BITMASK |
14265                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
14266                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
14267                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
14268                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
14269            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
14270                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
14271                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_N_S",
14272                            new String[] {
14273                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
14274                                    Integer.class.getName()
14275                            });
14276    
14277            /**
14278             * Returns all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14279             *
14280             * @param groupId the group ID
14281             * @param userId the user ID
14282             * @param nodeId the node ID
14283             * @param status the status
14284             * @return the matching wiki pages
14285             */
14286            @Override
14287            public List<WikiPage> findByG_U_N_S(long groupId, long userId, long nodeId,
14288                    int status) {
14289                    return findByG_U_N_S(groupId, userId, nodeId, status,
14290                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14291            }
14292    
14293            /**
14294             * Returns a range of all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14295             *
14296             * <p>
14297             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
14298             * </p>
14299             *
14300             * @param groupId the group ID
14301             * @param userId the user ID
14302             * @param nodeId the node ID
14303             * @param status the status
14304             * @param start the lower bound of the range of wiki pages
14305             * @param end the upper bound of the range of wiki pages (not inclusive)
14306             * @return the range of matching wiki pages
14307             */
14308            @Override
14309            public List<WikiPage> findByG_U_N_S(long groupId, long userId, long nodeId,
14310                    int status, int start, int end) {
14311                    return findByG_U_N_S(groupId, userId, nodeId, status, start, end, null);
14312            }
14313    
14314            /**
14315             * Returns an ordered range of all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14316             *
14317             * <p>
14318             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
14319             * </p>
14320             *
14321             * @param groupId the group ID
14322             * @param userId the user ID
14323             * @param nodeId the node ID
14324             * @param status the status
14325             * @param start the lower bound of the range of wiki pages
14326             * @param end the upper bound of the range of wiki pages (not inclusive)
14327             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14328             * @return the ordered range of matching wiki pages
14329             */
14330            @Override
14331            public List<WikiPage> findByG_U_N_S(long groupId, long userId, long nodeId,
14332                    int status, int start, int end,
14333                    OrderByComparator<WikiPage> orderByComparator) {
14334                    boolean pagination = true;
14335                    FinderPath finderPath = null;
14336                    Object[] finderArgs = null;
14337    
14338                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14339                                    (orderByComparator == null)) {
14340                            pagination = false;
14341                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S;
14342                            finderArgs = new Object[] { groupId, userId, nodeId, status };
14343                    }
14344                    else {
14345                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_N_S;
14346                            finderArgs = new Object[] {
14347                                            groupId, userId, nodeId, status,
14348                                            
14349                                            start, end, orderByComparator
14350                                    };
14351                    }
14352    
14353                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
14354                                    finderArgs, this);
14355    
14356                    if ((list != null) && !list.isEmpty()) {
14357                            for (WikiPage wikiPage : list) {
14358                                    if ((groupId != wikiPage.getGroupId()) ||
14359                                                    (userId != wikiPage.getUserId()) ||
14360                                                    (nodeId != wikiPage.getNodeId()) ||
14361                                                    (status != wikiPage.getStatus())) {
14362                                            list = null;
14363    
14364                                            break;
14365                                    }
14366                            }
14367                    }
14368    
14369                    if (list == null) {
14370                            StringBundler query = null;
14371    
14372                            if (orderByComparator != null) {
14373                                    query = new StringBundler(6 +
14374                                                    (orderByComparator.getOrderByFields().length * 3));
14375                            }
14376                            else {
14377                                    query = new StringBundler(6);
14378                            }
14379    
14380                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
14381    
14382                            query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
14383    
14384                            query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
14385    
14386                            query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
14387    
14388                            query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
14389    
14390                            if (orderByComparator != null) {
14391                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14392                                            orderByComparator);
14393                            }
14394                            else
14395                             if (pagination) {
14396                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
14397                            }
14398    
14399                            String sql = query.toString();
14400    
14401                            Session session = null;
14402    
14403                            try {
14404                                    session = openSession();
14405    
14406                                    Query q = session.createQuery(sql);
14407    
14408                                    QueryPos qPos = QueryPos.getInstance(q);
14409    
14410                                    qPos.add(groupId);
14411    
14412                                    qPos.add(userId);
14413    
14414                                    qPos.add(nodeId);
14415    
14416                                    qPos.add(status);
14417    
14418                                    if (!pagination) {
14419                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
14420                                                            start, end, false);
14421    
14422                                            Collections.sort(list);
14423    
14424                                            list = Collections.unmodifiableList(list);
14425                                    }
14426                                    else {
14427                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
14428                                                            start, end);
14429                                    }
14430    
14431                                    cacheResult(list);
14432    
14433                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14434                            }
14435                            catch (Exception e) {
14436                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14437    
14438                                    throw processException(e);
14439                            }
14440                            finally {
14441                                    closeSession(session);
14442                            }
14443                    }
14444    
14445                    return list;
14446            }
14447    
14448            /**
14449             * Returns the first wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14450             *
14451             * @param groupId the group ID
14452             * @param userId the user ID
14453             * @param nodeId the node ID
14454             * @param status the status
14455             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14456             * @return the first matching wiki page
14457             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
14458             */
14459            @Override
14460            public WikiPage findByG_U_N_S_First(long groupId, long userId, long nodeId,
14461                    int status, OrderByComparator<WikiPage> orderByComparator)
14462                    throws NoSuchPageException {
14463                    WikiPage wikiPage = fetchByG_U_N_S_First(groupId, userId, nodeId,
14464                                    status, orderByComparator);
14465    
14466                    if (wikiPage != null) {
14467                            return wikiPage;
14468                    }
14469    
14470                    StringBundler msg = new StringBundler(10);
14471    
14472                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14473    
14474                    msg.append("groupId=");
14475                    msg.append(groupId);
14476    
14477                    msg.append(", userId=");
14478                    msg.append(userId);
14479    
14480                    msg.append(", nodeId=");
14481                    msg.append(nodeId);
14482    
14483                    msg.append(", status=");
14484                    msg.append(status);
14485    
14486                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14487    
14488                    throw new NoSuchPageException(msg.toString());
14489            }
14490    
14491            /**
14492             * Returns the first wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14493             *
14494             * @param groupId the group ID
14495             * @param userId the user ID
14496             * @param nodeId the node ID
14497             * @param status the status
14498             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14499             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
14500             */
14501            @Override
14502            public WikiPage fetchByG_U_N_S_First(long groupId, long userId,
14503                    long nodeId, int status, OrderByComparator<WikiPage> orderByComparator) {
14504                    List<WikiPage> list = findByG_U_N_S(groupId, userId, nodeId, status, 0,
14505                                    1, orderByComparator);
14506    
14507                    if (!list.isEmpty()) {
14508                            return list.get(0);
14509                    }
14510    
14511                    return null;
14512            }
14513    
14514            /**
14515             * Returns the last wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14516             *
14517             * @param groupId the group ID
14518             * @param userId the user ID
14519             * @param nodeId the node ID
14520             * @param status the status
14521             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14522             * @return the last matching wiki page
14523             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
14524             */
14525            @Override
14526            public WikiPage findByG_U_N_S_Last(long groupId, long userId, long nodeId,
14527                    int status, OrderByComparator<WikiPage> orderByComparator)
14528                    throws NoSuchPageException {
14529                    WikiPage wikiPage = fetchByG_U_N_S_Last(groupId, userId, nodeId,
14530                                    status, orderByComparator);
14531    
14532                    if (wikiPage != null) {
14533                            return wikiPage;
14534                    }
14535    
14536                    StringBundler msg = new StringBundler(10);
14537    
14538                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14539    
14540                    msg.append("groupId=");
14541                    msg.append(groupId);
14542    
14543                    msg.append(", userId=");
14544                    msg.append(userId);
14545    
14546                    msg.append(", nodeId=");
14547                    msg.append(nodeId);
14548    
14549                    msg.append(", status=");
14550                    msg.append(status);
14551    
14552                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14553    
14554                    throw new NoSuchPageException(msg.toString());
14555            }
14556    
14557            /**
14558             * Returns the last wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14559             *
14560             * @param groupId the group ID
14561             * @param userId the user ID
14562             * @param nodeId the node ID
14563             * @param status the status
14564             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14565             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
14566             */
14567            @Override
14568            public WikiPage fetchByG_U_N_S_Last(long groupId, long userId, long nodeId,
14569                    int status, OrderByComparator<WikiPage> orderByComparator) {
14570                    int count = countByG_U_N_S(groupId, userId, nodeId, status);
14571    
14572                    if (count == 0) {
14573                            return null;
14574                    }
14575    
14576                    List<WikiPage> list = findByG_U_N_S(groupId, userId, nodeId, status,
14577                                    count - 1, count, orderByComparator);
14578    
14579                    if (!list.isEmpty()) {
14580                            return list.get(0);
14581                    }
14582    
14583                    return null;
14584            }
14585    
14586            /**
14587             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14588             *
14589             * @param pageId the primary key of the current wiki page
14590             * @param groupId the group ID
14591             * @param userId the user ID
14592             * @param nodeId the node ID
14593             * @param status the status
14594             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14595             * @return the previous, current, and next wiki page
14596             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
14597             */
14598            @Override
14599            public WikiPage[] findByG_U_N_S_PrevAndNext(long pageId, long groupId,
14600                    long userId, long nodeId, int status,
14601                    OrderByComparator<WikiPage> orderByComparator)
14602                    throws NoSuchPageException {
14603                    WikiPage wikiPage = findByPrimaryKey(pageId);
14604    
14605                    Session session = null;
14606    
14607                    try {
14608                            session = openSession();
14609    
14610                            WikiPage[] array = new WikiPageImpl[3];
14611    
14612                            array[0] = getByG_U_N_S_PrevAndNext(session, wikiPage, groupId,
14613                                            userId, nodeId, status, orderByComparator, true);
14614    
14615                            array[1] = wikiPage;
14616    
14617                            array[2] = getByG_U_N_S_PrevAndNext(session, wikiPage, groupId,
14618                                            userId, nodeId, status, orderByComparator, false);
14619    
14620                            return array;
14621                    }
14622                    catch (Exception e) {
14623                            throw processException(e);
14624                    }
14625                    finally {
14626                            closeSession(session);
14627                    }
14628            }
14629    
14630            protected WikiPage getByG_U_N_S_PrevAndNext(Session session,
14631                    WikiPage wikiPage, long groupId, long userId, long nodeId, int status,
14632                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
14633                    StringBundler query = null;
14634    
14635                    if (orderByComparator != null) {
14636                            query = new StringBundler(6 +
14637                                            (orderByComparator.getOrderByFields().length * 6));
14638                    }
14639                    else {
14640                            query = new StringBundler(3);
14641                    }
14642    
14643                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
14644    
14645                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
14646    
14647                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
14648    
14649                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
14650    
14651                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
14652    
14653                    if (orderByComparator != null) {
14654                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14655    
14656                            if (orderByConditionFields.length > 0) {
14657                                    query.append(WHERE_AND);
14658                            }
14659    
14660                            for (int i = 0; i < orderByConditionFields.length; i++) {
14661                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14662                                    query.append(orderByConditionFields[i]);
14663    
14664                                    if ((i + 1) < orderByConditionFields.length) {
14665                                            if (orderByComparator.isAscending() ^ previous) {
14666                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14667                                            }
14668                                            else {
14669                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14670                                            }
14671                                    }
14672                                    else {
14673                                            if (orderByComparator.isAscending() ^ previous) {
14674                                                    query.append(WHERE_GREATER_THAN);
14675                                            }
14676                                            else {
14677                                                    query.append(WHERE_LESSER_THAN);
14678                                            }
14679                                    }
14680                            }
14681    
14682                            query.append(ORDER_BY_CLAUSE);
14683    
14684                            String[] orderByFields = orderByComparator.getOrderByFields();
14685    
14686                            for (int i = 0; i < orderByFields.length; i++) {
14687                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14688                                    query.append(orderByFields[i]);
14689    
14690                                    if ((i + 1) < orderByFields.length) {
14691                                            if (orderByComparator.isAscending() ^ previous) {
14692                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14693                                            }
14694                                            else {
14695                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14696                                            }
14697                                    }
14698                                    else {
14699                                            if (orderByComparator.isAscending() ^ previous) {
14700                                                    query.append(ORDER_BY_ASC);
14701                                            }
14702                                            else {
14703                                                    query.append(ORDER_BY_DESC);
14704                                            }
14705                                    }
14706                            }
14707                    }
14708                    else {
14709                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
14710                    }
14711    
14712                    String sql = query.toString();
14713    
14714                    Query q = session.createQuery(sql);
14715    
14716                    q.setFirstResult(0);
14717                    q.setMaxResults(2);
14718    
14719                    QueryPos qPos = QueryPos.getInstance(q);
14720    
14721                    qPos.add(groupId);
14722    
14723                    qPos.add(userId);
14724    
14725                    qPos.add(nodeId);
14726    
14727                    qPos.add(status);
14728    
14729                    if (orderByComparator != null) {
14730                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
14731    
14732                            for (Object value : values) {
14733                                    qPos.add(value);
14734                            }
14735                    }
14736    
14737                    List<WikiPage> list = q.list();
14738    
14739                    if (list.size() == 2) {
14740                            return list.get(1);
14741                    }
14742                    else {
14743                            return null;
14744                    }
14745            }
14746    
14747            /**
14748             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14749             *
14750             * @param groupId the group ID
14751             * @param userId the user ID
14752             * @param nodeId the node ID
14753             * @param status the status
14754             * @return the matching wiki pages that the user has permission to view
14755             */
14756            @Override
14757            public List<WikiPage> filterFindByG_U_N_S(long groupId, long userId,
14758                    long nodeId, int status) {
14759                    return filterFindByG_U_N_S(groupId, userId, nodeId, status,
14760                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14761            }
14762    
14763            /**
14764             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14765             *
14766             * <p>
14767             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
14768             * </p>
14769             *
14770             * @param groupId the group ID
14771             * @param userId the user ID
14772             * @param nodeId the node ID
14773             * @param status the status
14774             * @param start the lower bound of the range of wiki pages
14775             * @param end the upper bound of the range of wiki pages (not inclusive)
14776             * @return the range of matching wiki pages that the user has permission to view
14777             */
14778            @Override
14779            public List<WikiPage> filterFindByG_U_N_S(long groupId, long userId,
14780                    long nodeId, int status, int start, int end) {
14781                    return filterFindByG_U_N_S(groupId, userId, nodeId, status, start, end,
14782                            null);
14783            }
14784    
14785            /**
14786             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14787             *
14788             * <p>
14789             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
14790             * </p>
14791             *
14792             * @param groupId the group ID
14793             * @param userId the user ID
14794             * @param nodeId the node ID
14795             * @param status the status
14796             * @param start the lower bound of the range of wiki pages
14797             * @param end the upper bound of the range of wiki pages (not inclusive)
14798             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14799             * @return the ordered range of matching wiki pages that the user has permission to view
14800             */
14801            @Override
14802            public List<WikiPage> filterFindByG_U_N_S(long groupId, long userId,
14803                    long nodeId, int status, int start, int end,
14804                    OrderByComparator<WikiPage> orderByComparator) {
14805                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14806                            return findByG_U_N_S(groupId, userId, nodeId, status, start, end,
14807                                    orderByComparator);
14808                    }
14809    
14810                    StringBundler query = null;
14811    
14812                    if (orderByComparator != null) {
14813                            query = new StringBundler(6 +
14814                                            (orderByComparator.getOrderByFields().length * 3));
14815                    }
14816                    else {
14817                            query = new StringBundler(6);
14818                    }
14819    
14820                    if (getDB().isSupportsInlineDistinct()) {
14821                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
14822                    }
14823                    else {
14824                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
14825                    }
14826    
14827                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
14828    
14829                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
14830    
14831                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
14832    
14833                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
14834    
14835                    if (!getDB().isSupportsInlineDistinct()) {
14836                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
14837                    }
14838    
14839                    if (orderByComparator != null) {
14840                            if (getDB().isSupportsInlineDistinct()) {
14841                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14842                                            orderByComparator, true);
14843                            }
14844                            else {
14845                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14846                                            orderByComparator, true);
14847                            }
14848                    }
14849                    else {
14850                            if (getDB().isSupportsInlineDistinct()) {
14851                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
14852                            }
14853                            else {
14854                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
14855                            }
14856                    }
14857    
14858                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14859                                    WikiPage.class.getName(),
14860                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14861    
14862                    Session session = null;
14863    
14864                    try {
14865                            session = openSession();
14866    
14867                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
14868    
14869                            if (getDB().isSupportsInlineDistinct()) {
14870                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
14871                            }
14872                            else {
14873                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
14874                            }
14875    
14876                            QueryPos qPos = QueryPos.getInstance(q);
14877    
14878                            qPos.add(groupId);
14879    
14880                            qPos.add(userId);
14881    
14882                            qPos.add(nodeId);
14883    
14884                            qPos.add(status);
14885    
14886                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
14887                    }
14888                    catch (Exception e) {
14889                            throw processException(e);
14890                    }
14891                    finally {
14892                            closeSession(session);
14893                    }
14894            }
14895    
14896            /**
14897             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
14898             *
14899             * @param pageId the primary key of the current wiki page
14900             * @param groupId the group ID
14901             * @param userId the user ID
14902             * @param nodeId the node ID
14903             * @param status the status
14904             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14905             * @return the previous, current, and next wiki page
14906             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
14907             */
14908            @Override
14909            public WikiPage[] filterFindByG_U_N_S_PrevAndNext(long pageId,
14910                    long groupId, long userId, long nodeId, int status,
14911                    OrderByComparator<WikiPage> orderByComparator)
14912                    throws NoSuchPageException {
14913                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14914                            return findByG_U_N_S_PrevAndNext(pageId, groupId, userId, nodeId,
14915                                    status, orderByComparator);
14916                    }
14917    
14918                    WikiPage wikiPage = findByPrimaryKey(pageId);
14919    
14920                    Session session = null;
14921    
14922                    try {
14923                            session = openSession();
14924    
14925                            WikiPage[] array = new WikiPageImpl[3];
14926    
14927                            array[0] = filterGetByG_U_N_S_PrevAndNext(session, wikiPage,
14928                                            groupId, userId, nodeId, status, orderByComparator, true);
14929    
14930                            array[1] = wikiPage;
14931    
14932                            array[2] = filterGetByG_U_N_S_PrevAndNext(session, wikiPage,
14933                                            groupId, userId, nodeId, status, orderByComparator, false);
14934    
14935                            return array;
14936                    }
14937                    catch (Exception e) {
14938                            throw processException(e);
14939                    }
14940                    finally {
14941                            closeSession(session);
14942                    }
14943            }
14944    
14945            protected WikiPage filterGetByG_U_N_S_PrevAndNext(Session session,
14946                    WikiPage wikiPage, long groupId, long userId, long nodeId, int status,
14947                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
14948                    StringBundler query = null;
14949    
14950                    if (orderByComparator != null) {
14951                            query = new StringBundler(6 +
14952                                            (orderByComparator.getOrderByFields().length * 6));
14953                    }
14954                    else {
14955                            query = new StringBundler(3);
14956                    }
14957    
14958                    if (getDB().isSupportsInlineDistinct()) {
14959                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
14960                    }
14961                    else {
14962                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
14963                    }
14964    
14965                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
14966    
14967                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
14968    
14969                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
14970    
14971                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
14972    
14973                    if (!getDB().isSupportsInlineDistinct()) {
14974                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
14975                    }
14976    
14977                    if (orderByComparator != null) {
14978                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14979    
14980                            if (orderByConditionFields.length > 0) {
14981                                    query.append(WHERE_AND);
14982                            }
14983    
14984                            for (int i = 0; i < orderByConditionFields.length; i++) {
14985                                    if (getDB().isSupportsInlineDistinct()) {
14986                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14987                                    }
14988                                    else {
14989                                            query.append(_ORDER_BY_ENTITY_TABLE);
14990                                    }
14991    
14992                                    query.append(orderByConditionFields[i]);
14993    
14994                                    if ((i + 1) < orderByConditionFields.length) {
14995                                            if (orderByComparator.isAscending() ^ previous) {
14996                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14997                                            }
14998                                            else {
14999                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15000                                            }
15001                                    }
15002                                    else {
15003                                            if (orderByComparator.isAscending() ^ previous) {
15004                                                    query.append(WHERE_GREATER_THAN);
15005                                            }
15006                                            else {
15007                                                    query.append(WHERE_LESSER_THAN);
15008                                            }
15009                                    }
15010                            }
15011    
15012                            query.append(ORDER_BY_CLAUSE);
15013    
15014                            String[] orderByFields = orderByComparator.getOrderByFields();
15015    
15016                            for (int i = 0; i < orderByFields.length; i++) {
15017                                    if (getDB().isSupportsInlineDistinct()) {
15018                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15019                                    }
15020                                    else {
15021                                            query.append(_ORDER_BY_ENTITY_TABLE);
15022                                    }
15023    
15024                                    query.append(orderByFields[i]);
15025    
15026                                    if ((i + 1) < orderByFields.length) {
15027                                            if (orderByComparator.isAscending() ^ previous) {
15028                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15029                                            }
15030                                            else {
15031                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15032                                            }
15033                                    }
15034                                    else {
15035                                            if (orderByComparator.isAscending() ^ previous) {
15036                                                    query.append(ORDER_BY_ASC);
15037                                            }
15038                                            else {
15039                                                    query.append(ORDER_BY_DESC);
15040                                            }
15041                                    }
15042                            }
15043                    }
15044                    else {
15045                            if (getDB().isSupportsInlineDistinct()) {
15046                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
15047                            }
15048                            else {
15049                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
15050                            }
15051                    }
15052    
15053                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15054                                    WikiPage.class.getName(),
15055                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15056    
15057                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
15058    
15059                    q.setFirstResult(0);
15060                    q.setMaxResults(2);
15061    
15062                    if (getDB().isSupportsInlineDistinct()) {
15063                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
15064                    }
15065                    else {
15066                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
15067                    }
15068    
15069                    QueryPos qPos = QueryPos.getInstance(q);
15070    
15071                    qPos.add(groupId);
15072    
15073                    qPos.add(userId);
15074    
15075                    qPos.add(nodeId);
15076    
15077                    qPos.add(status);
15078    
15079                    if (orderByComparator != null) {
15080                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
15081    
15082                            for (Object value : values) {
15083                                    qPos.add(value);
15084                            }
15085                    }
15086    
15087                    List<WikiPage> list = q.list();
15088    
15089                    if (list.size() == 2) {
15090                            return list.get(1);
15091                    }
15092                    else {
15093                            return null;
15094                    }
15095            }
15096    
15097            /**
15098             * Removes all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63; from the database.
15099             *
15100             * @param groupId the group ID
15101             * @param userId the user ID
15102             * @param nodeId the node ID
15103             * @param status the status
15104             */
15105            @Override
15106            public void removeByG_U_N_S(long groupId, long userId, long nodeId,
15107                    int status) {
15108                    for (WikiPage wikiPage : findByG_U_N_S(groupId, userId, nodeId, status,
15109                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15110                            remove(wikiPage);
15111                    }
15112            }
15113    
15114            /**
15115             * Returns the number of wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
15116             *
15117             * @param groupId the group ID
15118             * @param userId the user ID
15119             * @param nodeId the node ID
15120             * @param status the status
15121             * @return the number of matching wiki pages
15122             */
15123            @Override
15124            public int countByG_U_N_S(long groupId, long userId, long nodeId, int status) {
15125                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_N_S;
15126    
15127                    Object[] finderArgs = new Object[] { groupId, userId, nodeId, status };
15128    
15129                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15130                                    this);
15131    
15132                    if (count == null) {
15133                            StringBundler query = new StringBundler(5);
15134    
15135                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15136    
15137                            query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
15138    
15139                            query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
15140    
15141                            query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
15142    
15143                            query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
15144    
15145                            String sql = query.toString();
15146    
15147                            Session session = null;
15148    
15149                            try {
15150                                    session = openSession();
15151    
15152                                    Query q = session.createQuery(sql);
15153    
15154                                    QueryPos qPos = QueryPos.getInstance(q);
15155    
15156                                    qPos.add(groupId);
15157    
15158                                    qPos.add(userId);
15159    
15160                                    qPos.add(nodeId);
15161    
15162                                    qPos.add(status);
15163    
15164                                    count = (Long)q.uniqueResult();
15165    
15166                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15167                            }
15168                            catch (Exception e) {
15169                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15170    
15171                                    throw processException(e);
15172                            }
15173                            finally {
15174                                    closeSession(session);
15175                            }
15176                    }
15177    
15178                    return count.intValue();
15179            }
15180    
15181            /**
15182             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
15183             *
15184             * @param groupId the group ID
15185             * @param userId the user ID
15186             * @param nodeId the node ID
15187             * @param status the status
15188             * @return the number of matching wiki pages that the user has permission to view
15189             */
15190            @Override
15191            public int filterCountByG_U_N_S(long groupId, long userId, long nodeId,
15192                    int status) {
15193                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15194                            return countByG_U_N_S(groupId, userId, nodeId, status);
15195                    }
15196    
15197                    StringBundler query = new StringBundler(5);
15198    
15199                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
15200    
15201                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
15202    
15203                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
15204    
15205                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
15206    
15207                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
15208    
15209                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15210                                    WikiPage.class.getName(),
15211                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15212    
15213                    Session session = null;
15214    
15215                    try {
15216                            session = openSession();
15217    
15218                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
15219    
15220                            q.addScalar(COUNT_COLUMN_NAME,
15221                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15222    
15223                            QueryPos qPos = QueryPos.getInstance(q);
15224    
15225                            qPos.add(groupId);
15226    
15227                            qPos.add(userId);
15228    
15229                            qPos.add(nodeId);
15230    
15231                            qPos.add(status);
15232    
15233                            Long count = (Long)q.uniqueResult();
15234    
15235                            return count.intValue();
15236                    }
15237                    catch (Exception e) {
15238                            throw processException(e);
15239                    }
15240                    finally {
15241                            closeSession(session);
15242                    }
15243            }
15244    
15245            private static final String _FINDER_COLUMN_G_U_N_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
15246            private static final String _FINDER_COLUMN_G_U_N_S_USERID_2 = "wikiPage.userId = ? AND ";
15247            private static final String _FINDER_COLUMN_G_U_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
15248            private static final String _FINDER_COLUMN_G_U_N_S_STATUS_2 = "wikiPage.status = ?";
15249            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
15250                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
15251                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_T_H",
15252                            new String[] {
15253                                    Long.class.getName(), Long.class.getName(),
15254                                    String.class.getName(), Boolean.class.getName(),
15255                                    
15256                            Integer.class.getName(), Integer.class.getName(),
15257                                    OrderByComparator.class.getName()
15258                            });
15259            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H =
15260                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
15261                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
15262                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_T_H",
15263                            new String[] {
15264                                    Long.class.getName(), Long.class.getName(),
15265                                    String.class.getName(), Boolean.class.getName()
15266                            },
15267                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
15268                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
15269                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
15270                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
15271                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
15272            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
15273                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
15274                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_T_H",
15275                            new String[] {
15276                                    Long.class.getName(), Long.class.getName(),
15277                                    String.class.getName(), Boolean.class.getName()
15278                            });
15279    
15280            /**
15281             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15282             *
15283             * @param groupId the group ID
15284             * @param nodeId the node ID
15285             * @param title the title
15286             * @param head the head
15287             * @return the matching wiki pages
15288             */
15289            @Override
15290            public List<WikiPage> findByG_N_T_H(long groupId, long nodeId,
15291                    String title, boolean head) {
15292                    return findByG_N_T_H(groupId, nodeId, title, head, QueryUtil.ALL_POS,
15293                            QueryUtil.ALL_POS, null);
15294            }
15295    
15296            /**
15297             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15298             *
15299             * <p>
15300             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
15301             * </p>
15302             *
15303             * @param groupId the group ID
15304             * @param nodeId the node ID
15305             * @param title the title
15306             * @param head the head
15307             * @param start the lower bound of the range of wiki pages
15308             * @param end the upper bound of the range of wiki pages (not inclusive)
15309             * @return the range of matching wiki pages
15310             */
15311            @Override
15312            public List<WikiPage> findByG_N_T_H(long groupId, long nodeId,
15313                    String title, boolean head, int start, int end) {
15314                    return findByG_N_T_H(groupId, nodeId, title, head, start, end, null);
15315            }
15316    
15317            /**
15318             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15319             *
15320             * <p>
15321             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
15322             * </p>
15323             *
15324             * @param groupId the group ID
15325             * @param nodeId the node ID
15326             * @param title the title
15327             * @param head the head
15328             * @param start the lower bound of the range of wiki pages
15329             * @param end the upper bound of the range of wiki pages (not inclusive)
15330             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15331             * @return the ordered range of matching wiki pages
15332             */
15333            @Override
15334            public List<WikiPage> findByG_N_T_H(long groupId, long nodeId,
15335                    String title, boolean head, int start, int end,
15336                    OrderByComparator<WikiPage> orderByComparator) {
15337                    boolean pagination = true;
15338                    FinderPath finderPath = null;
15339                    Object[] finderArgs = null;
15340    
15341                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15342                                    (orderByComparator == null)) {
15343                            pagination = false;
15344                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H;
15345                            finderArgs = new Object[] { groupId, nodeId, title, head };
15346                    }
15347                    else {
15348                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_T_H;
15349                            finderArgs = new Object[] {
15350                                            groupId, nodeId, title, head,
15351                                            
15352                                            start, end, orderByComparator
15353                                    };
15354                    }
15355    
15356                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
15357                                    finderArgs, this);
15358    
15359                    if ((list != null) && !list.isEmpty()) {
15360                            for (WikiPage wikiPage : list) {
15361                                    if ((groupId != wikiPage.getGroupId()) ||
15362                                                    (nodeId != wikiPage.getNodeId()) ||
15363                                                    !Validator.equals(title, wikiPage.getTitle()) ||
15364                                                    (head != wikiPage.getHead())) {
15365                                            list = null;
15366    
15367                                            break;
15368                                    }
15369                            }
15370                    }
15371    
15372                    if (list == null) {
15373                            StringBundler query = null;
15374    
15375                            if (orderByComparator != null) {
15376                                    query = new StringBundler(6 +
15377                                                    (orderByComparator.getOrderByFields().length * 3));
15378                            }
15379                            else {
15380                                    query = new StringBundler(6);
15381                            }
15382    
15383                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
15384    
15385                            query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
15386    
15387                            query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
15388    
15389                            boolean bindTitle = false;
15390    
15391                            if (title == null) {
15392                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
15393                            }
15394                            else if (title.equals(StringPool.BLANK)) {
15395                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
15396                            }
15397                            else {
15398                                    bindTitle = true;
15399    
15400                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
15401                            }
15402    
15403                            query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
15404    
15405                            if (orderByComparator != null) {
15406                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15407                                            orderByComparator);
15408                            }
15409                            else
15410                             if (pagination) {
15411                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
15412                            }
15413    
15414                            String sql = query.toString();
15415    
15416                            Session session = null;
15417    
15418                            try {
15419                                    session = openSession();
15420    
15421                                    Query q = session.createQuery(sql);
15422    
15423                                    QueryPos qPos = QueryPos.getInstance(q);
15424    
15425                                    qPos.add(groupId);
15426    
15427                                    qPos.add(nodeId);
15428    
15429                                    if (bindTitle) {
15430                                            qPos.add(StringUtil.toLowerCase(title));
15431                                    }
15432    
15433                                    qPos.add(head);
15434    
15435                                    if (!pagination) {
15436                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
15437                                                            start, end, false);
15438    
15439                                            Collections.sort(list);
15440    
15441                                            list = Collections.unmodifiableList(list);
15442                                    }
15443                                    else {
15444                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
15445                                                            start, end);
15446                                    }
15447    
15448                                    cacheResult(list);
15449    
15450                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15451                            }
15452                            catch (Exception e) {
15453                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15454    
15455                                    throw processException(e);
15456                            }
15457                            finally {
15458                                    closeSession(session);
15459                            }
15460                    }
15461    
15462                    return list;
15463            }
15464    
15465            /**
15466             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15467             *
15468             * @param groupId the group ID
15469             * @param nodeId the node ID
15470             * @param title the title
15471             * @param head the head
15472             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15473             * @return the first matching wiki page
15474             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
15475             */
15476            @Override
15477            public WikiPage findByG_N_T_H_First(long groupId, long nodeId,
15478                    String title, boolean head,
15479                    OrderByComparator<WikiPage> orderByComparator)
15480                    throws NoSuchPageException {
15481                    WikiPage wikiPage = fetchByG_N_T_H_First(groupId, nodeId, title, head,
15482                                    orderByComparator);
15483    
15484                    if (wikiPage != null) {
15485                            return wikiPage;
15486                    }
15487    
15488                    StringBundler msg = new StringBundler(10);
15489    
15490                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15491    
15492                    msg.append("groupId=");
15493                    msg.append(groupId);
15494    
15495                    msg.append(", nodeId=");
15496                    msg.append(nodeId);
15497    
15498                    msg.append(", title=");
15499                    msg.append(title);
15500    
15501                    msg.append(", head=");
15502                    msg.append(head);
15503    
15504                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15505    
15506                    throw new NoSuchPageException(msg.toString());
15507            }
15508    
15509            /**
15510             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15511             *
15512             * @param groupId the group ID
15513             * @param nodeId the node ID
15514             * @param title the title
15515             * @param head the head
15516             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15517             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
15518             */
15519            @Override
15520            public WikiPage fetchByG_N_T_H_First(long groupId, long nodeId,
15521                    String title, boolean head,
15522                    OrderByComparator<WikiPage> orderByComparator) {
15523                    List<WikiPage> list = findByG_N_T_H(groupId, nodeId, title, head, 0, 1,
15524                                    orderByComparator);
15525    
15526                    if (!list.isEmpty()) {
15527                            return list.get(0);
15528                    }
15529    
15530                    return null;
15531            }
15532    
15533            /**
15534             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15535             *
15536             * @param groupId the group ID
15537             * @param nodeId the node ID
15538             * @param title the title
15539             * @param head the head
15540             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15541             * @return the last matching wiki page
15542             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
15543             */
15544            @Override
15545            public WikiPage findByG_N_T_H_Last(long groupId, long nodeId, String title,
15546                    boolean head, OrderByComparator<WikiPage> orderByComparator)
15547                    throws NoSuchPageException {
15548                    WikiPage wikiPage = fetchByG_N_T_H_Last(groupId, nodeId, title, head,
15549                                    orderByComparator);
15550    
15551                    if (wikiPage != null) {
15552                            return wikiPage;
15553                    }
15554    
15555                    StringBundler msg = new StringBundler(10);
15556    
15557                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15558    
15559                    msg.append("groupId=");
15560                    msg.append(groupId);
15561    
15562                    msg.append(", nodeId=");
15563                    msg.append(nodeId);
15564    
15565                    msg.append(", title=");
15566                    msg.append(title);
15567    
15568                    msg.append(", head=");
15569                    msg.append(head);
15570    
15571                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15572    
15573                    throw new NoSuchPageException(msg.toString());
15574            }
15575    
15576            /**
15577             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15578             *
15579             * @param groupId the group ID
15580             * @param nodeId the node ID
15581             * @param title the title
15582             * @param head the head
15583             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15584             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
15585             */
15586            @Override
15587            public WikiPage fetchByG_N_T_H_Last(long groupId, long nodeId,
15588                    String title, boolean head,
15589                    OrderByComparator<WikiPage> orderByComparator) {
15590                    int count = countByG_N_T_H(groupId, nodeId, title, head);
15591    
15592                    if (count == 0) {
15593                            return null;
15594                    }
15595    
15596                    List<WikiPage> list = findByG_N_T_H(groupId, nodeId, title, head,
15597                                    count - 1, count, orderByComparator);
15598    
15599                    if (!list.isEmpty()) {
15600                            return list.get(0);
15601                    }
15602    
15603                    return null;
15604            }
15605    
15606            /**
15607             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15608             *
15609             * @param pageId the primary key of the current wiki page
15610             * @param groupId the group ID
15611             * @param nodeId the node ID
15612             * @param title the title
15613             * @param head the head
15614             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15615             * @return the previous, current, and next wiki page
15616             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
15617             */
15618            @Override
15619            public WikiPage[] findByG_N_T_H_PrevAndNext(long pageId, long groupId,
15620                    long nodeId, String title, boolean head,
15621                    OrderByComparator<WikiPage> orderByComparator)
15622                    throws NoSuchPageException {
15623                    WikiPage wikiPage = findByPrimaryKey(pageId);
15624    
15625                    Session session = null;
15626    
15627                    try {
15628                            session = openSession();
15629    
15630                            WikiPage[] array = new WikiPageImpl[3];
15631    
15632                            array[0] = getByG_N_T_H_PrevAndNext(session, wikiPage, groupId,
15633                                            nodeId, title, head, orderByComparator, true);
15634    
15635                            array[1] = wikiPage;
15636    
15637                            array[2] = getByG_N_T_H_PrevAndNext(session, wikiPage, groupId,
15638                                            nodeId, title, head, orderByComparator, false);
15639    
15640                            return array;
15641                    }
15642                    catch (Exception e) {
15643                            throw processException(e);
15644                    }
15645                    finally {
15646                            closeSession(session);
15647                    }
15648            }
15649    
15650            protected WikiPage getByG_N_T_H_PrevAndNext(Session session,
15651                    WikiPage wikiPage, long groupId, long nodeId, String title,
15652                    boolean head, OrderByComparator<WikiPage> orderByComparator,
15653                    boolean previous) {
15654                    StringBundler query = null;
15655    
15656                    if (orderByComparator != null) {
15657                            query = new StringBundler(6 +
15658                                            (orderByComparator.getOrderByFields().length * 6));
15659                    }
15660                    else {
15661                            query = new StringBundler(3);
15662                    }
15663    
15664                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
15665    
15666                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
15667    
15668                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
15669    
15670                    boolean bindTitle = false;
15671    
15672                    if (title == null) {
15673                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
15674                    }
15675                    else if (title.equals(StringPool.BLANK)) {
15676                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
15677                    }
15678                    else {
15679                            bindTitle = true;
15680    
15681                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
15682                    }
15683    
15684                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
15685    
15686                    if (orderByComparator != null) {
15687                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15688    
15689                            if (orderByConditionFields.length > 0) {
15690                                    query.append(WHERE_AND);
15691                            }
15692    
15693                            for (int i = 0; i < orderByConditionFields.length; i++) {
15694                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15695                                    query.append(orderByConditionFields[i]);
15696    
15697                                    if ((i + 1) < orderByConditionFields.length) {
15698                                            if (orderByComparator.isAscending() ^ previous) {
15699                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15700                                            }
15701                                            else {
15702                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15703                                            }
15704                                    }
15705                                    else {
15706                                            if (orderByComparator.isAscending() ^ previous) {
15707                                                    query.append(WHERE_GREATER_THAN);
15708                                            }
15709                                            else {
15710                                                    query.append(WHERE_LESSER_THAN);
15711                                            }
15712                                    }
15713                            }
15714    
15715                            query.append(ORDER_BY_CLAUSE);
15716    
15717                            String[] orderByFields = orderByComparator.getOrderByFields();
15718    
15719                            for (int i = 0; i < orderByFields.length; i++) {
15720                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15721                                    query.append(orderByFields[i]);
15722    
15723                                    if ((i + 1) < orderByFields.length) {
15724                                            if (orderByComparator.isAscending() ^ previous) {
15725                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15726                                            }
15727                                            else {
15728                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15729                                            }
15730                                    }
15731                                    else {
15732                                            if (orderByComparator.isAscending() ^ previous) {
15733                                                    query.append(ORDER_BY_ASC);
15734                                            }
15735                                            else {
15736                                                    query.append(ORDER_BY_DESC);
15737                                            }
15738                                    }
15739                            }
15740                    }
15741                    else {
15742                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
15743                    }
15744    
15745                    String sql = query.toString();
15746    
15747                    Query q = session.createQuery(sql);
15748    
15749                    q.setFirstResult(0);
15750                    q.setMaxResults(2);
15751    
15752                    QueryPos qPos = QueryPos.getInstance(q);
15753    
15754                    qPos.add(groupId);
15755    
15756                    qPos.add(nodeId);
15757    
15758                    if (bindTitle) {
15759                            qPos.add(StringUtil.toLowerCase(title));
15760                    }
15761    
15762                    qPos.add(head);
15763    
15764                    if (orderByComparator != null) {
15765                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
15766    
15767                            for (Object value : values) {
15768                                    qPos.add(value);
15769                            }
15770                    }
15771    
15772                    List<WikiPage> list = q.list();
15773    
15774                    if (list.size() == 2) {
15775                            return list.get(1);
15776                    }
15777                    else {
15778                            return null;
15779                    }
15780            }
15781    
15782            /**
15783             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15784             *
15785             * @param groupId the group ID
15786             * @param nodeId the node ID
15787             * @param title the title
15788             * @param head the head
15789             * @return the matching wiki pages that the user has permission to view
15790             */
15791            @Override
15792            public List<WikiPage> filterFindByG_N_T_H(long groupId, long nodeId,
15793                    String title, boolean head) {
15794                    return filterFindByG_N_T_H(groupId, nodeId, title, head,
15795                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15796            }
15797    
15798            /**
15799             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15800             *
15801             * <p>
15802             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
15803             * </p>
15804             *
15805             * @param groupId the group ID
15806             * @param nodeId the node ID
15807             * @param title the title
15808             * @param head the head
15809             * @param start the lower bound of the range of wiki pages
15810             * @param end the upper bound of the range of wiki pages (not inclusive)
15811             * @return the range of matching wiki pages that the user has permission to view
15812             */
15813            @Override
15814            public List<WikiPage> filterFindByG_N_T_H(long groupId, long nodeId,
15815                    String title, boolean head, int start, int end) {
15816                    return filterFindByG_N_T_H(groupId, nodeId, title, head, start, end,
15817                            null);
15818            }
15819    
15820            /**
15821             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15822             *
15823             * <p>
15824             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
15825             * </p>
15826             *
15827             * @param groupId the group ID
15828             * @param nodeId the node ID
15829             * @param title the title
15830             * @param head the head
15831             * @param start the lower bound of the range of wiki pages
15832             * @param end the upper bound of the range of wiki pages (not inclusive)
15833             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15834             * @return the ordered range of matching wiki pages that the user has permission to view
15835             */
15836            @Override
15837            public List<WikiPage> filterFindByG_N_T_H(long groupId, long nodeId,
15838                    String title, boolean head, int start, int end,
15839                    OrderByComparator<WikiPage> orderByComparator) {
15840                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15841                            return findByG_N_T_H(groupId, nodeId, title, head, start, end,
15842                                    orderByComparator);
15843                    }
15844    
15845                    StringBundler query = null;
15846    
15847                    if (orderByComparator != null) {
15848                            query = new StringBundler(6 +
15849                                            (orderByComparator.getOrderByFields().length * 3));
15850                    }
15851                    else {
15852                            query = new StringBundler(6);
15853                    }
15854    
15855                    if (getDB().isSupportsInlineDistinct()) {
15856                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
15857                    }
15858                    else {
15859                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
15860                    }
15861    
15862                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
15863    
15864                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
15865    
15866                    boolean bindTitle = false;
15867    
15868                    if (title == null) {
15869                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
15870                    }
15871                    else if (title.equals(StringPool.BLANK)) {
15872                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
15873                    }
15874                    else {
15875                            bindTitle = true;
15876    
15877                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
15878                    }
15879    
15880                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
15881    
15882                    if (!getDB().isSupportsInlineDistinct()) {
15883                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
15884                    }
15885    
15886                    if (orderByComparator != null) {
15887                            if (getDB().isSupportsInlineDistinct()) {
15888                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15889                                            orderByComparator, true);
15890                            }
15891                            else {
15892                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15893                                            orderByComparator, true);
15894                            }
15895                    }
15896                    else {
15897                            if (getDB().isSupportsInlineDistinct()) {
15898                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
15899                            }
15900                            else {
15901                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
15902                            }
15903                    }
15904    
15905                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15906                                    WikiPage.class.getName(),
15907                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15908    
15909                    Session session = null;
15910    
15911                    try {
15912                            session = openSession();
15913    
15914                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
15915    
15916                            if (getDB().isSupportsInlineDistinct()) {
15917                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
15918                            }
15919                            else {
15920                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
15921                            }
15922    
15923                            QueryPos qPos = QueryPos.getInstance(q);
15924    
15925                            qPos.add(groupId);
15926    
15927                            qPos.add(nodeId);
15928    
15929                            if (bindTitle) {
15930                                    qPos.add(StringUtil.toLowerCase(title));
15931                            }
15932    
15933                            qPos.add(head);
15934    
15935                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
15936                    }
15937                    catch (Exception e) {
15938                            throw processException(e);
15939                    }
15940                    finally {
15941                            closeSession(session);
15942                    }
15943            }
15944    
15945            /**
15946             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
15947             *
15948             * @param pageId the primary key of the current wiki page
15949             * @param groupId the group ID
15950             * @param nodeId the node ID
15951             * @param title the title
15952             * @param head the head
15953             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15954             * @return the previous, current, and next wiki page
15955             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
15956             */
15957            @Override
15958            public WikiPage[] filterFindByG_N_T_H_PrevAndNext(long pageId,
15959                    long groupId, long nodeId, String title, boolean head,
15960                    OrderByComparator<WikiPage> orderByComparator)
15961                    throws NoSuchPageException {
15962                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15963                            return findByG_N_T_H_PrevAndNext(pageId, groupId, nodeId, title,
15964                                    head, orderByComparator);
15965                    }
15966    
15967                    WikiPage wikiPage = findByPrimaryKey(pageId);
15968    
15969                    Session session = null;
15970    
15971                    try {
15972                            session = openSession();
15973    
15974                            WikiPage[] array = new WikiPageImpl[3];
15975    
15976                            array[0] = filterGetByG_N_T_H_PrevAndNext(session, wikiPage,
15977                                            groupId, nodeId, title, head, orderByComparator, true);
15978    
15979                            array[1] = wikiPage;
15980    
15981                            array[2] = filterGetByG_N_T_H_PrevAndNext(session, wikiPage,
15982                                            groupId, nodeId, title, head, orderByComparator, false);
15983    
15984                            return array;
15985                    }
15986                    catch (Exception e) {
15987                            throw processException(e);
15988                    }
15989                    finally {
15990                            closeSession(session);
15991                    }
15992            }
15993    
15994            protected WikiPage filterGetByG_N_T_H_PrevAndNext(Session session,
15995                    WikiPage wikiPage, long groupId, long nodeId, String title,
15996                    boolean head, OrderByComparator<WikiPage> orderByComparator,
15997                    boolean previous) {
15998                    StringBundler query = null;
15999    
16000                    if (orderByComparator != null) {
16001                            query = new StringBundler(6 +
16002                                            (orderByComparator.getOrderByFields().length * 6));
16003                    }
16004                    else {
16005                            query = new StringBundler(3);
16006                    }
16007    
16008                    if (getDB().isSupportsInlineDistinct()) {
16009                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
16010                    }
16011                    else {
16012                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
16013                    }
16014    
16015                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
16016    
16017                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
16018    
16019                    boolean bindTitle = false;
16020    
16021                    if (title == null) {
16022                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
16023                    }
16024                    else if (title.equals(StringPool.BLANK)) {
16025                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
16026                    }
16027                    else {
16028                            bindTitle = true;
16029    
16030                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
16031                    }
16032    
16033                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
16034    
16035                    if (!getDB().isSupportsInlineDistinct()) {
16036                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
16037                    }
16038    
16039                    if (orderByComparator != null) {
16040                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16041    
16042                            if (orderByConditionFields.length > 0) {
16043                                    query.append(WHERE_AND);
16044                            }
16045    
16046                            for (int i = 0; i < orderByConditionFields.length; i++) {
16047                                    if (getDB().isSupportsInlineDistinct()) {
16048                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16049                                    }
16050                                    else {
16051                                            query.append(_ORDER_BY_ENTITY_TABLE);
16052                                    }
16053    
16054                                    query.append(orderByConditionFields[i]);
16055    
16056                                    if ((i + 1) < orderByConditionFields.length) {
16057                                            if (orderByComparator.isAscending() ^ previous) {
16058                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16059                                            }
16060                                            else {
16061                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16062                                            }
16063                                    }
16064                                    else {
16065                                            if (orderByComparator.isAscending() ^ previous) {
16066                                                    query.append(WHERE_GREATER_THAN);
16067                                            }
16068                                            else {
16069                                                    query.append(WHERE_LESSER_THAN);
16070                                            }
16071                                    }
16072                            }
16073    
16074                            query.append(ORDER_BY_CLAUSE);
16075    
16076                            String[] orderByFields = orderByComparator.getOrderByFields();
16077    
16078                            for (int i = 0; i < orderByFields.length; i++) {
16079                                    if (getDB().isSupportsInlineDistinct()) {
16080                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16081                                    }
16082                                    else {
16083                                            query.append(_ORDER_BY_ENTITY_TABLE);
16084                                    }
16085    
16086                                    query.append(orderByFields[i]);
16087    
16088                                    if ((i + 1) < orderByFields.length) {
16089                                            if (orderByComparator.isAscending() ^ previous) {
16090                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16091                                            }
16092                                            else {
16093                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16094                                            }
16095                                    }
16096                                    else {
16097                                            if (orderByComparator.isAscending() ^ previous) {
16098                                                    query.append(ORDER_BY_ASC);
16099                                            }
16100                                            else {
16101                                                    query.append(ORDER_BY_DESC);
16102                                            }
16103                                    }
16104                            }
16105                    }
16106                    else {
16107                            if (getDB().isSupportsInlineDistinct()) {
16108                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
16109                            }
16110                            else {
16111                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
16112                            }
16113                    }
16114    
16115                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16116                                    WikiPage.class.getName(),
16117                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16118    
16119                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
16120    
16121                    q.setFirstResult(0);
16122                    q.setMaxResults(2);
16123    
16124                    if (getDB().isSupportsInlineDistinct()) {
16125                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
16126                    }
16127                    else {
16128                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
16129                    }
16130    
16131                    QueryPos qPos = QueryPos.getInstance(q);
16132    
16133                    qPos.add(groupId);
16134    
16135                    qPos.add(nodeId);
16136    
16137                    if (bindTitle) {
16138                            qPos.add(StringUtil.toLowerCase(title));
16139                    }
16140    
16141                    qPos.add(head);
16142    
16143                    if (orderByComparator != null) {
16144                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
16145    
16146                            for (Object value : values) {
16147                                    qPos.add(value);
16148                            }
16149                    }
16150    
16151                    List<WikiPage> list = q.list();
16152    
16153                    if (list.size() == 2) {
16154                            return list.get(1);
16155                    }
16156                    else {
16157                            return null;
16158                    }
16159            }
16160    
16161            /**
16162             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63; from the database.
16163             *
16164             * @param groupId the group ID
16165             * @param nodeId the node ID
16166             * @param title the title
16167             * @param head the head
16168             */
16169            @Override
16170            public void removeByG_N_T_H(long groupId, long nodeId, String title,
16171                    boolean head) {
16172                    for (WikiPage wikiPage : findByG_N_T_H(groupId, nodeId, title, head,
16173                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16174                            remove(wikiPage);
16175                    }
16176            }
16177    
16178            /**
16179             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
16180             *
16181             * @param groupId the group ID
16182             * @param nodeId the node ID
16183             * @param title the title
16184             * @param head the head
16185             * @return the number of matching wiki pages
16186             */
16187            @Override
16188            public int countByG_N_T_H(long groupId, long nodeId, String title,
16189                    boolean head) {
16190                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_T_H;
16191    
16192                    Object[] finderArgs = new Object[] { groupId, nodeId, title, head };
16193    
16194                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16195                                    this);
16196    
16197                    if (count == null) {
16198                            StringBundler query = new StringBundler(5);
16199    
16200                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
16201    
16202                            query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
16203    
16204                            query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
16205    
16206                            boolean bindTitle = false;
16207    
16208                            if (title == null) {
16209                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
16210                            }
16211                            else if (title.equals(StringPool.BLANK)) {
16212                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
16213                            }
16214                            else {
16215                                    bindTitle = true;
16216    
16217                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
16218                            }
16219    
16220                            query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
16221    
16222                            String sql = query.toString();
16223    
16224                            Session session = null;
16225    
16226                            try {
16227                                    session = openSession();
16228    
16229                                    Query q = session.createQuery(sql);
16230    
16231                                    QueryPos qPos = QueryPos.getInstance(q);
16232    
16233                                    qPos.add(groupId);
16234    
16235                                    qPos.add(nodeId);
16236    
16237                                    if (bindTitle) {
16238                                            qPos.add(StringUtil.toLowerCase(title));
16239                                    }
16240    
16241                                    qPos.add(head);
16242    
16243                                    count = (Long)q.uniqueResult();
16244    
16245                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16246                            }
16247                            catch (Exception e) {
16248                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16249    
16250                                    throw processException(e);
16251                            }
16252                            finally {
16253                                    closeSession(session);
16254                            }
16255                    }
16256    
16257                    return count.intValue();
16258            }
16259    
16260            /**
16261             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
16262             *
16263             * @param groupId the group ID
16264             * @param nodeId the node ID
16265             * @param title the title
16266             * @param head the head
16267             * @return the number of matching wiki pages that the user has permission to view
16268             */
16269            @Override
16270            public int filterCountByG_N_T_H(long groupId, long nodeId, String title,
16271                    boolean head) {
16272                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16273                            return countByG_N_T_H(groupId, nodeId, title, head);
16274                    }
16275    
16276                    StringBundler query = new StringBundler(5);
16277    
16278                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
16279    
16280                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
16281    
16282                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
16283    
16284                    boolean bindTitle = false;
16285    
16286                    if (title == null) {
16287                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
16288                    }
16289                    else if (title.equals(StringPool.BLANK)) {
16290                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
16291                    }
16292                    else {
16293                            bindTitle = true;
16294    
16295                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
16296                    }
16297    
16298                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
16299    
16300                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16301                                    WikiPage.class.getName(),
16302                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16303    
16304                    Session session = null;
16305    
16306                    try {
16307                            session = openSession();
16308    
16309                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
16310    
16311                            q.addScalar(COUNT_COLUMN_NAME,
16312                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16313    
16314                            QueryPos qPos = QueryPos.getInstance(q);
16315    
16316                            qPos.add(groupId);
16317    
16318                            qPos.add(nodeId);
16319    
16320                            if (bindTitle) {
16321                                    qPos.add(StringUtil.toLowerCase(title));
16322                            }
16323    
16324                            qPos.add(head);
16325    
16326                            Long count = (Long)q.uniqueResult();
16327    
16328                            return count.intValue();
16329                    }
16330                    catch (Exception e) {
16331                            throw processException(e);
16332                    }
16333                    finally {
16334                            closeSession(session);
16335                    }
16336            }
16337    
16338            private static final String _FINDER_COLUMN_G_N_T_H_GROUPID_2 = "wikiPage.groupId = ? AND ";
16339            private static final String _FINDER_COLUMN_G_N_T_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
16340            private static final String _FINDER_COLUMN_G_N_T_H_TITLE_1 = "wikiPage.title IS NULL AND ";
16341            private static final String _FINDER_COLUMN_G_N_T_H_TITLE_2 = "lower(wikiPage.title) = ? AND ";
16342            private static final String _FINDER_COLUMN_G_N_T_H_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = '') AND ";
16343            private static final String _FINDER_COLUMN_G_N_T_H_HEAD_2 = "wikiPage.head = ?";
16344            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
16345                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
16346                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_H_S",
16347                            new String[] {
16348                                    Long.class.getName(), Long.class.getName(),
16349                                    Boolean.class.getName(), Integer.class.getName(),
16350                                    
16351                            Integer.class.getName(), Integer.class.getName(),
16352                                    OrderByComparator.class.getName()
16353                            });
16354            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S =
16355                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
16356                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
16357                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_H_S",
16358                            new String[] {
16359                                    Long.class.getName(), Long.class.getName(),
16360                                    Boolean.class.getName(), Integer.class.getName()
16361                            },
16362                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
16363                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
16364                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
16365                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
16366                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
16367                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
16368            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
16369                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
16370                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_H_S",
16371                            new String[] {
16372                                    Long.class.getName(), Long.class.getName(),
16373                                    Boolean.class.getName(), Integer.class.getName()
16374                            });
16375    
16376            /**
16377             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16378             *
16379             * @param groupId the group ID
16380             * @param nodeId the node ID
16381             * @param head the head
16382             * @param status the status
16383             * @return the matching wiki pages
16384             */
16385            @Override
16386            public List<WikiPage> findByG_N_H_S(long groupId, long nodeId,
16387                    boolean head, int status) {
16388                    return findByG_N_H_S(groupId, nodeId, head, status, QueryUtil.ALL_POS,
16389                            QueryUtil.ALL_POS, null);
16390            }
16391    
16392            /**
16393             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16394             *
16395             * <p>
16396             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
16397             * </p>
16398             *
16399             * @param groupId the group ID
16400             * @param nodeId the node ID
16401             * @param head the head
16402             * @param status the status
16403             * @param start the lower bound of the range of wiki pages
16404             * @param end the upper bound of the range of wiki pages (not inclusive)
16405             * @return the range of matching wiki pages
16406             */
16407            @Override
16408            public List<WikiPage> findByG_N_H_S(long groupId, long nodeId,
16409                    boolean head, int status, int start, int end) {
16410                    return findByG_N_H_S(groupId, nodeId, head, status, start, end, null);
16411            }
16412    
16413            /**
16414             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16415             *
16416             * <p>
16417             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
16418             * </p>
16419             *
16420             * @param groupId the group ID
16421             * @param nodeId the node ID
16422             * @param head the head
16423             * @param status the status
16424             * @param start the lower bound of the range of wiki pages
16425             * @param end the upper bound of the range of wiki pages (not inclusive)
16426             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16427             * @return the ordered range of matching wiki pages
16428             */
16429            @Override
16430            public List<WikiPage> findByG_N_H_S(long groupId, long nodeId,
16431                    boolean head, int status, int start, int end,
16432                    OrderByComparator<WikiPage> orderByComparator) {
16433                    boolean pagination = true;
16434                    FinderPath finderPath = null;
16435                    Object[] finderArgs = null;
16436    
16437                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16438                                    (orderByComparator == null)) {
16439                            pagination = false;
16440                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S;
16441                            finderArgs = new Object[] { groupId, nodeId, head, status };
16442                    }
16443                    else {
16444                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_S;
16445                            finderArgs = new Object[] {
16446                                            groupId, nodeId, head, status,
16447                                            
16448                                            start, end, orderByComparator
16449                                    };
16450                    }
16451    
16452                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
16453                                    finderArgs, this);
16454    
16455                    if ((list != null) && !list.isEmpty()) {
16456                            for (WikiPage wikiPage : list) {
16457                                    if ((groupId != wikiPage.getGroupId()) ||
16458                                                    (nodeId != wikiPage.getNodeId()) ||
16459                                                    (head != wikiPage.getHead()) ||
16460                                                    (status != wikiPage.getStatus())) {
16461                                            list = null;
16462    
16463                                            break;
16464                                    }
16465                            }
16466                    }
16467    
16468                    if (list == null) {
16469                            StringBundler query = null;
16470    
16471                            if (orderByComparator != null) {
16472                                    query = new StringBundler(6 +
16473                                                    (orderByComparator.getOrderByFields().length * 3));
16474                            }
16475                            else {
16476                                    query = new StringBundler(6);
16477                            }
16478    
16479                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
16480    
16481                            query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
16482    
16483                            query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
16484    
16485                            query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
16486    
16487                            query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
16488    
16489                            if (orderByComparator != null) {
16490                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16491                                            orderByComparator);
16492                            }
16493                            else
16494                             if (pagination) {
16495                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
16496                            }
16497    
16498                            String sql = query.toString();
16499    
16500                            Session session = null;
16501    
16502                            try {
16503                                    session = openSession();
16504    
16505                                    Query q = session.createQuery(sql);
16506    
16507                                    QueryPos qPos = QueryPos.getInstance(q);
16508    
16509                                    qPos.add(groupId);
16510    
16511                                    qPos.add(nodeId);
16512    
16513                                    qPos.add(head);
16514    
16515                                    qPos.add(status);
16516    
16517                                    if (!pagination) {
16518                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
16519                                                            start, end, false);
16520    
16521                                            Collections.sort(list);
16522    
16523                                            list = Collections.unmodifiableList(list);
16524                                    }
16525                                    else {
16526                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
16527                                                            start, end);
16528                                    }
16529    
16530                                    cacheResult(list);
16531    
16532                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16533                            }
16534                            catch (Exception e) {
16535                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16536    
16537                                    throw processException(e);
16538                            }
16539                            finally {
16540                                    closeSession(session);
16541                            }
16542                    }
16543    
16544                    return list;
16545            }
16546    
16547            /**
16548             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16549             *
16550             * @param groupId the group ID
16551             * @param nodeId the node ID
16552             * @param head the head
16553             * @param status the status
16554             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16555             * @return the first matching wiki page
16556             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
16557             */
16558            @Override
16559            public WikiPage findByG_N_H_S_First(long groupId, long nodeId,
16560                    boolean head, int status, OrderByComparator<WikiPage> orderByComparator)
16561                    throws NoSuchPageException {
16562                    WikiPage wikiPage = fetchByG_N_H_S_First(groupId, nodeId, head, status,
16563                                    orderByComparator);
16564    
16565                    if (wikiPage != null) {
16566                            return wikiPage;
16567                    }
16568    
16569                    StringBundler msg = new StringBundler(10);
16570    
16571                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16572    
16573                    msg.append("groupId=");
16574                    msg.append(groupId);
16575    
16576                    msg.append(", nodeId=");
16577                    msg.append(nodeId);
16578    
16579                    msg.append(", head=");
16580                    msg.append(head);
16581    
16582                    msg.append(", status=");
16583                    msg.append(status);
16584    
16585                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16586    
16587                    throw new NoSuchPageException(msg.toString());
16588            }
16589    
16590            /**
16591             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16592             *
16593             * @param groupId the group ID
16594             * @param nodeId the node ID
16595             * @param head the head
16596             * @param status the status
16597             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16598             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
16599             */
16600            @Override
16601            public WikiPage fetchByG_N_H_S_First(long groupId, long nodeId,
16602                    boolean head, int status, OrderByComparator<WikiPage> orderByComparator) {
16603                    List<WikiPage> list = findByG_N_H_S(groupId, nodeId, head, status, 0,
16604                                    1, orderByComparator);
16605    
16606                    if (!list.isEmpty()) {
16607                            return list.get(0);
16608                    }
16609    
16610                    return null;
16611            }
16612    
16613            /**
16614             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16615             *
16616             * @param groupId the group ID
16617             * @param nodeId the node ID
16618             * @param head the head
16619             * @param status the status
16620             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16621             * @return the last matching wiki page
16622             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
16623             */
16624            @Override
16625            public WikiPage findByG_N_H_S_Last(long groupId, long nodeId, boolean head,
16626                    int status, OrderByComparator<WikiPage> orderByComparator)
16627                    throws NoSuchPageException {
16628                    WikiPage wikiPage = fetchByG_N_H_S_Last(groupId, nodeId, head, status,
16629                                    orderByComparator);
16630    
16631                    if (wikiPage != null) {
16632                            return wikiPage;
16633                    }
16634    
16635                    StringBundler msg = new StringBundler(10);
16636    
16637                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16638    
16639                    msg.append("groupId=");
16640                    msg.append(groupId);
16641    
16642                    msg.append(", nodeId=");
16643                    msg.append(nodeId);
16644    
16645                    msg.append(", head=");
16646                    msg.append(head);
16647    
16648                    msg.append(", status=");
16649                    msg.append(status);
16650    
16651                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16652    
16653                    throw new NoSuchPageException(msg.toString());
16654            }
16655    
16656            /**
16657             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16658             *
16659             * @param groupId the group ID
16660             * @param nodeId the node ID
16661             * @param head the head
16662             * @param status the status
16663             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16664             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
16665             */
16666            @Override
16667            public WikiPage fetchByG_N_H_S_Last(long groupId, long nodeId,
16668                    boolean head, int status, OrderByComparator<WikiPage> orderByComparator) {
16669                    int count = countByG_N_H_S(groupId, nodeId, head, status);
16670    
16671                    if (count == 0) {
16672                            return null;
16673                    }
16674    
16675                    List<WikiPage> list = findByG_N_H_S(groupId, nodeId, head, status,
16676                                    count - 1, count, orderByComparator);
16677    
16678                    if (!list.isEmpty()) {
16679                            return list.get(0);
16680                    }
16681    
16682                    return null;
16683            }
16684    
16685            /**
16686             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16687             *
16688             * @param pageId the primary key of the current wiki page
16689             * @param groupId the group ID
16690             * @param nodeId the node ID
16691             * @param head the head
16692             * @param status the status
16693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16694             * @return the previous, current, and next wiki page
16695             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
16696             */
16697            @Override
16698            public WikiPage[] findByG_N_H_S_PrevAndNext(long pageId, long groupId,
16699                    long nodeId, boolean head, int status,
16700                    OrderByComparator<WikiPage> orderByComparator)
16701                    throws NoSuchPageException {
16702                    WikiPage wikiPage = findByPrimaryKey(pageId);
16703    
16704                    Session session = null;
16705    
16706                    try {
16707                            session = openSession();
16708    
16709                            WikiPage[] array = new WikiPageImpl[3];
16710    
16711                            array[0] = getByG_N_H_S_PrevAndNext(session, wikiPage, groupId,
16712                                            nodeId, head, status, orderByComparator, true);
16713    
16714                            array[1] = wikiPage;
16715    
16716                            array[2] = getByG_N_H_S_PrevAndNext(session, wikiPage, groupId,
16717                                            nodeId, head, status, orderByComparator, false);
16718    
16719                            return array;
16720                    }
16721                    catch (Exception e) {
16722                            throw processException(e);
16723                    }
16724                    finally {
16725                            closeSession(session);
16726                    }
16727            }
16728    
16729            protected WikiPage getByG_N_H_S_PrevAndNext(Session session,
16730                    WikiPage wikiPage, long groupId, long nodeId, boolean head, int status,
16731                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
16732                    StringBundler query = null;
16733    
16734                    if (orderByComparator != null) {
16735                            query = new StringBundler(6 +
16736                                            (orderByComparator.getOrderByFields().length * 6));
16737                    }
16738                    else {
16739                            query = new StringBundler(3);
16740                    }
16741    
16742                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
16743    
16744                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
16745    
16746                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
16747    
16748                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
16749    
16750                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
16751    
16752                    if (orderByComparator != null) {
16753                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16754    
16755                            if (orderByConditionFields.length > 0) {
16756                                    query.append(WHERE_AND);
16757                            }
16758    
16759                            for (int i = 0; i < orderByConditionFields.length; i++) {
16760                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16761                                    query.append(orderByConditionFields[i]);
16762    
16763                                    if ((i + 1) < orderByConditionFields.length) {
16764                                            if (orderByComparator.isAscending() ^ previous) {
16765                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16766                                            }
16767                                            else {
16768                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16769                                            }
16770                                    }
16771                                    else {
16772                                            if (orderByComparator.isAscending() ^ previous) {
16773                                                    query.append(WHERE_GREATER_THAN);
16774                                            }
16775                                            else {
16776                                                    query.append(WHERE_LESSER_THAN);
16777                                            }
16778                                    }
16779                            }
16780    
16781                            query.append(ORDER_BY_CLAUSE);
16782    
16783                            String[] orderByFields = orderByComparator.getOrderByFields();
16784    
16785                            for (int i = 0; i < orderByFields.length; i++) {
16786                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16787                                    query.append(orderByFields[i]);
16788    
16789                                    if ((i + 1) < orderByFields.length) {
16790                                            if (orderByComparator.isAscending() ^ previous) {
16791                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16792                                            }
16793                                            else {
16794                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16795                                            }
16796                                    }
16797                                    else {
16798                                            if (orderByComparator.isAscending() ^ previous) {
16799                                                    query.append(ORDER_BY_ASC);
16800                                            }
16801                                            else {
16802                                                    query.append(ORDER_BY_DESC);
16803                                            }
16804                                    }
16805                            }
16806                    }
16807                    else {
16808                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
16809                    }
16810    
16811                    String sql = query.toString();
16812    
16813                    Query q = session.createQuery(sql);
16814    
16815                    q.setFirstResult(0);
16816                    q.setMaxResults(2);
16817    
16818                    QueryPos qPos = QueryPos.getInstance(q);
16819    
16820                    qPos.add(groupId);
16821    
16822                    qPos.add(nodeId);
16823    
16824                    qPos.add(head);
16825    
16826                    qPos.add(status);
16827    
16828                    if (orderByComparator != null) {
16829                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
16830    
16831                            for (Object value : values) {
16832                                    qPos.add(value);
16833                            }
16834                    }
16835    
16836                    List<WikiPage> list = q.list();
16837    
16838                    if (list.size() == 2) {
16839                            return list.get(1);
16840                    }
16841                    else {
16842                            return null;
16843                    }
16844            }
16845    
16846            /**
16847             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16848             *
16849             * @param groupId the group ID
16850             * @param nodeId the node ID
16851             * @param head the head
16852             * @param status the status
16853             * @return the matching wiki pages that the user has permission to view
16854             */
16855            @Override
16856            public List<WikiPage> filterFindByG_N_H_S(long groupId, long nodeId,
16857                    boolean head, int status) {
16858                    return filterFindByG_N_H_S(groupId, nodeId, head, status,
16859                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16860            }
16861    
16862            /**
16863             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16864             *
16865             * <p>
16866             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
16867             * </p>
16868             *
16869             * @param groupId the group ID
16870             * @param nodeId the node ID
16871             * @param head the head
16872             * @param status the status
16873             * @param start the lower bound of the range of wiki pages
16874             * @param end the upper bound of the range of wiki pages (not inclusive)
16875             * @return the range of matching wiki pages that the user has permission to view
16876             */
16877            @Override
16878            public List<WikiPage> filterFindByG_N_H_S(long groupId, long nodeId,
16879                    boolean head, int status, int start, int end) {
16880                    return filterFindByG_N_H_S(groupId, nodeId, head, status, start, end,
16881                            null);
16882            }
16883    
16884            /**
16885             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16886             *
16887             * <p>
16888             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
16889             * </p>
16890             *
16891             * @param groupId the group ID
16892             * @param nodeId the node ID
16893             * @param head the head
16894             * @param status the status
16895             * @param start the lower bound of the range of wiki pages
16896             * @param end the upper bound of the range of wiki pages (not inclusive)
16897             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16898             * @return the ordered range of matching wiki pages that the user has permission to view
16899             */
16900            @Override
16901            public List<WikiPage> filterFindByG_N_H_S(long groupId, long nodeId,
16902                    boolean head, int status, int start, int end,
16903                    OrderByComparator<WikiPage> orderByComparator) {
16904                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16905                            return findByG_N_H_S(groupId, nodeId, head, status, start, end,
16906                                    orderByComparator);
16907                    }
16908    
16909                    StringBundler query = null;
16910    
16911                    if (orderByComparator != null) {
16912                            query = new StringBundler(6 +
16913                                            (orderByComparator.getOrderByFields().length * 3));
16914                    }
16915                    else {
16916                            query = new StringBundler(6);
16917                    }
16918    
16919                    if (getDB().isSupportsInlineDistinct()) {
16920                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
16921                    }
16922                    else {
16923                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
16924                    }
16925    
16926                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
16927    
16928                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
16929    
16930                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
16931    
16932                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
16933    
16934                    if (!getDB().isSupportsInlineDistinct()) {
16935                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
16936                    }
16937    
16938                    if (orderByComparator != null) {
16939                            if (getDB().isSupportsInlineDistinct()) {
16940                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16941                                            orderByComparator, true);
16942                            }
16943                            else {
16944                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16945                                            orderByComparator, true);
16946                            }
16947                    }
16948                    else {
16949                            if (getDB().isSupportsInlineDistinct()) {
16950                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
16951                            }
16952                            else {
16953                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
16954                            }
16955                    }
16956    
16957                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16958                                    WikiPage.class.getName(),
16959                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16960    
16961                    Session session = null;
16962    
16963                    try {
16964                            session = openSession();
16965    
16966                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
16967    
16968                            if (getDB().isSupportsInlineDistinct()) {
16969                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
16970                            }
16971                            else {
16972                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
16973                            }
16974    
16975                            QueryPos qPos = QueryPos.getInstance(q);
16976    
16977                            qPos.add(groupId);
16978    
16979                            qPos.add(nodeId);
16980    
16981                            qPos.add(head);
16982    
16983                            qPos.add(status);
16984    
16985                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
16986                    }
16987                    catch (Exception e) {
16988                            throw processException(e);
16989                    }
16990                    finally {
16991                            closeSession(session);
16992                    }
16993            }
16994    
16995            /**
16996             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16997             *
16998             * @param pageId the primary key of the current wiki page
16999             * @param groupId the group ID
17000             * @param nodeId the node ID
17001             * @param head the head
17002             * @param status the status
17003             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17004             * @return the previous, current, and next wiki page
17005             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
17006             */
17007            @Override
17008            public WikiPage[] filterFindByG_N_H_S_PrevAndNext(long pageId,
17009                    long groupId, long nodeId, boolean head, int status,
17010                    OrderByComparator<WikiPage> orderByComparator)
17011                    throws NoSuchPageException {
17012                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17013                            return findByG_N_H_S_PrevAndNext(pageId, groupId, nodeId, head,
17014                                    status, orderByComparator);
17015                    }
17016    
17017                    WikiPage wikiPage = findByPrimaryKey(pageId);
17018    
17019                    Session session = null;
17020    
17021                    try {
17022                            session = openSession();
17023    
17024                            WikiPage[] array = new WikiPageImpl[3];
17025    
17026                            array[0] = filterGetByG_N_H_S_PrevAndNext(session, wikiPage,
17027                                            groupId, nodeId, head, status, orderByComparator, true);
17028    
17029                            array[1] = wikiPage;
17030    
17031                            array[2] = filterGetByG_N_H_S_PrevAndNext(session, wikiPage,
17032                                            groupId, nodeId, head, status, orderByComparator, false);
17033    
17034                            return array;
17035                    }
17036                    catch (Exception e) {
17037                            throw processException(e);
17038                    }
17039                    finally {
17040                            closeSession(session);
17041                    }
17042            }
17043    
17044            protected WikiPage filterGetByG_N_H_S_PrevAndNext(Session session,
17045                    WikiPage wikiPage, long groupId, long nodeId, boolean head, int status,
17046                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
17047                    StringBundler query = null;
17048    
17049                    if (orderByComparator != null) {
17050                            query = new StringBundler(6 +
17051                                            (orderByComparator.getOrderByFields().length * 6));
17052                    }
17053                    else {
17054                            query = new StringBundler(3);
17055                    }
17056    
17057                    if (getDB().isSupportsInlineDistinct()) {
17058                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
17059                    }
17060                    else {
17061                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
17062                    }
17063    
17064                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
17065    
17066                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
17067    
17068                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
17069    
17070                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
17071    
17072                    if (!getDB().isSupportsInlineDistinct()) {
17073                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
17074                    }
17075    
17076                    if (orderByComparator != null) {
17077                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17078    
17079                            if (orderByConditionFields.length > 0) {
17080                                    query.append(WHERE_AND);
17081                            }
17082    
17083                            for (int i = 0; i < orderByConditionFields.length; i++) {
17084                                    if (getDB().isSupportsInlineDistinct()) {
17085                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17086                                    }
17087                                    else {
17088                                            query.append(_ORDER_BY_ENTITY_TABLE);
17089                                    }
17090    
17091                                    query.append(orderByConditionFields[i]);
17092    
17093                                    if ((i + 1) < orderByConditionFields.length) {
17094                                            if (orderByComparator.isAscending() ^ previous) {
17095                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17096                                            }
17097                                            else {
17098                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17099                                            }
17100                                    }
17101                                    else {
17102                                            if (orderByComparator.isAscending() ^ previous) {
17103                                                    query.append(WHERE_GREATER_THAN);
17104                                            }
17105                                            else {
17106                                                    query.append(WHERE_LESSER_THAN);
17107                                            }
17108                                    }
17109                            }
17110    
17111                            query.append(ORDER_BY_CLAUSE);
17112    
17113                            String[] orderByFields = orderByComparator.getOrderByFields();
17114    
17115                            for (int i = 0; i < orderByFields.length; i++) {
17116                                    if (getDB().isSupportsInlineDistinct()) {
17117                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17118                                    }
17119                                    else {
17120                                            query.append(_ORDER_BY_ENTITY_TABLE);
17121                                    }
17122    
17123                                    query.append(orderByFields[i]);
17124    
17125                                    if ((i + 1) < orderByFields.length) {
17126                                            if (orderByComparator.isAscending() ^ previous) {
17127                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17128                                            }
17129                                            else {
17130                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17131                                            }
17132                                    }
17133                                    else {
17134                                            if (orderByComparator.isAscending() ^ previous) {
17135                                                    query.append(ORDER_BY_ASC);
17136                                            }
17137                                            else {
17138                                                    query.append(ORDER_BY_DESC);
17139                                            }
17140                                    }
17141                            }
17142                    }
17143                    else {
17144                            if (getDB().isSupportsInlineDistinct()) {
17145                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
17146                            }
17147                            else {
17148                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
17149                            }
17150                    }
17151    
17152                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17153                                    WikiPage.class.getName(),
17154                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17155    
17156                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
17157    
17158                    q.setFirstResult(0);
17159                    q.setMaxResults(2);
17160    
17161                    if (getDB().isSupportsInlineDistinct()) {
17162                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
17163                    }
17164                    else {
17165                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
17166                    }
17167    
17168                    QueryPos qPos = QueryPos.getInstance(q);
17169    
17170                    qPos.add(groupId);
17171    
17172                    qPos.add(nodeId);
17173    
17174                    qPos.add(head);
17175    
17176                    qPos.add(status);
17177    
17178                    if (orderByComparator != null) {
17179                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
17180    
17181                            for (Object value : values) {
17182                                    qPos.add(value);
17183                            }
17184                    }
17185    
17186                    List<WikiPage> list = q.list();
17187    
17188                    if (list.size() == 2) {
17189                            return list.get(1);
17190                    }
17191                    else {
17192                            return null;
17193                    }
17194            }
17195    
17196            /**
17197             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63; from the database.
17198             *
17199             * @param groupId the group ID
17200             * @param nodeId the node ID
17201             * @param head the head
17202             * @param status the status
17203             */
17204            @Override
17205            public void removeByG_N_H_S(long groupId, long nodeId, boolean head,
17206                    int status) {
17207                    for (WikiPage wikiPage : findByG_N_H_S(groupId, nodeId, head, status,
17208                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17209                            remove(wikiPage);
17210                    }
17211            }
17212    
17213            /**
17214             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
17215             *
17216             * @param groupId the group ID
17217             * @param nodeId the node ID
17218             * @param head the head
17219             * @param status the status
17220             * @return the number of matching wiki pages
17221             */
17222            @Override
17223            public int countByG_N_H_S(long groupId, long nodeId, boolean head,
17224                    int status) {
17225                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_H_S;
17226    
17227                    Object[] finderArgs = new Object[] { groupId, nodeId, head, status };
17228    
17229                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17230                                    this);
17231    
17232                    if (count == null) {
17233                            StringBundler query = new StringBundler(5);
17234    
17235                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
17236    
17237                            query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
17238    
17239                            query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
17240    
17241                            query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
17242    
17243                            query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
17244    
17245                            String sql = query.toString();
17246    
17247                            Session session = null;
17248    
17249                            try {
17250                                    session = openSession();
17251    
17252                                    Query q = session.createQuery(sql);
17253    
17254                                    QueryPos qPos = QueryPos.getInstance(q);
17255    
17256                                    qPos.add(groupId);
17257    
17258                                    qPos.add(nodeId);
17259    
17260                                    qPos.add(head);
17261    
17262                                    qPos.add(status);
17263    
17264                                    count = (Long)q.uniqueResult();
17265    
17266                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17267                            }
17268                            catch (Exception e) {
17269                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17270    
17271                                    throw processException(e);
17272                            }
17273                            finally {
17274                                    closeSession(session);
17275                            }
17276                    }
17277    
17278                    return count.intValue();
17279            }
17280    
17281            /**
17282             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
17283             *
17284             * @param groupId the group ID
17285             * @param nodeId the node ID
17286             * @param head the head
17287             * @param status the status
17288             * @return the number of matching wiki pages that the user has permission to view
17289             */
17290            @Override
17291            public int filterCountByG_N_H_S(long groupId, long nodeId, boolean head,
17292                    int status) {
17293                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17294                            return countByG_N_H_S(groupId, nodeId, head, status);
17295                    }
17296    
17297                    StringBundler query = new StringBundler(5);
17298    
17299                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
17300    
17301                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
17302    
17303                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
17304    
17305                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
17306    
17307                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
17308    
17309                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17310                                    WikiPage.class.getName(),
17311                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17312    
17313                    Session session = null;
17314    
17315                    try {
17316                            session = openSession();
17317    
17318                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17319    
17320                            q.addScalar(COUNT_COLUMN_NAME,
17321                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17322    
17323                            QueryPos qPos = QueryPos.getInstance(q);
17324    
17325                            qPos.add(groupId);
17326    
17327                            qPos.add(nodeId);
17328    
17329                            qPos.add(head);
17330    
17331                            qPos.add(status);
17332    
17333                            Long count = (Long)q.uniqueResult();
17334    
17335                            return count.intValue();
17336                    }
17337                    catch (Exception e) {
17338                            throw processException(e);
17339                    }
17340                    finally {
17341                            closeSession(session);
17342                    }
17343            }
17344    
17345            private static final String _FINDER_COLUMN_G_N_H_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
17346            private static final String _FINDER_COLUMN_G_N_H_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
17347            private static final String _FINDER_COLUMN_G_N_H_S_HEAD_2 = "wikiPage.head = ? AND ";
17348            private static final String _FINDER_COLUMN_G_N_H_S_STATUS_2 = "wikiPage.status = ?";
17349            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
17350                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
17351                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_P_S",
17352                            new String[] {
17353                                    Long.class.getName(), Boolean.class.getName(),
17354                                    String.class.getName(), Integer.class.getName(),
17355                                    
17356                            Integer.class.getName(), Integer.class.getName(),
17357                                    OrderByComparator.class.getName()
17358                            });
17359            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S =
17360                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
17361                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
17362                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_P_S",
17363                            new String[] {
17364                                    Long.class.getName(), Boolean.class.getName(),
17365                                    String.class.getName(), Integer.class.getName()
17366                            },
17367                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
17368                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
17369                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK |
17370                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
17371                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
17372                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
17373            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
17374                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
17375                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_P_S",
17376                            new String[] {
17377                                    Long.class.getName(), Boolean.class.getName(),
17378                                    String.class.getName(), Integer.class.getName()
17379                            });
17380    
17381            /**
17382             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
17383             *
17384             * @param nodeId the node ID
17385             * @param head the head
17386             * @param parentTitle the parent title
17387             * @param status the status
17388             * @return the matching wiki pages
17389             */
17390            @Override
17391            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
17392                    String parentTitle, int status) {
17393                    return findByN_H_P_S(nodeId, head, parentTitle, status,
17394                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17395            }
17396    
17397            /**
17398             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
17399             *
17400             * <p>
17401             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
17402             * </p>
17403             *
17404             * @param nodeId the node ID
17405             * @param head the head
17406             * @param parentTitle the parent title
17407             * @param status the status
17408             * @param start the lower bound of the range of wiki pages
17409             * @param end the upper bound of the range of wiki pages (not inclusive)
17410             * @return the range of matching wiki pages
17411             */
17412            @Override
17413            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
17414                    String parentTitle, int status, int start, int end) {
17415                    return findByN_H_P_S(nodeId, head, parentTitle, status, start, end, null);
17416            }
17417    
17418            /**
17419             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
17420             *
17421             * <p>
17422             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
17423             * </p>
17424             *
17425             * @param nodeId the node ID
17426             * @param head the head
17427             * @param parentTitle the parent title
17428             * @param status the status
17429             * @param start the lower bound of the range of wiki pages
17430             * @param end the upper bound of the range of wiki pages (not inclusive)
17431             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17432             * @return the ordered range of matching wiki pages
17433             */
17434            @Override
17435            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
17436                    String parentTitle, int status, int start, int end,
17437                    OrderByComparator<WikiPage> orderByComparator) {
17438                    boolean pagination = true;
17439                    FinderPath finderPath = null;
17440                    Object[] finderArgs = null;
17441    
17442                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17443                                    (orderByComparator == null)) {
17444                            pagination = false;
17445                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S;
17446                            finderArgs = new Object[] { nodeId, head, parentTitle, status };
17447                    }
17448                    else {
17449                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P_S;
17450                            finderArgs = new Object[] {
17451                                            nodeId, head, parentTitle, status,
17452                                            
17453                                            start, end, orderByComparator
17454                                    };
17455                    }
17456    
17457                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
17458                                    finderArgs, this);
17459    
17460                    if ((list != null) && !list.isEmpty()) {
17461                            for (WikiPage wikiPage : list) {
17462                                    if ((nodeId != wikiPage.getNodeId()) ||
17463                                                    (head != wikiPage.getHead()) ||
17464                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle()) ||
17465                                                    (status != wikiPage.getStatus())) {
17466                                            list = null;
17467    
17468                                            break;
17469                                    }
17470                            }
17471                    }
17472    
17473                    if (list == null) {
17474                            StringBundler query = null;
17475    
17476                            if (orderByComparator != null) {
17477                                    query = new StringBundler(6 +
17478                                                    (orderByComparator.getOrderByFields().length * 3));
17479                            }
17480                            else {
17481                                    query = new StringBundler(6);
17482                            }
17483    
17484                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
17485    
17486                            query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
17487    
17488                            query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
17489    
17490                            boolean bindParentTitle = false;
17491    
17492                            if (parentTitle == null) {
17493                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
17494                            }
17495                            else if (parentTitle.equals(StringPool.BLANK)) {
17496                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
17497                            }
17498                            else {
17499                                    bindParentTitle = true;
17500    
17501                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
17502                            }
17503    
17504                            query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
17505    
17506                            if (orderByComparator != null) {
17507                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17508                                            orderByComparator);
17509                            }
17510                            else
17511                             if (pagination) {
17512                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
17513                            }
17514    
17515                            String sql = query.toString();
17516    
17517                            Session session = null;
17518    
17519                            try {
17520                                    session = openSession();
17521    
17522                                    Query q = session.createQuery(sql);
17523    
17524                                    QueryPos qPos = QueryPos.getInstance(q);
17525    
17526                                    qPos.add(nodeId);
17527    
17528                                    qPos.add(head);
17529    
17530                                    if (bindParentTitle) {
17531                                            qPos.add(StringUtil.toLowerCase(parentTitle));
17532                                    }
17533    
17534                                    qPos.add(status);
17535    
17536                                    if (!pagination) {
17537                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
17538                                                            start, end, false);
17539    
17540                                            Collections.sort(list);
17541    
17542                                            list = Collections.unmodifiableList(list);
17543                                    }
17544                                    else {
17545                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
17546                                                            start, end);
17547                                    }
17548    
17549                                    cacheResult(list);
17550    
17551                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17552                            }
17553                            catch (Exception e) {
17554                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17555    
17556                                    throw processException(e);
17557                            }
17558                            finally {
17559                                    closeSession(session);
17560                            }
17561                    }
17562    
17563                    return list;
17564            }
17565    
17566            /**
17567             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
17568             *
17569             * @param nodeId the node ID
17570             * @param head the head
17571             * @param parentTitle the parent title
17572             * @param status the status
17573             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17574             * @return the first matching wiki page
17575             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
17576             */
17577            @Override
17578            public WikiPage findByN_H_P_S_First(long nodeId, boolean head,
17579                    String parentTitle, int status,
17580                    OrderByComparator<WikiPage> orderByComparator)
17581                    throws NoSuchPageException {
17582                    WikiPage wikiPage = fetchByN_H_P_S_First(nodeId, head, parentTitle,
17583                                    status, orderByComparator);
17584    
17585                    if (wikiPage != null) {
17586                            return wikiPage;
17587                    }
17588    
17589                    StringBundler msg = new StringBundler(10);
17590    
17591                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17592    
17593                    msg.append("nodeId=");
17594                    msg.append(nodeId);
17595    
17596                    msg.append(", head=");
17597                    msg.append(head);
17598    
17599                    msg.append(", parentTitle=");
17600                    msg.append(parentTitle);
17601    
17602                    msg.append(", status=");
17603                    msg.append(status);
17604    
17605                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17606    
17607                    throw new NoSuchPageException(msg.toString());
17608            }
17609    
17610            /**
17611             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
17612             *
17613             * @param nodeId the node ID
17614             * @param head the head
17615             * @param parentTitle the parent title
17616             * @param status the status
17617             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17618             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
17619             */
17620            @Override
17621            public WikiPage fetchByN_H_P_S_First(long nodeId, boolean head,
17622                    String parentTitle, int status,
17623                    OrderByComparator<WikiPage> orderByComparator) {
17624                    List<WikiPage> list = findByN_H_P_S(nodeId, head, parentTitle, status,
17625                                    0, 1, orderByComparator);
17626    
17627                    if (!list.isEmpty()) {
17628                            return list.get(0);
17629                    }
17630    
17631                    return null;
17632            }
17633    
17634            /**
17635             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
17636             *
17637             * @param nodeId the node ID
17638             * @param head the head
17639             * @param parentTitle the parent title
17640             * @param status the status
17641             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17642             * @return the last matching wiki page
17643             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
17644             */
17645            @Override
17646            public WikiPage findByN_H_P_S_Last(long nodeId, boolean head,
17647                    String parentTitle, int status,
17648                    OrderByComparator<WikiPage> orderByComparator)
17649                    throws NoSuchPageException {
17650                    WikiPage wikiPage = fetchByN_H_P_S_Last(nodeId, head, parentTitle,
17651                                    status, orderByComparator);
17652    
17653                    if (wikiPage != null) {
17654                            return wikiPage;
17655                    }
17656    
17657                    StringBundler msg = new StringBundler(10);
17658    
17659                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17660    
17661                    msg.append("nodeId=");
17662                    msg.append(nodeId);
17663    
17664                    msg.append(", head=");
17665                    msg.append(head);
17666    
17667                    msg.append(", parentTitle=");
17668                    msg.append(parentTitle);
17669    
17670                    msg.append(", status=");
17671                    msg.append(status);
17672    
17673                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17674    
17675                    throw new NoSuchPageException(msg.toString());
17676            }
17677    
17678            /**
17679             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
17680             *
17681             * @param nodeId the node ID
17682             * @param head the head
17683             * @param parentTitle the parent title
17684             * @param status the status
17685             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17686             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
17687             */
17688            @Override
17689            public WikiPage fetchByN_H_P_S_Last(long nodeId, boolean head,
17690                    String parentTitle, int status,
17691                    OrderByComparator<WikiPage> orderByComparator) {
17692                    int count = countByN_H_P_S(nodeId, head, parentTitle, status);
17693    
17694                    if (count == 0) {
17695                            return null;
17696                    }
17697    
17698                    List<WikiPage> list = findByN_H_P_S(nodeId, head, parentTitle, status,
17699                                    count - 1, count, orderByComparator);
17700    
17701                    if (!list.isEmpty()) {
17702                            return list.get(0);
17703                    }
17704    
17705                    return null;
17706            }
17707    
17708            /**
17709             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
17710             *
17711             * @param pageId the primary key of the current wiki page
17712             * @param nodeId the node ID
17713             * @param head the head
17714             * @param parentTitle the parent title
17715             * @param status the status
17716             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17717             * @return the previous, current, and next wiki page
17718             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
17719             */
17720            @Override
17721            public WikiPage[] findByN_H_P_S_PrevAndNext(long pageId, long nodeId,
17722                    boolean head, String parentTitle, int status,
17723                    OrderByComparator<WikiPage> orderByComparator)
17724                    throws NoSuchPageException {
17725                    WikiPage wikiPage = findByPrimaryKey(pageId);
17726    
17727                    Session session = null;
17728    
17729                    try {
17730                            session = openSession();
17731    
17732                            WikiPage[] array = new WikiPageImpl[3];
17733    
17734                            array[0] = getByN_H_P_S_PrevAndNext(session, wikiPage, nodeId,
17735                                            head, parentTitle, status, orderByComparator, true);
17736    
17737                            array[1] = wikiPage;
17738    
17739                            array[2] = getByN_H_P_S_PrevAndNext(session, wikiPage, nodeId,
17740                                            head, parentTitle, status, orderByComparator, false);
17741    
17742                            return array;
17743                    }
17744                    catch (Exception e) {
17745                            throw processException(e);
17746                    }
17747                    finally {
17748                            closeSession(session);
17749                    }
17750            }
17751    
17752            protected WikiPage getByN_H_P_S_PrevAndNext(Session session,
17753                    WikiPage wikiPage, long nodeId, boolean head, String parentTitle,
17754                    int status, OrderByComparator<WikiPage> orderByComparator,
17755                    boolean previous) {
17756                    StringBundler query = null;
17757    
17758                    if (orderByComparator != null) {
17759                            query = new StringBundler(6 +
17760                                            (orderByComparator.getOrderByFields().length * 6));
17761                    }
17762                    else {
17763                            query = new StringBundler(3);
17764                    }
17765    
17766                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
17767    
17768                    query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
17769    
17770                    query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
17771    
17772                    boolean bindParentTitle = false;
17773    
17774                    if (parentTitle == null) {
17775                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
17776                    }
17777                    else if (parentTitle.equals(StringPool.BLANK)) {
17778                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
17779                    }
17780                    else {
17781                            bindParentTitle = true;
17782    
17783                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
17784                    }
17785    
17786                    query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
17787    
17788                    if (orderByComparator != null) {
17789                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17790    
17791                            if (orderByConditionFields.length > 0) {
17792                                    query.append(WHERE_AND);
17793                            }
17794    
17795                            for (int i = 0; i < orderByConditionFields.length; i++) {
17796                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17797                                    query.append(orderByConditionFields[i]);
17798    
17799                                    if ((i + 1) < orderByConditionFields.length) {
17800                                            if (orderByComparator.isAscending() ^ previous) {
17801                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17802                                            }
17803                                            else {
17804                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17805                                            }
17806                                    }
17807                                    else {
17808                                            if (orderByComparator.isAscending() ^ previous) {
17809                                                    query.append(WHERE_GREATER_THAN);
17810                                            }
17811                                            else {
17812                                                    query.append(WHERE_LESSER_THAN);
17813                                            }
17814                                    }
17815                            }
17816    
17817                            query.append(ORDER_BY_CLAUSE);
17818    
17819                            String[] orderByFields = orderByComparator.getOrderByFields();
17820    
17821                            for (int i = 0; i < orderByFields.length; i++) {
17822                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17823                                    query.append(orderByFields[i]);
17824    
17825                                    if ((i + 1) < orderByFields.length) {
17826                                            if (orderByComparator.isAscending() ^ previous) {
17827                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17828                                            }
17829                                            else {
17830                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17831                                            }
17832                                    }
17833                                    else {
17834                                            if (orderByComparator.isAscending() ^ previous) {
17835                                                    query.append(ORDER_BY_ASC);
17836                                            }
17837                                            else {
17838                                                    query.append(ORDER_BY_DESC);
17839                                            }
17840                                    }
17841                            }
17842                    }
17843                    else {
17844                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
17845                    }
17846    
17847                    String sql = query.toString();
17848    
17849                    Query q = session.createQuery(sql);
17850    
17851                    q.setFirstResult(0);
17852                    q.setMaxResults(2);
17853    
17854                    QueryPos qPos = QueryPos.getInstance(q);
17855    
17856                    qPos.add(nodeId);
17857    
17858                    qPos.add(head);
17859    
17860                    if (bindParentTitle) {
17861                            qPos.add(StringUtil.toLowerCase(parentTitle));
17862                    }
17863    
17864                    qPos.add(status);
17865    
17866                    if (orderByComparator != null) {
17867                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
17868    
17869                            for (Object value : values) {
17870                                    qPos.add(value);
17871                            }
17872                    }
17873    
17874                    List<WikiPage> list = q.list();
17875    
17876                    if (list.size() == 2) {
17877                            return list.get(1);
17878                    }
17879                    else {
17880                            return null;
17881                    }
17882            }
17883    
17884            /**
17885             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63; from the database.
17886             *
17887             * @param nodeId the node ID
17888             * @param head the head
17889             * @param parentTitle the parent title
17890             * @param status the status
17891             */
17892            @Override
17893            public void removeByN_H_P_S(long nodeId, boolean head, String parentTitle,
17894                    int status) {
17895                    for (WikiPage wikiPage : findByN_H_P_S(nodeId, head, parentTitle,
17896                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17897                            remove(wikiPage);
17898                    }
17899            }
17900    
17901            /**
17902             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
17903             *
17904             * @param nodeId the node ID
17905             * @param head the head
17906             * @param parentTitle the parent title
17907             * @param status the status
17908             * @return the number of matching wiki pages
17909             */
17910            @Override
17911            public int countByN_H_P_S(long nodeId, boolean head, String parentTitle,
17912                    int status) {
17913                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_H_P_S;
17914    
17915                    Object[] finderArgs = new Object[] { nodeId, head, parentTitle, status };
17916    
17917                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17918                                    this);
17919    
17920                    if (count == null) {
17921                            StringBundler query = new StringBundler(5);
17922    
17923                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
17924    
17925                            query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
17926    
17927                            query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
17928    
17929                            boolean bindParentTitle = false;
17930    
17931                            if (parentTitle == null) {
17932                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
17933                            }
17934                            else if (parentTitle.equals(StringPool.BLANK)) {
17935                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
17936                            }
17937                            else {
17938                                    bindParentTitle = true;
17939    
17940                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
17941                            }
17942    
17943                            query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
17944    
17945                            String sql = query.toString();
17946    
17947                            Session session = null;
17948    
17949                            try {
17950                                    session = openSession();
17951    
17952                                    Query q = session.createQuery(sql);
17953    
17954                                    QueryPos qPos = QueryPos.getInstance(q);
17955    
17956                                    qPos.add(nodeId);
17957    
17958                                    qPos.add(head);
17959    
17960                                    if (bindParentTitle) {
17961                                            qPos.add(StringUtil.toLowerCase(parentTitle));
17962                                    }
17963    
17964                                    qPos.add(status);
17965    
17966                                    count = (Long)q.uniqueResult();
17967    
17968                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17969                            }
17970                            catch (Exception e) {
17971                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17972    
17973                                    throw processException(e);
17974                            }
17975                            finally {
17976                                    closeSession(session);
17977                            }
17978                    }
17979    
17980                    return count.intValue();
17981            }
17982    
17983            private static final String _FINDER_COLUMN_N_H_P_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
17984            private static final String _FINDER_COLUMN_N_H_P_S_HEAD_2 = "wikiPage.head = ? AND ";
17985            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL AND ";
17986            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = ? AND ";
17987            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = '') AND ";
17988            private static final String _FINDER_COLUMN_N_H_P_S_STATUS_2 = "wikiPage.status = ?";
17989            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P_NOTS =
17990                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
17991                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
17992                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_P_NotS",
17993                            new String[] {
17994                                    Long.class.getName(), Boolean.class.getName(),
17995                                    String.class.getName(), Integer.class.getName(),
17996                                    
17997                            Integer.class.getName(), Integer.class.getName(),
17998                                    OrderByComparator.class.getName()
17999                            });
18000            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_N_H_P_NOTS =
18001                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
18002                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
18003                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByN_H_P_NotS",
18004                            new String[] {
18005                                    Long.class.getName(), Boolean.class.getName(),
18006                                    String.class.getName(), Integer.class.getName()
18007                            });
18008    
18009            /**
18010             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status &ne; &#63;.
18011             *
18012             * @param nodeId the node ID
18013             * @param head the head
18014             * @param parentTitle the parent title
18015             * @param status the status
18016             * @return the matching wiki pages
18017             */
18018            @Override
18019            public List<WikiPage> findByN_H_P_NotS(long nodeId, boolean head,
18020                    String parentTitle, int status) {
18021                    return findByN_H_P_NotS(nodeId, head, parentTitle, status,
18022                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18023            }
18024    
18025            /**
18026             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status &ne; &#63;.
18027             *
18028             * <p>
18029             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
18030             * </p>
18031             *
18032             * @param nodeId the node ID
18033             * @param head the head
18034             * @param parentTitle the parent title
18035             * @param status the status
18036             * @param start the lower bound of the range of wiki pages
18037             * @param end the upper bound of the range of wiki pages (not inclusive)
18038             * @return the range of matching wiki pages
18039             */
18040            @Override
18041            public List<WikiPage> findByN_H_P_NotS(long nodeId, boolean head,
18042                    String parentTitle, int status, int start, int end) {
18043                    return findByN_H_P_NotS(nodeId, head, parentTitle, status, start, end,
18044                            null);
18045            }
18046    
18047            /**
18048             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status &ne; &#63;.
18049             *
18050             * <p>
18051             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
18052             * </p>
18053             *
18054             * @param nodeId the node ID
18055             * @param head the head
18056             * @param parentTitle the parent title
18057             * @param status the status
18058             * @param start the lower bound of the range of wiki pages
18059             * @param end the upper bound of the range of wiki pages (not inclusive)
18060             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18061             * @return the ordered range of matching wiki pages
18062             */
18063            @Override
18064            public List<WikiPage> findByN_H_P_NotS(long nodeId, boolean head,
18065                    String parentTitle, int status, int start, int end,
18066                    OrderByComparator<WikiPage> orderByComparator) {
18067                    boolean pagination = true;
18068                    FinderPath finderPath = null;
18069                    Object[] finderArgs = null;
18070    
18071                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P_NOTS;
18072                    finderArgs = new Object[] {
18073                                    nodeId, head, parentTitle, status,
18074                                    
18075                                    start, end, orderByComparator
18076                            };
18077    
18078                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
18079                                    finderArgs, this);
18080    
18081                    if ((list != null) && !list.isEmpty()) {
18082                            for (WikiPage wikiPage : list) {
18083                                    if ((nodeId != wikiPage.getNodeId()) ||
18084                                                    (head != wikiPage.getHead()) ||
18085                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle()) ||
18086                                                    (status == wikiPage.getStatus())) {
18087                                            list = null;
18088    
18089                                            break;
18090                                    }
18091                            }
18092                    }
18093    
18094                    if (list == null) {
18095                            StringBundler query = null;
18096    
18097                            if (orderByComparator != null) {
18098                                    query = new StringBundler(6 +
18099                                                    (orderByComparator.getOrderByFields().length * 3));
18100                            }
18101                            else {
18102                                    query = new StringBundler(6);
18103                            }
18104    
18105                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
18106    
18107                            query.append(_FINDER_COLUMN_N_H_P_NOTS_NODEID_2);
18108    
18109                            query.append(_FINDER_COLUMN_N_H_P_NOTS_HEAD_2);
18110    
18111                            boolean bindParentTitle = false;
18112    
18113                            if (parentTitle == null) {
18114                                    query.append(_FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_1);
18115                            }
18116                            else if (parentTitle.equals(StringPool.BLANK)) {
18117                                    query.append(_FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_3);
18118                            }
18119                            else {
18120                                    bindParentTitle = true;
18121    
18122                                    query.append(_FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_2);
18123                            }
18124    
18125                            query.append(_FINDER_COLUMN_N_H_P_NOTS_STATUS_2);
18126    
18127                            if (orderByComparator != null) {
18128                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18129                                            orderByComparator);
18130                            }
18131                            else
18132                             if (pagination) {
18133                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
18134                            }
18135    
18136                            String sql = query.toString();
18137    
18138                            Session session = null;
18139    
18140                            try {
18141                                    session = openSession();
18142    
18143                                    Query q = session.createQuery(sql);
18144    
18145                                    QueryPos qPos = QueryPos.getInstance(q);
18146    
18147                                    qPos.add(nodeId);
18148    
18149                                    qPos.add(head);
18150    
18151                                    if (bindParentTitle) {
18152                                            qPos.add(StringUtil.toLowerCase(parentTitle));
18153                                    }
18154    
18155                                    qPos.add(status);
18156    
18157                                    if (!pagination) {
18158                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
18159                                                            start, end, false);
18160    
18161                                            Collections.sort(list);
18162    
18163                                            list = Collections.unmodifiableList(list);
18164                                    }
18165                                    else {
18166                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
18167                                                            start, end);
18168                                    }
18169    
18170                                    cacheResult(list);
18171    
18172                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18173                            }
18174                            catch (Exception e) {
18175                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18176    
18177                                    throw processException(e);
18178                            }
18179                            finally {
18180                                    closeSession(session);
18181                            }
18182                    }
18183    
18184                    return list;
18185            }
18186    
18187            /**
18188             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status &ne; &#63;.
18189             *
18190             * @param nodeId the node ID
18191             * @param head the head
18192             * @param parentTitle the parent title
18193             * @param status the status
18194             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18195             * @return the first matching wiki page
18196             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
18197             */
18198            @Override
18199            public WikiPage findByN_H_P_NotS_First(long nodeId, boolean head,
18200                    String parentTitle, int status,
18201                    OrderByComparator<WikiPage> orderByComparator)
18202                    throws NoSuchPageException {
18203                    WikiPage wikiPage = fetchByN_H_P_NotS_First(nodeId, head, parentTitle,
18204                                    status, orderByComparator);
18205    
18206                    if (wikiPage != null) {
18207                            return wikiPage;
18208                    }
18209    
18210                    StringBundler msg = new StringBundler(10);
18211    
18212                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18213    
18214                    msg.append("nodeId=");
18215                    msg.append(nodeId);
18216    
18217                    msg.append(", head=");
18218                    msg.append(head);
18219    
18220                    msg.append(", parentTitle=");
18221                    msg.append(parentTitle);
18222    
18223                    msg.append(", status=");
18224                    msg.append(status);
18225    
18226                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18227    
18228                    throw new NoSuchPageException(msg.toString());
18229            }
18230    
18231            /**
18232             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status &ne; &#63;.
18233             *
18234             * @param nodeId the node ID
18235             * @param head the head
18236             * @param parentTitle the parent title
18237             * @param status the status
18238             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18239             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
18240             */
18241            @Override
18242            public WikiPage fetchByN_H_P_NotS_First(long nodeId, boolean head,
18243                    String parentTitle, int status,
18244                    OrderByComparator<WikiPage> orderByComparator) {
18245                    List<WikiPage> list = findByN_H_P_NotS(nodeId, head, parentTitle,
18246                                    status, 0, 1, orderByComparator);
18247    
18248                    if (!list.isEmpty()) {
18249                            return list.get(0);
18250                    }
18251    
18252                    return null;
18253            }
18254    
18255            /**
18256             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status &ne; &#63;.
18257             *
18258             * @param nodeId the node ID
18259             * @param head the head
18260             * @param parentTitle the parent title
18261             * @param status the status
18262             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18263             * @return the last matching wiki page
18264             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
18265             */
18266            @Override
18267            public WikiPage findByN_H_P_NotS_Last(long nodeId, boolean head,
18268                    String parentTitle, int status,
18269                    OrderByComparator<WikiPage> orderByComparator)
18270                    throws NoSuchPageException {
18271                    WikiPage wikiPage = fetchByN_H_P_NotS_Last(nodeId, head, parentTitle,
18272                                    status, orderByComparator);
18273    
18274                    if (wikiPage != null) {
18275                            return wikiPage;
18276                    }
18277    
18278                    StringBundler msg = new StringBundler(10);
18279    
18280                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18281    
18282                    msg.append("nodeId=");
18283                    msg.append(nodeId);
18284    
18285                    msg.append(", head=");
18286                    msg.append(head);
18287    
18288                    msg.append(", parentTitle=");
18289                    msg.append(parentTitle);
18290    
18291                    msg.append(", status=");
18292                    msg.append(status);
18293    
18294                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18295    
18296                    throw new NoSuchPageException(msg.toString());
18297            }
18298    
18299            /**
18300             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status &ne; &#63;.
18301             *
18302             * @param nodeId the node ID
18303             * @param head the head
18304             * @param parentTitle the parent title
18305             * @param status the status
18306             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18307             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
18308             */
18309            @Override
18310            public WikiPage fetchByN_H_P_NotS_Last(long nodeId, boolean head,
18311                    String parentTitle, int status,
18312                    OrderByComparator<WikiPage> orderByComparator) {
18313                    int count = countByN_H_P_NotS(nodeId, head, parentTitle, status);
18314    
18315                    if (count == 0) {
18316                            return null;
18317                    }
18318    
18319                    List<WikiPage> list = findByN_H_P_NotS(nodeId, head, parentTitle,
18320                                    status, count - 1, count, orderByComparator);
18321    
18322                    if (!list.isEmpty()) {
18323                            return list.get(0);
18324                    }
18325    
18326                    return null;
18327            }
18328    
18329            /**
18330             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status &ne; &#63;.
18331             *
18332             * @param pageId the primary key of the current wiki page
18333             * @param nodeId the node ID
18334             * @param head the head
18335             * @param parentTitle the parent title
18336             * @param status the status
18337             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18338             * @return the previous, current, and next wiki page
18339             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
18340             */
18341            @Override
18342            public WikiPage[] findByN_H_P_NotS_PrevAndNext(long pageId, long nodeId,
18343                    boolean head, String parentTitle, int status,
18344                    OrderByComparator<WikiPage> orderByComparator)
18345                    throws NoSuchPageException {
18346                    WikiPage wikiPage = findByPrimaryKey(pageId);
18347    
18348                    Session session = null;
18349    
18350                    try {
18351                            session = openSession();
18352    
18353                            WikiPage[] array = new WikiPageImpl[3];
18354    
18355                            array[0] = getByN_H_P_NotS_PrevAndNext(session, wikiPage, nodeId,
18356                                            head, parentTitle, status, orderByComparator, true);
18357    
18358                            array[1] = wikiPage;
18359    
18360                            array[2] = getByN_H_P_NotS_PrevAndNext(session, wikiPage, nodeId,
18361                                            head, parentTitle, status, orderByComparator, false);
18362    
18363                            return array;
18364                    }
18365                    catch (Exception e) {
18366                            throw processException(e);
18367                    }
18368                    finally {
18369                            closeSession(session);
18370                    }
18371            }
18372    
18373            protected WikiPage getByN_H_P_NotS_PrevAndNext(Session session,
18374                    WikiPage wikiPage, long nodeId, boolean head, String parentTitle,
18375                    int status, OrderByComparator<WikiPage> orderByComparator,
18376                    boolean previous) {
18377                    StringBundler query = null;
18378    
18379                    if (orderByComparator != null) {
18380                            query = new StringBundler(6 +
18381                                            (orderByComparator.getOrderByFields().length * 6));
18382                    }
18383                    else {
18384                            query = new StringBundler(3);
18385                    }
18386    
18387                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
18388    
18389                    query.append(_FINDER_COLUMN_N_H_P_NOTS_NODEID_2);
18390    
18391                    query.append(_FINDER_COLUMN_N_H_P_NOTS_HEAD_2);
18392    
18393                    boolean bindParentTitle = false;
18394    
18395                    if (parentTitle == null) {
18396                            query.append(_FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_1);
18397                    }
18398                    else if (parentTitle.equals(StringPool.BLANK)) {
18399                            query.append(_FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_3);
18400                    }
18401                    else {
18402                            bindParentTitle = true;
18403    
18404                            query.append(_FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_2);
18405                    }
18406    
18407                    query.append(_FINDER_COLUMN_N_H_P_NOTS_STATUS_2);
18408    
18409                    if (orderByComparator != null) {
18410                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18411    
18412                            if (orderByConditionFields.length > 0) {
18413                                    query.append(WHERE_AND);
18414                            }
18415    
18416                            for (int i = 0; i < orderByConditionFields.length; i++) {
18417                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18418                                    query.append(orderByConditionFields[i]);
18419    
18420                                    if ((i + 1) < orderByConditionFields.length) {
18421                                            if (orderByComparator.isAscending() ^ previous) {
18422                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18423                                            }
18424                                            else {
18425                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18426                                            }
18427                                    }
18428                                    else {
18429                                            if (orderByComparator.isAscending() ^ previous) {
18430                                                    query.append(WHERE_GREATER_THAN);
18431                                            }
18432                                            else {
18433                                                    query.append(WHERE_LESSER_THAN);
18434                                            }
18435                                    }
18436                            }
18437    
18438                            query.append(ORDER_BY_CLAUSE);
18439    
18440                            String[] orderByFields = orderByComparator.getOrderByFields();
18441    
18442                            for (int i = 0; i < orderByFields.length; i++) {
18443                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18444                                    query.append(orderByFields[i]);
18445    
18446                                    if ((i + 1) < orderByFields.length) {
18447                                            if (orderByComparator.isAscending() ^ previous) {
18448                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18449                                            }
18450                                            else {
18451                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18452                                            }
18453                                    }
18454                                    else {
18455                                            if (orderByComparator.isAscending() ^ previous) {
18456                                                    query.append(ORDER_BY_ASC);
18457                                            }
18458                                            else {
18459                                                    query.append(ORDER_BY_DESC);
18460                                            }
18461                                    }
18462                            }
18463                    }
18464                    else {
18465                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
18466                    }
18467    
18468                    String sql = query.toString();
18469    
18470                    Query q = session.createQuery(sql);
18471    
18472                    q.setFirstResult(0);
18473                    q.setMaxResults(2);
18474    
18475                    QueryPos qPos = QueryPos.getInstance(q);
18476    
18477                    qPos.add(nodeId);
18478    
18479                    qPos.add(head);
18480    
18481                    if (bindParentTitle) {
18482                            qPos.add(StringUtil.toLowerCase(parentTitle));
18483                    }
18484    
18485                    qPos.add(status);
18486    
18487                    if (orderByComparator != null) {
18488                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
18489    
18490                            for (Object value : values) {
18491                                    qPos.add(value);
18492                            }
18493                    }
18494    
18495                    List<WikiPage> list = q.list();
18496    
18497                    if (list.size() == 2) {
18498                            return list.get(1);
18499                    }
18500                    else {
18501                            return null;
18502                    }
18503            }
18504    
18505            /**
18506             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status &ne; &#63; from the database.
18507             *
18508             * @param nodeId the node ID
18509             * @param head the head
18510             * @param parentTitle the parent title
18511             * @param status the status
18512             */
18513            @Override
18514            public void removeByN_H_P_NotS(long nodeId, boolean head,
18515                    String parentTitle, int status) {
18516                    for (WikiPage wikiPage : findByN_H_P_NotS(nodeId, head, parentTitle,
18517                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18518                            remove(wikiPage);
18519                    }
18520            }
18521    
18522            /**
18523             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status &ne; &#63;.
18524             *
18525             * @param nodeId the node ID
18526             * @param head the head
18527             * @param parentTitle the parent title
18528             * @param status the status
18529             * @return the number of matching wiki pages
18530             */
18531            @Override
18532            public int countByN_H_P_NotS(long nodeId, boolean head, String parentTitle,
18533                    int status) {
18534                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_N_H_P_NOTS;
18535    
18536                    Object[] finderArgs = new Object[] { nodeId, head, parentTitle, status };
18537    
18538                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18539                                    this);
18540    
18541                    if (count == null) {
18542                            StringBundler query = new StringBundler(5);
18543    
18544                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
18545    
18546                            query.append(_FINDER_COLUMN_N_H_P_NOTS_NODEID_2);
18547    
18548                            query.append(_FINDER_COLUMN_N_H_P_NOTS_HEAD_2);
18549    
18550                            boolean bindParentTitle = false;
18551    
18552                            if (parentTitle == null) {
18553                                    query.append(_FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_1);
18554                            }
18555                            else if (parentTitle.equals(StringPool.BLANK)) {
18556                                    query.append(_FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_3);
18557                            }
18558                            else {
18559                                    bindParentTitle = true;
18560    
18561                                    query.append(_FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_2);
18562                            }
18563    
18564                            query.append(_FINDER_COLUMN_N_H_P_NOTS_STATUS_2);
18565    
18566                            String sql = query.toString();
18567    
18568                            Session session = null;
18569    
18570                            try {
18571                                    session = openSession();
18572    
18573                                    Query q = session.createQuery(sql);
18574    
18575                                    QueryPos qPos = QueryPos.getInstance(q);
18576    
18577                                    qPos.add(nodeId);
18578    
18579                                    qPos.add(head);
18580    
18581                                    if (bindParentTitle) {
18582                                            qPos.add(StringUtil.toLowerCase(parentTitle));
18583                                    }
18584    
18585                                    qPos.add(status);
18586    
18587                                    count = (Long)q.uniqueResult();
18588    
18589                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18590                            }
18591                            catch (Exception e) {
18592                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18593    
18594                                    throw processException(e);
18595                            }
18596                            finally {
18597                                    closeSession(session);
18598                            }
18599                    }
18600    
18601                    return count.intValue();
18602            }
18603    
18604            private static final String _FINDER_COLUMN_N_H_P_NOTS_NODEID_2 = "wikiPage.nodeId = ? AND ";
18605            private static final String _FINDER_COLUMN_N_H_P_NOTS_HEAD_2 = "wikiPage.head = ? AND ";
18606            private static final String _FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL AND ";
18607            private static final String _FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = ? AND ";
18608            private static final String _FINDER_COLUMN_N_H_P_NOTS_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = '') AND ";
18609            private static final String _FINDER_COLUMN_N_H_P_NOTS_STATUS_2 = "wikiPage.status != ?";
18610            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_R_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
18611                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
18612                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_R_S",
18613                            new String[] {
18614                                    Long.class.getName(), Boolean.class.getName(),
18615                                    String.class.getName(), Integer.class.getName(),
18616                                    
18617                            Integer.class.getName(), Integer.class.getName(),
18618                                    OrderByComparator.class.getName()
18619                            });
18620            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_R_S =
18621                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
18622                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
18623                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_R_S",
18624                            new String[] {
18625                                    Long.class.getName(), Boolean.class.getName(),
18626                                    String.class.getName(), Integer.class.getName()
18627                            },
18628                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
18629                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
18630                            WikiPageModelImpl.REDIRECTTITLE_COLUMN_BITMASK |
18631                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
18632                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
18633                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
18634            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_R_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
18635                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
18636                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_R_S",
18637                            new String[] {
18638                                    Long.class.getName(), Boolean.class.getName(),
18639                                    String.class.getName(), Integer.class.getName()
18640                            });
18641    
18642            /**
18643             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status = &#63;.
18644             *
18645             * @param nodeId the node ID
18646             * @param head the head
18647             * @param redirectTitle the redirect title
18648             * @param status the status
18649             * @return the matching wiki pages
18650             */
18651            @Override
18652            public List<WikiPage> findByN_H_R_S(long nodeId, boolean head,
18653                    String redirectTitle, int status) {
18654                    return findByN_H_R_S(nodeId, head, redirectTitle, status,
18655                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18656            }
18657    
18658            /**
18659             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status = &#63;.
18660             *
18661             * <p>
18662             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
18663             * </p>
18664             *
18665             * @param nodeId the node ID
18666             * @param head the head
18667             * @param redirectTitle the redirect title
18668             * @param status the status
18669             * @param start the lower bound of the range of wiki pages
18670             * @param end the upper bound of the range of wiki pages (not inclusive)
18671             * @return the range of matching wiki pages
18672             */
18673            @Override
18674            public List<WikiPage> findByN_H_R_S(long nodeId, boolean head,
18675                    String redirectTitle, int status, int start, int end) {
18676                    return findByN_H_R_S(nodeId, head, redirectTitle, status, start, end,
18677                            null);
18678            }
18679    
18680            /**
18681             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status = &#63;.
18682             *
18683             * <p>
18684             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
18685             * </p>
18686             *
18687             * @param nodeId the node ID
18688             * @param head the head
18689             * @param redirectTitle the redirect title
18690             * @param status the status
18691             * @param start the lower bound of the range of wiki pages
18692             * @param end the upper bound of the range of wiki pages (not inclusive)
18693             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18694             * @return the ordered range of matching wiki pages
18695             */
18696            @Override
18697            public List<WikiPage> findByN_H_R_S(long nodeId, boolean head,
18698                    String redirectTitle, int status, int start, int end,
18699                    OrderByComparator<WikiPage> orderByComparator) {
18700                    boolean pagination = true;
18701                    FinderPath finderPath = null;
18702                    Object[] finderArgs = null;
18703    
18704                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18705                                    (orderByComparator == null)) {
18706                            pagination = false;
18707                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_R_S;
18708                            finderArgs = new Object[] { nodeId, head, redirectTitle, status };
18709                    }
18710                    else {
18711                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_R_S;
18712                            finderArgs = new Object[] {
18713                                            nodeId, head, redirectTitle, status,
18714                                            
18715                                            start, end, orderByComparator
18716                                    };
18717                    }
18718    
18719                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
18720                                    finderArgs, this);
18721    
18722                    if ((list != null) && !list.isEmpty()) {
18723                            for (WikiPage wikiPage : list) {
18724                                    if ((nodeId != wikiPage.getNodeId()) ||
18725                                                    (head != wikiPage.getHead()) ||
18726                                                    !Validator.equals(redirectTitle,
18727                                                            wikiPage.getRedirectTitle()) ||
18728                                                    (status != wikiPage.getStatus())) {
18729                                            list = null;
18730    
18731                                            break;
18732                                    }
18733                            }
18734                    }
18735    
18736                    if (list == null) {
18737                            StringBundler query = null;
18738    
18739                            if (orderByComparator != null) {
18740                                    query = new StringBundler(6 +
18741                                                    (orderByComparator.getOrderByFields().length * 3));
18742                            }
18743                            else {
18744                                    query = new StringBundler(6);
18745                            }
18746    
18747                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
18748    
18749                            query.append(_FINDER_COLUMN_N_H_R_S_NODEID_2);
18750    
18751                            query.append(_FINDER_COLUMN_N_H_R_S_HEAD_2);
18752    
18753                            boolean bindRedirectTitle = false;
18754    
18755                            if (redirectTitle == null) {
18756                                    query.append(_FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_1);
18757                            }
18758                            else if (redirectTitle.equals(StringPool.BLANK)) {
18759                                    query.append(_FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_3);
18760                            }
18761                            else {
18762                                    bindRedirectTitle = true;
18763    
18764                                    query.append(_FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_2);
18765                            }
18766    
18767                            query.append(_FINDER_COLUMN_N_H_R_S_STATUS_2);
18768    
18769                            if (orderByComparator != null) {
18770                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18771                                            orderByComparator);
18772                            }
18773                            else
18774                             if (pagination) {
18775                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
18776                            }
18777    
18778                            String sql = query.toString();
18779    
18780                            Session session = null;
18781    
18782                            try {
18783                                    session = openSession();
18784    
18785                                    Query q = session.createQuery(sql);
18786    
18787                                    QueryPos qPos = QueryPos.getInstance(q);
18788    
18789                                    qPos.add(nodeId);
18790    
18791                                    qPos.add(head);
18792    
18793                                    if (bindRedirectTitle) {
18794                                            qPos.add(StringUtil.toLowerCase(redirectTitle));
18795                                    }
18796    
18797                                    qPos.add(status);
18798    
18799                                    if (!pagination) {
18800                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
18801                                                            start, end, false);
18802    
18803                                            Collections.sort(list);
18804    
18805                                            list = Collections.unmodifiableList(list);
18806                                    }
18807                                    else {
18808                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
18809                                                            start, end);
18810                                    }
18811    
18812                                    cacheResult(list);
18813    
18814                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18815                            }
18816                            catch (Exception e) {
18817                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18818    
18819                                    throw processException(e);
18820                            }
18821                            finally {
18822                                    closeSession(session);
18823                            }
18824                    }
18825    
18826                    return list;
18827            }
18828    
18829            /**
18830             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status = &#63;.
18831             *
18832             * @param nodeId the node ID
18833             * @param head the head
18834             * @param redirectTitle the redirect title
18835             * @param status the status
18836             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18837             * @return the first matching wiki page
18838             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
18839             */
18840            @Override
18841            public WikiPage findByN_H_R_S_First(long nodeId, boolean head,
18842                    String redirectTitle, int status,
18843                    OrderByComparator<WikiPage> orderByComparator)
18844                    throws NoSuchPageException {
18845                    WikiPage wikiPage = fetchByN_H_R_S_First(nodeId, head, redirectTitle,
18846                                    status, orderByComparator);
18847    
18848                    if (wikiPage != null) {
18849                            return wikiPage;
18850                    }
18851    
18852                    StringBundler msg = new StringBundler(10);
18853    
18854                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18855    
18856                    msg.append("nodeId=");
18857                    msg.append(nodeId);
18858    
18859                    msg.append(", head=");
18860                    msg.append(head);
18861    
18862                    msg.append(", redirectTitle=");
18863                    msg.append(redirectTitle);
18864    
18865                    msg.append(", status=");
18866                    msg.append(status);
18867    
18868                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18869    
18870                    throw new NoSuchPageException(msg.toString());
18871            }
18872    
18873            /**
18874             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status = &#63;.
18875             *
18876             * @param nodeId the node ID
18877             * @param head the head
18878             * @param redirectTitle the redirect title
18879             * @param status the status
18880             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18881             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
18882             */
18883            @Override
18884            public WikiPage fetchByN_H_R_S_First(long nodeId, boolean head,
18885                    String redirectTitle, int status,
18886                    OrderByComparator<WikiPage> orderByComparator) {
18887                    List<WikiPage> list = findByN_H_R_S(nodeId, head, redirectTitle,
18888                                    status, 0, 1, orderByComparator);
18889    
18890                    if (!list.isEmpty()) {
18891                            return list.get(0);
18892                    }
18893    
18894                    return null;
18895            }
18896    
18897            /**
18898             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status = &#63;.
18899             *
18900             * @param nodeId the node ID
18901             * @param head the head
18902             * @param redirectTitle the redirect title
18903             * @param status the status
18904             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18905             * @return the last matching wiki page
18906             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
18907             */
18908            @Override
18909            public WikiPage findByN_H_R_S_Last(long nodeId, boolean head,
18910                    String redirectTitle, int status,
18911                    OrderByComparator<WikiPage> orderByComparator)
18912                    throws NoSuchPageException {
18913                    WikiPage wikiPage = fetchByN_H_R_S_Last(nodeId, head, redirectTitle,
18914                                    status, orderByComparator);
18915    
18916                    if (wikiPage != null) {
18917                            return wikiPage;
18918                    }
18919    
18920                    StringBundler msg = new StringBundler(10);
18921    
18922                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18923    
18924                    msg.append("nodeId=");
18925                    msg.append(nodeId);
18926    
18927                    msg.append(", head=");
18928                    msg.append(head);
18929    
18930                    msg.append(", redirectTitle=");
18931                    msg.append(redirectTitle);
18932    
18933                    msg.append(", status=");
18934                    msg.append(status);
18935    
18936                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18937    
18938                    throw new NoSuchPageException(msg.toString());
18939            }
18940    
18941            /**
18942             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status = &#63;.
18943             *
18944             * @param nodeId the node ID
18945             * @param head the head
18946             * @param redirectTitle the redirect title
18947             * @param status the status
18948             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18949             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
18950             */
18951            @Override
18952            public WikiPage fetchByN_H_R_S_Last(long nodeId, boolean head,
18953                    String redirectTitle, int status,
18954                    OrderByComparator<WikiPage> orderByComparator) {
18955                    int count = countByN_H_R_S(nodeId, head, redirectTitle, status);
18956    
18957                    if (count == 0) {
18958                            return null;
18959                    }
18960    
18961                    List<WikiPage> list = findByN_H_R_S(nodeId, head, redirectTitle,
18962                                    status, count - 1, count, orderByComparator);
18963    
18964                    if (!list.isEmpty()) {
18965                            return list.get(0);
18966                    }
18967    
18968                    return null;
18969            }
18970    
18971            /**
18972             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status = &#63;.
18973             *
18974             * @param pageId the primary key of the current wiki page
18975             * @param nodeId the node ID
18976             * @param head the head
18977             * @param redirectTitle the redirect title
18978             * @param status the status
18979             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18980             * @return the previous, current, and next wiki page
18981             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
18982             */
18983            @Override
18984            public WikiPage[] findByN_H_R_S_PrevAndNext(long pageId, long nodeId,
18985                    boolean head, String redirectTitle, int status,
18986                    OrderByComparator<WikiPage> orderByComparator)
18987                    throws NoSuchPageException {
18988                    WikiPage wikiPage = findByPrimaryKey(pageId);
18989    
18990                    Session session = null;
18991    
18992                    try {
18993                            session = openSession();
18994    
18995                            WikiPage[] array = new WikiPageImpl[3];
18996    
18997                            array[0] = getByN_H_R_S_PrevAndNext(session, wikiPage, nodeId,
18998                                            head, redirectTitle, status, orderByComparator, true);
18999    
19000                            array[1] = wikiPage;
19001    
19002                            array[2] = getByN_H_R_S_PrevAndNext(session, wikiPage, nodeId,
19003                                            head, redirectTitle, status, orderByComparator, false);
19004    
19005                            return array;
19006                    }
19007                    catch (Exception e) {
19008                            throw processException(e);
19009                    }
19010                    finally {
19011                            closeSession(session);
19012                    }
19013            }
19014    
19015            protected WikiPage getByN_H_R_S_PrevAndNext(Session session,
19016                    WikiPage wikiPage, long nodeId, boolean head, String redirectTitle,
19017                    int status, OrderByComparator<WikiPage> orderByComparator,
19018                    boolean previous) {
19019                    StringBundler query = null;
19020    
19021                    if (orderByComparator != null) {
19022                            query = new StringBundler(6 +
19023                                            (orderByComparator.getOrderByFields().length * 6));
19024                    }
19025                    else {
19026                            query = new StringBundler(3);
19027                    }
19028    
19029                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
19030    
19031                    query.append(_FINDER_COLUMN_N_H_R_S_NODEID_2);
19032    
19033                    query.append(_FINDER_COLUMN_N_H_R_S_HEAD_2);
19034    
19035                    boolean bindRedirectTitle = false;
19036    
19037                    if (redirectTitle == null) {
19038                            query.append(_FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_1);
19039                    }
19040                    else if (redirectTitle.equals(StringPool.BLANK)) {
19041                            query.append(_FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_3);
19042                    }
19043                    else {
19044                            bindRedirectTitle = true;
19045    
19046                            query.append(_FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_2);
19047                    }
19048    
19049                    query.append(_FINDER_COLUMN_N_H_R_S_STATUS_2);
19050    
19051                    if (orderByComparator != null) {
19052                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19053    
19054                            if (orderByConditionFields.length > 0) {
19055                                    query.append(WHERE_AND);
19056                            }
19057    
19058                            for (int i = 0; i < orderByConditionFields.length; i++) {
19059                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19060                                    query.append(orderByConditionFields[i]);
19061    
19062                                    if ((i + 1) < orderByConditionFields.length) {
19063                                            if (orderByComparator.isAscending() ^ previous) {
19064                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19065                                            }
19066                                            else {
19067                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19068                                            }
19069                                    }
19070                                    else {
19071                                            if (orderByComparator.isAscending() ^ previous) {
19072                                                    query.append(WHERE_GREATER_THAN);
19073                                            }
19074                                            else {
19075                                                    query.append(WHERE_LESSER_THAN);
19076                                            }
19077                                    }
19078                            }
19079    
19080                            query.append(ORDER_BY_CLAUSE);
19081    
19082                            String[] orderByFields = orderByComparator.getOrderByFields();
19083    
19084                            for (int i = 0; i < orderByFields.length; i++) {
19085                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19086                                    query.append(orderByFields[i]);
19087    
19088                                    if ((i + 1) < orderByFields.length) {
19089                                            if (orderByComparator.isAscending() ^ previous) {
19090                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19091                                            }
19092                                            else {
19093                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19094                                            }
19095                                    }
19096                                    else {
19097                                            if (orderByComparator.isAscending() ^ previous) {
19098                                                    query.append(ORDER_BY_ASC);
19099                                            }
19100                                            else {
19101                                                    query.append(ORDER_BY_DESC);
19102                                            }
19103                                    }
19104                            }
19105                    }
19106                    else {
19107                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
19108                    }
19109    
19110                    String sql = query.toString();
19111    
19112                    Query q = session.createQuery(sql);
19113    
19114                    q.setFirstResult(0);
19115                    q.setMaxResults(2);
19116    
19117                    QueryPos qPos = QueryPos.getInstance(q);
19118    
19119                    qPos.add(nodeId);
19120    
19121                    qPos.add(head);
19122    
19123                    if (bindRedirectTitle) {
19124                            qPos.add(StringUtil.toLowerCase(redirectTitle));
19125                    }
19126    
19127                    qPos.add(status);
19128    
19129                    if (orderByComparator != null) {
19130                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
19131    
19132                            for (Object value : values) {
19133                                    qPos.add(value);
19134                            }
19135                    }
19136    
19137                    List<WikiPage> list = q.list();
19138    
19139                    if (list.size() == 2) {
19140                            return list.get(1);
19141                    }
19142                    else {
19143                            return null;
19144                    }
19145            }
19146    
19147            /**
19148             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status = &#63; from the database.
19149             *
19150             * @param nodeId the node ID
19151             * @param head the head
19152             * @param redirectTitle the redirect title
19153             * @param status the status
19154             */
19155            @Override
19156            public void removeByN_H_R_S(long nodeId, boolean head,
19157                    String redirectTitle, int status) {
19158                    for (WikiPage wikiPage : findByN_H_R_S(nodeId, head, redirectTitle,
19159                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19160                            remove(wikiPage);
19161                    }
19162            }
19163    
19164            /**
19165             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status = &#63;.
19166             *
19167             * @param nodeId the node ID
19168             * @param head the head
19169             * @param redirectTitle the redirect title
19170             * @param status the status
19171             * @return the number of matching wiki pages
19172             */
19173            @Override
19174            public int countByN_H_R_S(long nodeId, boolean head, String redirectTitle,
19175                    int status) {
19176                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_H_R_S;
19177    
19178                    Object[] finderArgs = new Object[] { nodeId, head, redirectTitle, status };
19179    
19180                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19181                                    this);
19182    
19183                    if (count == null) {
19184                            StringBundler query = new StringBundler(5);
19185    
19186                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
19187    
19188                            query.append(_FINDER_COLUMN_N_H_R_S_NODEID_2);
19189    
19190                            query.append(_FINDER_COLUMN_N_H_R_S_HEAD_2);
19191    
19192                            boolean bindRedirectTitle = false;
19193    
19194                            if (redirectTitle == null) {
19195                                    query.append(_FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_1);
19196                            }
19197                            else if (redirectTitle.equals(StringPool.BLANK)) {
19198                                    query.append(_FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_3);
19199                            }
19200                            else {
19201                                    bindRedirectTitle = true;
19202    
19203                                    query.append(_FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_2);
19204                            }
19205    
19206                            query.append(_FINDER_COLUMN_N_H_R_S_STATUS_2);
19207    
19208                            String sql = query.toString();
19209    
19210                            Session session = null;
19211    
19212                            try {
19213                                    session = openSession();
19214    
19215                                    Query q = session.createQuery(sql);
19216    
19217                                    QueryPos qPos = QueryPos.getInstance(q);
19218    
19219                                    qPos.add(nodeId);
19220    
19221                                    qPos.add(head);
19222    
19223                                    if (bindRedirectTitle) {
19224                                            qPos.add(StringUtil.toLowerCase(redirectTitle));
19225                                    }
19226    
19227                                    qPos.add(status);
19228    
19229                                    count = (Long)q.uniqueResult();
19230    
19231                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19232                            }
19233                            catch (Exception e) {
19234                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19235    
19236                                    throw processException(e);
19237                            }
19238                            finally {
19239                                    closeSession(session);
19240                            }
19241                    }
19242    
19243                    return count.intValue();
19244            }
19245    
19246            private static final String _FINDER_COLUMN_N_H_R_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
19247            private static final String _FINDER_COLUMN_N_H_R_S_HEAD_2 = "wikiPage.head = ? AND ";
19248            private static final String _FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_1 = "wikiPage.redirectTitle IS NULL AND ";
19249            private static final String _FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_2 = "lower(wikiPage.redirectTitle) = ? AND ";
19250            private static final String _FINDER_COLUMN_N_H_R_S_REDIRECTTITLE_3 = "(wikiPage.redirectTitle IS NULL OR wikiPage.redirectTitle = '') AND ";
19251            private static final String _FINDER_COLUMN_N_H_R_S_STATUS_2 = "wikiPage.status = ?";
19252            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_R_NOTS =
19253                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
19254                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
19255                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_R_NotS",
19256                            new String[] {
19257                                    Long.class.getName(), Boolean.class.getName(),
19258                                    String.class.getName(), Integer.class.getName(),
19259                                    
19260                            Integer.class.getName(), Integer.class.getName(),
19261                                    OrderByComparator.class.getName()
19262                            });
19263            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_N_H_R_NOTS =
19264                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
19265                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
19266                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByN_H_R_NotS",
19267                            new String[] {
19268                                    Long.class.getName(), Boolean.class.getName(),
19269                                    String.class.getName(), Integer.class.getName()
19270                            });
19271    
19272            /**
19273             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status &ne; &#63;.
19274             *
19275             * @param nodeId the node ID
19276             * @param head the head
19277             * @param redirectTitle the redirect title
19278             * @param status the status
19279             * @return the matching wiki pages
19280             */
19281            @Override
19282            public List<WikiPage> findByN_H_R_NotS(long nodeId, boolean head,
19283                    String redirectTitle, int status) {
19284                    return findByN_H_R_NotS(nodeId, head, redirectTitle, status,
19285                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19286            }
19287    
19288            /**
19289             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status &ne; &#63;.
19290             *
19291             * <p>
19292             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
19293             * </p>
19294             *
19295             * @param nodeId the node ID
19296             * @param head the head
19297             * @param redirectTitle the redirect title
19298             * @param status the status
19299             * @param start the lower bound of the range of wiki pages
19300             * @param end the upper bound of the range of wiki pages (not inclusive)
19301             * @return the range of matching wiki pages
19302             */
19303            @Override
19304            public List<WikiPage> findByN_H_R_NotS(long nodeId, boolean head,
19305                    String redirectTitle, int status, int start, int end) {
19306                    return findByN_H_R_NotS(nodeId, head, redirectTitle, status, start,
19307                            end, null);
19308            }
19309    
19310            /**
19311             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status &ne; &#63;.
19312             *
19313             * <p>
19314             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
19315             * </p>
19316             *
19317             * @param nodeId the node ID
19318             * @param head the head
19319             * @param redirectTitle the redirect title
19320             * @param status the status
19321             * @param start the lower bound of the range of wiki pages
19322             * @param end the upper bound of the range of wiki pages (not inclusive)
19323             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19324             * @return the ordered range of matching wiki pages
19325             */
19326            @Override
19327            public List<WikiPage> findByN_H_R_NotS(long nodeId, boolean head,
19328                    String redirectTitle, int status, int start, int end,
19329                    OrderByComparator<WikiPage> orderByComparator) {
19330                    boolean pagination = true;
19331                    FinderPath finderPath = null;
19332                    Object[] finderArgs = null;
19333    
19334                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_R_NOTS;
19335                    finderArgs = new Object[] {
19336                                    nodeId, head, redirectTitle, status,
19337                                    
19338                                    start, end, orderByComparator
19339                            };
19340    
19341                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
19342                                    finderArgs, this);
19343    
19344                    if ((list != null) && !list.isEmpty()) {
19345                            for (WikiPage wikiPage : list) {
19346                                    if ((nodeId != wikiPage.getNodeId()) ||
19347                                                    (head != wikiPage.getHead()) ||
19348                                                    !Validator.equals(redirectTitle,
19349                                                            wikiPage.getRedirectTitle()) ||
19350                                                    (status == wikiPage.getStatus())) {
19351                                            list = null;
19352    
19353                                            break;
19354                                    }
19355                            }
19356                    }
19357    
19358                    if (list == null) {
19359                            StringBundler query = null;
19360    
19361                            if (orderByComparator != null) {
19362                                    query = new StringBundler(6 +
19363                                                    (orderByComparator.getOrderByFields().length * 3));
19364                            }
19365                            else {
19366                                    query = new StringBundler(6);
19367                            }
19368    
19369                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
19370    
19371                            query.append(_FINDER_COLUMN_N_H_R_NOTS_NODEID_2);
19372    
19373                            query.append(_FINDER_COLUMN_N_H_R_NOTS_HEAD_2);
19374    
19375                            boolean bindRedirectTitle = false;
19376    
19377                            if (redirectTitle == null) {
19378                                    query.append(_FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_1);
19379                            }
19380                            else if (redirectTitle.equals(StringPool.BLANK)) {
19381                                    query.append(_FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_3);
19382                            }
19383                            else {
19384                                    bindRedirectTitle = true;
19385    
19386                                    query.append(_FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_2);
19387                            }
19388    
19389                            query.append(_FINDER_COLUMN_N_H_R_NOTS_STATUS_2);
19390    
19391                            if (orderByComparator != null) {
19392                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19393                                            orderByComparator);
19394                            }
19395                            else
19396                             if (pagination) {
19397                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
19398                            }
19399    
19400                            String sql = query.toString();
19401    
19402                            Session session = null;
19403    
19404                            try {
19405                                    session = openSession();
19406    
19407                                    Query q = session.createQuery(sql);
19408    
19409                                    QueryPos qPos = QueryPos.getInstance(q);
19410    
19411                                    qPos.add(nodeId);
19412    
19413                                    qPos.add(head);
19414    
19415                                    if (bindRedirectTitle) {
19416                                            qPos.add(StringUtil.toLowerCase(redirectTitle));
19417                                    }
19418    
19419                                    qPos.add(status);
19420    
19421                                    if (!pagination) {
19422                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
19423                                                            start, end, false);
19424    
19425                                            Collections.sort(list);
19426    
19427                                            list = Collections.unmodifiableList(list);
19428                                    }
19429                                    else {
19430                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
19431                                                            start, end);
19432                                    }
19433    
19434                                    cacheResult(list);
19435    
19436                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19437                            }
19438                            catch (Exception e) {
19439                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19440    
19441                                    throw processException(e);
19442                            }
19443                            finally {
19444                                    closeSession(session);
19445                            }
19446                    }
19447    
19448                    return list;
19449            }
19450    
19451            /**
19452             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status &ne; &#63;.
19453             *
19454             * @param nodeId the node ID
19455             * @param head the head
19456             * @param redirectTitle the redirect title
19457             * @param status the status
19458             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19459             * @return the first matching wiki page
19460             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
19461             */
19462            @Override
19463            public WikiPage findByN_H_R_NotS_First(long nodeId, boolean head,
19464                    String redirectTitle, int status,
19465                    OrderByComparator<WikiPage> orderByComparator)
19466                    throws NoSuchPageException {
19467                    WikiPage wikiPage = fetchByN_H_R_NotS_First(nodeId, head,
19468                                    redirectTitle, status, orderByComparator);
19469    
19470                    if (wikiPage != null) {
19471                            return wikiPage;
19472                    }
19473    
19474                    StringBundler msg = new StringBundler(10);
19475    
19476                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19477    
19478                    msg.append("nodeId=");
19479                    msg.append(nodeId);
19480    
19481                    msg.append(", head=");
19482                    msg.append(head);
19483    
19484                    msg.append(", redirectTitle=");
19485                    msg.append(redirectTitle);
19486    
19487                    msg.append(", status=");
19488                    msg.append(status);
19489    
19490                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19491    
19492                    throw new NoSuchPageException(msg.toString());
19493            }
19494    
19495            /**
19496             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status &ne; &#63;.
19497             *
19498             * @param nodeId the node ID
19499             * @param head the head
19500             * @param redirectTitle the redirect title
19501             * @param status the status
19502             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19503             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
19504             */
19505            @Override
19506            public WikiPage fetchByN_H_R_NotS_First(long nodeId, boolean head,
19507                    String redirectTitle, int status,
19508                    OrderByComparator<WikiPage> orderByComparator) {
19509                    List<WikiPage> list = findByN_H_R_NotS(nodeId, head, redirectTitle,
19510                                    status, 0, 1, orderByComparator);
19511    
19512                    if (!list.isEmpty()) {
19513                            return list.get(0);
19514                    }
19515    
19516                    return null;
19517            }
19518    
19519            /**
19520             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status &ne; &#63;.
19521             *
19522             * @param nodeId the node ID
19523             * @param head the head
19524             * @param redirectTitle the redirect title
19525             * @param status the status
19526             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19527             * @return the last matching wiki page
19528             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
19529             */
19530            @Override
19531            public WikiPage findByN_H_R_NotS_Last(long nodeId, boolean head,
19532                    String redirectTitle, int status,
19533                    OrderByComparator<WikiPage> orderByComparator)
19534                    throws NoSuchPageException {
19535                    WikiPage wikiPage = fetchByN_H_R_NotS_Last(nodeId, head, redirectTitle,
19536                                    status, orderByComparator);
19537    
19538                    if (wikiPage != null) {
19539                            return wikiPage;
19540                    }
19541    
19542                    StringBundler msg = new StringBundler(10);
19543    
19544                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19545    
19546                    msg.append("nodeId=");
19547                    msg.append(nodeId);
19548    
19549                    msg.append(", head=");
19550                    msg.append(head);
19551    
19552                    msg.append(", redirectTitle=");
19553                    msg.append(redirectTitle);
19554    
19555                    msg.append(", status=");
19556                    msg.append(status);
19557    
19558                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19559    
19560                    throw new NoSuchPageException(msg.toString());
19561            }
19562    
19563            /**
19564             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status &ne; &#63;.
19565             *
19566             * @param nodeId the node ID
19567             * @param head the head
19568             * @param redirectTitle the redirect title
19569             * @param status the status
19570             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19571             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
19572             */
19573            @Override
19574            public WikiPage fetchByN_H_R_NotS_Last(long nodeId, boolean head,
19575                    String redirectTitle, int status,
19576                    OrderByComparator<WikiPage> orderByComparator) {
19577                    int count = countByN_H_R_NotS(nodeId, head, redirectTitle, status);
19578    
19579                    if (count == 0) {
19580                            return null;
19581                    }
19582    
19583                    List<WikiPage> list = findByN_H_R_NotS(nodeId, head, redirectTitle,
19584                                    status, count - 1, count, orderByComparator);
19585    
19586                    if (!list.isEmpty()) {
19587                            return list.get(0);
19588                    }
19589    
19590                    return null;
19591            }
19592    
19593            /**
19594             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status &ne; &#63;.
19595             *
19596             * @param pageId the primary key of the current wiki page
19597             * @param nodeId the node ID
19598             * @param head the head
19599             * @param redirectTitle the redirect title
19600             * @param status the status
19601             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19602             * @return the previous, current, and next wiki page
19603             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
19604             */
19605            @Override
19606            public WikiPage[] findByN_H_R_NotS_PrevAndNext(long pageId, long nodeId,
19607                    boolean head, String redirectTitle, int status,
19608                    OrderByComparator<WikiPage> orderByComparator)
19609                    throws NoSuchPageException {
19610                    WikiPage wikiPage = findByPrimaryKey(pageId);
19611    
19612                    Session session = null;
19613    
19614                    try {
19615                            session = openSession();
19616    
19617                            WikiPage[] array = new WikiPageImpl[3];
19618    
19619                            array[0] = getByN_H_R_NotS_PrevAndNext(session, wikiPage, nodeId,
19620                                            head, redirectTitle, status, orderByComparator, true);
19621    
19622                            array[1] = wikiPage;
19623    
19624                            array[2] = getByN_H_R_NotS_PrevAndNext(session, wikiPage, nodeId,
19625                                            head, redirectTitle, status, orderByComparator, false);
19626    
19627                            return array;
19628                    }
19629                    catch (Exception e) {
19630                            throw processException(e);
19631                    }
19632                    finally {
19633                            closeSession(session);
19634                    }
19635            }
19636    
19637            protected WikiPage getByN_H_R_NotS_PrevAndNext(Session session,
19638                    WikiPage wikiPage, long nodeId, boolean head, String redirectTitle,
19639                    int status, OrderByComparator<WikiPage> orderByComparator,
19640                    boolean previous) {
19641                    StringBundler query = null;
19642    
19643                    if (orderByComparator != null) {
19644                            query = new StringBundler(6 +
19645                                            (orderByComparator.getOrderByFields().length * 6));
19646                    }
19647                    else {
19648                            query = new StringBundler(3);
19649                    }
19650    
19651                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
19652    
19653                    query.append(_FINDER_COLUMN_N_H_R_NOTS_NODEID_2);
19654    
19655                    query.append(_FINDER_COLUMN_N_H_R_NOTS_HEAD_2);
19656    
19657                    boolean bindRedirectTitle = false;
19658    
19659                    if (redirectTitle == null) {
19660                            query.append(_FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_1);
19661                    }
19662                    else if (redirectTitle.equals(StringPool.BLANK)) {
19663                            query.append(_FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_3);
19664                    }
19665                    else {
19666                            bindRedirectTitle = true;
19667    
19668                            query.append(_FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_2);
19669                    }
19670    
19671                    query.append(_FINDER_COLUMN_N_H_R_NOTS_STATUS_2);
19672    
19673                    if (orderByComparator != null) {
19674                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19675    
19676                            if (orderByConditionFields.length > 0) {
19677                                    query.append(WHERE_AND);
19678                            }
19679    
19680                            for (int i = 0; i < orderByConditionFields.length; i++) {
19681                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19682                                    query.append(orderByConditionFields[i]);
19683    
19684                                    if ((i + 1) < orderByConditionFields.length) {
19685                                            if (orderByComparator.isAscending() ^ previous) {
19686                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19687                                            }
19688                                            else {
19689                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19690                                            }
19691                                    }
19692                                    else {
19693                                            if (orderByComparator.isAscending() ^ previous) {
19694                                                    query.append(WHERE_GREATER_THAN);
19695                                            }
19696                                            else {
19697                                                    query.append(WHERE_LESSER_THAN);
19698                                            }
19699                                    }
19700                            }
19701    
19702                            query.append(ORDER_BY_CLAUSE);
19703    
19704                            String[] orderByFields = orderByComparator.getOrderByFields();
19705    
19706                            for (int i = 0; i < orderByFields.length; i++) {
19707                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19708                                    query.append(orderByFields[i]);
19709    
19710                                    if ((i + 1) < orderByFields.length) {
19711                                            if (orderByComparator.isAscending() ^ previous) {
19712                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19713                                            }
19714                                            else {
19715                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19716                                            }
19717                                    }
19718                                    else {
19719                                            if (orderByComparator.isAscending() ^ previous) {
19720                                                    query.append(ORDER_BY_ASC);
19721                                            }
19722                                            else {
19723                                                    query.append(ORDER_BY_DESC);
19724                                            }
19725                                    }
19726                            }
19727                    }
19728                    else {
19729                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
19730                    }
19731    
19732                    String sql = query.toString();
19733    
19734                    Query q = session.createQuery(sql);
19735    
19736                    q.setFirstResult(0);
19737                    q.setMaxResults(2);
19738    
19739                    QueryPos qPos = QueryPos.getInstance(q);
19740    
19741                    qPos.add(nodeId);
19742    
19743                    qPos.add(head);
19744    
19745                    if (bindRedirectTitle) {
19746                            qPos.add(StringUtil.toLowerCase(redirectTitle));
19747                    }
19748    
19749                    qPos.add(status);
19750    
19751                    if (orderByComparator != null) {
19752                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
19753    
19754                            for (Object value : values) {
19755                                    qPos.add(value);
19756                            }
19757                    }
19758    
19759                    List<WikiPage> list = q.list();
19760    
19761                    if (list.size() == 2) {
19762                            return list.get(1);
19763                    }
19764                    else {
19765                            return null;
19766                    }
19767            }
19768    
19769            /**
19770             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status &ne; &#63; from the database.
19771             *
19772             * @param nodeId the node ID
19773             * @param head the head
19774             * @param redirectTitle the redirect title
19775             * @param status the status
19776             */
19777            @Override
19778            public void removeByN_H_R_NotS(long nodeId, boolean head,
19779                    String redirectTitle, int status) {
19780                    for (WikiPage wikiPage : findByN_H_R_NotS(nodeId, head, redirectTitle,
19781                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19782                            remove(wikiPage);
19783                    }
19784            }
19785    
19786            /**
19787             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and redirectTitle = &#63; and status &ne; &#63;.
19788             *
19789             * @param nodeId the node ID
19790             * @param head the head
19791             * @param redirectTitle the redirect title
19792             * @param status the status
19793             * @return the number of matching wiki pages
19794             */
19795            @Override
19796            public int countByN_H_R_NotS(long nodeId, boolean head,
19797                    String redirectTitle, int status) {
19798                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_N_H_R_NOTS;
19799    
19800                    Object[] finderArgs = new Object[] { nodeId, head, redirectTitle, status };
19801    
19802                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19803                                    this);
19804    
19805                    if (count == null) {
19806                            StringBundler query = new StringBundler(5);
19807    
19808                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
19809    
19810                            query.append(_FINDER_COLUMN_N_H_R_NOTS_NODEID_2);
19811    
19812                            query.append(_FINDER_COLUMN_N_H_R_NOTS_HEAD_2);
19813    
19814                            boolean bindRedirectTitle = false;
19815    
19816                            if (redirectTitle == null) {
19817                                    query.append(_FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_1);
19818                            }
19819                            else if (redirectTitle.equals(StringPool.BLANK)) {
19820                                    query.append(_FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_3);
19821                            }
19822                            else {
19823                                    bindRedirectTitle = true;
19824    
19825                                    query.append(_FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_2);
19826                            }
19827    
19828                            query.append(_FINDER_COLUMN_N_H_R_NOTS_STATUS_2);
19829    
19830                            String sql = query.toString();
19831    
19832                            Session session = null;
19833    
19834                            try {
19835                                    session = openSession();
19836    
19837                                    Query q = session.createQuery(sql);
19838    
19839                                    QueryPos qPos = QueryPos.getInstance(q);
19840    
19841                                    qPos.add(nodeId);
19842    
19843                                    qPos.add(head);
19844    
19845                                    if (bindRedirectTitle) {
19846                                            qPos.add(StringUtil.toLowerCase(redirectTitle));
19847                                    }
19848    
19849                                    qPos.add(status);
19850    
19851                                    count = (Long)q.uniqueResult();
19852    
19853                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19854                            }
19855                            catch (Exception e) {
19856                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19857    
19858                                    throw processException(e);
19859                            }
19860                            finally {
19861                                    closeSession(session);
19862                            }
19863                    }
19864    
19865                    return count.intValue();
19866            }
19867    
19868            private static final String _FINDER_COLUMN_N_H_R_NOTS_NODEID_2 = "wikiPage.nodeId = ? AND ";
19869            private static final String _FINDER_COLUMN_N_H_R_NOTS_HEAD_2 = "wikiPage.head = ? AND ";
19870            private static final String _FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_1 = "wikiPage.redirectTitle IS NULL AND ";
19871            private static final String _FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_2 = "lower(wikiPage.redirectTitle) = ? AND ";
19872            private static final String _FINDER_COLUMN_N_H_R_NOTS_REDIRECTTITLE_3 = "(wikiPage.redirectTitle IS NULL OR wikiPage.redirectTitle = '') AND ";
19873            private static final String _FINDER_COLUMN_N_H_R_NOTS_STATUS_2 = "wikiPage.status != ?";
19874            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_P_S =
19875                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
19876                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
19877                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_H_P_S",
19878                            new String[] {
19879                                    Long.class.getName(), Long.class.getName(),
19880                                    Boolean.class.getName(), String.class.getName(),
19881                                    Integer.class.getName(),
19882                                    
19883                            Integer.class.getName(), Integer.class.getName(),
19884                                    OrderByComparator.class.getName()
19885                            });
19886            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S =
19887                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
19888                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
19889                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_H_P_S",
19890                            new String[] {
19891                                    Long.class.getName(), Long.class.getName(),
19892                                    Boolean.class.getName(), String.class.getName(),
19893                                    Integer.class.getName()
19894                            },
19895                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
19896                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
19897                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
19898                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK |
19899                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
19900                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
19901                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
19902            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
19903                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
19904                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_H_P_S",
19905                            new String[] {
19906                                    Long.class.getName(), Long.class.getName(),
19907                                    Boolean.class.getName(), String.class.getName(),
19908                                    Integer.class.getName()
19909                            });
19910    
19911            /**
19912             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
19913             *
19914             * @param groupId the group ID
19915             * @param nodeId the node ID
19916             * @param head the head
19917             * @param parentTitle the parent title
19918             * @param status the status
19919             * @return the matching wiki pages
19920             */
19921            @Override
19922            public List<WikiPage> findByG_N_H_P_S(long groupId, long nodeId,
19923                    boolean head, String parentTitle, int status) {
19924                    return findByG_N_H_P_S(groupId, nodeId, head, parentTitle, status,
19925                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19926            }
19927    
19928            /**
19929             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
19930             *
19931             * <p>
19932             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
19933             * </p>
19934             *
19935             * @param groupId the group ID
19936             * @param nodeId the node ID
19937             * @param head the head
19938             * @param parentTitle the parent title
19939             * @param status the status
19940             * @param start the lower bound of the range of wiki pages
19941             * @param end the upper bound of the range of wiki pages (not inclusive)
19942             * @return the range of matching wiki pages
19943             */
19944            @Override
19945            public List<WikiPage> findByG_N_H_P_S(long groupId, long nodeId,
19946                    boolean head, String parentTitle, int status, int start, int end) {
19947                    return findByG_N_H_P_S(groupId, nodeId, head, parentTitle, status,
19948                            start, end, null);
19949            }
19950    
19951            /**
19952             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
19953             *
19954             * <p>
19955             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
19956             * </p>
19957             *
19958             * @param groupId the group ID
19959             * @param nodeId the node ID
19960             * @param head the head
19961             * @param parentTitle the parent title
19962             * @param status the status
19963             * @param start the lower bound of the range of wiki pages
19964             * @param end the upper bound of the range of wiki pages (not inclusive)
19965             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19966             * @return the ordered range of matching wiki pages
19967             */
19968            @Override
19969            public List<WikiPage> findByG_N_H_P_S(long groupId, long nodeId,
19970                    boolean head, String parentTitle, int status, int start, int end,
19971                    OrderByComparator<WikiPage> orderByComparator) {
19972                    boolean pagination = true;
19973                    FinderPath finderPath = null;
19974                    Object[] finderArgs = null;
19975    
19976                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19977                                    (orderByComparator == null)) {
19978                            pagination = false;
19979                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S;
19980                            finderArgs = new Object[] { groupId, nodeId, head, parentTitle, status };
19981                    }
19982                    else {
19983                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_P_S;
19984                            finderArgs = new Object[] {
19985                                            groupId, nodeId, head, parentTitle, status,
19986                                            
19987                                            start, end, orderByComparator
19988                                    };
19989                    }
19990    
19991                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
19992                                    finderArgs, this);
19993    
19994                    if ((list != null) && !list.isEmpty()) {
19995                            for (WikiPage wikiPage : list) {
19996                                    if ((groupId != wikiPage.getGroupId()) ||
19997                                                    (nodeId != wikiPage.getNodeId()) ||
19998                                                    (head != wikiPage.getHead()) ||
19999                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle()) ||
20000                                                    (status != wikiPage.getStatus())) {
20001                                            list = null;
20002    
20003                                            break;
20004                                    }
20005                            }
20006                    }
20007    
20008                    if (list == null) {
20009                            StringBundler query = null;
20010    
20011                            if (orderByComparator != null) {
20012                                    query = new StringBundler(7 +
20013                                                    (orderByComparator.getOrderByFields().length * 3));
20014                            }
20015                            else {
20016                                    query = new StringBundler(7);
20017                            }
20018    
20019                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
20020    
20021                            query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
20022    
20023                            query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
20024    
20025                            query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
20026    
20027                            boolean bindParentTitle = false;
20028    
20029                            if (parentTitle == null) {
20030                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
20031                            }
20032                            else if (parentTitle.equals(StringPool.BLANK)) {
20033                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
20034                            }
20035                            else {
20036                                    bindParentTitle = true;
20037    
20038                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
20039                            }
20040    
20041                            query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
20042    
20043                            if (orderByComparator != null) {
20044                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20045                                            orderByComparator);
20046                            }
20047                            else
20048                             if (pagination) {
20049                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
20050                            }
20051    
20052                            String sql = query.toString();
20053    
20054                            Session session = null;
20055    
20056                            try {
20057                                    session = openSession();
20058    
20059                                    Query q = session.createQuery(sql);
20060    
20061                                    QueryPos qPos = QueryPos.getInstance(q);
20062    
20063                                    qPos.add(groupId);
20064    
20065                                    qPos.add(nodeId);
20066    
20067                                    qPos.add(head);
20068    
20069                                    if (bindParentTitle) {
20070                                            qPos.add(StringUtil.toLowerCase(parentTitle));
20071                                    }
20072    
20073                                    qPos.add(status);
20074    
20075                                    if (!pagination) {
20076                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
20077                                                            start, end, false);
20078    
20079                                            Collections.sort(list);
20080    
20081                                            list = Collections.unmodifiableList(list);
20082                                    }
20083                                    else {
20084                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
20085                                                            start, end);
20086                                    }
20087    
20088                                    cacheResult(list);
20089    
20090                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
20091                            }
20092                            catch (Exception e) {
20093                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20094    
20095                                    throw processException(e);
20096                            }
20097                            finally {
20098                                    closeSession(session);
20099                            }
20100                    }
20101    
20102                    return list;
20103            }
20104    
20105            /**
20106             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20107             *
20108             * @param groupId the group ID
20109             * @param nodeId the node ID
20110             * @param head the head
20111             * @param parentTitle the parent title
20112             * @param status the status
20113             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20114             * @return the first matching wiki page
20115             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
20116             */
20117            @Override
20118            public WikiPage findByG_N_H_P_S_First(long groupId, long nodeId,
20119                    boolean head, String parentTitle, int status,
20120                    OrderByComparator<WikiPage> orderByComparator)
20121                    throws NoSuchPageException {
20122                    WikiPage wikiPage = fetchByG_N_H_P_S_First(groupId, nodeId, head,
20123                                    parentTitle, status, orderByComparator);
20124    
20125                    if (wikiPage != null) {
20126                            return wikiPage;
20127                    }
20128    
20129                    StringBundler msg = new StringBundler(12);
20130    
20131                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20132    
20133                    msg.append("groupId=");
20134                    msg.append(groupId);
20135    
20136                    msg.append(", nodeId=");
20137                    msg.append(nodeId);
20138    
20139                    msg.append(", head=");
20140                    msg.append(head);
20141    
20142                    msg.append(", parentTitle=");
20143                    msg.append(parentTitle);
20144    
20145                    msg.append(", status=");
20146                    msg.append(status);
20147    
20148                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20149    
20150                    throw new NoSuchPageException(msg.toString());
20151            }
20152    
20153            /**
20154             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20155             *
20156             * @param groupId the group ID
20157             * @param nodeId the node ID
20158             * @param head the head
20159             * @param parentTitle the parent title
20160             * @param status the status
20161             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20162             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
20163             */
20164            @Override
20165            public WikiPage fetchByG_N_H_P_S_First(long groupId, long nodeId,
20166                    boolean head, String parentTitle, int status,
20167                    OrderByComparator<WikiPage> orderByComparator) {
20168                    List<WikiPage> list = findByG_N_H_P_S(groupId, nodeId, head,
20169                                    parentTitle, status, 0, 1, orderByComparator);
20170    
20171                    if (!list.isEmpty()) {
20172                            return list.get(0);
20173                    }
20174    
20175                    return null;
20176            }
20177    
20178            /**
20179             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20180             *
20181             * @param groupId the group ID
20182             * @param nodeId the node ID
20183             * @param head the head
20184             * @param parentTitle the parent title
20185             * @param status the status
20186             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20187             * @return the last matching wiki page
20188             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
20189             */
20190            @Override
20191            public WikiPage findByG_N_H_P_S_Last(long groupId, long nodeId,
20192                    boolean head, String parentTitle, int status,
20193                    OrderByComparator<WikiPage> orderByComparator)
20194                    throws NoSuchPageException {
20195                    WikiPage wikiPage = fetchByG_N_H_P_S_Last(groupId, nodeId, head,
20196                                    parentTitle, status, orderByComparator);
20197    
20198                    if (wikiPage != null) {
20199                            return wikiPage;
20200                    }
20201    
20202                    StringBundler msg = new StringBundler(12);
20203    
20204                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20205    
20206                    msg.append("groupId=");
20207                    msg.append(groupId);
20208    
20209                    msg.append(", nodeId=");
20210                    msg.append(nodeId);
20211    
20212                    msg.append(", head=");
20213                    msg.append(head);
20214    
20215                    msg.append(", parentTitle=");
20216                    msg.append(parentTitle);
20217    
20218                    msg.append(", status=");
20219                    msg.append(status);
20220    
20221                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20222    
20223                    throw new NoSuchPageException(msg.toString());
20224            }
20225    
20226            /**
20227             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20228             *
20229             * @param groupId the group ID
20230             * @param nodeId the node ID
20231             * @param head the head
20232             * @param parentTitle the parent title
20233             * @param status the status
20234             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20235             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
20236             */
20237            @Override
20238            public WikiPage fetchByG_N_H_P_S_Last(long groupId, long nodeId,
20239                    boolean head, String parentTitle, int status,
20240                    OrderByComparator<WikiPage> orderByComparator) {
20241                    int count = countByG_N_H_P_S(groupId, nodeId, head, parentTitle, status);
20242    
20243                    if (count == 0) {
20244                            return null;
20245                    }
20246    
20247                    List<WikiPage> list = findByG_N_H_P_S(groupId, nodeId, head,
20248                                    parentTitle, status, count - 1, count, orderByComparator);
20249    
20250                    if (!list.isEmpty()) {
20251                            return list.get(0);
20252                    }
20253    
20254                    return null;
20255            }
20256    
20257            /**
20258             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20259             *
20260             * @param pageId the primary key of the current wiki page
20261             * @param groupId the group ID
20262             * @param nodeId the node ID
20263             * @param head the head
20264             * @param parentTitle the parent title
20265             * @param status the status
20266             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20267             * @return the previous, current, and next wiki page
20268             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
20269             */
20270            @Override
20271            public WikiPage[] findByG_N_H_P_S_PrevAndNext(long pageId, long groupId,
20272                    long nodeId, boolean head, String parentTitle, int status,
20273                    OrderByComparator<WikiPage> orderByComparator)
20274                    throws NoSuchPageException {
20275                    WikiPage wikiPage = findByPrimaryKey(pageId);
20276    
20277                    Session session = null;
20278    
20279                    try {
20280                            session = openSession();
20281    
20282                            WikiPage[] array = new WikiPageImpl[3];
20283    
20284                            array[0] = getByG_N_H_P_S_PrevAndNext(session, wikiPage, groupId,
20285                                            nodeId, head, parentTitle, status, orderByComparator, true);
20286    
20287                            array[1] = wikiPage;
20288    
20289                            array[2] = getByG_N_H_P_S_PrevAndNext(session, wikiPage, groupId,
20290                                            nodeId, head, parentTitle, status, orderByComparator, false);
20291    
20292                            return array;
20293                    }
20294                    catch (Exception e) {
20295                            throw processException(e);
20296                    }
20297                    finally {
20298                            closeSession(session);
20299                    }
20300            }
20301    
20302            protected WikiPage getByG_N_H_P_S_PrevAndNext(Session session,
20303                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
20304                    String parentTitle, int status,
20305                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
20306                    StringBundler query = null;
20307    
20308                    if (orderByComparator != null) {
20309                            query = new StringBundler(6 +
20310                                            (orderByComparator.getOrderByFields().length * 6));
20311                    }
20312                    else {
20313                            query = new StringBundler(3);
20314                    }
20315    
20316                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
20317    
20318                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
20319    
20320                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
20321    
20322                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
20323    
20324                    boolean bindParentTitle = false;
20325    
20326                    if (parentTitle == null) {
20327                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
20328                    }
20329                    else if (parentTitle.equals(StringPool.BLANK)) {
20330                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
20331                    }
20332                    else {
20333                            bindParentTitle = true;
20334    
20335                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
20336                    }
20337    
20338                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
20339    
20340                    if (orderByComparator != null) {
20341                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20342    
20343                            if (orderByConditionFields.length > 0) {
20344                                    query.append(WHERE_AND);
20345                            }
20346    
20347                            for (int i = 0; i < orderByConditionFields.length; i++) {
20348                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20349                                    query.append(orderByConditionFields[i]);
20350    
20351                                    if ((i + 1) < orderByConditionFields.length) {
20352                                            if (orderByComparator.isAscending() ^ previous) {
20353                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20354                                            }
20355                                            else {
20356                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20357                                            }
20358                                    }
20359                                    else {
20360                                            if (orderByComparator.isAscending() ^ previous) {
20361                                                    query.append(WHERE_GREATER_THAN);
20362                                            }
20363                                            else {
20364                                                    query.append(WHERE_LESSER_THAN);
20365                                            }
20366                                    }
20367                            }
20368    
20369                            query.append(ORDER_BY_CLAUSE);
20370    
20371                            String[] orderByFields = orderByComparator.getOrderByFields();
20372    
20373                            for (int i = 0; i < orderByFields.length; i++) {
20374                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20375                                    query.append(orderByFields[i]);
20376    
20377                                    if ((i + 1) < orderByFields.length) {
20378                                            if (orderByComparator.isAscending() ^ previous) {
20379                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20380                                            }
20381                                            else {
20382                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20383                                            }
20384                                    }
20385                                    else {
20386                                            if (orderByComparator.isAscending() ^ previous) {
20387                                                    query.append(ORDER_BY_ASC);
20388                                            }
20389                                            else {
20390                                                    query.append(ORDER_BY_DESC);
20391                                            }
20392                                    }
20393                            }
20394                    }
20395                    else {
20396                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
20397                    }
20398    
20399                    String sql = query.toString();
20400    
20401                    Query q = session.createQuery(sql);
20402    
20403                    q.setFirstResult(0);
20404                    q.setMaxResults(2);
20405    
20406                    QueryPos qPos = QueryPos.getInstance(q);
20407    
20408                    qPos.add(groupId);
20409    
20410                    qPos.add(nodeId);
20411    
20412                    qPos.add(head);
20413    
20414                    if (bindParentTitle) {
20415                            qPos.add(StringUtil.toLowerCase(parentTitle));
20416                    }
20417    
20418                    qPos.add(status);
20419    
20420                    if (orderByComparator != null) {
20421                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
20422    
20423                            for (Object value : values) {
20424                                    qPos.add(value);
20425                            }
20426                    }
20427    
20428                    List<WikiPage> list = q.list();
20429    
20430                    if (list.size() == 2) {
20431                            return list.get(1);
20432                    }
20433                    else {
20434                            return null;
20435                    }
20436            }
20437    
20438            /**
20439             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20440             *
20441             * @param groupId the group ID
20442             * @param nodeId the node ID
20443             * @param head the head
20444             * @param parentTitle the parent title
20445             * @param status the status
20446             * @return the matching wiki pages that the user has permission to view
20447             */
20448            @Override
20449            public List<WikiPage> filterFindByG_N_H_P_S(long groupId, long nodeId,
20450                    boolean head, String parentTitle, int status) {
20451                    return filterFindByG_N_H_P_S(groupId, nodeId, head, parentTitle,
20452                            status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20453            }
20454    
20455            /**
20456             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20457             *
20458             * <p>
20459             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
20460             * </p>
20461             *
20462             * @param groupId the group ID
20463             * @param nodeId the node ID
20464             * @param head the head
20465             * @param parentTitle the parent title
20466             * @param status the status
20467             * @param start the lower bound of the range of wiki pages
20468             * @param end the upper bound of the range of wiki pages (not inclusive)
20469             * @return the range of matching wiki pages that the user has permission to view
20470             */
20471            @Override
20472            public List<WikiPage> filterFindByG_N_H_P_S(long groupId, long nodeId,
20473                    boolean head, String parentTitle, int status, int start, int end) {
20474                    return filterFindByG_N_H_P_S(groupId, nodeId, head, parentTitle,
20475                            status, start, end, null);
20476            }
20477    
20478            /**
20479             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20480             *
20481             * <p>
20482             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
20483             * </p>
20484             *
20485             * @param groupId the group ID
20486             * @param nodeId the node ID
20487             * @param head the head
20488             * @param parentTitle the parent title
20489             * @param status the status
20490             * @param start the lower bound of the range of wiki pages
20491             * @param end the upper bound of the range of wiki pages (not inclusive)
20492             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20493             * @return the ordered range of matching wiki pages that the user has permission to view
20494             */
20495            @Override
20496            public List<WikiPage> filterFindByG_N_H_P_S(long groupId, long nodeId,
20497                    boolean head, String parentTitle, int status, int start, int end,
20498                    OrderByComparator<WikiPage> orderByComparator) {
20499                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20500                            return findByG_N_H_P_S(groupId, nodeId, head, parentTitle, status,
20501                                    start, end, orderByComparator);
20502                    }
20503    
20504                    StringBundler query = null;
20505    
20506                    if (orderByComparator != null) {
20507                            query = new StringBundler(7 +
20508                                            (orderByComparator.getOrderByFields().length * 3));
20509                    }
20510                    else {
20511                            query = new StringBundler(7);
20512                    }
20513    
20514                    if (getDB().isSupportsInlineDistinct()) {
20515                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
20516                    }
20517                    else {
20518                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
20519                    }
20520    
20521                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
20522    
20523                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
20524    
20525                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
20526    
20527                    boolean bindParentTitle = false;
20528    
20529                    if (parentTitle == null) {
20530                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
20531                    }
20532                    else if (parentTitle.equals(StringPool.BLANK)) {
20533                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
20534                    }
20535                    else {
20536                            bindParentTitle = true;
20537    
20538                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
20539                    }
20540    
20541                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
20542    
20543                    if (!getDB().isSupportsInlineDistinct()) {
20544                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
20545                    }
20546    
20547                    if (orderByComparator != null) {
20548                            if (getDB().isSupportsInlineDistinct()) {
20549                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20550                                            orderByComparator, true);
20551                            }
20552                            else {
20553                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20554                                            orderByComparator, true);
20555                            }
20556                    }
20557                    else {
20558                            if (getDB().isSupportsInlineDistinct()) {
20559                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
20560                            }
20561                            else {
20562                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
20563                            }
20564                    }
20565    
20566                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20567                                    WikiPage.class.getName(),
20568                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20569    
20570                    Session session = null;
20571    
20572                    try {
20573                            session = openSession();
20574    
20575                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
20576    
20577                            if (getDB().isSupportsInlineDistinct()) {
20578                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
20579                            }
20580                            else {
20581                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
20582                            }
20583    
20584                            QueryPos qPos = QueryPos.getInstance(q);
20585    
20586                            qPos.add(groupId);
20587    
20588                            qPos.add(nodeId);
20589    
20590                            qPos.add(head);
20591    
20592                            if (bindParentTitle) {
20593                                    qPos.add(StringUtil.toLowerCase(parentTitle));
20594                            }
20595    
20596                            qPos.add(status);
20597    
20598                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
20599                    }
20600                    catch (Exception e) {
20601                            throw processException(e);
20602                    }
20603                    finally {
20604                            closeSession(session);
20605                    }
20606            }
20607    
20608            /**
20609             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20610             *
20611             * @param pageId the primary key of the current wiki page
20612             * @param groupId the group ID
20613             * @param nodeId the node ID
20614             * @param head the head
20615             * @param parentTitle the parent title
20616             * @param status the status
20617             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20618             * @return the previous, current, and next wiki page
20619             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
20620             */
20621            @Override
20622            public WikiPage[] filterFindByG_N_H_P_S_PrevAndNext(long pageId,
20623                    long groupId, long nodeId, boolean head, String parentTitle,
20624                    int status, OrderByComparator<WikiPage> orderByComparator)
20625                    throws NoSuchPageException {
20626                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20627                            return findByG_N_H_P_S_PrevAndNext(pageId, groupId, nodeId, head,
20628                                    parentTitle, status, orderByComparator);
20629                    }
20630    
20631                    WikiPage wikiPage = findByPrimaryKey(pageId);
20632    
20633                    Session session = null;
20634    
20635                    try {
20636                            session = openSession();
20637    
20638                            WikiPage[] array = new WikiPageImpl[3];
20639    
20640                            array[0] = filterGetByG_N_H_P_S_PrevAndNext(session, wikiPage,
20641                                            groupId, nodeId, head, parentTitle, status,
20642                                            orderByComparator, true);
20643    
20644                            array[1] = wikiPage;
20645    
20646                            array[2] = filterGetByG_N_H_P_S_PrevAndNext(session, wikiPage,
20647                                            groupId, nodeId, head, parentTitle, status,
20648                                            orderByComparator, false);
20649    
20650                            return array;
20651                    }
20652                    catch (Exception e) {
20653                            throw processException(e);
20654                    }
20655                    finally {
20656                            closeSession(session);
20657                    }
20658            }
20659    
20660            protected WikiPage filterGetByG_N_H_P_S_PrevAndNext(Session session,
20661                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
20662                    String parentTitle, int status,
20663                    OrderByComparator<WikiPage> orderByComparator, boolean previous) {
20664                    StringBundler query = null;
20665    
20666                    if (orderByComparator != null) {
20667                            query = new StringBundler(6 +
20668                                            (orderByComparator.getOrderByFields().length * 6));
20669                    }
20670                    else {
20671                            query = new StringBundler(3);
20672                    }
20673    
20674                    if (getDB().isSupportsInlineDistinct()) {
20675                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
20676                    }
20677                    else {
20678                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
20679                    }
20680    
20681                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
20682    
20683                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
20684    
20685                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
20686    
20687                    boolean bindParentTitle = false;
20688    
20689                    if (parentTitle == null) {
20690                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
20691                    }
20692                    else if (parentTitle.equals(StringPool.BLANK)) {
20693                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
20694                    }
20695                    else {
20696                            bindParentTitle = true;
20697    
20698                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
20699                    }
20700    
20701                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
20702    
20703                    if (!getDB().isSupportsInlineDistinct()) {
20704                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
20705                    }
20706    
20707                    if (orderByComparator != null) {
20708                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20709    
20710                            if (orderByConditionFields.length > 0) {
20711                                    query.append(WHERE_AND);
20712                            }
20713    
20714                            for (int i = 0; i < orderByConditionFields.length; i++) {
20715                                    if (getDB().isSupportsInlineDistinct()) {
20716                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20717                                    }
20718                                    else {
20719                                            query.append(_ORDER_BY_ENTITY_TABLE);
20720                                    }
20721    
20722                                    query.append(orderByConditionFields[i]);
20723    
20724                                    if ((i + 1) < orderByConditionFields.length) {
20725                                            if (orderByComparator.isAscending() ^ previous) {
20726                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20727                                            }
20728                                            else {
20729                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20730                                            }
20731                                    }
20732                                    else {
20733                                            if (orderByComparator.isAscending() ^ previous) {
20734                                                    query.append(WHERE_GREATER_THAN);
20735                                            }
20736                                            else {
20737                                                    query.append(WHERE_LESSER_THAN);
20738                                            }
20739                                    }
20740                            }
20741    
20742                            query.append(ORDER_BY_CLAUSE);
20743    
20744                            String[] orderByFields = orderByComparator.getOrderByFields();
20745    
20746                            for (int i = 0; i < orderByFields.length; i++) {
20747                                    if (getDB().isSupportsInlineDistinct()) {
20748                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20749                                    }
20750                                    else {
20751                                            query.append(_ORDER_BY_ENTITY_TABLE);
20752                                    }
20753    
20754                                    query.append(orderByFields[i]);
20755    
20756                                    if ((i + 1) < orderByFields.length) {
20757                                            if (orderByComparator.isAscending() ^ previous) {
20758                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20759                                            }
20760                                            else {
20761                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20762                                            }
20763                                    }
20764                                    else {
20765                                            if (orderByComparator.isAscending() ^ previous) {
20766                                                    query.append(ORDER_BY_ASC);
20767                                            }
20768                                            else {
20769                                                    query.append(ORDER_BY_DESC);
20770                                            }
20771                                    }
20772                            }
20773                    }
20774                    else {
20775                            if (getDB().isSupportsInlineDistinct()) {
20776                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
20777                            }
20778                            else {
20779                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
20780                            }
20781                    }
20782    
20783                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20784                                    WikiPage.class.getName(),
20785                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20786    
20787                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
20788    
20789                    q.setFirstResult(0);
20790                    q.setMaxResults(2);
20791    
20792                    if (getDB().isSupportsInlineDistinct()) {
20793                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
20794                    }
20795                    else {
20796                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
20797                    }
20798    
20799                    QueryPos qPos = QueryPos.getInstance(q);
20800    
20801                    qPos.add(groupId);
20802    
20803                    qPos.add(nodeId);
20804    
20805                    qPos.add(head);
20806    
20807                    if (bindParentTitle) {
20808                            qPos.add(StringUtil.toLowerCase(parentTitle));
20809                    }
20810    
20811                    qPos.add(status);
20812    
20813                    if (orderByComparator != null) {
20814                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
20815    
20816                            for (Object value : values) {
20817                                    qPos.add(value);
20818                            }
20819                    }
20820    
20821                    List<WikiPage> list = q.list();
20822    
20823                    if (list.size() == 2) {
20824                            return list.get(1);
20825                    }
20826                    else {
20827                            return null;
20828                    }
20829            }
20830    
20831            /**
20832             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63; from the database.
20833             *
20834             * @param groupId the group ID
20835             * @param nodeId the node ID
20836             * @param head the head
20837             * @param parentTitle the parent title
20838             * @param status the status
20839             */
20840            @Override
20841            public void removeByG_N_H_P_S(long groupId, long nodeId, boolean head,
20842                    String parentTitle, int status) {
20843                    for (WikiPage wikiPage : findByG_N_H_P_S(groupId, nodeId, head,
20844                                    parentTitle, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
20845                            remove(wikiPage);
20846                    }
20847            }
20848    
20849            /**
20850             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20851             *
20852             * @param groupId the group ID
20853             * @param nodeId the node ID
20854             * @param head the head
20855             * @param parentTitle the parent title
20856             * @param status the status
20857             * @return the number of matching wiki pages
20858             */
20859            @Override
20860            public int countByG_N_H_P_S(long groupId, long nodeId, boolean head,
20861                    String parentTitle, int status) {
20862                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_H_P_S;
20863    
20864                    Object[] finderArgs = new Object[] {
20865                                    groupId, nodeId, head, parentTitle, status
20866                            };
20867    
20868                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20869                                    this);
20870    
20871                    if (count == null) {
20872                            StringBundler query = new StringBundler(6);
20873    
20874                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
20875    
20876                            query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
20877    
20878                            query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
20879    
20880                            query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
20881    
20882                            boolean bindParentTitle = false;
20883    
20884                            if (parentTitle == null) {
20885                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
20886                            }
20887                            else if (parentTitle.equals(StringPool.BLANK)) {
20888                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
20889                            }
20890                            else {
20891                                    bindParentTitle = true;
20892    
20893                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
20894                            }
20895    
20896                            query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
20897    
20898                            String sql = query.toString();
20899    
20900                            Session session = null;
20901    
20902                            try {
20903                                    session = openSession();
20904    
20905                                    Query q = session.createQuery(sql);
20906    
20907                                    QueryPos qPos = QueryPos.getInstance(q);
20908    
20909                                    qPos.add(groupId);
20910    
20911                                    qPos.add(nodeId);
20912    
20913                                    qPos.add(head);
20914    
20915                                    if (bindParentTitle) {
20916                                            qPos.add(StringUtil.toLowerCase(parentTitle));
20917                                    }
20918    
20919                                    qPos.add(status);
20920    
20921                                    count = (Long)q.uniqueResult();
20922    
20923                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20924                            }
20925                            catch (Exception e) {
20926                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20927    
20928                                    throw processException(e);
20929                            }
20930                            finally {
20931                                    closeSession(session);
20932                            }
20933                    }
20934    
20935                    return count.intValue();
20936            }
20937    
20938            /**
20939             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
20940             *
20941             * @param groupId the group ID
20942             * @param nodeId the node ID
20943             * @param head the head
20944             * @param parentTitle the parent title
20945             * @param status the status
20946             * @return the number of matching wiki pages that the user has permission to view
20947             */
20948            @Override
20949            public int filterCountByG_N_H_P_S(long groupId, long nodeId, boolean head,
20950                    String parentTitle, int status) {
20951                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20952                            return countByG_N_H_P_S(groupId, nodeId, head, parentTitle, status);
20953                    }
20954    
20955                    StringBundler query = new StringBundler(6);
20956    
20957                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
20958    
20959                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
20960    
20961                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
20962    
20963                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
20964    
20965                    boolean bindParentTitle = false;
20966    
20967                    if (parentTitle == null) {
20968                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
20969                    }
20970                    else if (parentTitle.equals(StringPool.BLANK)) {
20971                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
20972                    }
20973                    else {
20974                            bindParentTitle = true;
20975    
20976                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
20977                    }
20978    
20979                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
20980    
20981                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20982                                    WikiPage.class.getName(),
20983                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20984    
20985                    Session session = null;
20986    
20987                    try {
20988                            session = openSession();
20989    
20990                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
20991    
20992                            q.addScalar(COUNT_COLUMN_NAME,
20993                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20994    
20995                            QueryPos qPos = QueryPos.getInstance(q);
20996    
20997                            qPos.add(groupId);
20998    
20999                            qPos.add(nodeId);
21000    
21001                            qPos.add(head);
21002    
21003                            if (bindParentTitle) {
21004                                    qPos.add(StringUtil.toLowerCase(parentTitle));
21005                            }
21006    
21007                            qPos.add(status);
21008    
21009                            Long count = (Long)q.uniqueResult();
21010    
21011                            return count.intValue();
21012                    }
21013                    catch (Exception e) {
21014                            throw processException(e);
21015                    }
21016                    finally {
21017                            closeSession(session);
21018                    }
21019            }
21020    
21021            private static final String _FINDER_COLUMN_G_N_H_P_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
21022            private static final String _FINDER_COLUMN_G_N_H_P_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
21023            private static final String _FINDER_COLUMN_G_N_H_P_S_HEAD_2 = "wikiPage.head = ? AND ";
21024            private static final String _FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL AND ";
21025            private static final String _FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = ? AND ";
21026            private static final String _FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = '') AND ";
21027            private static final String _FINDER_COLUMN_G_N_H_P_S_STATUS_2 = "wikiPage.status = ?";
21028    
21029            public WikiPagePersistenceImpl() {
21030                    setModelClass(WikiPage.class);
21031            }
21032    
21033            /**
21034             * Caches the wiki page in the entity cache if it is enabled.
21035             *
21036             * @param wikiPage the wiki page
21037             */
21038            @Override
21039            public void cacheResult(WikiPage wikiPage) {
21040                    EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
21041                            WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
21042    
21043                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
21044                            new Object[] { wikiPage.getUuid(), wikiPage.getGroupId() }, wikiPage);
21045    
21046                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
21047                            new Object[] {
21048                                    wikiPage.getResourcePrimKey(), wikiPage.getNodeId(),
21049                                    wikiPage.getVersion()
21050                            }, wikiPage);
21051    
21052                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
21053                            new Object[] {
21054                                    wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion()
21055                            }, wikiPage);
21056    
21057                    wikiPage.resetOriginalValues();
21058            }
21059    
21060            /**
21061             * Caches the wiki pages in the entity cache if it is enabled.
21062             *
21063             * @param wikiPages the wiki pages
21064             */
21065            @Override
21066            public void cacheResult(List<WikiPage> wikiPages) {
21067                    for (WikiPage wikiPage : wikiPages) {
21068                            if (EntityCacheUtil.getResult(
21069                                                    WikiPageModelImpl.ENTITY_CACHE_ENABLED,
21070                                                    WikiPageImpl.class, wikiPage.getPrimaryKey()) == null) {
21071                                    cacheResult(wikiPage);
21072                            }
21073                            else {
21074                                    wikiPage.resetOriginalValues();
21075                            }
21076                    }
21077            }
21078    
21079            /**
21080             * Clears the cache for all wiki pages.
21081             *
21082             * <p>
21083             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
21084             * </p>
21085             */
21086            @Override
21087            public void clearCache() {
21088                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
21089                            CacheRegistryUtil.clear(WikiPageImpl.class.getName());
21090                    }
21091    
21092                    EntityCacheUtil.clearCache(WikiPageImpl.class);
21093    
21094                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
21095                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
21096                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
21097            }
21098    
21099            /**
21100             * Clears the cache for the wiki page.
21101             *
21102             * <p>
21103             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
21104             * </p>
21105             */
21106            @Override
21107            public void clearCache(WikiPage wikiPage) {
21108                    EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
21109                            WikiPageImpl.class, wikiPage.getPrimaryKey());
21110    
21111                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
21112                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
21113    
21114                    clearUniqueFindersCache(wikiPage);
21115            }
21116    
21117            @Override
21118            public void clearCache(List<WikiPage> wikiPages) {
21119                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
21120                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
21121    
21122                    for (WikiPage wikiPage : wikiPages) {
21123                            EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
21124                                    WikiPageImpl.class, wikiPage.getPrimaryKey());
21125    
21126                            clearUniqueFindersCache(wikiPage);
21127                    }
21128            }
21129    
21130            protected void cacheUniqueFindersCache(WikiPage wikiPage) {
21131                    if (wikiPage.isNew()) {
21132                            Object[] args = new Object[] {
21133                                            wikiPage.getUuid(), wikiPage.getGroupId()
21134                                    };
21135    
21136                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
21137                                    Long.valueOf(1));
21138                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
21139                                    wikiPage);
21140    
21141                            args = new Object[] {
21142                                            wikiPage.getResourcePrimKey(), wikiPage.getNodeId(),
21143                                            wikiPage.getVersion()
21144                                    };
21145    
21146                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N_V, args,
21147                                    Long.valueOf(1));
21148                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V, args, wikiPage);
21149    
21150                            args = new Object[] {
21151                                            wikiPage.getNodeId(), wikiPage.getTitle(),
21152                                            wikiPage.getVersion()
21153                                    };
21154    
21155                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_V, args,
21156                                    Long.valueOf(1));
21157                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V, args, wikiPage);
21158                    }
21159                    else {
21160                            WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
21161    
21162                            if ((wikiPageModelImpl.getColumnBitmask() &
21163                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
21164                                    Object[] args = new Object[] {
21165                                                    wikiPage.getUuid(), wikiPage.getGroupId()
21166                                            };
21167    
21168                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
21169                                            Long.valueOf(1));
21170                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
21171                                            wikiPage);
21172                            }
21173    
21174                            if ((wikiPageModelImpl.getColumnBitmask() &
21175                                            FINDER_PATH_FETCH_BY_R_N_V.getColumnBitmask()) != 0) {
21176                                    Object[] args = new Object[] {
21177                                                    wikiPage.getResourcePrimKey(), wikiPage.getNodeId(),
21178                                                    wikiPage.getVersion()
21179                                            };
21180    
21181                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N_V, args,
21182                                            Long.valueOf(1));
21183                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V, args,
21184                                            wikiPage);
21185                            }
21186    
21187                            if ((wikiPageModelImpl.getColumnBitmask() &
21188                                            FINDER_PATH_FETCH_BY_N_T_V.getColumnBitmask()) != 0) {
21189                                    Object[] args = new Object[] {
21190                                                    wikiPage.getNodeId(), wikiPage.getTitle(),
21191                                                    wikiPage.getVersion()
21192                                            };
21193    
21194                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_V, args,
21195                                            Long.valueOf(1));
21196                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V, args,
21197                                            wikiPage);
21198                            }
21199                    }
21200            }
21201    
21202            protected void clearUniqueFindersCache(WikiPage wikiPage) {
21203                    WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
21204    
21205                    Object[] args = new Object[] { wikiPage.getUuid(), wikiPage.getGroupId() };
21206    
21207                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
21208                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
21209    
21210                    if ((wikiPageModelImpl.getColumnBitmask() &
21211                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
21212                            args = new Object[] {
21213                                            wikiPageModelImpl.getOriginalUuid(),
21214                                            wikiPageModelImpl.getOriginalGroupId()
21215                                    };
21216    
21217                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
21218                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
21219                    }
21220    
21221                    args = new Object[] {
21222                                    wikiPage.getResourcePrimKey(), wikiPage.getNodeId(),
21223                                    wikiPage.getVersion()
21224                            };
21225    
21226                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_V, args);
21227                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V, args);
21228    
21229                    if ((wikiPageModelImpl.getColumnBitmask() &
21230                                    FINDER_PATH_FETCH_BY_R_N_V.getColumnBitmask()) != 0) {
21231                            args = new Object[] {
21232                                            wikiPageModelImpl.getOriginalResourcePrimKey(),
21233                                            wikiPageModelImpl.getOriginalNodeId(),
21234                                            wikiPageModelImpl.getOriginalVersion()
21235                                    };
21236    
21237                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_V, args);
21238                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V, args);
21239                    }
21240    
21241                    args = new Object[] {
21242                                    wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion()
21243                            };
21244    
21245                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_V, args);
21246                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V, args);
21247    
21248                    if ((wikiPageModelImpl.getColumnBitmask() &
21249                                    FINDER_PATH_FETCH_BY_N_T_V.getColumnBitmask()) != 0) {
21250                            args = new Object[] {
21251                                            wikiPageModelImpl.getOriginalNodeId(),
21252                                            wikiPageModelImpl.getOriginalTitle(),
21253                                            wikiPageModelImpl.getOriginalVersion()
21254                                    };
21255    
21256                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_V, args);
21257                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V, args);
21258                    }
21259            }
21260    
21261            /**
21262             * Creates a new wiki page with the primary key. Does not add the wiki page to the database.
21263             *
21264             * @param pageId the primary key for the new wiki page
21265             * @return the new wiki page
21266             */
21267            @Override
21268            public WikiPage create(long pageId) {
21269                    WikiPage wikiPage = new WikiPageImpl();
21270    
21271                    wikiPage.setNew(true);
21272                    wikiPage.setPrimaryKey(pageId);
21273    
21274                    String uuid = PortalUUIDUtil.generate();
21275    
21276                    wikiPage.setUuid(uuid);
21277    
21278                    return wikiPage;
21279            }
21280    
21281            /**
21282             * Removes the wiki page with the primary key from the database. Also notifies the appropriate model listeners.
21283             *
21284             * @param pageId the primary key of the wiki page
21285             * @return the wiki page that was removed
21286             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
21287             */
21288            @Override
21289            public WikiPage remove(long pageId) throws NoSuchPageException {
21290                    return remove((Serializable)pageId);
21291            }
21292    
21293            /**
21294             * Removes the wiki page with the primary key from the database. Also notifies the appropriate model listeners.
21295             *
21296             * @param primaryKey the primary key of the wiki page
21297             * @return the wiki page that was removed
21298             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
21299             */
21300            @Override
21301            public WikiPage remove(Serializable primaryKey) throws NoSuchPageException {
21302                    Session session = null;
21303    
21304                    try {
21305                            session = openSession();
21306    
21307                            WikiPage wikiPage = (WikiPage)session.get(WikiPageImpl.class,
21308                                            primaryKey);
21309    
21310                            if (wikiPage == null) {
21311                                    if (_log.isWarnEnabled()) {
21312                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
21313                                    }
21314    
21315                                    throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
21316                                            primaryKey);
21317                            }
21318    
21319                            return remove(wikiPage);
21320                    }
21321                    catch (NoSuchPageException nsee) {
21322                            throw nsee;
21323                    }
21324                    catch (Exception e) {
21325                            throw processException(e);
21326                    }
21327                    finally {
21328                            closeSession(session);
21329                    }
21330            }
21331    
21332            @Override
21333            protected WikiPage removeImpl(WikiPage wikiPage) {
21334                    wikiPage = toUnwrappedModel(wikiPage);
21335    
21336                    Session session = null;
21337    
21338                    try {
21339                            session = openSession();
21340    
21341                            if (!session.contains(wikiPage)) {
21342                                    wikiPage = (WikiPage)session.get(WikiPageImpl.class,
21343                                                    wikiPage.getPrimaryKeyObj());
21344                            }
21345    
21346                            if (wikiPage != null) {
21347                                    session.delete(wikiPage);
21348                            }
21349                    }
21350                    catch (Exception e) {
21351                            throw processException(e);
21352                    }
21353                    finally {
21354                            closeSession(session);
21355                    }
21356    
21357                    if (wikiPage != null) {
21358                            clearCache(wikiPage);
21359                    }
21360    
21361                    return wikiPage;
21362            }
21363    
21364            @Override
21365            public WikiPage updateImpl(com.liferay.portlet.wiki.model.WikiPage wikiPage) {
21366                    wikiPage = toUnwrappedModel(wikiPage);
21367    
21368                    boolean isNew = wikiPage.isNew();
21369    
21370                    WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
21371    
21372                    if (Validator.isNull(wikiPage.getUuid())) {
21373                            String uuid = PortalUUIDUtil.generate();
21374    
21375                            wikiPage.setUuid(uuid);
21376                    }
21377    
21378                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
21379    
21380                    if (userId > 0) {
21381                            long companyId = wikiPage.getCompanyId();
21382    
21383                            long groupId = wikiPage.getGroupId();
21384    
21385                            long pageId = 0;
21386    
21387                            if (!isNew) {
21388                                    pageId = wikiPage.getPrimaryKey();
21389                            }
21390    
21391                            try {
21392                                    wikiPage.setTitle(SanitizerUtil.sanitize(companyId, groupId,
21393                                                    userId,
21394                                                    com.liferay.portlet.wiki.model.WikiPage.class.getName(),
21395                                                    pageId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
21396                                                    wikiPage.getTitle(), null));
21397                            }
21398                            catch (SanitizerException se) {
21399                                    throw new SystemException(se);
21400                            }
21401                    }
21402    
21403                    Session session = null;
21404    
21405                    try {
21406                            session = openSession();
21407    
21408                            if (wikiPage.isNew()) {
21409                                    session.save(wikiPage);
21410    
21411                                    wikiPage.setNew(false);
21412                            }
21413                            else {
21414                                    session.merge(wikiPage);
21415                            }
21416                    }
21417                    catch (Exception e) {
21418                            throw processException(e);
21419                    }
21420                    finally {
21421                            closeSession(session);
21422                    }
21423    
21424                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
21425    
21426                    if (isNew || !WikiPageModelImpl.COLUMN_BITMASK_ENABLED) {
21427                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
21428                    }
21429    
21430                    else {
21431                            if ((wikiPageModelImpl.getColumnBitmask() &
21432                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
21433                                    Object[] args = new Object[] { wikiPageModelImpl.getOriginalUuid() };
21434    
21435                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
21436                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
21437                                            args);
21438    
21439                                    args = new Object[] { wikiPageModelImpl.getUuid() };
21440    
21441                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
21442                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
21443                                            args);
21444                            }
21445    
21446                            if ((wikiPageModelImpl.getColumnBitmask() &
21447                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
21448                                    Object[] args = new Object[] {
21449                                                    wikiPageModelImpl.getOriginalUuid(),
21450                                                    wikiPageModelImpl.getOriginalCompanyId()
21451                                            };
21452    
21453                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
21454                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
21455                                            args);
21456    
21457                                    args = new Object[] {
21458                                                    wikiPageModelImpl.getUuid(),
21459                                                    wikiPageModelImpl.getCompanyId()
21460                                            };
21461    
21462                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
21463                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
21464                                            args);
21465                            }
21466    
21467                            if ((wikiPageModelImpl.getColumnBitmask() &
21468                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
21469                                    Object[] args = new Object[] {
21470                                                    wikiPageModelImpl.getOriginalResourcePrimKey()
21471                                            };
21472    
21473                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
21474                                            args);
21475                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
21476                                            args);
21477    
21478                                    args = new Object[] { wikiPageModelImpl.getResourcePrimKey() };
21479    
21480                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
21481                                            args);
21482                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
21483                                            args);
21484                            }
21485    
21486                            if ((wikiPageModelImpl.getColumnBitmask() &
21487                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID.getColumnBitmask()) != 0) {
21488                                    Object[] args = new Object[] {
21489                                                    wikiPageModelImpl.getOriginalNodeId()
21490                                            };
21491    
21492                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NODEID, args);
21493                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID,
21494                                            args);
21495    
21496                                    args = new Object[] { wikiPageModelImpl.getNodeId() };
21497    
21498                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NODEID, args);
21499                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID,
21500                                            args);
21501                            }
21502    
21503                            if ((wikiPageModelImpl.getColumnBitmask() &
21504                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT.getColumnBitmask()) != 0) {
21505                                    Object[] args = new Object[] {
21506                                                    wikiPageModelImpl.getOriginalFormat()
21507                                            };
21508    
21509                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FORMAT, args);
21510                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT,
21511                                            args);
21512    
21513                                    args = new Object[] { wikiPageModelImpl.getFormat() };
21514    
21515                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FORMAT, args);
21516                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT,
21517                                            args);
21518                            }
21519    
21520                            if ((wikiPageModelImpl.getColumnBitmask() &
21521                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N.getColumnBitmask()) != 0) {
21522                                    Object[] args = new Object[] {
21523                                                    wikiPageModelImpl.getOriginalResourcePrimKey(),
21524                                                    wikiPageModelImpl.getOriginalNodeId()
21525                                            };
21526    
21527                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N, args);
21528                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N,
21529                                            args);
21530    
21531                                    args = new Object[] {
21532                                                    wikiPageModelImpl.getResourcePrimKey(),
21533                                                    wikiPageModelImpl.getNodeId()
21534                                            };
21535    
21536                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N, args);
21537                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N,
21538                                            args);
21539                            }
21540    
21541                            if ((wikiPageModelImpl.getColumnBitmask() &
21542                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S.getColumnBitmask()) != 0) {
21543                                    Object[] args = new Object[] {
21544                                                    wikiPageModelImpl.getOriginalResourcePrimKey(),
21545                                                    wikiPageModelImpl.getOriginalStatus()
21546                                            };
21547    
21548                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_S, args);
21549                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S,
21550                                            args);
21551    
21552                                    args = new Object[] {
21553                                                    wikiPageModelImpl.getResourcePrimKey(),
21554                                                    wikiPageModelImpl.getStatus()
21555                                            };
21556    
21557                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_S, args);
21558                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S,
21559                                            args);
21560                            }
21561    
21562                            if ((wikiPageModelImpl.getColumnBitmask() &
21563                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T.getColumnBitmask()) != 0) {
21564                                    Object[] args = new Object[] {
21565                                                    wikiPageModelImpl.getOriginalNodeId(),
21566                                                    wikiPageModelImpl.getOriginalTitle()
21567                                            };
21568    
21569                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T, args);
21570                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T,
21571                                            args);
21572    
21573                                    args = new Object[] {
21574                                                    wikiPageModelImpl.getNodeId(),
21575                                                    wikiPageModelImpl.getTitle()
21576                                            };
21577    
21578                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T, args);
21579                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T,
21580                                            args);
21581                            }
21582    
21583                            if ((wikiPageModelImpl.getColumnBitmask() &
21584                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H.getColumnBitmask()) != 0) {
21585                                    Object[] args = new Object[] {
21586                                                    wikiPageModelImpl.getOriginalNodeId(),
21587                                                    wikiPageModelImpl.getOriginalHead()
21588                                            };
21589    
21590                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H, args);
21591                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H,
21592                                            args);
21593    
21594                                    args = new Object[] {
21595                                                    wikiPageModelImpl.getNodeId(),
21596                                                    wikiPageModelImpl.getHead()
21597                                            };
21598    
21599                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H, args);
21600                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H,
21601                                            args);
21602                            }
21603    
21604                            if ((wikiPageModelImpl.getColumnBitmask() &
21605                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P.getColumnBitmask()) != 0) {
21606                                    Object[] args = new Object[] {
21607                                                    wikiPageModelImpl.getOriginalNodeId(),
21608                                                    wikiPageModelImpl.getOriginalParentTitle()
21609                                            };
21610    
21611                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_P, args);
21612                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P,
21613                                            args);
21614    
21615                                    args = new Object[] {
21616                                                    wikiPageModelImpl.getNodeId(),
21617                                                    wikiPageModelImpl.getParentTitle()
21618                                            };
21619    
21620                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_P, args);
21621                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P,
21622                                            args);
21623                            }
21624    
21625                            if ((wikiPageModelImpl.getColumnBitmask() &
21626                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R.getColumnBitmask()) != 0) {
21627                                    Object[] args = new Object[] {
21628                                                    wikiPageModelImpl.getOriginalNodeId(),
21629                                                    wikiPageModelImpl.getOriginalRedirectTitle()
21630                                            };
21631    
21632                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_R, args);
21633                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R,
21634                                            args);
21635    
21636                                    args = new Object[] {
21637                                                    wikiPageModelImpl.getNodeId(),
21638                                                    wikiPageModelImpl.getRedirectTitle()
21639                                            };
21640    
21641                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_R, args);
21642                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R,
21643                                            args);
21644                            }
21645    
21646                            if ((wikiPageModelImpl.getColumnBitmask() &
21647                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S.getColumnBitmask()) != 0) {
21648                                    Object[] args = new Object[] {
21649                                                    wikiPageModelImpl.getOriginalNodeId(),
21650                                                    wikiPageModelImpl.getOriginalStatus()
21651                                            };
21652    
21653                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_S, args);
21654                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S,
21655                                            args);
21656    
21657                                    args = new Object[] {
21658                                                    wikiPageModelImpl.getNodeId(),
21659                                                    wikiPageModelImpl.getStatus()
21660                                            };
21661    
21662                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_S, args);
21663                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S,
21664                                            args);
21665                            }
21666    
21667                            if ((wikiPageModelImpl.getColumnBitmask() &
21668                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_H.getColumnBitmask()) != 0) {
21669                                    Object[] args = new Object[] {
21670                                                    wikiPageModelImpl.getOriginalResourcePrimKey(),
21671                                                    wikiPageModelImpl.getOriginalNodeId(),
21672                                                    wikiPageModelImpl.getOriginalHead()
21673                                            };
21674    
21675                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_H, args);
21676                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_H,
21677                                            args);
21678    
21679                                    args = new Object[] {
21680                                                    wikiPageModelImpl.getResourcePrimKey(),
21681                                                    wikiPageModelImpl.getNodeId(),
21682                                                    wikiPageModelImpl.getHead()
21683                                            };
21684    
21685                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_H, args);
21686                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_H,
21687                                            args);
21688                            }
21689    
21690                            if ((wikiPageModelImpl.getColumnBitmask() &
21691                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S.getColumnBitmask()) != 0) {
21692                                    Object[] args = new Object[] {
21693                                                    wikiPageModelImpl.getOriginalResourcePrimKey(),
21694                                                    wikiPageModelImpl.getOriginalNodeId(),
21695                                                    wikiPageModelImpl.getOriginalStatus()
21696                                            };
21697    
21698                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_S, args);
21699                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S,
21700                                            args);
21701    
21702                                    args = new Object[] {
21703                                                    wikiPageModelImpl.getResourcePrimKey(),
21704                                                    wikiPageModelImpl.getNodeId(),
21705                                                    wikiPageModelImpl.getStatus()
21706                                            };
21707    
21708                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_S, args);
21709                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S,
21710                                            args);
21711                            }
21712    
21713                            if ((wikiPageModelImpl.getColumnBitmask() &
21714                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H.getColumnBitmask()) != 0) {
21715                                    Object[] args = new Object[] {
21716                                                    wikiPageModelImpl.getOriginalGroupId(),
21717                                                    wikiPageModelImpl.getOriginalNodeId(),
21718                                                    wikiPageModelImpl.getOriginalHead()
21719                                            };
21720    
21721                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H, args);
21722                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H,
21723                                            args);
21724    
21725                                    args = new Object[] {
21726                                                    wikiPageModelImpl.getGroupId(),
21727                                                    wikiPageModelImpl.getNodeId(),
21728                                                    wikiPageModelImpl.getHead()
21729                                            };
21730    
21731                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H, args);
21732                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H,
21733                                            args);
21734                            }
21735    
21736                            if ((wikiPageModelImpl.getColumnBitmask() &
21737                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S.getColumnBitmask()) != 0) {
21738                                    Object[] args = new Object[] {
21739                                                    wikiPageModelImpl.getOriginalGroupId(),
21740                                                    wikiPageModelImpl.getOriginalNodeId(),
21741                                                    wikiPageModelImpl.getOriginalStatus()
21742                                            };
21743    
21744                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_S, args);
21745                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S,
21746                                            args);
21747    
21748                                    args = new Object[] {
21749                                                    wikiPageModelImpl.getGroupId(),
21750                                                    wikiPageModelImpl.getNodeId(),
21751                                                    wikiPageModelImpl.getStatus()
21752                                            };
21753    
21754                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_S, args);
21755                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S,
21756                                            args);
21757                            }
21758    
21759                            if ((wikiPageModelImpl.getColumnBitmask() &
21760                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S.getColumnBitmask()) != 0) {
21761                                    Object[] args = new Object[] {
21762                                                    wikiPageModelImpl.getOriginalUserId(),
21763                                                    wikiPageModelImpl.getOriginalNodeId(),
21764                                                    wikiPageModelImpl.getOriginalStatus()
21765                                            };
21766    
21767                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_N_S, args);
21768                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S,
21769                                            args);
21770    
21771                                    args = new Object[] {
21772                                                    wikiPageModelImpl.getUserId(),
21773                                                    wikiPageModelImpl.getNodeId(),
21774                                                    wikiPageModelImpl.getStatus()
21775                                            };
21776    
21777                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_N_S, args);
21778                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S,
21779                                            args);
21780                            }
21781    
21782                            if ((wikiPageModelImpl.getColumnBitmask() &
21783                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H.getColumnBitmask()) != 0) {
21784                                    Object[] args = new Object[] {
21785                                                    wikiPageModelImpl.getOriginalNodeId(),
21786                                                    wikiPageModelImpl.getOriginalTitle(),
21787                                                    wikiPageModelImpl.getOriginalHead()
21788                                            };
21789    
21790                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_H, args);
21791                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H,
21792                                            args);
21793    
21794                                    args = new Object[] {
21795                                                    wikiPageModelImpl.getNodeId(),
21796                                                    wikiPageModelImpl.getTitle(),
21797                                                    wikiPageModelImpl.getHead()
21798                                            };
21799    
21800                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_H, args);
21801                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H,
21802                                            args);
21803                            }
21804    
21805                            if ((wikiPageModelImpl.getColumnBitmask() &
21806                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S.getColumnBitmask()) != 0) {
21807                                    Object[] args = new Object[] {
21808                                                    wikiPageModelImpl.getOriginalNodeId(),
21809                                                    wikiPageModelImpl.getOriginalTitle(),
21810                                                    wikiPageModelImpl.getOriginalStatus()
21811                                            };
21812    
21813                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_S, args);
21814                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S,
21815                                            args);
21816    
21817                                    args = new Object[] {
21818                                                    wikiPageModelImpl.getNodeId(),
21819                                                    wikiPageModelImpl.getTitle(),
21820                                                    wikiPageModelImpl.getStatus()
21821                                            };
21822    
21823                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_S, args);
21824                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S,
21825                                            args);
21826                            }
21827    
21828                            if ((wikiPageModelImpl.getColumnBitmask() &
21829                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P.getColumnBitmask()) != 0) {
21830                                    Object[] args = new Object[] {
21831                                                    wikiPageModelImpl.getOriginalNodeId(),
21832                                                    wikiPageModelImpl.getOriginalHead(),
21833                                                    wikiPageModelImpl.getOriginalParentTitle()
21834                                            };
21835    
21836                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P, args);
21837                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P,
21838                                            args);
21839    
21840                                    args = new Object[] {
21841                                                    wikiPageModelImpl.getNodeId(),
21842                                                    wikiPageModelImpl.getHead(),
21843                                                    wikiPageModelImpl.getParentTitle()
21844                                            };
21845    
21846                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P, args);
21847                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P,
21848                                            args);
21849                            }
21850    
21851                            if ((wikiPageModelImpl.getColumnBitmask() &
21852                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_R.getColumnBitmask()) != 0) {
21853                                    Object[] args = new Object[] {
21854                                                    wikiPageModelImpl.getOriginalNodeId(),
21855                                                    wikiPageModelImpl.getOriginalHead(),
21856                                                    wikiPageModelImpl.getOriginalRedirectTitle()
21857                                            };
21858    
21859                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_R, args);
21860                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_R,
21861                                            args);
21862    
21863                                    args = new Object[] {
21864                                                    wikiPageModelImpl.getNodeId(),
21865                                                    wikiPageModelImpl.getHead(),
21866                                                    wikiPageModelImpl.getRedirectTitle()
21867                                            };
21868    
21869                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_R, args);
21870                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_R,
21871                                            args);
21872                            }
21873    
21874                            if ((wikiPageModelImpl.getColumnBitmask() &
21875                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S.getColumnBitmask()) != 0) {
21876                                    Object[] args = new Object[] {
21877                                                    wikiPageModelImpl.getOriginalNodeId(),
21878                                                    wikiPageModelImpl.getOriginalHead(),
21879                                                    wikiPageModelImpl.getOriginalStatus()
21880                                            };
21881    
21882                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_S, args);
21883                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S,
21884                                            args);
21885    
21886                                    args = new Object[] {
21887                                                    wikiPageModelImpl.getNodeId(),
21888                                                    wikiPageModelImpl.getHead(),
21889                                                    wikiPageModelImpl.getStatus()
21890                                            };
21891    
21892                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_S, args);
21893                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S,
21894                                            args);
21895                            }
21896    
21897                            if ((wikiPageModelImpl.getColumnBitmask() &
21898                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S.getColumnBitmask()) != 0) {
21899                                    Object[] args = new Object[] {
21900                                                    wikiPageModelImpl.getOriginalGroupId(),
21901                                                    wikiPageModelImpl.getOriginalUserId(),
21902                                                    wikiPageModelImpl.getOriginalNodeId(),
21903                                                    wikiPageModelImpl.getOriginalStatus()
21904                                            };
21905    
21906                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_N_S, args);
21907                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S,
21908                                            args);
21909    
21910                                    args = new Object[] {
21911                                                    wikiPageModelImpl.getGroupId(),
21912                                                    wikiPageModelImpl.getUserId(),
21913                                                    wikiPageModelImpl.getNodeId(),
21914                                                    wikiPageModelImpl.getStatus()
21915                                            };
21916    
21917                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_N_S, args);
21918                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S,
21919                                            args);
21920                            }
21921    
21922                            if ((wikiPageModelImpl.getColumnBitmask() &
21923                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H.getColumnBitmask()) != 0) {
21924                                    Object[] args = new Object[] {
21925                                                    wikiPageModelImpl.getOriginalGroupId(),
21926                                                    wikiPageModelImpl.getOriginalNodeId(),
21927                                                    wikiPageModelImpl.getOriginalTitle(),
21928                                                    wikiPageModelImpl.getOriginalHead()
21929                                            };
21930    
21931                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_T_H, args);
21932                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H,
21933                                            args);
21934    
21935                                    args = new Object[] {
21936                                                    wikiPageModelImpl.getGroupId(),
21937                                                    wikiPageModelImpl.getNodeId(),
21938                                                    wikiPageModelImpl.getTitle(),
21939                                                    wikiPageModelImpl.getHead()
21940                                            };
21941    
21942                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_T_H, args);
21943                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H,
21944                                            args);
21945                            }
21946    
21947                            if ((wikiPageModelImpl.getColumnBitmask() &
21948                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S.getColumnBitmask()) != 0) {
21949                                    Object[] args = new Object[] {
21950                                                    wikiPageModelImpl.getOriginalGroupId(),
21951                                                    wikiPageModelImpl.getOriginalNodeId(),
21952                                                    wikiPageModelImpl.getOriginalHead(),
21953                                                    wikiPageModelImpl.getOriginalStatus()
21954                                            };
21955    
21956                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_S, args);
21957                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S,
21958                                            args);
21959    
21960                                    args = new Object[] {
21961                                                    wikiPageModelImpl.getGroupId(),
21962                                                    wikiPageModelImpl.getNodeId(),
21963                                                    wikiPageModelImpl.getHead(),
21964                                                    wikiPageModelImpl.getStatus()
21965                                            };
21966    
21967                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_S, args);
21968                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S,
21969                                            args);
21970                            }
21971    
21972                            if ((wikiPageModelImpl.getColumnBitmask() &
21973                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S.getColumnBitmask()) != 0) {
21974                                    Object[] args = new Object[] {
21975                                                    wikiPageModelImpl.getOriginalNodeId(),
21976                                                    wikiPageModelImpl.getOriginalHead(),
21977                                                    wikiPageModelImpl.getOriginalParentTitle(),
21978                                                    wikiPageModelImpl.getOriginalStatus()
21979                                            };
21980    
21981                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P_S, args);
21982                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S,
21983                                            args);
21984    
21985                                    args = new Object[] {
21986                                                    wikiPageModelImpl.getNodeId(),
21987                                                    wikiPageModelImpl.getHead(),
21988                                                    wikiPageModelImpl.getParentTitle(),
21989                                                    wikiPageModelImpl.getStatus()
21990                                            };
21991    
21992                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P_S, args);
21993                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S,
21994                                            args);
21995                            }
21996    
21997                            if ((wikiPageModelImpl.getColumnBitmask() &
21998                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_R_S.getColumnBitmask()) != 0) {
21999                                    Object[] args = new Object[] {
22000                                                    wikiPageModelImpl.getOriginalNodeId(),
22001                                                    wikiPageModelImpl.getOriginalHead(),
22002                                                    wikiPageModelImpl.getOriginalRedirectTitle(),
22003                                                    wikiPageModelImpl.getOriginalStatus()
22004                                            };
22005    
22006                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_R_S, args);
22007                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_R_S,
22008                                            args);
22009    
22010                                    args = new Object[] {
22011                                                    wikiPageModelImpl.getNodeId(),
22012                                                    wikiPageModelImpl.getHead(),
22013                                                    wikiPageModelImpl.getRedirectTitle(),
22014                                                    wikiPageModelImpl.getStatus()
22015                                            };
22016    
22017                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_R_S, args);
22018                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_R_S,
22019                                            args);
22020                            }
22021    
22022                            if ((wikiPageModelImpl.getColumnBitmask() &
22023                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S.getColumnBitmask()) != 0) {
22024                                    Object[] args = new Object[] {
22025                                                    wikiPageModelImpl.getOriginalGroupId(),
22026                                                    wikiPageModelImpl.getOriginalNodeId(),
22027                                                    wikiPageModelImpl.getOriginalHead(),
22028                                                    wikiPageModelImpl.getOriginalParentTitle(),
22029                                                    wikiPageModelImpl.getOriginalStatus()
22030                                            };
22031    
22032                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_P_S,
22033                                            args);
22034                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S,
22035                                            args);
22036    
22037                                    args = new Object[] {
22038                                                    wikiPageModelImpl.getGroupId(),
22039                                                    wikiPageModelImpl.getNodeId(),
22040                                                    wikiPageModelImpl.getHead(),
22041                                                    wikiPageModelImpl.getParentTitle(),
22042                                                    wikiPageModelImpl.getStatus()
22043                                            };
22044    
22045                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_P_S,
22046                                            args);
22047                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S,
22048                                            args);
22049                            }
22050                    }
22051    
22052                    EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
22053                            WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage, false);
22054    
22055                    clearUniqueFindersCache(wikiPage);
22056                    cacheUniqueFindersCache(wikiPage);
22057    
22058                    wikiPage.resetOriginalValues();
22059    
22060                    return wikiPage;
22061            }
22062    
22063            protected WikiPage toUnwrappedModel(WikiPage wikiPage) {
22064                    if (wikiPage instanceof WikiPageImpl) {
22065                            return wikiPage;
22066                    }
22067    
22068                    WikiPageImpl wikiPageImpl = new WikiPageImpl();
22069    
22070                    wikiPageImpl.setNew(wikiPage.isNew());
22071                    wikiPageImpl.setPrimaryKey(wikiPage.getPrimaryKey());
22072    
22073                    wikiPageImpl.setUuid(wikiPage.getUuid());
22074                    wikiPageImpl.setPageId(wikiPage.getPageId());
22075                    wikiPageImpl.setResourcePrimKey(wikiPage.getResourcePrimKey());
22076                    wikiPageImpl.setGroupId(wikiPage.getGroupId());
22077                    wikiPageImpl.setCompanyId(wikiPage.getCompanyId());
22078                    wikiPageImpl.setUserId(wikiPage.getUserId());
22079                    wikiPageImpl.setUserName(wikiPage.getUserName());
22080                    wikiPageImpl.setCreateDate(wikiPage.getCreateDate());
22081                    wikiPageImpl.setModifiedDate(wikiPage.getModifiedDate());
22082                    wikiPageImpl.setNodeId(wikiPage.getNodeId());
22083                    wikiPageImpl.setTitle(wikiPage.getTitle());
22084                    wikiPageImpl.setVersion(wikiPage.getVersion());
22085                    wikiPageImpl.setMinorEdit(wikiPage.isMinorEdit());
22086                    wikiPageImpl.setContent(wikiPage.getContent());
22087                    wikiPageImpl.setSummary(wikiPage.getSummary());
22088                    wikiPageImpl.setFormat(wikiPage.getFormat());
22089                    wikiPageImpl.setHead(wikiPage.isHead());
22090                    wikiPageImpl.setParentTitle(wikiPage.getParentTitle());
22091                    wikiPageImpl.setRedirectTitle(wikiPage.getRedirectTitle());
22092                    wikiPageImpl.setStatus(wikiPage.getStatus());
22093                    wikiPageImpl.setStatusByUserId(wikiPage.getStatusByUserId());
22094                    wikiPageImpl.setStatusByUserName(wikiPage.getStatusByUserName());
22095                    wikiPageImpl.setStatusDate(wikiPage.getStatusDate());
22096    
22097                    return wikiPageImpl;
22098            }
22099    
22100            /**
22101             * Returns the wiki page with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
22102             *
22103             * @param primaryKey the primary key of the wiki page
22104             * @return the wiki page
22105             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
22106             */
22107            @Override
22108            public WikiPage findByPrimaryKey(Serializable primaryKey)
22109                    throws NoSuchPageException {
22110                    WikiPage wikiPage = fetchByPrimaryKey(primaryKey);
22111    
22112                    if (wikiPage == null) {
22113                            if (_log.isWarnEnabled()) {
22114                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
22115                            }
22116    
22117                            throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
22118                                    primaryKey);
22119                    }
22120    
22121                    return wikiPage;
22122            }
22123    
22124            /**
22125             * Returns the wiki page with the primary key or throws a {@link com.liferay.portlet.wiki.NoSuchPageException} if it could not be found.
22126             *
22127             * @param pageId the primary key of the wiki page
22128             * @return the wiki page
22129             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
22130             */
22131            @Override
22132            public WikiPage findByPrimaryKey(long pageId) throws NoSuchPageException {
22133                    return findByPrimaryKey((Serializable)pageId);
22134            }
22135    
22136            /**
22137             * Returns the wiki page with the primary key or returns <code>null</code> if it could not be found.
22138             *
22139             * @param primaryKey the primary key of the wiki page
22140             * @return the wiki page, or <code>null</code> if a wiki page with the primary key could not be found
22141             */
22142            @Override
22143            public WikiPage fetchByPrimaryKey(Serializable primaryKey) {
22144                    WikiPage wikiPage = (WikiPage)EntityCacheUtil.getResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
22145                                    WikiPageImpl.class, primaryKey);
22146    
22147                    if (wikiPage == _nullWikiPage) {
22148                            return null;
22149                    }
22150    
22151                    if (wikiPage == null) {
22152                            Session session = null;
22153    
22154                            try {
22155                                    session = openSession();
22156    
22157                                    wikiPage = (WikiPage)session.get(WikiPageImpl.class, primaryKey);
22158    
22159                                    if (wikiPage != null) {
22160                                            cacheResult(wikiPage);
22161                                    }
22162                                    else {
22163                                            EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
22164                                                    WikiPageImpl.class, primaryKey, _nullWikiPage);
22165                                    }
22166                            }
22167                            catch (Exception e) {
22168                                    EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
22169                                            WikiPageImpl.class, primaryKey);
22170    
22171                                    throw processException(e);
22172                            }
22173                            finally {
22174                                    closeSession(session);
22175                            }
22176                    }
22177    
22178                    return wikiPage;
22179            }
22180    
22181            /**
22182             * Returns the wiki page with the primary key or returns <code>null</code> if it could not be found.
22183             *
22184             * @param pageId the primary key of the wiki page
22185             * @return the wiki page, or <code>null</code> if a wiki page with the primary key could not be found
22186             */
22187            @Override
22188            public WikiPage fetchByPrimaryKey(long pageId) {
22189                    return fetchByPrimaryKey((Serializable)pageId);
22190            }
22191    
22192            @Override
22193            public Map<Serializable, WikiPage> fetchByPrimaryKeys(
22194                    Set<Serializable> primaryKeys) {
22195                    if (primaryKeys.isEmpty()) {
22196                            return Collections.emptyMap();
22197                    }
22198    
22199                    Map<Serializable, WikiPage> map = new HashMap<Serializable, WikiPage>();
22200    
22201                    if (primaryKeys.size() == 1) {
22202                            Iterator<Serializable> iterator = primaryKeys.iterator();
22203    
22204                            Serializable primaryKey = iterator.next();
22205    
22206                            WikiPage wikiPage = fetchByPrimaryKey(primaryKey);
22207    
22208                            if (wikiPage != null) {
22209                                    map.put(primaryKey, wikiPage);
22210                            }
22211    
22212                            return map;
22213                    }
22214    
22215                    Set<Serializable> uncachedPrimaryKeys = null;
22216    
22217                    for (Serializable primaryKey : primaryKeys) {
22218                            WikiPage wikiPage = (WikiPage)EntityCacheUtil.getResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
22219                                            WikiPageImpl.class, primaryKey);
22220    
22221                            if (wikiPage == null) {
22222                                    if (uncachedPrimaryKeys == null) {
22223                                            uncachedPrimaryKeys = new HashSet<Serializable>();
22224                                    }
22225    
22226                                    uncachedPrimaryKeys.add(primaryKey);
22227                            }
22228                            else {
22229                                    map.put(primaryKey, wikiPage);
22230                            }
22231                    }
22232    
22233                    if (uncachedPrimaryKeys == null) {
22234                            return map;
22235                    }
22236    
22237                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
22238                                    1);
22239    
22240                    query.append(_SQL_SELECT_WIKIPAGE_WHERE_PKS_IN);
22241    
22242                    for (Serializable primaryKey : uncachedPrimaryKeys) {
22243                            query.append(String.valueOf(primaryKey));
22244    
22245                            query.append(StringPool.COMMA);
22246                    }
22247    
22248                    query.setIndex(query.index() - 1);
22249    
22250                    query.append(StringPool.CLOSE_PARENTHESIS);
22251    
22252                    String sql = query.toString();
22253    
22254                    Session session = null;
22255    
22256                    try {
22257                            session = openSession();
22258    
22259                            Query q = session.createQuery(sql);
22260    
22261                            for (WikiPage wikiPage : (List<WikiPage>)q.list()) {
22262                                    map.put(wikiPage.getPrimaryKeyObj(), wikiPage);
22263    
22264                                    cacheResult(wikiPage);
22265    
22266                                    uncachedPrimaryKeys.remove(wikiPage.getPrimaryKeyObj());
22267                            }
22268    
22269                            for (Serializable primaryKey : uncachedPrimaryKeys) {
22270                                    EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
22271                                            WikiPageImpl.class, primaryKey, _nullWikiPage);
22272                            }
22273                    }
22274                    catch (Exception e) {
22275                            throw processException(e);
22276                    }
22277                    finally {
22278                            closeSession(session);
22279                    }
22280    
22281                    return map;
22282            }
22283    
22284            /**
22285             * Returns all the wiki pages.
22286             *
22287             * @return the wiki pages
22288             */
22289            @Override
22290            public List<WikiPage> findAll() {
22291                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
22292            }
22293    
22294            /**
22295             * Returns a range of all the wiki pages.
22296             *
22297             * <p>
22298             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
22299             * </p>
22300             *
22301             * @param start the lower bound of the range of wiki pages
22302             * @param end the upper bound of the range of wiki pages (not inclusive)
22303             * @return the range of wiki pages
22304             */
22305            @Override
22306            public List<WikiPage> findAll(int start, int end) {
22307                    return findAll(start, end, null);
22308            }
22309    
22310            /**
22311             * Returns an ordered range of all the wiki pages.
22312             *
22313             * <p>
22314             * 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.wiki.model.impl.WikiPageModelImpl}. 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.
22315             * </p>
22316             *
22317             * @param start the lower bound of the range of wiki pages
22318             * @param end the upper bound of the range of wiki pages (not inclusive)
22319             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22320             * @return the ordered range of wiki pages
22321             */
22322            @Override
22323            public List<WikiPage> findAll(int start, int end,
22324                    OrderByComparator<WikiPage> orderByComparator) {
22325                    boolean pagination = true;
22326                    FinderPath finderPath = null;
22327                    Object[] finderArgs = null;
22328    
22329                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22330                                    (orderByComparator == null)) {
22331                            pagination = false;
22332                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
22333                            finderArgs = FINDER_ARGS_EMPTY;
22334                    }
22335                    else {
22336                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
22337                            finderArgs = new Object[] { start, end, orderByComparator };
22338                    }
22339    
22340                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
22341                                    finderArgs, this);
22342    
22343                    if (list == null) {
22344                            StringBundler query = null;
22345                            String sql = null;
22346    
22347                            if (orderByComparator != null) {
22348                                    query = new StringBundler(2 +
22349                                                    (orderByComparator.getOrderByFields().length * 3));
22350    
22351                                    query.append(_SQL_SELECT_WIKIPAGE);
22352    
22353                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22354                                            orderByComparator);
22355    
22356                                    sql = query.toString();
22357                            }
22358                            else {
22359                                    sql = _SQL_SELECT_WIKIPAGE;
22360    
22361                                    if (pagination) {
22362                                            sql = sql.concat(WikiPageModelImpl.ORDER_BY_JPQL);
22363                                    }
22364                            }
22365    
22366                            Session session = null;
22367    
22368                            try {
22369                                    session = openSession();
22370    
22371                                    Query q = session.createQuery(sql);
22372    
22373                                    if (!pagination) {
22374                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
22375                                                            start, end, false);
22376    
22377                                            Collections.sort(list);
22378    
22379                                            list = Collections.unmodifiableList(list);
22380                                    }
22381                                    else {
22382                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
22383                                                            start, end);
22384                                    }
22385    
22386                                    cacheResult(list);
22387    
22388                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
22389                            }
22390                            catch (Exception e) {
22391                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22392    
22393                                    throw processException(e);
22394                            }
22395                            finally {
22396                                    closeSession(session);
22397                            }
22398                    }
22399    
22400                    return list;
22401            }
22402    
22403            /**
22404             * Removes all the wiki pages from the database.
22405             *
22406             */
22407            @Override
22408            public void removeAll() {
22409                    for (WikiPage wikiPage : findAll()) {
22410                            remove(wikiPage);
22411                    }
22412            }
22413    
22414            /**
22415             * Returns the number of wiki pages.
22416             *
22417             * @return the number of wiki pages
22418             */
22419            @Override
22420            public int countAll() {
22421                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
22422                                    FINDER_ARGS_EMPTY, this);
22423    
22424                    if (count == null) {
22425                            Session session = null;
22426    
22427                            try {
22428                                    session = openSession();
22429    
22430                                    Query q = session.createQuery(_SQL_COUNT_WIKIPAGE);
22431    
22432                                    count = (Long)q.uniqueResult();
22433    
22434                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
22435                                            FINDER_ARGS_EMPTY, count);
22436                            }
22437                            catch (Exception e) {
22438                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
22439                                            FINDER_ARGS_EMPTY);
22440    
22441                                    throw processException(e);
22442                            }
22443                            finally {
22444                                    closeSession(session);
22445                            }
22446                    }
22447    
22448                    return count.intValue();
22449            }
22450    
22451            @Override
22452            protected Set<String> getBadColumnNames() {
22453                    return _badColumnNames;
22454            }
22455    
22456            /**
22457             * Initializes the wiki page persistence.
22458             */
22459            public void afterPropertiesSet() {
22460            }
22461    
22462            public void destroy() {
22463                    EntityCacheUtil.removeCache(WikiPageImpl.class.getName());
22464                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
22465                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
22466                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
22467            }
22468    
22469            private static final String _SQL_SELECT_WIKIPAGE = "SELECT wikiPage FROM WikiPage wikiPage";
22470            private static final String _SQL_SELECT_WIKIPAGE_WHERE_PKS_IN = "SELECT wikiPage FROM WikiPage wikiPage WHERE pageId IN (";
22471            private static final String _SQL_SELECT_WIKIPAGE_WHERE = "SELECT wikiPage FROM WikiPage wikiPage WHERE ";
22472            private static final String _SQL_COUNT_WIKIPAGE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage";
22473            private static final String _SQL_COUNT_WIKIPAGE_WHERE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage WHERE ";
22474            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "wikiPage.resourcePrimKey";
22475            private static final String _FILTER_SQL_SELECT_WIKIPAGE_WHERE = "SELECT DISTINCT {wikiPage.*} FROM WikiPage wikiPage WHERE ";
22476            private static final String _FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1 =
22477                    "SELECT {WikiPage.*} FROM (SELECT DISTINCT wikiPage.pageId FROM WikiPage wikiPage WHERE ";
22478            private static final String _FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2 =
22479                    ") TEMP_TABLE INNER JOIN WikiPage ON TEMP_TABLE.pageId = WikiPage.pageId";
22480            private static final String _FILTER_SQL_COUNT_WIKIPAGE_WHERE = "SELECT COUNT(DISTINCT wikiPage.pageId) AS COUNT_VALUE FROM WikiPage wikiPage WHERE ";
22481            private static final String _FILTER_ENTITY_ALIAS = "wikiPage";
22482            private static final String _FILTER_ENTITY_TABLE = "WikiPage";
22483            private static final String _ORDER_BY_ENTITY_ALIAS = "wikiPage.";
22484            private static final String _ORDER_BY_ENTITY_TABLE = "WikiPage.";
22485            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiPage exists with the primary key ";
22486            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiPage exists with the key {";
22487            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
22488            private static final Log _log = LogFactoryUtil.getLog(WikiPagePersistenceImpl.class);
22489            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
22490                                    "uuid"
22491                            });
22492            private static final WikiPage _nullWikiPage = new WikiPageImpl() {
22493                            @Override
22494                            public Object clone() {
22495                                    return this;
22496                            }
22497    
22498                            @Override
22499                            public CacheModel<WikiPage> toCacheModel() {
22500                                    return _nullWikiPageCacheModel;
22501                            }
22502                    };
22503    
22504            private static final CacheModel<WikiPage> _nullWikiPageCacheModel = new CacheModel<WikiPage>() {
22505                            @Override
22506                            public WikiPage toEntityModel() {
22507                                    return _nullWikiPage;
22508                            }
22509                    };
22510    }