001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.wiki.service.persistence;
016    
017    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderPath;
021    import com.liferay.portal.kernel.dao.orm.Query;
022    import com.liferay.portal.kernel.dao.orm.QueryPos;
023    import com.liferay.portal.kernel.dao.orm.QueryUtil;
024    import com.liferay.portal.kernel.dao.orm.SQLQuery;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.sanitizer.Sanitizer;
030    import com.liferay.portal.kernel.sanitizer.SanitizerException;
031    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
032    import com.liferay.portal.kernel.util.ContentTypes;
033    import com.liferay.portal.kernel.util.GetterUtil;
034    import com.liferay.portal.kernel.util.InstanceFactory;
035    import com.liferay.portal.kernel.util.OrderByComparator;
036    import com.liferay.portal.kernel.util.StringBundler;
037    import com.liferay.portal.kernel.util.StringPool;
038    import com.liferay.portal.kernel.util.StringUtil;
039    import com.liferay.portal.kernel.util.UnmodifiableList;
040    import com.liferay.portal.kernel.util.Validator;
041    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
042    import com.liferay.portal.model.CacheModel;
043    import com.liferay.portal.model.ModelListener;
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    
053    import java.io.Serializable;
054    
055    import java.util.ArrayList;
056    import java.util.Collections;
057    import java.util.List;
058    
059    /**
060     * The persistence implementation for the wiki page service.
061     *
062     * <p>
063     * Caching information and settings can be found in <code>portal.properties</code>
064     * </p>
065     *
066     * @author Brian Wing Shun Chan
067     * @see WikiPagePersistence
068     * @see WikiPageUtil
069     * @generated
070     */
071    public class WikiPagePersistenceImpl extends BasePersistenceImpl<WikiPage>
072            implements WikiPagePersistence {
073            /*
074             * NOTE FOR DEVELOPERS:
075             *
076             * 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.
077             */
078            public static final String FINDER_CLASS_NAME_ENTITY = WikiPageImpl.class.getName();
079            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080                    ".List1";
081            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082                    ".List2";
083            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
084                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
085                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
086            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
087                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
088                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
089            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
090                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
092            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
093                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
094                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
095                            new String[] {
096                                    String.class.getName(),
097                                    
098                            Integer.class.getName(), Integer.class.getName(),
099                                    OrderByComparator.class.getName()
100                            });
101            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
102                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
104                            new String[] { String.class.getName() },
105                            WikiPageModelImpl.UUID_COLUMN_BITMASK |
106                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
107                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
108                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
109            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
110                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
112                            new String[] { String.class.getName() });
113    
114            /**
115             * Returns all the wiki pages where uuid = &#63;.
116             *
117             * @param uuid the uuid
118             * @return the matching wiki pages
119             * @throws SystemException if a system exception occurred
120             */
121            public List<WikiPage> findByUuid(String uuid) throws SystemException {
122                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
123            }
124    
125            /**
126             * Returns a range of all the wiki pages where uuid = &#63;.
127             *
128             * <p>
129             * 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.
130             * </p>
131             *
132             * @param uuid the uuid
133             * @param start the lower bound of the range of wiki pages
134             * @param end the upper bound of the range of wiki pages (not inclusive)
135             * @return the range of matching wiki pages
136             * @throws SystemException if a system exception occurred
137             */
138            public List<WikiPage> findByUuid(String uuid, int start, int end)
139                    throws SystemException {
140                    return findByUuid(uuid, start, end, null);
141            }
142    
143            /**
144             * Returns an ordered range of all the wiki pages where uuid = &#63;.
145             *
146             * <p>
147             * 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.
148             * </p>
149             *
150             * @param uuid the uuid
151             * @param start the lower bound of the range of wiki pages
152             * @param end the upper bound of the range of wiki pages (not inclusive)
153             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
154             * @return the ordered range of matching wiki pages
155             * @throws SystemException if a system exception occurred
156             */
157            public List<WikiPage> findByUuid(String uuid, int start, int end,
158                    OrderByComparator orderByComparator) throws SystemException {
159                    boolean pagination = true;
160                    FinderPath finderPath = null;
161                    Object[] finderArgs = null;
162    
163                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
164                                    (orderByComparator == null)) {
165                            pagination = false;
166                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
167                            finderArgs = new Object[] { uuid };
168                    }
169                    else {
170                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
171                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
172                    }
173    
174                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
175                                    finderArgs, this);
176    
177                    if ((list != null) && !list.isEmpty()) {
178                            for (WikiPage wikiPage : list) {
179                                    if (!Validator.equals(uuid, wikiPage.getUuid())) {
180                                            list = null;
181    
182                                            break;
183                                    }
184                            }
185                    }
186    
187                    if (list == null) {
188                            StringBundler query = null;
189    
190                            if (orderByComparator != null) {
191                                    query = new StringBundler(3 +
192                                                    (orderByComparator.getOrderByFields().length * 3));
193                            }
194                            else {
195                                    query = new StringBundler(3);
196                            }
197    
198                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
199    
200                            boolean bindUuid = false;
201    
202                            if (uuid == null) {
203                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
204                            }
205                            else if (uuid.equals(StringPool.BLANK)) {
206                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
207                            }
208                            else {
209                                    bindUuid = true;
210    
211                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
212                            }
213    
214                            if (orderByComparator != null) {
215                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
216                                            orderByComparator);
217                            }
218                            else
219                             if (pagination) {
220                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
221                            }
222    
223                            String sql = query.toString();
224    
225                            Session session = null;
226    
227                            try {
228                                    session = openSession();
229    
230                                    Query q = session.createQuery(sql);
231    
232                                    QueryPos qPos = QueryPos.getInstance(q);
233    
234                                    if (bindUuid) {
235                                            qPos.add(uuid);
236                                    }
237    
238                                    if (!pagination) {
239                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
240                                                            start, end, false);
241    
242                                            Collections.sort(list);
243    
244                                            list = new UnmodifiableList<WikiPage>(list);
245                                    }
246                                    else {
247                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
248                                                            start, end);
249                                    }
250    
251                                    cacheResult(list);
252    
253                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
254                            }
255                            catch (Exception e) {
256                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
257    
258                                    throw processException(e);
259                            }
260                            finally {
261                                    closeSession(session);
262                            }
263                    }
264    
265                    return list;
266            }
267    
268            /**
269             * Returns the first wiki page in the ordered set where uuid = &#63;.
270             *
271             * @param uuid the uuid
272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
273             * @return the first matching wiki page
274             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
275             * @throws SystemException if a system exception occurred
276             */
277            public WikiPage findByUuid_First(String uuid,
278                    OrderByComparator orderByComparator)
279                    throws NoSuchPageException, SystemException {
280                    WikiPage wikiPage = fetchByUuid_First(uuid, orderByComparator);
281    
282                    if (wikiPage != null) {
283                            return wikiPage;
284                    }
285    
286                    StringBundler msg = new StringBundler(4);
287    
288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
289    
290                    msg.append("uuid=");
291                    msg.append(uuid);
292    
293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
294    
295                    throw new NoSuchPageException(msg.toString());
296            }
297    
298            /**
299             * Returns the first wiki page in the ordered set where uuid = &#63;.
300             *
301             * @param uuid the uuid
302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
303             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
304             * @throws SystemException if a system exception occurred
305             */
306            public WikiPage fetchByUuid_First(String uuid,
307                    OrderByComparator orderByComparator) throws SystemException {
308                    List<WikiPage> list = findByUuid(uuid, 0, 1, orderByComparator);
309    
310                    if (!list.isEmpty()) {
311                            return list.get(0);
312                    }
313    
314                    return null;
315            }
316    
317            /**
318             * Returns the last wiki page in the ordered set where uuid = &#63;.
319             *
320             * @param uuid the uuid
321             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
322             * @return the last matching wiki page
323             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
324             * @throws SystemException if a system exception occurred
325             */
326            public WikiPage findByUuid_Last(String uuid,
327                    OrderByComparator orderByComparator)
328                    throws NoSuchPageException, SystemException {
329                    WikiPage wikiPage = fetchByUuid_Last(uuid, orderByComparator);
330    
331                    if (wikiPage != null) {
332                            return wikiPage;
333                    }
334    
335                    StringBundler msg = new StringBundler(4);
336    
337                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
338    
339                    msg.append("uuid=");
340                    msg.append(uuid);
341    
342                    msg.append(StringPool.CLOSE_CURLY_BRACE);
343    
344                    throw new NoSuchPageException(msg.toString());
345            }
346    
347            /**
348             * Returns the last wiki page in the ordered set where uuid = &#63;.
349             *
350             * @param uuid the uuid
351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
352             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
353             * @throws SystemException if a system exception occurred
354             */
355            public WikiPage fetchByUuid_Last(String uuid,
356                    OrderByComparator orderByComparator) throws SystemException {
357                    int count = countByUuid(uuid);
358    
359                    List<WikiPage> list = findByUuid(uuid, count - 1, count,
360                                    orderByComparator);
361    
362                    if (!list.isEmpty()) {
363                            return list.get(0);
364                    }
365    
366                    return null;
367            }
368    
369            /**
370             * Returns the wiki pages before and after the current wiki page in the ordered set where uuid = &#63;.
371             *
372             * @param pageId the primary key of the current wiki page
373             * @param uuid the uuid
374             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
375             * @return the previous, current, and next wiki page
376             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
377             * @throws SystemException if a system exception occurred
378             */
379            public WikiPage[] findByUuid_PrevAndNext(long pageId, String uuid,
380                    OrderByComparator orderByComparator)
381                    throws NoSuchPageException, SystemException {
382                    WikiPage wikiPage = findByPrimaryKey(pageId);
383    
384                    Session session = null;
385    
386                    try {
387                            session = openSession();
388    
389                            WikiPage[] array = new WikiPageImpl[3];
390    
391                            array[0] = getByUuid_PrevAndNext(session, wikiPage, uuid,
392                                            orderByComparator, true);
393    
394                            array[1] = wikiPage;
395    
396                            array[2] = getByUuid_PrevAndNext(session, wikiPage, uuid,
397                                            orderByComparator, false);
398    
399                            return array;
400                    }
401                    catch (Exception e) {
402                            throw processException(e);
403                    }
404                    finally {
405                            closeSession(session);
406                    }
407            }
408    
409            protected WikiPage getByUuid_PrevAndNext(Session session,
410                    WikiPage wikiPage, String uuid, OrderByComparator orderByComparator,
411                    boolean previous) {
412                    StringBundler query = null;
413    
414                    if (orderByComparator != null) {
415                            query = new StringBundler(6 +
416                                            (orderByComparator.getOrderByFields().length * 6));
417                    }
418                    else {
419                            query = new StringBundler(3);
420                    }
421    
422                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
423    
424                    boolean bindUuid = false;
425    
426                    if (uuid == null) {
427                            query.append(_FINDER_COLUMN_UUID_UUID_1);
428                    }
429                    else if (uuid.equals(StringPool.BLANK)) {
430                            query.append(_FINDER_COLUMN_UUID_UUID_3);
431                    }
432                    else {
433                            bindUuid = true;
434    
435                            query.append(_FINDER_COLUMN_UUID_UUID_2);
436                    }
437    
438                    if (orderByComparator != null) {
439                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
440    
441                            if (orderByConditionFields.length > 0) {
442                                    query.append(WHERE_AND);
443                            }
444    
445                            for (int i = 0; i < orderByConditionFields.length; i++) {
446                                    query.append(_ORDER_BY_ENTITY_ALIAS);
447                                    query.append(orderByConditionFields[i]);
448    
449                                    if ((i + 1) < orderByConditionFields.length) {
450                                            if (orderByComparator.isAscending() ^ previous) {
451                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
452                                            }
453                                            else {
454                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
455                                            }
456                                    }
457                                    else {
458                                            if (orderByComparator.isAscending() ^ previous) {
459                                                    query.append(WHERE_GREATER_THAN);
460                                            }
461                                            else {
462                                                    query.append(WHERE_LESSER_THAN);
463                                            }
464                                    }
465                            }
466    
467                            query.append(ORDER_BY_CLAUSE);
468    
469                            String[] orderByFields = orderByComparator.getOrderByFields();
470    
471                            for (int i = 0; i < orderByFields.length; i++) {
472                                    query.append(_ORDER_BY_ENTITY_ALIAS);
473                                    query.append(orderByFields[i]);
474    
475                                    if ((i + 1) < orderByFields.length) {
476                                            if (orderByComparator.isAscending() ^ previous) {
477                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
478                                            }
479                                            else {
480                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
481                                            }
482                                    }
483                                    else {
484                                            if (orderByComparator.isAscending() ^ previous) {
485                                                    query.append(ORDER_BY_ASC);
486                                            }
487                                            else {
488                                                    query.append(ORDER_BY_DESC);
489                                            }
490                                    }
491                            }
492                    }
493                    else {
494                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
495                    }
496    
497                    String sql = query.toString();
498    
499                    Query q = session.createQuery(sql);
500    
501                    q.setFirstResult(0);
502                    q.setMaxResults(2);
503    
504                    QueryPos qPos = QueryPos.getInstance(q);
505    
506                    if (bindUuid) {
507                            qPos.add(uuid);
508                    }
509    
510                    if (orderByComparator != null) {
511                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
512    
513                            for (Object value : values) {
514                                    qPos.add(value);
515                            }
516                    }
517    
518                    List<WikiPage> list = q.list();
519    
520                    if (list.size() == 2) {
521                            return list.get(1);
522                    }
523                    else {
524                            return null;
525                    }
526            }
527    
528            /**
529             * Removes all the wiki pages where uuid = &#63; from the database.
530             *
531             * @param uuid the uuid
532             * @throws SystemException if a system exception occurred
533             */
534            public void removeByUuid(String uuid) throws SystemException {
535                    for (WikiPage wikiPage : findByUuid(uuid, QueryUtil.ALL_POS,
536                                    QueryUtil.ALL_POS, null)) {
537                            remove(wikiPage);
538                    }
539            }
540    
541            /**
542             * Returns the number of wiki pages where uuid = &#63;.
543             *
544             * @param uuid the uuid
545             * @return the number of matching wiki pages
546             * @throws SystemException if a system exception occurred
547             */
548            public int countByUuid(String uuid) throws SystemException {
549                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
550    
551                    Object[] finderArgs = new Object[] { uuid };
552    
553                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
554                                    this);
555    
556                    if (count == null) {
557                            StringBundler query = new StringBundler(2);
558    
559                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
560    
561                            boolean bindUuid = false;
562    
563                            if (uuid == null) {
564                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
565                            }
566                            else if (uuid.equals(StringPool.BLANK)) {
567                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
568                            }
569                            else {
570                                    bindUuid = true;
571    
572                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
573                            }
574    
575                            String sql = query.toString();
576    
577                            Session session = null;
578    
579                            try {
580                                    session = openSession();
581    
582                                    Query q = session.createQuery(sql);
583    
584                                    QueryPos qPos = QueryPos.getInstance(q);
585    
586                                    if (bindUuid) {
587                                            qPos.add(uuid);
588                                    }
589    
590                                    count = (Long)q.uniqueResult();
591    
592                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
593                            }
594                            catch (Exception e) {
595                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
596    
597                                    throw processException(e);
598                            }
599                            finally {
600                                    closeSession(session);
601                            }
602                    }
603    
604                    return count.intValue();
605            }
606    
607            private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiPage.uuid IS NULL";
608            private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiPage.uuid = ?";
609            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = '')";
610            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
611                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
612                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
613                            new String[] { String.class.getName(), Long.class.getName() },
614                            WikiPageModelImpl.UUID_COLUMN_BITMASK |
615                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK);
616            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
617                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
618                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
619                            new String[] { String.class.getName(), Long.class.getName() });
620    
621            /**
622             * 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.
623             *
624             * @param uuid the uuid
625             * @param groupId the group ID
626             * @return the matching wiki page
627             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
628             * @throws SystemException if a system exception occurred
629             */
630            public WikiPage findByUUID_G(String uuid, long groupId)
631                    throws NoSuchPageException, SystemException {
632                    WikiPage wikiPage = fetchByUUID_G(uuid, groupId);
633    
634                    if (wikiPage == null) {
635                            StringBundler msg = new StringBundler(6);
636    
637                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
638    
639                            msg.append("uuid=");
640                            msg.append(uuid);
641    
642                            msg.append(", groupId=");
643                            msg.append(groupId);
644    
645                            msg.append(StringPool.CLOSE_CURLY_BRACE);
646    
647                            if (_log.isWarnEnabled()) {
648                                    _log.warn(msg.toString());
649                            }
650    
651                            throw new NoSuchPageException(msg.toString());
652                    }
653    
654                    return wikiPage;
655            }
656    
657            /**
658             * 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.
659             *
660             * @param uuid the uuid
661             * @param groupId the group ID
662             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
663             * @throws SystemException if a system exception occurred
664             */
665            public WikiPage fetchByUUID_G(String uuid, long groupId)
666                    throws SystemException {
667                    return fetchByUUID_G(uuid, groupId, true);
668            }
669    
670            /**
671             * 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.
672             *
673             * @param uuid the uuid
674             * @param groupId the group ID
675             * @param retrieveFromCache whether to use the finder cache
676             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
677             * @throws SystemException if a system exception occurred
678             */
679            public WikiPage fetchByUUID_G(String uuid, long groupId,
680                    boolean retrieveFromCache) throws SystemException {
681                    Object[] finderArgs = new Object[] { uuid, groupId };
682    
683                    Object result = null;
684    
685                    if (retrieveFromCache) {
686                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
687                                            finderArgs, this);
688                    }
689    
690                    if (result instanceof WikiPage) {
691                            WikiPage wikiPage = (WikiPage)result;
692    
693                            if (!Validator.equals(uuid, wikiPage.getUuid()) ||
694                                            (groupId != wikiPage.getGroupId())) {
695                                    result = null;
696                            }
697                    }
698    
699                    if (result == null) {
700                            StringBundler query = new StringBundler(4);
701    
702                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
703    
704                            boolean bindUuid = false;
705    
706                            if (uuid == null) {
707                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
708                            }
709                            else if (uuid.equals(StringPool.BLANK)) {
710                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
711                            }
712                            else {
713                                    bindUuid = true;
714    
715                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
716                            }
717    
718                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
719    
720                            String sql = query.toString();
721    
722                            Session session = null;
723    
724                            try {
725                                    session = openSession();
726    
727                                    Query q = session.createQuery(sql);
728    
729                                    QueryPos qPos = QueryPos.getInstance(q);
730    
731                                    if (bindUuid) {
732                                            qPos.add(uuid);
733                                    }
734    
735                                    qPos.add(groupId);
736    
737                                    List<WikiPage> list = q.list();
738    
739                                    if (list.isEmpty()) {
740                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
741                                                    finderArgs, list);
742                                    }
743                                    else {
744                                            WikiPage wikiPage = list.get(0);
745    
746                                            result = wikiPage;
747    
748                                            cacheResult(wikiPage);
749    
750                                            if ((wikiPage.getUuid() == null) ||
751                                                            !wikiPage.getUuid().equals(uuid) ||
752                                                            (wikiPage.getGroupId() != groupId)) {
753                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
754                                                            finderArgs, wikiPage);
755                                            }
756                                    }
757                            }
758                            catch (Exception e) {
759                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
760                                            finderArgs);
761    
762                                    throw processException(e);
763                            }
764                            finally {
765                                    closeSession(session);
766                            }
767                    }
768    
769                    if (result instanceof List<?>) {
770                            return null;
771                    }
772                    else {
773                            return (WikiPage)result;
774                    }
775            }
776    
777            /**
778             * Removes the wiki page where uuid = &#63; and groupId = &#63; from the database.
779             *
780             * @param uuid the uuid
781             * @param groupId the group ID
782             * @return the wiki page that was removed
783             * @throws SystemException if a system exception occurred
784             */
785            public WikiPage removeByUUID_G(String uuid, long groupId)
786                    throws NoSuchPageException, SystemException {
787                    WikiPage wikiPage = findByUUID_G(uuid, groupId);
788    
789                    return remove(wikiPage);
790            }
791    
792            /**
793             * Returns the number of wiki pages where uuid = &#63; and groupId = &#63;.
794             *
795             * @param uuid the uuid
796             * @param groupId the group ID
797             * @return the number of matching wiki pages
798             * @throws SystemException if a system exception occurred
799             */
800            public int countByUUID_G(String uuid, long groupId)
801                    throws SystemException {
802                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
803    
804                    Object[] finderArgs = new Object[] { uuid, groupId };
805    
806                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
807                                    this);
808    
809                    if (count == null) {
810                            StringBundler query = new StringBundler(3);
811    
812                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
813    
814                            boolean bindUuid = false;
815    
816                            if (uuid == null) {
817                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
818                            }
819                            else if (uuid.equals(StringPool.BLANK)) {
820                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
821                            }
822                            else {
823                                    bindUuid = true;
824    
825                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
826                            }
827    
828                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
829    
830                            String sql = query.toString();
831    
832                            Session session = null;
833    
834                            try {
835                                    session = openSession();
836    
837                                    Query q = session.createQuery(sql);
838    
839                                    QueryPos qPos = QueryPos.getInstance(q);
840    
841                                    if (bindUuid) {
842                                            qPos.add(uuid);
843                                    }
844    
845                                    qPos.add(groupId);
846    
847                                    count = (Long)q.uniqueResult();
848    
849                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
850                            }
851                            catch (Exception e) {
852                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
853    
854                                    throw processException(e);
855                            }
856                            finally {
857                                    closeSession(session);
858                            }
859                    }
860    
861                    return count.intValue();
862            }
863    
864            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiPage.uuid IS NULL AND ";
865            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiPage.uuid = ? AND ";
866            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = '') AND ";
867            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiPage.groupId = ?";
868            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
869                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
870                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
871                            new String[] {
872                                    String.class.getName(), Long.class.getName(),
873                                    
874                            Integer.class.getName(), Integer.class.getName(),
875                                    OrderByComparator.class.getName()
876                            });
877            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
878                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
879                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
880                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
881                            new String[] { String.class.getName(), Long.class.getName() },
882                            WikiPageModelImpl.UUID_COLUMN_BITMASK |
883                            WikiPageModelImpl.COMPANYID_COLUMN_BITMASK |
884                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
885                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
886                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
887            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
888                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
889                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
890                            new String[] { String.class.getName(), Long.class.getName() });
891    
892            /**
893             * Returns all the wiki pages where uuid = &#63; and companyId = &#63;.
894             *
895             * @param uuid the uuid
896             * @param companyId the company ID
897             * @return the matching wiki pages
898             * @throws SystemException if a system exception occurred
899             */
900            public List<WikiPage> findByUuid_C(String uuid, long companyId)
901                    throws SystemException {
902                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
903                            QueryUtil.ALL_POS, null);
904            }
905    
906            /**
907             * Returns a range of all the wiki pages where uuid = &#63; and companyId = &#63;.
908             *
909             * <p>
910             * 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.
911             * </p>
912             *
913             * @param uuid the uuid
914             * @param companyId the company ID
915             * @param start the lower bound of the range of wiki pages
916             * @param end the upper bound of the range of wiki pages (not inclusive)
917             * @return the range of matching wiki pages
918             * @throws SystemException if a system exception occurred
919             */
920            public List<WikiPage> findByUuid_C(String uuid, long companyId, int start,
921                    int end) throws SystemException {
922                    return findByUuid_C(uuid, companyId, start, end, null);
923            }
924    
925            /**
926             * Returns an ordered range of all the wiki pages where uuid = &#63; and companyId = &#63;.
927             *
928             * <p>
929             * 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.
930             * </p>
931             *
932             * @param uuid the uuid
933             * @param companyId the company ID
934             * @param start the lower bound of the range of wiki pages
935             * @param end the upper bound of the range of wiki pages (not inclusive)
936             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
937             * @return the ordered range of matching wiki pages
938             * @throws SystemException if a system exception occurred
939             */
940            public List<WikiPage> findByUuid_C(String uuid, long companyId, int start,
941                    int end, OrderByComparator orderByComparator) throws SystemException {
942                    boolean pagination = true;
943                    FinderPath finderPath = null;
944                    Object[] finderArgs = null;
945    
946                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
947                                    (orderByComparator == null)) {
948                            pagination = false;
949                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
950                            finderArgs = new Object[] { uuid, companyId };
951                    }
952                    else {
953                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
954                            finderArgs = new Object[] {
955                                            uuid, companyId,
956                                            
957                                            start, end, orderByComparator
958                                    };
959                    }
960    
961                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
962                                    finderArgs, this);
963    
964                    if ((list != null) && !list.isEmpty()) {
965                            for (WikiPage wikiPage : list) {
966                                    if (!Validator.equals(uuid, wikiPage.getUuid()) ||
967                                                    (companyId != wikiPage.getCompanyId())) {
968                                            list = null;
969    
970                                            break;
971                                    }
972                            }
973                    }
974    
975                    if (list == null) {
976                            StringBundler query = null;
977    
978                            if (orderByComparator != null) {
979                                    query = new StringBundler(4 +
980                                                    (orderByComparator.getOrderByFields().length * 3));
981                            }
982                            else {
983                                    query = new StringBundler(4);
984                            }
985    
986                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
987    
988                            boolean bindUuid = false;
989    
990                            if (uuid == null) {
991                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
992                            }
993                            else if (uuid.equals(StringPool.BLANK)) {
994                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
995                            }
996                            else {
997                                    bindUuid = true;
998    
999                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1000                            }
1001    
1002                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1003    
1004                            if (orderByComparator != null) {
1005                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1006                                            orderByComparator);
1007                            }
1008                            else
1009                             if (pagination) {
1010                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1011                            }
1012    
1013                            String sql = query.toString();
1014    
1015                            Session session = null;
1016    
1017                            try {
1018                                    session = openSession();
1019    
1020                                    Query q = session.createQuery(sql);
1021    
1022                                    QueryPos qPos = QueryPos.getInstance(q);
1023    
1024                                    if (bindUuid) {
1025                                            qPos.add(uuid);
1026                                    }
1027    
1028                                    qPos.add(companyId);
1029    
1030                                    if (!pagination) {
1031                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
1032                                                            start, end, false);
1033    
1034                                            Collections.sort(list);
1035    
1036                                            list = new UnmodifiableList<WikiPage>(list);
1037                                    }
1038                                    else {
1039                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
1040                                                            start, end);
1041                                    }
1042    
1043                                    cacheResult(list);
1044    
1045                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1046                            }
1047                            catch (Exception e) {
1048                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1049    
1050                                    throw processException(e);
1051                            }
1052                            finally {
1053                                    closeSession(session);
1054                            }
1055                    }
1056    
1057                    return list;
1058            }
1059    
1060            /**
1061             * Returns the first wiki page in the ordered set where uuid = &#63; and companyId = &#63;.
1062             *
1063             * @param uuid the uuid
1064             * @param companyId the company ID
1065             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1066             * @return the first matching wiki page
1067             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1068             * @throws SystemException if a system exception occurred
1069             */
1070            public WikiPage findByUuid_C_First(String uuid, long companyId,
1071                    OrderByComparator orderByComparator)
1072                    throws NoSuchPageException, SystemException {
1073                    WikiPage wikiPage = fetchByUuid_C_First(uuid, companyId,
1074                                    orderByComparator);
1075    
1076                    if (wikiPage != null) {
1077                            return wikiPage;
1078                    }
1079    
1080                    StringBundler msg = new StringBundler(6);
1081    
1082                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1083    
1084                    msg.append("uuid=");
1085                    msg.append(uuid);
1086    
1087                    msg.append(", companyId=");
1088                    msg.append(companyId);
1089    
1090                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1091    
1092                    throw new NoSuchPageException(msg.toString());
1093            }
1094    
1095            /**
1096             * Returns the first wiki page in the ordered set where uuid = &#63; and companyId = &#63;.
1097             *
1098             * @param uuid the uuid
1099             * @param companyId the company ID
1100             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1101             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
1102             * @throws SystemException if a system exception occurred
1103             */
1104            public WikiPage fetchByUuid_C_First(String uuid, long companyId,
1105                    OrderByComparator orderByComparator) throws SystemException {
1106                    List<WikiPage> list = findByUuid_C(uuid, companyId, 0, 1,
1107                                    orderByComparator);
1108    
1109                    if (!list.isEmpty()) {
1110                            return list.get(0);
1111                    }
1112    
1113                    return null;
1114            }
1115    
1116            /**
1117             * Returns the last wiki page in the ordered set where uuid = &#63; and companyId = &#63;.
1118             *
1119             * @param uuid the uuid
1120             * @param companyId the company ID
1121             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1122             * @return the last matching wiki page
1123             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1124             * @throws SystemException if a system exception occurred
1125             */
1126            public WikiPage findByUuid_C_Last(String uuid, long companyId,
1127                    OrderByComparator orderByComparator)
1128                    throws NoSuchPageException, SystemException {
1129                    WikiPage wikiPage = fetchByUuid_C_Last(uuid, companyId,
1130                                    orderByComparator);
1131    
1132                    if (wikiPage != null) {
1133                            return wikiPage;
1134                    }
1135    
1136                    StringBundler msg = new StringBundler(6);
1137    
1138                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1139    
1140                    msg.append("uuid=");
1141                    msg.append(uuid);
1142    
1143                    msg.append(", companyId=");
1144                    msg.append(companyId);
1145    
1146                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1147    
1148                    throw new NoSuchPageException(msg.toString());
1149            }
1150    
1151            /**
1152             * Returns the last wiki page in the ordered set where uuid = &#63; and companyId = &#63;.
1153             *
1154             * @param uuid the uuid
1155             * @param companyId the company ID
1156             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1157             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
1158             * @throws SystemException if a system exception occurred
1159             */
1160            public WikiPage fetchByUuid_C_Last(String uuid, long companyId,
1161                    OrderByComparator orderByComparator) throws SystemException {
1162                    int count = countByUuid_C(uuid, companyId);
1163    
1164                    List<WikiPage> list = findByUuid_C(uuid, companyId, count - 1, count,
1165                                    orderByComparator);
1166    
1167                    if (!list.isEmpty()) {
1168                            return list.get(0);
1169                    }
1170    
1171                    return null;
1172            }
1173    
1174            /**
1175             * Returns the wiki pages before and after the current wiki page in the ordered set where uuid = &#63; and companyId = &#63;.
1176             *
1177             * @param pageId the primary key of the current wiki page
1178             * @param uuid the uuid
1179             * @param companyId the company ID
1180             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1181             * @return the previous, current, and next wiki page
1182             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
1183             * @throws SystemException if a system exception occurred
1184             */
1185            public WikiPage[] findByUuid_C_PrevAndNext(long pageId, String uuid,
1186                    long companyId, OrderByComparator orderByComparator)
1187                    throws NoSuchPageException, SystemException {
1188                    WikiPage wikiPage = findByPrimaryKey(pageId);
1189    
1190                    Session session = null;
1191    
1192                    try {
1193                            session = openSession();
1194    
1195                            WikiPage[] array = new WikiPageImpl[3];
1196    
1197                            array[0] = getByUuid_C_PrevAndNext(session, wikiPage, uuid,
1198                                            companyId, orderByComparator, true);
1199    
1200                            array[1] = wikiPage;
1201    
1202                            array[2] = getByUuid_C_PrevAndNext(session, wikiPage, uuid,
1203                                            companyId, orderByComparator, false);
1204    
1205                            return array;
1206                    }
1207                    catch (Exception e) {
1208                            throw processException(e);
1209                    }
1210                    finally {
1211                            closeSession(session);
1212                    }
1213            }
1214    
1215            protected WikiPage getByUuid_C_PrevAndNext(Session session,
1216                    WikiPage wikiPage, String uuid, long companyId,
1217                    OrderByComparator orderByComparator, boolean previous) {
1218                    StringBundler query = null;
1219    
1220                    if (orderByComparator != null) {
1221                            query = new StringBundler(6 +
1222                                            (orderByComparator.getOrderByFields().length * 6));
1223                    }
1224                    else {
1225                            query = new StringBundler(3);
1226                    }
1227    
1228                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1229    
1230                    boolean bindUuid = false;
1231    
1232                    if (uuid == null) {
1233                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1234                    }
1235                    else if (uuid.equals(StringPool.BLANK)) {
1236                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1237                    }
1238                    else {
1239                            bindUuid = true;
1240    
1241                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1242                    }
1243    
1244                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1245    
1246                    if (orderByComparator != null) {
1247                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1248    
1249                            if (orderByConditionFields.length > 0) {
1250                                    query.append(WHERE_AND);
1251                            }
1252    
1253                            for (int i = 0; i < orderByConditionFields.length; i++) {
1254                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1255                                    query.append(orderByConditionFields[i]);
1256    
1257                                    if ((i + 1) < orderByConditionFields.length) {
1258                                            if (orderByComparator.isAscending() ^ previous) {
1259                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1260                                            }
1261                                            else {
1262                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1263                                            }
1264                                    }
1265                                    else {
1266                                            if (orderByComparator.isAscending() ^ previous) {
1267                                                    query.append(WHERE_GREATER_THAN);
1268                                            }
1269                                            else {
1270                                                    query.append(WHERE_LESSER_THAN);
1271                                            }
1272                                    }
1273                            }
1274    
1275                            query.append(ORDER_BY_CLAUSE);
1276    
1277                            String[] orderByFields = orderByComparator.getOrderByFields();
1278    
1279                            for (int i = 0; i < orderByFields.length; i++) {
1280                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1281                                    query.append(orderByFields[i]);
1282    
1283                                    if ((i + 1) < orderByFields.length) {
1284                                            if (orderByComparator.isAscending() ^ previous) {
1285                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1286                                            }
1287                                            else {
1288                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1289                                            }
1290                                    }
1291                                    else {
1292                                            if (orderByComparator.isAscending() ^ previous) {
1293                                                    query.append(ORDER_BY_ASC);
1294                                            }
1295                                            else {
1296                                                    query.append(ORDER_BY_DESC);
1297                                            }
1298                                    }
1299                            }
1300                    }
1301                    else {
1302                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1303                    }
1304    
1305                    String sql = query.toString();
1306    
1307                    Query q = session.createQuery(sql);
1308    
1309                    q.setFirstResult(0);
1310                    q.setMaxResults(2);
1311    
1312                    QueryPos qPos = QueryPos.getInstance(q);
1313    
1314                    if (bindUuid) {
1315                            qPos.add(uuid);
1316                    }
1317    
1318                    qPos.add(companyId);
1319    
1320                    if (orderByComparator != null) {
1321                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
1322    
1323                            for (Object value : values) {
1324                                    qPos.add(value);
1325                            }
1326                    }
1327    
1328                    List<WikiPage> list = q.list();
1329    
1330                    if (list.size() == 2) {
1331                            return list.get(1);
1332                    }
1333                    else {
1334                            return null;
1335                    }
1336            }
1337    
1338            /**
1339             * Removes all the wiki pages where uuid = &#63; and companyId = &#63; from the database.
1340             *
1341             * @param uuid the uuid
1342             * @param companyId the company ID
1343             * @throws SystemException if a system exception occurred
1344             */
1345            public void removeByUuid_C(String uuid, long companyId)
1346                    throws SystemException {
1347                    for (WikiPage wikiPage : findByUuid_C(uuid, companyId,
1348                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1349                            remove(wikiPage);
1350                    }
1351            }
1352    
1353            /**
1354             * Returns the number of wiki pages where uuid = &#63; and companyId = &#63;.
1355             *
1356             * @param uuid the uuid
1357             * @param companyId the company ID
1358             * @return the number of matching wiki pages
1359             * @throws SystemException if a system exception occurred
1360             */
1361            public int countByUuid_C(String uuid, long companyId)
1362                    throws SystemException {
1363                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1364    
1365                    Object[] finderArgs = new Object[] { uuid, companyId };
1366    
1367                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1368                                    this);
1369    
1370                    if (count == null) {
1371                            StringBundler query = new StringBundler(3);
1372    
1373                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
1374    
1375                            boolean bindUuid = false;
1376    
1377                            if (uuid == null) {
1378                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1379                            }
1380                            else if (uuid.equals(StringPool.BLANK)) {
1381                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1382                            }
1383                            else {
1384                                    bindUuid = true;
1385    
1386                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1387                            }
1388    
1389                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1390    
1391                            String sql = query.toString();
1392    
1393                            Session session = null;
1394    
1395                            try {
1396                                    session = openSession();
1397    
1398                                    Query q = session.createQuery(sql);
1399    
1400                                    QueryPos qPos = QueryPos.getInstance(q);
1401    
1402                                    if (bindUuid) {
1403                                            qPos.add(uuid);
1404                                    }
1405    
1406                                    qPos.add(companyId);
1407    
1408                                    count = (Long)q.uniqueResult();
1409    
1410                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1411                            }
1412                            catch (Exception e) {
1413                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1414    
1415                                    throw processException(e);
1416                            }
1417                            finally {
1418                                    closeSession(session);
1419                            }
1420                    }
1421    
1422                    return count.intValue();
1423            }
1424    
1425            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "wikiPage.uuid IS NULL AND ";
1426            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "wikiPage.uuid = ? AND ";
1427            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = '') AND ";
1428            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "wikiPage.companyId = ?";
1429            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1430                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
1431                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByNodeId",
1432                            new String[] {
1433                                    Long.class.getName(),
1434                                    
1435                            Integer.class.getName(), Integer.class.getName(),
1436                                    OrderByComparator.class.getName()
1437                            });
1438            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID =
1439                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1440                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
1441                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByNodeId",
1442                            new String[] { Long.class.getName() },
1443                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
1444                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
1445                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
1446            public static final FinderPath FINDER_PATH_COUNT_BY_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1447                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
1448                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByNodeId",
1449                            new String[] { Long.class.getName() });
1450    
1451            /**
1452             * Returns all the wiki pages where nodeId = &#63;.
1453             *
1454             * @param nodeId the node ID
1455             * @return the matching wiki pages
1456             * @throws SystemException if a system exception occurred
1457             */
1458            public List<WikiPage> findByNodeId(long nodeId) throws SystemException {
1459                    return findByNodeId(nodeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1460            }
1461    
1462            /**
1463             * Returns a range of all the wiki pages where nodeId = &#63;.
1464             *
1465             * <p>
1466             * 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.
1467             * </p>
1468             *
1469             * @param nodeId the node ID
1470             * @param start the lower bound of the range of wiki pages
1471             * @param end the upper bound of the range of wiki pages (not inclusive)
1472             * @return the range of matching wiki pages
1473             * @throws SystemException if a system exception occurred
1474             */
1475            public List<WikiPage> findByNodeId(long nodeId, int start, int end)
1476                    throws SystemException {
1477                    return findByNodeId(nodeId, start, end, null);
1478            }
1479    
1480            /**
1481             * Returns an ordered range of all the wiki pages where nodeId = &#63;.
1482             *
1483             * <p>
1484             * 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.
1485             * </p>
1486             *
1487             * @param nodeId the node ID
1488             * @param start the lower bound of the range of wiki pages
1489             * @param end the upper bound of the range of wiki pages (not inclusive)
1490             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1491             * @return the ordered range of matching wiki pages
1492             * @throws SystemException if a system exception occurred
1493             */
1494            public List<WikiPage> findByNodeId(long nodeId, int start, int end,
1495                    OrderByComparator orderByComparator) throws SystemException {
1496                    boolean pagination = true;
1497                    FinderPath finderPath = null;
1498                    Object[] finderArgs = null;
1499    
1500                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1501                                    (orderByComparator == null)) {
1502                            pagination = false;
1503                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID;
1504                            finderArgs = new Object[] { nodeId };
1505                    }
1506                    else {
1507                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NODEID;
1508                            finderArgs = new Object[] { nodeId, start, end, orderByComparator };
1509                    }
1510    
1511                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
1512                                    finderArgs, this);
1513    
1514                    if ((list != null) && !list.isEmpty()) {
1515                            for (WikiPage wikiPage : list) {
1516                                    if ((nodeId != wikiPage.getNodeId())) {
1517                                            list = null;
1518    
1519                                            break;
1520                                    }
1521                            }
1522                    }
1523    
1524                    if (list == null) {
1525                            StringBundler query = null;
1526    
1527                            if (orderByComparator != null) {
1528                                    query = new StringBundler(3 +
1529                                                    (orderByComparator.getOrderByFields().length * 3));
1530                            }
1531                            else {
1532                                    query = new StringBundler(3);
1533                            }
1534    
1535                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1536    
1537                            query.append(_FINDER_COLUMN_NODEID_NODEID_2);
1538    
1539                            if (orderByComparator != null) {
1540                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1541                                            orderByComparator);
1542                            }
1543                            else
1544                             if (pagination) {
1545                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1546                            }
1547    
1548                            String sql = query.toString();
1549    
1550                            Session session = null;
1551    
1552                            try {
1553                                    session = openSession();
1554    
1555                                    Query q = session.createQuery(sql);
1556    
1557                                    QueryPos qPos = QueryPos.getInstance(q);
1558    
1559                                    qPos.add(nodeId);
1560    
1561                                    if (!pagination) {
1562                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
1563                                                            start, end, false);
1564    
1565                                            Collections.sort(list);
1566    
1567                                            list = new UnmodifiableList<WikiPage>(list);
1568                                    }
1569                                    else {
1570                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
1571                                                            start, end);
1572                                    }
1573    
1574                                    cacheResult(list);
1575    
1576                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1577                            }
1578                            catch (Exception e) {
1579                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1580    
1581                                    throw processException(e);
1582                            }
1583                            finally {
1584                                    closeSession(session);
1585                            }
1586                    }
1587    
1588                    return list;
1589            }
1590    
1591            /**
1592             * Returns the first wiki page in the ordered set where nodeId = &#63;.
1593             *
1594             * @param nodeId the node ID
1595             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1596             * @return the first matching wiki page
1597             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1598             * @throws SystemException if a system exception occurred
1599             */
1600            public WikiPage findByNodeId_First(long nodeId,
1601                    OrderByComparator orderByComparator)
1602                    throws NoSuchPageException, SystemException {
1603                    WikiPage wikiPage = fetchByNodeId_First(nodeId, orderByComparator);
1604    
1605                    if (wikiPage != null) {
1606                            return wikiPage;
1607                    }
1608    
1609                    StringBundler msg = new StringBundler(4);
1610    
1611                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1612    
1613                    msg.append("nodeId=");
1614                    msg.append(nodeId);
1615    
1616                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1617    
1618                    throw new NoSuchPageException(msg.toString());
1619            }
1620    
1621            /**
1622             * Returns the first wiki page in the ordered set where nodeId = &#63;.
1623             *
1624             * @param nodeId the node ID
1625             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1626             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
1627             * @throws SystemException if a system exception occurred
1628             */
1629            public WikiPage fetchByNodeId_First(long nodeId,
1630                    OrderByComparator orderByComparator) throws SystemException {
1631                    List<WikiPage> list = findByNodeId(nodeId, 0, 1, orderByComparator);
1632    
1633                    if (!list.isEmpty()) {
1634                            return list.get(0);
1635                    }
1636    
1637                    return null;
1638            }
1639    
1640            /**
1641             * Returns the last wiki page in the ordered set where nodeId = &#63;.
1642             *
1643             * @param nodeId the node ID
1644             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1645             * @return the last matching wiki page
1646             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1647             * @throws SystemException if a system exception occurred
1648             */
1649            public WikiPage findByNodeId_Last(long nodeId,
1650                    OrderByComparator orderByComparator)
1651                    throws NoSuchPageException, SystemException {
1652                    WikiPage wikiPage = fetchByNodeId_Last(nodeId, orderByComparator);
1653    
1654                    if (wikiPage != null) {
1655                            return wikiPage;
1656                    }
1657    
1658                    StringBundler msg = new StringBundler(4);
1659    
1660                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1661    
1662                    msg.append("nodeId=");
1663                    msg.append(nodeId);
1664    
1665                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1666    
1667                    throw new NoSuchPageException(msg.toString());
1668            }
1669    
1670            /**
1671             * Returns the last wiki page in the ordered set where nodeId = &#63;.
1672             *
1673             * @param nodeId the node ID
1674             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1675             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
1676             * @throws SystemException if a system exception occurred
1677             */
1678            public WikiPage fetchByNodeId_Last(long nodeId,
1679                    OrderByComparator orderByComparator) throws SystemException {
1680                    int count = countByNodeId(nodeId);
1681    
1682                    List<WikiPage> list = findByNodeId(nodeId, count - 1, count,
1683                                    orderByComparator);
1684    
1685                    if (!list.isEmpty()) {
1686                            return list.get(0);
1687                    }
1688    
1689                    return null;
1690            }
1691    
1692            /**
1693             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63;.
1694             *
1695             * @param pageId the primary key of the current wiki page
1696             * @param nodeId the node ID
1697             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1698             * @return the previous, current, and next wiki page
1699             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
1700             * @throws SystemException if a system exception occurred
1701             */
1702            public WikiPage[] findByNodeId_PrevAndNext(long pageId, long nodeId,
1703                    OrderByComparator orderByComparator)
1704                    throws NoSuchPageException, SystemException {
1705                    WikiPage wikiPage = findByPrimaryKey(pageId);
1706    
1707                    Session session = null;
1708    
1709                    try {
1710                            session = openSession();
1711    
1712                            WikiPage[] array = new WikiPageImpl[3];
1713    
1714                            array[0] = getByNodeId_PrevAndNext(session, wikiPage, nodeId,
1715                                            orderByComparator, true);
1716    
1717                            array[1] = wikiPage;
1718    
1719                            array[2] = getByNodeId_PrevAndNext(session, wikiPage, nodeId,
1720                                            orderByComparator, false);
1721    
1722                            return array;
1723                    }
1724                    catch (Exception e) {
1725                            throw processException(e);
1726                    }
1727                    finally {
1728                            closeSession(session);
1729                    }
1730            }
1731    
1732            protected WikiPage getByNodeId_PrevAndNext(Session session,
1733                    WikiPage wikiPage, long nodeId, OrderByComparator orderByComparator,
1734                    boolean previous) {
1735                    StringBundler query = null;
1736    
1737                    if (orderByComparator != null) {
1738                            query = new StringBundler(6 +
1739                                            (orderByComparator.getOrderByFields().length * 6));
1740                    }
1741                    else {
1742                            query = new StringBundler(3);
1743                    }
1744    
1745                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1746    
1747                    query.append(_FINDER_COLUMN_NODEID_NODEID_2);
1748    
1749                    if (orderByComparator != null) {
1750                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1751    
1752                            if (orderByConditionFields.length > 0) {
1753                                    query.append(WHERE_AND);
1754                            }
1755    
1756                            for (int i = 0; i < orderByConditionFields.length; i++) {
1757                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1758                                    query.append(orderByConditionFields[i]);
1759    
1760                                    if ((i + 1) < orderByConditionFields.length) {
1761                                            if (orderByComparator.isAscending() ^ previous) {
1762                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1763                                            }
1764                                            else {
1765                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1766                                            }
1767                                    }
1768                                    else {
1769                                            if (orderByComparator.isAscending() ^ previous) {
1770                                                    query.append(WHERE_GREATER_THAN);
1771                                            }
1772                                            else {
1773                                                    query.append(WHERE_LESSER_THAN);
1774                                            }
1775                                    }
1776                            }
1777    
1778                            query.append(ORDER_BY_CLAUSE);
1779    
1780                            String[] orderByFields = orderByComparator.getOrderByFields();
1781    
1782                            for (int i = 0; i < orderByFields.length; i++) {
1783                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1784                                    query.append(orderByFields[i]);
1785    
1786                                    if ((i + 1) < orderByFields.length) {
1787                                            if (orderByComparator.isAscending() ^ previous) {
1788                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1789                                            }
1790                                            else {
1791                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1792                                            }
1793                                    }
1794                                    else {
1795                                            if (orderByComparator.isAscending() ^ previous) {
1796                                                    query.append(ORDER_BY_ASC);
1797                                            }
1798                                            else {
1799                                                    query.append(ORDER_BY_DESC);
1800                                            }
1801                                    }
1802                            }
1803                    }
1804                    else {
1805                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1806                    }
1807    
1808                    String sql = query.toString();
1809    
1810                    Query q = session.createQuery(sql);
1811    
1812                    q.setFirstResult(0);
1813                    q.setMaxResults(2);
1814    
1815                    QueryPos qPos = QueryPos.getInstance(q);
1816    
1817                    qPos.add(nodeId);
1818    
1819                    if (orderByComparator != null) {
1820                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
1821    
1822                            for (Object value : values) {
1823                                    qPos.add(value);
1824                            }
1825                    }
1826    
1827                    List<WikiPage> list = q.list();
1828    
1829                    if (list.size() == 2) {
1830                            return list.get(1);
1831                    }
1832                    else {
1833                            return null;
1834                    }
1835            }
1836    
1837            /**
1838             * Removes all the wiki pages where nodeId = &#63; from the database.
1839             *
1840             * @param nodeId the node ID
1841             * @throws SystemException if a system exception occurred
1842             */
1843            public void removeByNodeId(long nodeId) throws SystemException {
1844                    for (WikiPage wikiPage : findByNodeId(nodeId, QueryUtil.ALL_POS,
1845                                    QueryUtil.ALL_POS, null)) {
1846                            remove(wikiPage);
1847                    }
1848            }
1849    
1850            /**
1851             * Returns the number of wiki pages where nodeId = &#63;.
1852             *
1853             * @param nodeId the node ID
1854             * @return the number of matching wiki pages
1855             * @throws SystemException if a system exception occurred
1856             */
1857            public int countByNodeId(long nodeId) throws SystemException {
1858                    FinderPath finderPath = FINDER_PATH_COUNT_BY_NODEID;
1859    
1860                    Object[] finderArgs = new Object[] { nodeId };
1861    
1862                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1863                                    this);
1864    
1865                    if (count == null) {
1866                            StringBundler query = new StringBundler(2);
1867    
1868                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
1869    
1870                            query.append(_FINDER_COLUMN_NODEID_NODEID_2);
1871    
1872                            String sql = query.toString();
1873    
1874                            Session session = null;
1875    
1876                            try {
1877                                    session = openSession();
1878    
1879                                    Query q = session.createQuery(sql);
1880    
1881                                    QueryPos qPos = QueryPos.getInstance(q);
1882    
1883                                    qPos.add(nodeId);
1884    
1885                                    count = (Long)q.uniqueResult();
1886    
1887                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1888                            }
1889                            catch (Exception e) {
1890                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1891    
1892                                    throw processException(e);
1893                            }
1894                            finally {
1895                                    closeSession(session);
1896                            }
1897                    }
1898    
1899                    return count.intValue();
1900            }
1901    
1902            private static final String _FINDER_COLUMN_NODEID_NODEID_2 = "wikiPage.nodeId = ?";
1903            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1904                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
1905                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFormat",
1906                            new String[] {
1907                                    String.class.getName(),
1908                                    
1909                            Integer.class.getName(), Integer.class.getName(),
1910                                    OrderByComparator.class.getName()
1911                            });
1912            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT =
1913                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1914                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
1915                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFormat",
1916                            new String[] { String.class.getName() },
1917                            WikiPageModelImpl.FORMAT_COLUMN_BITMASK |
1918                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
1919                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
1920                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
1921            public static final FinderPath FINDER_PATH_COUNT_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1922                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
1923                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFormat",
1924                            new String[] { String.class.getName() });
1925    
1926            /**
1927             * Returns all the wiki pages where format = &#63;.
1928             *
1929             * @param format the format
1930             * @return the matching wiki pages
1931             * @throws SystemException if a system exception occurred
1932             */
1933            public List<WikiPage> findByFormat(String format) throws SystemException {
1934                    return findByFormat(format, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1935            }
1936    
1937            /**
1938             * Returns a range of all the wiki pages where format = &#63;.
1939             *
1940             * <p>
1941             * 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.
1942             * </p>
1943             *
1944             * @param format the format
1945             * @param start the lower bound of the range of wiki pages
1946             * @param end the upper bound of the range of wiki pages (not inclusive)
1947             * @return the range of matching wiki pages
1948             * @throws SystemException if a system exception occurred
1949             */
1950            public List<WikiPage> findByFormat(String format, int start, int end)
1951                    throws SystemException {
1952                    return findByFormat(format, start, end, null);
1953            }
1954    
1955            /**
1956             * Returns an ordered range of all the wiki pages where format = &#63;.
1957             *
1958             * <p>
1959             * 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.
1960             * </p>
1961             *
1962             * @param format the format
1963             * @param start the lower bound of the range of wiki pages
1964             * @param end the upper bound of the range of wiki pages (not inclusive)
1965             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1966             * @return the ordered range of matching wiki pages
1967             * @throws SystemException if a system exception occurred
1968             */
1969            public List<WikiPage> findByFormat(String format, int start, int end,
1970                    OrderByComparator orderByComparator) throws SystemException {
1971                    boolean pagination = true;
1972                    FinderPath finderPath = null;
1973                    Object[] finderArgs = null;
1974    
1975                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1976                                    (orderByComparator == null)) {
1977                            pagination = false;
1978                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT;
1979                            finderArgs = new Object[] { format };
1980                    }
1981                    else {
1982                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FORMAT;
1983                            finderArgs = new Object[] { format, start, end, orderByComparator };
1984                    }
1985    
1986                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
1987                                    finderArgs, this);
1988    
1989                    if ((list != null) && !list.isEmpty()) {
1990                            for (WikiPage wikiPage : list) {
1991                                    if (!Validator.equals(format, wikiPage.getFormat())) {
1992                                            list = null;
1993    
1994                                            break;
1995                                    }
1996                            }
1997                    }
1998    
1999                    if (list == null) {
2000                            StringBundler query = null;
2001    
2002                            if (orderByComparator != null) {
2003                                    query = new StringBundler(3 +
2004                                                    (orderByComparator.getOrderByFields().length * 3));
2005                            }
2006                            else {
2007                                    query = new StringBundler(3);
2008                            }
2009    
2010                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2011    
2012                            boolean bindFormat = false;
2013    
2014                            if (format == null) {
2015                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
2016                            }
2017                            else if (format.equals(StringPool.BLANK)) {
2018                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
2019                            }
2020                            else {
2021                                    bindFormat = true;
2022    
2023                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
2024                            }
2025    
2026                            if (orderByComparator != null) {
2027                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2028                                            orderByComparator);
2029                            }
2030                            else
2031                             if (pagination) {
2032                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2033                            }
2034    
2035                            String sql = query.toString();
2036    
2037                            Session session = null;
2038    
2039                            try {
2040                                    session = openSession();
2041    
2042                                    Query q = session.createQuery(sql);
2043    
2044                                    QueryPos qPos = QueryPos.getInstance(q);
2045    
2046                                    if (bindFormat) {
2047                                            qPos.add(format);
2048                                    }
2049    
2050                                    if (!pagination) {
2051                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
2052                                                            start, end, false);
2053    
2054                                            Collections.sort(list);
2055    
2056                                            list = new UnmodifiableList<WikiPage>(list);
2057                                    }
2058                                    else {
2059                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
2060                                                            start, end);
2061                                    }
2062    
2063                                    cacheResult(list);
2064    
2065                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2066                            }
2067                            catch (Exception e) {
2068                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2069    
2070                                    throw processException(e);
2071                            }
2072                            finally {
2073                                    closeSession(session);
2074                            }
2075                    }
2076    
2077                    return list;
2078            }
2079    
2080            /**
2081             * Returns the first wiki page in the ordered set where format = &#63;.
2082             *
2083             * @param format the format
2084             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2085             * @return the first matching wiki page
2086             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2087             * @throws SystemException if a system exception occurred
2088             */
2089            public WikiPage findByFormat_First(String format,
2090                    OrderByComparator orderByComparator)
2091                    throws NoSuchPageException, SystemException {
2092                    WikiPage wikiPage = fetchByFormat_First(format, orderByComparator);
2093    
2094                    if (wikiPage != null) {
2095                            return wikiPage;
2096                    }
2097    
2098                    StringBundler msg = new StringBundler(4);
2099    
2100                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2101    
2102                    msg.append("format=");
2103                    msg.append(format);
2104    
2105                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2106    
2107                    throw new NoSuchPageException(msg.toString());
2108            }
2109    
2110            /**
2111             * Returns the first wiki page in the ordered set where format = &#63;.
2112             *
2113             * @param format the format
2114             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2115             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
2116             * @throws SystemException if a system exception occurred
2117             */
2118            public WikiPage fetchByFormat_First(String format,
2119                    OrderByComparator orderByComparator) throws SystemException {
2120                    List<WikiPage> list = findByFormat(format, 0, 1, orderByComparator);
2121    
2122                    if (!list.isEmpty()) {
2123                            return list.get(0);
2124                    }
2125    
2126                    return null;
2127            }
2128    
2129            /**
2130             * Returns the last wiki page in the ordered set where format = &#63;.
2131             *
2132             * @param format the format
2133             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2134             * @return the last matching wiki page
2135             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2136             * @throws SystemException if a system exception occurred
2137             */
2138            public WikiPage findByFormat_Last(String format,
2139                    OrderByComparator orderByComparator)
2140                    throws NoSuchPageException, SystemException {
2141                    WikiPage wikiPage = fetchByFormat_Last(format, orderByComparator);
2142    
2143                    if (wikiPage != null) {
2144                            return wikiPage;
2145                    }
2146    
2147                    StringBundler msg = new StringBundler(4);
2148    
2149                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2150    
2151                    msg.append("format=");
2152                    msg.append(format);
2153    
2154                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2155    
2156                    throw new NoSuchPageException(msg.toString());
2157            }
2158    
2159            /**
2160             * Returns the last wiki page in the ordered set where format = &#63;.
2161             *
2162             * @param format the format
2163             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2164             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
2165             * @throws SystemException if a system exception occurred
2166             */
2167            public WikiPage fetchByFormat_Last(String format,
2168                    OrderByComparator orderByComparator) throws SystemException {
2169                    int count = countByFormat(format);
2170    
2171                    List<WikiPage> list = findByFormat(format, count - 1, count,
2172                                    orderByComparator);
2173    
2174                    if (!list.isEmpty()) {
2175                            return list.get(0);
2176                    }
2177    
2178                    return null;
2179            }
2180    
2181            /**
2182             * Returns the wiki pages before and after the current wiki page in the ordered set where format = &#63;.
2183             *
2184             * @param pageId the primary key of the current wiki page
2185             * @param format the format
2186             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2187             * @return the previous, current, and next wiki page
2188             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
2189             * @throws SystemException if a system exception occurred
2190             */
2191            public WikiPage[] findByFormat_PrevAndNext(long pageId, String format,
2192                    OrderByComparator orderByComparator)
2193                    throws NoSuchPageException, SystemException {
2194                    WikiPage wikiPage = findByPrimaryKey(pageId);
2195    
2196                    Session session = null;
2197    
2198                    try {
2199                            session = openSession();
2200    
2201                            WikiPage[] array = new WikiPageImpl[3];
2202    
2203                            array[0] = getByFormat_PrevAndNext(session, wikiPage, format,
2204                                            orderByComparator, true);
2205    
2206                            array[1] = wikiPage;
2207    
2208                            array[2] = getByFormat_PrevAndNext(session, wikiPage, format,
2209                                            orderByComparator, false);
2210    
2211                            return array;
2212                    }
2213                    catch (Exception e) {
2214                            throw processException(e);
2215                    }
2216                    finally {
2217                            closeSession(session);
2218                    }
2219            }
2220    
2221            protected WikiPage getByFormat_PrevAndNext(Session session,
2222                    WikiPage wikiPage, String format, OrderByComparator orderByComparator,
2223                    boolean previous) {
2224                    StringBundler query = null;
2225    
2226                    if (orderByComparator != null) {
2227                            query = new StringBundler(6 +
2228                                            (orderByComparator.getOrderByFields().length * 6));
2229                    }
2230                    else {
2231                            query = new StringBundler(3);
2232                    }
2233    
2234                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2235    
2236                    boolean bindFormat = false;
2237    
2238                    if (format == null) {
2239                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
2240                    }
2241                    else if (format.equals(StringPool.BLANK)) {
2242                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
2243                    }
2244                    else {
2245                            bindFormat = true;
2246    
2247                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
2248                    }
2249    
2250                    if (orderByComparator != null) {
2251                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2252    
2253                            if (orderByConditionFields.length > 0) {
2254                                    query.append(WHERE_AND);
2255                            }
2256    
2257                            for (int i = 0; i < orderByConditionFields.length; i++) {
2258                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2259                                    query.append(orderByConditionFields[i]);
2260    
2261                                    if ((i + 1) < orderByConditionFields.length) {
2262                                            if (orderByComparator.isAscending() ^ previous) {
2263                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2264                                            }
2265                                            else {
2266                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2267                                            }
2268                                    }
2269                                    else {
2270                                            if (orderByComparator.isAscending() ^ previous) {
2271                                                    query.append(WHERE_GREATER_THAN);
2272                                            }
2273                                            else {
2274                                                    query.append(WHERE_LESSER_THAN);
2275                                            }
2276                                    }
2277                            }
2278    
2279                            query.append(ORDER_BY_CLAUSE);
2280    
2281                            String[] orderByFields = orderByComparator.getOrderByFields();
2282    
2283                            for (int i = 0; i < orderByFields.length; i++) {
2284                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2285                                    query.append(orderByFields[i]);
2286    
2287                                    if ((i + 1) < orderByFields.length) {
2288                                            if (orderByComparator.isAscending() ^ previous) {
2289                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2290                                            }
2291                                            else {
2292                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2293                                            }
2294                                    }
2295                                    else {
2296                                            if (orderByComparator.isAscending() ^ previous) {
2297                                                    query.append(ORDER_BY_ASC);
2298                                            }
2299                                            else {
2300                                                    query.append(ORDER_BY_DESC);
2301                                            }
2302                                    }
2303                            }
2304                    }
2305                    else {
2306                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2307                    }
2308    
2309                    String sql = query.toString();
2310    
2311                    Query q = session.createQuery(sql);
2312    
2313                    q.setFirstResult(0);
2314                    q.setMaxResults(2);
2315    
2316                    QueryPos qPos = QueryPos.getInstance(q);
2317    
2318                    if (bindFormat) {
2319                            qPos.add(format);
2320                    }
2321    
2322                    if (orderByComparator != null) {
2323                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
2324    
2325                            for (Object value : values) {
2326                                    qPos.add(value);
2327                            }
2328                    }
2329    
2330                    List<WikiPage> list = q.list();
2331    
2332                    if (list.size() == 2) {
2333                            return list.get(1);
2334                    }
2335                    else {
2336                            return null;
2337                    }
2338            }
2339    
2340            /**
2341             * Removes all the wiki pages where format = &#63; from the database.
2342             *
2343             * @param format the format
2344             * @throws SystemException if a system exception occurred
2345             */
2346            public void removeByFormat(String format) throws SystemException {
2347                    for (WikiPage wikiPage : findByFormat(format, QueryUtil.ALL_POS,
2348                                    QueryUtil.ALL_POS, null)) {
2349                            remove(wikiPage);
2350                    }
2351            }
2352    
2353            /**
2354             * Returns the number of wiki pages where format = &#63;.
2355             *
2356             * @param format the format
2357             * @return the number of matching wiki pages
2358             * @throws SystemException if a system exception occurred
2359             */
2360            public int countByFormat(String format) throws SystemException {
2361                    FinderPath finderPath = FINDER_PATH_COUNT_BY_FORMAT;
2362    
2363                    Object[] finderArgs = new Object[] { format };
2364    
2365                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2366                                    this);
2367    
2368                    if (count == null) {
2369                            StringBundler query = new StringBundler(2);
2370    
2371                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
2372    
2373                            boolean bindFormat = false;
2374    
2375                            if (format == null) {
2376                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
2377                            }
2378                            else if (format.equals(StringPool.BLANK)) {
2379                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
2380                            }
2381                            else {
2382                                    bindFormat = true;
2383    
2384                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
2385                            }
2386    
2387                            String sql = query.toString();
2388    
2389                            Session session = null;
2390    
2391                            try {
2392                                    session = openSession();
2393    
2394                                    Query q = session.createQuery(sql);
2395    
2396                                    QueryPos qPos = QueryPos.getInstance(q);
2397    
2398                                    if (bindFormat) {
2399                                            qPos.add(format);
2400                                    }
2401    
2402                                    count = (Long)q.uniqueResult();
2403    
2404                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2405                            }
2406                            catch (Exception e) {
2407                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2408    
2409                                    throw processException(e);
2410                            }
2411                            finally {
2412                                    closeSession(session);
2413                            }
2414                    }
2415    
2416                    return count.intValue();
2417            }
2418    
2419            private static final String _FINDER_COLUMN_FORMAT_FORMAT_1 = "wikiPage.format IS NULL";
2420            private static final String _FINDER_COLUMN_FORMAT_FORMAT_2 = "wikiPage.format = ?";
2421            private static final String _FINDER_COLUMN_FORMAT_FORMAT_3 = "(wikiPage.format IS NULL OR wikiPage.format = '')";
2422            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2423                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
2424                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_N",
2425                            new String[] {
2426                                    Long.class.getName(), Long.class.getName(),
2427                                    
2428                            Integer.class.getName(), Integer.class.getName(),
2429                                    OrderByComparator.class.getName()
2430                            });
2431            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2432                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
2433                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_N",
2434                            new String[] { Long.class.getName(), Long.class.getName() },
2435                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
2436                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
2437                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
2438                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
2439            public static final FinderPath FINDER_PATH_COUNT_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2440                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
2441                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N",
2442                            new String[] { Long.class.getName(), Long.class.getName() });
2443    
2444            /**
2445             * Returns all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
2446             *
2447             * @param resourcePrimKey the resource prim key
2448             * @param nodeId the node ID
2449             * @return the matching wiki pages
2450             * @throws SystemException if a system exception occurred
2451             */
2452            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId)
2453                    throws SystemException {
2454                    return findByR_N(resourcePrimKey, nodeId, QueryUtil.ALL_POS,
2455                            QueryUtil.ALL_POS, null);
2456            }
2457    
2458            /**
2459             * Returns a range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
2460             *
2461             * <p>
2462             * 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.
2463             * </p>
2464             *
2465             * @param resourcePrimKey the resource prim key
2466             * @param nodeId the node ID
2467             * @param start the lower bound of the range of wiki pages
2468             * @param end the upper bound of the range of wiki pages (not inclusive)
2469             * @return the range of matching wiki pages
2470             * @throws SystemException if a system exception occurred
2471             */
2472            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId,
2473                    int start, int end) throws SystemException {
2474                    return findByR_N(resourcePrimKey, nodeId, start, end, null);
2475            }
2476    
2477            /**
2478             * Returns an ordered range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
2479             *
2480             * <p>
2481             * 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.
2482             * </p>
2483             *
2484             * @param resourcePrimKey the resource prim key
2485             * @param nodeId the node ID
2486             * @param start the lower bound of the range of wiki pages
2487             * @param end the upper bound of the range of wiki pages (not inclusive)
2488             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2489             * @return the ordered range of matching wiki pages
2490             * @throws SystemException if a system exception occurred
2491             */
2492            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId,
2493                    int start, int end, OrderByComparator orderByComparator)
2494                    throws SystemException {
2495                    boolean pagination = true;
2496                    FinderPath finderPath = null;
2497                    Object[] finderArgs = null;
2498    
2499                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2500                                    (orderByComparator == null)) {
2501                            pagination = false;
2502                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N;
2503                            finderArgs = new Object[] { resourcePrimKey, nodeId };
2504                    }
2505                    else {
2506                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N;
2507                            finderArgs = new Object[] {
2508                                            resourcePrimKey, nodeId,
2509                                            
2510                                            start, end, orderByComparator
2511                                    };
2512                    }
2513    
2514                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
2515                                    finderArgs, this);
2516    
2517                    if ((list != null) && !list.isEmpty()) {
2518                            for (WikiPage wikiPage : list) {
2519                                    if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
2520                                                    (nodeId != wikiPage.getNodeId())) {
2521                                            list = null;
2522    
2523                                            break;
2524                                    }
2525                            }
2526                    }
2527    
2528                    if (list == null) {
2529                            StringBundler query = null;
2530    
2531                            if (orderByComparator != null) {
2532                                    query = new StringBundler(4 +
2533                                                    (orderByComparator.getOrderByFields().length * 3));
2534                            }
2535                            else {
2536                                    query = new StringBundler(4);
2537                            }
2538    
2539                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2540    
2541                            query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
2542    
2543                            query.append(_FINDER_COLUMN_R_N_NODEID_2);
2544    
2545                            if (orderByComparator != null) {
2546                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2547                                            orderByComparator);
2548                            }
2549                            else
2550                             if (pagination) {
2551                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2552                            }
2553    
2554                            String sql = query.toString();
2555    
2556                            Session session = null;
2557    
2558                            try {
2559                                    session = openSession();
2560    
2561                                    Query q = session.createQuery(sql);
2562    
2563                                    QueryPos qPos = QueryPos.getInstance(q);
2564    
2565                                    qPos.add(resourcePrimKey);
2566    
2567                                    qPos.add(nodeId);
2568    
2569                                    if (!pagination) {
2570                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
2571                                                            start, end, false);
2572    
2573                                            Collections.sort(list);
2574    
2575                                            list = new UnmodifiableList<WikiPage>(list);
2576                                    }
2577                                    else {
2578                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
2579                                                            start, end);
2580                                    }
2581    
2582                                    cacheResult(list);
2583    
2584                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2585                            }
2586                            catch (Exception e) {
2587                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2588    
2589                                    throw processException(e);
2590                            }
2591                            finally {
2592                                    closeSession(session);
2593                            }
2594                    }
2595    
2596                    return list;
2597            }
2598    
2599            /**
2600             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
2601             *
2602             * @param resourcePrimKey the resource prim key
2603             * @param nodeId the node ID
2604             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2605             * @return the first matching wiki page
2606             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2607             * @throws SystemException if a system exception occurred
2608             */
2609            public WikiPage findByR_N_First(long resourcePrimKey, long nodeId,
2610                    OrderByComparator orderByComparator)
2611                    throws NoSuchPageException, SystemException {
2612                    WikiPage wikiPage = fetchByR_N_First(resourcePrimKey, nodeId,
2613                                    orderByComparator);
2614    
2615                    if (wikiPage != null) {
2616                            return wikiPage;
2617                    }
2618    
2619                    StringBundler msg = new StringBundler(6);
2620    
2621                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2622    
2623                    msg.append("resourcePrimKey=");
2624                    msg.append(resourcePrimKey);
2625    
2626                    msg.append(", nodeId=");
2627                    msg.append(nodeId);
2628    
2629                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2630    
2631                    throw new NoSuchPageException(msg.toString());
2632            }
2633    
2634            /**
2635             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
2636             *
2637             * @param resourcePrimKey the resource prim key
2638             * @param nodeId the node ID
2639             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2640             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
2641             * @throws SystemException if a system exception occurred
2642             */
2643            public WikiPage fetchByR_N_First(long resourcePrimKey, long nodeId,
2644                    OrderByComparator orderByComparator) throws SystemException {
2645                    List<WikiPage> list = findByR_N(resourcePrimKey, nodeId, 0, 1,
2646                                    orderByComparator);
2647    
2648                    if (!list.isEmpty()) {
2649                            return list.get(0);
2650                    }
2651    
2652                    return null;
2653            }
2654    
2655            /**
2656             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
2657             *
2658             * @param resourcePrimKey the resource prim key
2659             * @param nodeId the node ID
2660             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2661             * @return the last matching wiki page
2662             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2663             * @throws SystemException if a system exception occurred
2664             */
2665            public WikiPage findByR_N_Last(long resourcePrimKey, long nodeId,
2666                    OrderByComparator orderByComparator)
2667                    throws NoSuchPageException, SystemException {
2668                    WikiPage wikiPage = fetchByR_N_Last(resourcePrimKey, nodeId,
2669                                    orderByComparator);
2670    
2671                    if (wikiPage != null) {
2672                            return wikiPage;
2673                    }
2674    
2675                    StringBundler msg = new StringBundler(6);
2676    
2677                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2678    
2679                    msg.append("resourcePrimKey=");
2680                    msg.append(resourcePrimKey);
2681    
2682                    msg.append(", nodeId=");
2683                    msg.append(nodeId);
2684    
2685                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2686    
2687                    throw new NoSuchPageException(msg.toString());
2688            }
2689    
2690            /**
2691             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
2692             *
2693             * @param resourcePrimKey the resource prim key
2694             * @param nodeId the node ID
2695             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2696             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
2697             * @throws SystemException if a system exception occurred
2698             */
2699            public WikiPage fetchByR_N_Last(long resourcePrimKey, long nodeId,
2700                    OrderByComparator orderByComparator) throws SystemException {
2701                    int count = countByR_N(resourcePrimKey, nodeId);
2702    
2703                    List<WikiPage> list = findByR_N(resourcePrimKey, nodeId, count - 1,
2704                                    count, orderByComparator);
2705    
2706                    if (!list.isEmpty()) {
2707                            return list.get(0);
2708                    }
2709    
2710                    return null;
2711            }
2712    
2713            /**
2714             * Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
2715             *
2716             * @param pageId the primary key of the current wiki page
2717             * @param resourcePrimKey the resource prim key
2718             * @param nodeId the node ID
2719             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2720             * @return the previous, current, and next wiki page
2721             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
2722             * @throws SystemException if a system exception occurred
2723             */
2724            public WikiPage[] findByR_N_PrevAndNext(long pageId, long resourcePrimKey,
2725                    long nodeId, OrderByComparator orderByComparator)
2726                    throws NoSuchPageException, SystemException {
2727                    WikiPage wikiPage = findByPrimaryKey(pageId);
2728    
2729                    Session session = null;
2730    
2731                    try {
2732                            session = openSession();
2733    
2734                            WikiPage[] array = new WikiPageImpl[3];
2735    
2736                            array[0] = getByR_N_PrevAndNext(session, wikiPage, resourcePrimKey,
2737                                            nodeId, orderByComparator, true);
2738    
2739                            array[1] = wikiPage;
2740    
2741                            array[2] = getByR_N_PrevAndNext(session, wikiPage, resourcePrimKey,
2742                                            nodeId, orderByComparator, false);
2743    
2744                            return array;
2745                    }
2746                    catch (Exception e) {
2747                            throw processException(e);
2748                    }
2749                    finally {
2750                            closeSession(session);
2751                    }
2752            }
2753    
2754            protected WikiPage getByR_N_PrevAndNext(Session session, WikiPage wikiPage,
2755                    long resourcePrimKey, long nodeId, OrderByComparator orderByComparator,
2756                    boolean previous) {
2757                    StringBundler query = null;
2758    
2759                    if (orderByComparator != null) {
2760                            query = new StringBundler(6 +
2761                                            (orderByComparator.getOrderByFields().length * 6));
2762                    }
2763                    else {
2764                            query = new StringBundler(3);
2765                    }
2766    
2767                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2768    
2769                    query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
2770    
2771                    query.append(_FINDER_COLUMN_R_N_NODEID_2);
2772    
2773                    if (orderByComparator != null) {
2774                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2775    
2776                            if (orderByConditionFields.length > 0) {
2777                                    query.append(WHERE_AND);
2778                            }
2779    
2780                            for (int i = 0; i < orderByConditionFields.length; i++) {
2781                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2782                                    query.append(orderByConditionFields[i]);
2783    
2784                                    if ((i + 1) < orderByConditionFields.length) {
2785                                            if (orderByComparator.isAscending() ^ previous) {
2786                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2787                                            }
2788                                            else {
2789                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2790                                            }
2791                                    }
2792                                    else {
2793                                            if (orderByComparator.isAscending() ^ previous) {
2794                                                    query.append(WHERE_GREATER_THAN);
2795                                            }
2796                                            else {
2797                                                    query.append(WHERE_LESSER_THAN);
2798                                            }
2799                                    }
2800                            }
2801    
2802                            query.append(ORDER_BY_CLAUSE);
2803    
2804                            String[] orderByFields = orderByComparator.getOrderByFields();
2805    
2806                            for (int i = 0; i < orderByFields.length; i++) {
2807                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2808                                    query.append(orderByFields[i]);
2809    
2810                                    if ((i + 1) < orderByFields.length) {
2811                                            if (orderByComparator.isAscending() ^ previous) {
2812                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2813                                            }
2814                                            else {
2815                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2816                                            }
2817                                    }
2818                                    else {
2819                                            if (orderByComparator.isAscending() ^ previous) {
2820                                                    query.append(ORDER_BY_ASC);
2821                                            }
2822                                            else {
2823                                                    query.append(ORDER_BY_DESC);
2824                                            }
2825                                    }
2826                            }
2827                    }
2828                    else {
2829                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2830                    }
2831    
2832                    String sql = query.toString();
2833    
2834                    Query q = session.createQuery(sql);
2835    
2836                    q.setFirstResult(0);
2837                    q.setMaxResults(2);
2838    
2839                    QueryPos qPos = QueryPos.getInstance(q);
2840    
2841                    qPos.add(resourcePrimKey);
2842    
2843                    qPos.add(nodeId);
2844    
2845                    if (orderByComparator != null) {
2846                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
2847    
2848                            for (Object value : values) {
2849                                    qPos.add(value);
2850                            }
2851                    }
2852    
2853                    List<WikiPage> list = q.list();
2854    
2855                    if (list.size() == 2) {
2856                            return list.get(1);
2857                    }
2858                    else {
2859                            return null;
2860                    }
2861            }
2862    
2863            /**
2864             * Removes all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; from the database.
2865             *
2866             * @param resourcePrimKey the resource prim key
2867             * @param nodeId the node ID
2868             * @throws SystemException if a system exception occurred
2869             */
2870            public void removeByR_N(long resourcePrimKey, long nodeId)
2871                    throws SystemException {
2872                    for (WikiPage wikiPage : findByR_N(resourcePrimKey, nodeId,
2873                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2874                            remove(wikiPage);
2875                    }
2876            }
2877    
2878            /**
2879             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
2880             *
2881             * @param resourcePrimKey the resource prim key
2882             * @param nodeId the node ID
2883             * @return the number of matching wiki pages
2884             * @throws SystemException if a system exception occurred
2885             */
2886            public int countByR_N(long resourcePrimKey, long nodeId)
2887                    throws SystemException {
2888                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_N;
2889    
2890                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId };
2891    
2892                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2893                                    this);
2894    
2895                    if (count == null) {
2896                            StringBundler query = new StringBundler(3);
2897    
2898                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
2899    
2900                            query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
2901    
2902                            query.append(_FINDER_COLUMN_R_N_NODEID_2);
2903    
2904                            String sql = query.toString();
2905    
2906                            Session session = null;
2907    
2908                            try {
2909                                    session = openSession();
2910    
2911                                    Query q = session.createQuery(sql);
2912    
2913                                    QueryPos qPos = QueryPos.getInstance(q);
2914    
2915                                    qPos.add(resourcePrimKey);
2916    
2917                                    qPos.add(nodeId);
2918    
2919                                    count = (Long)q.uniqueResult();
2920    
2921                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2922                            }
2923                            catch (Exception e) {
2924                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2925    
2926                                    throw processException(e);
2927                            }
2928                            finally {
2929                                    closeSession(session);
2930                            }
2931                    }
2932    
2933                    return count.intValue();
2934            }
2935    
2936            private static final String _FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
2937            private static final String _FINDER_COLUMN_R_N_NODEID_2 = "wikiPage.nodeId = ?";
2938            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2939                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
2940                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_T",
2941                            new String[] {
2942                                    Long.class.getName(), String.class.getName(),
2943                                    
2944                            Integer.class.getName(), Integer.class.getName(),
2945                                    OrderByComparator.class.getName()
2946                            });
2947            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2948                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
2949                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_T",
2950                            new String[] { Long.class.getName(), String.class.getName() },
2951                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
2952                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
2953                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
2954            public static final FinderPath FINDER_PATH_COUNT_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
2955                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
2956                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T",
2957                            new String[] { Long.class.getName(), String.class.getName() });
2958    
2959            /**
2960             * Returns all the wiki pages where nodeId = &#63; and title = &#63;.
2961             *
2962             * @param nodeId the node ID
2963             * @param title the title
2964             * @return the matching wiki pages
2965             * @throws SystemException if a system exception occurred
2966             */
2967            public List<WikiPage> findByN_T(long nodeId, String title)
2968                    throws SystemException {
2969                    return findByN_T(nodeId, title, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2970                            null);
2971            }
2972    
2973            /**
2974             * Returns a range of all the wiki pages where nodeId = &#63; and title = &#63;.
2975             *
2976             * <p>
2977             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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.
2978             * </p>
2979             *
2980             * @param nodeId the node ID
2981             * @param title the title
2982             * @param start the lower bound of the range of wiki pages
2983             * @param end the upper bound of the range of wiki pages (not inclusive)
2984             * @return the range of matching wiki pages
2985             * @throws SystemException if a system exception occurred
2986             */
2987            public List<WikiPage> findByN_T(long nodeId, String title, int start,
2988                    int end) throws SystemException {
2989                    return findByN_T(nodeId, title, start, end, null);
2990            }
2991    
2992            /**
2993             * Returns an ordered range of all the wiki pages where nodeId = &#63; and title = &#63;.
2994             *
2995             * <p>
2996             * 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.
2997             * </p>
2998             *
2999             * @param nodeId the node ID
3000             * @param title the title
3001             * @param start the lower bound of the range of wiki pages
3002             * @param end the upper bound of the range of wiki pages (not inclusive)
3003             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3004             * @return the ordered range of matching wiki pages
3005             * @throws SystemException if a system exception occurred
3006             */
3007            public List<WikiPage> findByN_T(long nodeId, String title, int start,
3008                    int end, OrderByComparator orderByComparator) throws SystemException {
3009                    boolean pagination = true;
3010                    FinderPath finderPath = null;
3011                    Object[] finderArgs = null;
3012    
3013                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3014                                    (orderByComparator == null)) {
3015                            pagination = false;
3016                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T;
3017                            finderArgs = new Object[] { nodeId, title };
3018                    }
3019                    else {
3020                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T;
3021                            finderArgs = new Object[] {
3022                                            nodeId, title,
3023                                            
3024                                            start, end, orderByComparator
3025                                    };
3026                    }
3027    
3028                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
3029                                    finderArgs, this);
3030    
3031                    if ((list != null) && !list.isEmpty()) {
3032                            for (WikiPage wikiPage : list) {
3033                                    if ((nodeId != wikiPage.getNodeId()) ||
3034                                                    !Validator.equals(title, wikiPage.getTitle())) {
3035                                            list = null;
3036    
3037                                            break;
3038                                    }
3039                            }
3040                    }
3041    
3042                    if (list == null) {
3043                            StringBundler query = null;
3044    
3045                            if (orderByComparator != null) {
3046                                    query = new StringBundler(4 +
3047                                                    (orderByComparator.getOrderByFields().length * 3));
3048                            }
3049                            else {
3050                                    query = new StringBundler(4);
3051                            }
3052    
3053                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3054    
3055                            query.append(_FINDER_COLUMN_N_T_NODEID_2);
3056    
3057                            boolean bindTitle = false;
3058    
3059                            if (title == null) {
3060                                    query.append(_FINDER_COLUMN_N_T_TITLE_1);
3061                            }
3062                            else if (title.equals(StringPool.BLANK)) {
3063                                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
3064                            }
3065                            else {
3066                                    bindTitle = true;
3067    
3068                                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
3069                            }
3070    
3071                            if (orderByComparator != null) {
3072                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3073                                            orderByComparator);
3074                            }
3075                            else
3076                             if (pagination) {
3077                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3078                            }
3079    
3080                            String sql = query.toString();
3081    
3082                            Session session = null;
3083    
3084                            try {
3085                                    session = openSession();
3086    
3087                                    Query q = session.createQuery(sql);
3088    
3089                                    QueryPos qPos = QueryPos.getInstance(q);
3090    
3091                                    qPos.add(nodeId);
3092    
3093                                    if (bindTitle) {
3094                                            qPos.add(title.toLowerCase());
3095                                    }
3096    
3097                                    if (!pagination) {
3098                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3099                                                            start, end, false);
3100    
3101                                            Collections.sort(list);
3102    
3103                                            list = new UnmodifiableList<WikiPage>(list);
3104                                    }
3105                                    else {
3106                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3107                                                            start, end);
3108                                    }
3109    
3110                                    cacheResult(list);
3111    
3112                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3113                            }
3114                            catch (Exception e) {
3115                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3116    
3117                                    throw processException(e);
3118                            }
3119                            finally {
3120                                    closeSession(session);
3121                            }
3122                    }
3123    
3124                    return list;
3125            }
3126    
3127            /**
3128             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63;.
3129             *
3130             * @param nodeId the node ID
3131             * @param title the title
3132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3133             * @return the first matching wiki page
3134             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3135             * @throws SystemException if a system exception occurred
3136             */
3137            public WikiPage findByN_T_First(long nodeId, String title,
3138                    OrderByComparator orderByComparator)
3139                    throws NoSuchPageException, SystemException {
3140                    WikiPage wikiPage = fetchByN_T_First(nodeId, title, orderByComparator);
3141    
3142                    if (wikiPage != null) {
3143                            return wikiPage;
3144                    }
3145    
3146                    StringBundler msg = new StringBundler(6);
3147    
3148                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3149    
3150                    msg.append("nodeId=");
3151                    msg.append(nodeId);
3152    
3153                    msg.append(", title=");
3154                    msg.append(title);
3155    
3156                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3157    
3158                    throw new NoSuchPageException(msg.toString());
3159            }
3160    
3161            /**
3162             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63;.
3163             *
3164             * @param nodeId the node ID
3165             * @param title the title
3166             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3167             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
3168             * @throws SystemException if a system exception occurred
3169             */
3170            public WikiPage fetchByN_T_First(long nodeId, String title,
3171                    OrderByComparator orderByComparator) throws SystemException {
3172                    List<WikiPage> list = findByN_T(nodeId, title, 0, 1, orderByComparator);
3173    
3174                    if (!list.isEmpty()) {
3175                            return list.get(0);
3176                    }
3177    
3178                    return null;
3179            }
3180    
3181            /**
3182             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63;.
3183             *
3184             * @param nodeId the node ID
3185             * @param title the title
3186             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3187             * @return the last matching wiki page
3188             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3189             * @throws SystemException if a system exception occurred
3190             */
3191            public WikiPage findByN_T_Last(long nodeId, String title,
3192                    OrderByComparator orderByComparator)
3193                    throws NoSuchPageException, SystemException {
3194                    WikiPage wikiPage = fetchByN_T_Last(nodeId, title, orderByComparator);
3195    
3196                    if (wikiPage != null) {
3197                            return wikiPage;
3198                    }
3199    
3200                    StringBundler msg = new StringBundler(6);
3201    
3202                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3203    
3204                    msg.append("nodeId=");
3205                    msg.append(nodeId);
3206    
3207                    msg.append(", title=");
3208                    msg.append(title);
3209    
3210                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3211    
3212                    throw new NoSuchPageException(msg.toString());
3213            }
3214    
3215            /**
3216             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63;.
3217             *
3218             * @param nodeId the node ID
3219             * @param title the title
3220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3221             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
3222             * @throws SystemException if a system exception occurred
3223             */
3224            public WikiPage fetchByN_T_Last(long nodeId, String title,
3225                    OrderByComparator orderByComparator) throws SystemException {
3226                    int count = countByN_T(nodeId, title);
3227    
3228                    List<WikiPage> list = findByN_T(nodeId, title, count - 1, count,
3229                                    orderByComparator);
3230    
3231                    if (!list.isEmpty()) {
3232                            return list.get(0);
3233                    }
3234    
3235                    return null;
3236            }
3237    
3238            /**
3239             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63;.
3240             *
3241             * @param pageId the primary key of the current wiki page
3242             * @param nodeId the node ID
3243             * @param title the title
3244             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3245             * @return the previous, current, and next wiki page
3246             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
3247             * @throws SystemException if a system exception occurred
3248             */
3249            public WikiPage[] findByN_T_PrevAndNext(long pageId, long nodeId,
3250                    String title, OrderByComparator orderByComparator)
3251                    throws NoSuchPageException, SystemException {
3252                    WikiPage wikiPage = findByPrimaryKey(pageId);
3253    
3254                    Session session = null;
3255    
3256                    try {
3257                            session = openSession();
3258    
3259                            WikiPage[] array = new WikiPageImpl[3];
3260    
3261                            array[0] = getByN_T_PrevAndNext(session, wikiPage, nodeId, title,
3262                                            orderByComparator, true);
3263    
3264                            array[1] = wikiPage;
3265    
3266                            array[2] = getByN_T_PrevAndNext(session, wikiPage, nodeId, title,
3267                                            orderByComparator, false);
3268    
3269                            return array;
3270                    }
3271                    catch (Exception e) {
3272                            throw processException(e);
3273                    }
3274                    finally {
3275                            closeSession(session);
3276                    }
3277            }
3278    
3279            protected WikiPage getByN_T_PrevAndNext(Session session, WikiPage wikiPage,
3280                    long nodeId, String title, OrderByComparator orderByComparator,
3281                    boolean previous) {
3282                    StringBundler query = null;
3283    
3284                    if (orderByComparator != null) {
3285                            query = new StringBundler(6 +
3286                                            (orderByComparator.getOrderByFields().length * 6));
3287                    }
3288                    else {
3289                            query = new StringBundler(3);
3290                    }
3291    
3292                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3293    
3294                    query.append(_FINDER_COLUMN_N_T_NODEID_2);
3295    
3296                    boolean bindTitle = false;
3297    
3298                    if (title == null) {
3299                            query.append(_FINDER_COLUMN_N_T_TITLE_1);
3300                    }
3301                    else if (title.equals(StringPool.BLANK)) {
3302                            query.append(_FINDER_COLUMN_N_T_TITLE_3);
3303                    }
3304                    else {
3305                            bindTitle = true;
3306    
3307                            query.append(_FINDER_COLUMN_N_T_TITLE_2);
3308                    }
3309    
3310                    if (orderByComparator != null) {
3311                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3312    
3313                            if (orderByConditionFields.length > 0) {
3314                                    query.append(WHERE_AND);
3315                            }
3316    
3317                            for (int i = 0; i < orderByConditionFields.length; i++) {
3318                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3319                                    query.append(orderByConditionFields[i]);
3320    
3321                                    if ((i + 1) < orderByConditionFields.length) {
3322                                            if (orderByComparator.isAscending() ^ previous) {
3323                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3324                                            }
3325                                            else {
3326                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3327                                            }
3328                                    }
3329                                    else {
3330                                            if (orderByComparator.isAscending() ^ previous) {
3331                                                    query.append(WHERE_GREATER_THAN);
3332                                            }
3333                                            else {
3334                                                    query.append(WHERE_LESSER_THAN);
3335                                            }
3336                                    }
3337                            }
3338    
3339                            query.append(ORDER_BY_CLAUSE);
3340    
3341                            String[] orderByFields = orderByComparator.getOrderByFields();
3342    
3343                            for (int i = 0; i < orderByFields.length; i++) {
3344                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3345                                    query.append(orderByFields[i]);
3346    
3347                                    if ((i + 1) < orderByFields.length) {
3348                                            if (orderByComparator.isAscending() ^ previous) {
3349                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3350                                            }
3351                                            else {
3352                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3353                                            }
3354                                    }
3355                                    else {
3356                                            if (orderByComparator.isAscending() ^ previous) {
3357                                                    query.append(ORDER_BY_ASC);
3358                                            }
3359                                            else {
3360                                                    query.append(ORDER_BY_DESC);
3361                                            }
3362                                    }
3363                            }
3364                    }
3365                    else {
3366                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3367                    }
3368    
3369                    String sql = query.toString();
3370    
3371                    Query q = session.createQuery(sql);
3372    
3373                    q.setFirstResult(0);
3374                    q.setMaxResults(2);
3375    
3376                    QueryPos qPos = QueryPos.getInstance(q);
3377    
3378                    qPos.add(nodeId);
3379    
3380                    if (bindTitle) {
3381                            qPos.add(title.toLowerCase());
3382                    }
3383    
3384                    if (orderByComparator != null) {
3385                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
3386    
3387                            for (Object value : values) {
3388                                    qPos.add(value);
3389                            }
3390                    }
3391    
3392                    List<WikiPage> list = q.list();
3393    
3394                    if (list.size() == 2) {
3395                            return list.get(1);
3396                    }
3397                    else {
3398                            return null;
3399                    }
3400            }
3401    
3402            /**
3403             * Removes all the wiki pages where nodeId = &#63; and title = &#63; from the database.
3404             *
3405             * @param nodeId the node ID
3406             * @param title the title
3407             * @throws SystemException if a system exception occurred
3408             */
3409            public void removeByN_T(long nodeId, String title)
3410                    throws SystemException {
3411                    for (WikiPage wikiPage : findByN_T(nodeId, title, QueryUtil.ALL_POS,
3412                                    QueryUtil.ALL_POS, null)) {
3413                            remove(wikiPage);
3414                    }
3415            }
3416    
3417            /**
3418             * Returns the number of wiki pages where nodeId = &#63; and title = &#63;.
3419             *
3420             * @param nodeId the node ID
3421             * @param title the title
3422             * @return the number of matching wiki pages
3423             * @throws SystemException if a system exception occurred
3424             */
3425            public int countByN_T(long nodeId, String title) throws SystemException {
3426                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_T;
3427    
3428                    Object[] finderArgs = new Object[] { nodeId, title };
3429    
3430                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3431                                    this);
3432    
3433                    if (count == null) {
3434                            StringBundler query = new StringBundler(3);
3435    
3436                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3437    
3438                            query.append(_FINDER_COLUMN_N_T_NODEID_2);
3439    
3440                            boolean bindTitle = false;
3441    
3442                            if (title == null) {
3443                                    query.append(_FINDER_COLUMN_N_T_TITLE_1);
3444                            }
3445                            else if (title.equals(StringPool.BLANK)) {
3446                                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
3447                            }
3448                            else {
3449                                    bindTitle = true;
3450    
3451                                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
3452                            }
3453    
3454                            String sql = query.toString();
3455    
3456                            Session session = null;
3457    
3458                            try {
3459                                    session = openSession();
3460    
3461                                    Query q = session.createQuery(sql);
3462    
3463                                    QueryPos qPos = QueryPos.getInstance(q);
3464    
3465                                    qPos.add(nodeId);
3466    
3467                                    if (bindTitle) {
3468                                            qPos.add(title.toLowerCase());
3469                                    }
3470    
3471                                    count = (Long)q.uniqueResult();
3472    
3473                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3474                            }
3475                            catch (Exception e) {
3476                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3477    
3478                                    throw processException(e);
3479                            }
3480                            finally {
3481                                    closeSession(session);
3482                            }
3483                    }
3484    
3485                    return count.intValue();
3486            }
3487    
3488            private static final String _FINDER_COLUMN_N_T_NODEID_2 = "wikiPage.nodeId = ? AND ";
3489            private static final String _FINDER_COLUMN_N_T_TITLE_1 = "wikiPage.title IS NULL";
3490            private static final String _FINDER_COLUMN_N_T_TITLE_2 = "lower(wikiPage.title) = ?";
3491            private static final String _FINDER_COLUMN_N_T_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = '')";
3492            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
3493                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
3494                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H",
3495                            new String[] {
3496                                    Long.class.getName(), Boolean.class.getName(),
3497                                    
3498                            Integer.class.getName(), Integer.class.getName(),
3499                                    OrderByComparator.class.getName()
3500                            });
3501            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
3502                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
3503                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H",
3504                            new String[] { Long.class.getName(), Boolean.class.getName() },
3505                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
3506                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
3507                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
3508                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
3509            public static final FinderPath FINDER_PATH_COUNT_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
3510                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
3511                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H",
3512                            new String[] { Long.class.getName(), Boolean.class.getName() });
3513    
3514            /**
3515             * Returns all the wiki pages where nodeId = &#63; and head = &#63;.
3516             *
3517             * @param nodeId the node ID
3518             * @param head the head
3519             * @return the matching wiki pages
3520             * @throws SystemException if a system exception occurred
3521             */
3522            public List<WikiPage> findByN_H(long nodeId, boolean head)
3523                    throws SystemException {
3524                    return findByN_H(nodeId, head, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3525                            null);
3526            }
3527    
3528            /**
3529             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63;.
3530             *
3531             * <p>
3532             * 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.
3533             * </p>
3534             *
3535             * @param nodeId the node ID
3536             * @param head the head
3537             * @param start the lower bound of the range of wiki pages
3538             * @param end the upper bound of the range of wiki pages (not inclusive)
3539             * @return the range of matching wiki pages
3540             * @throws SystemException if a system exception occurred
3541             */
3542            public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
3543                    int end) throws SystemException {
3544                    return findByN_H(nodeId, head, start, end, null);
3545            }
3546    
3547            /**
3548             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63;.
3549             *
3550             * <p>
3551             * 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.
3552             * </p>
3553             *
3554             * @param nodeId the node ID
3555             * @param head the head
3556             * @param start the lower bound of the range of wiki pages
3557             * @param end the upper bound of the range of wiki pages (not inclusive)
3558             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3559             * @return the ordered range of matching wiki pages
3560             * @throws SystemException if a system exception occurred
3561             */
3562            public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
3563                    int end, OrderByComparator orderByComparator) throws SystemException {
3564                    boolean pagination = true;
3565                    FinderPath finderPath = null;
3566                    Object[] finderArgs = null;
3567    
3568                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3569                                    (orderByComparator == null)) {
3570                            pagination = false;
3571                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H;
3572                            finderArgs = new Object[] { nodeId, head };
3573                    }
3574                    else {
3575                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H;
3576                            finderArgs = new Object[] {
3577                                            nodeId, head,
3578                                            
3579                                            start, end, orderByComparator
3580                                    };
3581                    }
3582    
3583                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
3584                                    finderArgs, this);
3585    
3586                    if ((list != null) && !list.isEmpty()) {
3587                            for (WikiPage wikiPage : list) {
3588                                    if ((nodeId != wikiPage.getNodeId()) ||
3589                                                    (head != wikiPage.getHead())) {
3590                                            list = null;
3591    
3592                                            break;
3593                                    }
3594                            }
3595                    }
3596    
3597                    if (list == null) {
3598                            StringBundler query = null;
3599    
3600                            if (orderByComparator != null) {
3601                                    query = new StringBundler(4 +
3602                                                    (orderByComparator.getOrderByFields().length * 3));
3603                            }
3604                            else {
3605                                    query = new StringBundler(4);
3606                            }
3607    
3608                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3609    
3610                            query.append(_FINDER_COLUMN_N_H_NODEID_2);
3611    
3612                            query.append(_FINDER_COLUMN_N_H_HEAD_2);
3613    
3614                            if (orderByComparator != null) {
3615                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3616                                            orderByComparator);
3617                            }
3618                            else
3619                             if (pagination) {
3620                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3621                            }
3622    
3623                            String sql = query.toString();
3624    
3625                            Session session = null;
3626    
3627                            try {
3628                                    session = openSession();
3629    
3630                                    Query q = session.createQuery(sql);
3631    
3632                                    QueryPos qPos = QueryPos.getInstance(q);
3633    
3634                                    qPos.add(nodeId);
3635    
3636                                    qPos.add(head);
3637    
3638                                    if (!pagination) {
3639                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3640                                                            start, end, false);
3641    
3642                                            Collections.sort(list);
3643    
3644                                            list = new UnmodifiableList<WikiPage>(list);
3645                                    }
3646                                    else {
3647                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3648                                                            start, end);
3649                                    }
3650    
3651                                    cacheResult(list);
3652    
3653                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3654                            }
3655                            catch (Exception e) {
3656                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3657    
3658                                    throw processException(e);
3659                            }
3660                            finally {
3661                                    closeSession(session);
3662                            }
3663                    }
3664    
3665                    return list;
3666            }
3667    
3668            /**
3669             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63;.
3670             *
3671             * @param nodeId the node ID
3672             * @param head the head
3673             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3674             * @return the first matching wiki page
3675             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3676             * @throws SystemException if a system exception occurred
3677             */
3678            public WikiPage findByN_H_First(long nodeId, boolean head,
3679                    OrderByComparator orderByComparator)
3680                    throws NoSuchPageException, SystemException {
3681                    WikiPage wikiPage = fetchByN_H_First(nodeId, head, orderByComparator);
3682    
3683                    if (wikiPage != null) {
3684                            return wikiPage;
3685                    }
3686    
3687                    StringBundler msg = new StringBundler(6);
3688    
3689                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3690    
3691                    msg.append("nodeId=");
3692                    msg.append(nodeId);
3693    
3694                    msg.append(", head=");
3695                    msg.append(head);
3696    
3697                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3698    
3699                    throw new NoSuchPageException(msg.toString());
3700            }
3701    
3702            /**
3703             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63;.
3704             *
3705             * @param nodeId the node ID
3706             * @param head the head
3707             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3708             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
3709             * @throws SystemException if a system exception occurred
3710             */
3711            public WikiPage fetchByN_H_First(long nodeId, boolean head,
3712                    OrderByComparator orderByComparator) throws SystemException {
3713                    List<WikiPage> list = findByN_H(nodeId, head, 0, 1, orderByComparator);
3714    
3715                    if (!list.isEmpty()) {
3716                            return list.get(0);
3717                    }
3718    
3719                    return null;
3720            }
3721    
3722            /**
3723             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63;.
3724             *
3725             * @param nodeId the node ID
3726             * @param head the head
3727             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3728             * @return the last matching wiki page
3729             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3730             * @throws SystemException if a system exception occurred
3731             */
3732            public WikiPage findByN_H_Last(long nodeId, boolean head,
3733                    OrderByComparator orderByComparator)
3734                    throws NoSuchPageException, SystemException {
3735                    WikiPage wikiPage = fetchByN_H_Last(nodeId, head, orderByComparator);
3736    
3737                    if (wikiPage != null) {
3738                            return wikiPage;
3739                    }
3740    
3741                    StringBundler msg = new StringBundler(6);
3742    
3743                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3744    
3745                    msg.append("nodeId=");
3746                    msg.append(nodeId);
3747    
3748                    msg.append(", head=");
3749                    msg.append(head);
3750    
3751                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3752    
3753                    throw new NoSuchPageException(msg.toString());
3754            }
3755    
3756            /**
3757             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63;.
3758             *
3759             * @param nodeId the node ID
3760             * @param head the head
3761             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3762             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
3763             * @throws SystemException if a system exception occurred
3764             */
3765            public WikiPage fetchByN_H_Last(long nodeId, boolean head,
3766                    OrderByComparator orderByComparator) throws SystemException {
3767                    int count = countByN_H(nodeId, head);
3768    
3769                    List<WikiPage> list = findByN_H(nodeId, head, count - 1, count,
3770                                    orderByComparator);
3771    
3772                    if (!list.isEmpty()) {
3773                            return list.get(0);
3774                    }
3775    
3776                    return null;
3777            }
3778    
3779            /**
3780             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63;.
3781             *
3782             * @param pageId the primary key of the current wiki page
3783             * @param nodeId the node ID
3784             * @param head the head
3785             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3786             * @return the previous, current, and next wiki page
3787             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
3788             * @throws SystemException if a system exception occurred
3789             */
3790            public WikiPage[] findByN_H_PrevAndNext(long pageId, long nodeId,
3791                    boolean head, OrderByComparator orderByComparator)
3792                    throws NoSuchPageException, SystemException {
3793                    WikiPage wikiPage = findByPrimaryKey(pageId);
3794    
3795                    Session session = null;
3796    
3797                    try {
3798                            session = openSession();
3799    
3800                            WikiPage[] array = new WikiPageImpl[3];
3801    
3802                            array[0] = getByN_H_PrevAndNext(session, wikiPage, nodeId, head,
3803                                            orderByComparator, true);
3804    
3805                            array[1] = wikiPage;
3806    
3807                            array[2] = getByN_H_PrevAndNext(session, wikiPage, nodeId, head,
3808                                            orderByComparator, false);
3809    
3810                            return array;
3811                    }
3812                    catch (Exception e) {
3813                            throw processException(e);
3814                    }
3815                    finally {
3816                            closeSession(session);
3817                    }
3818            }
3819    
3820            protected WikiPage getByN_H_PrevAndNext(Session session, WikiPage wikiPage,
3821                    long nodeId, boolean head, OrderByComparator orderByComparator,
3822                    boolean previous) {
3823                    StringBundler query = null;
3824    
3825                    if (orderByComparator != null) {
3826                            query = new StringBundler(6 +
3827                                            (orderByComparator.getOrderByFields().length * 6));
3828                    }
3829                    else {
3830                            query = new StringBundler(3);
3831                    }
3832    
3833                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3834    
3835                    query.append(_FINDER_COLUMN_N_H_NODEID_2);
3836    
3837                    query.append(_FINDER_COLUMN_N_H_HEAD_2);
3838    
3839                    if (orderByComparator != null) {
3840                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3841    
3842                            if (orderByConditionFields.length > 0) {
3843                                    query.append(WHERE_AND);
3844                            }
3845    
3846                            for (int i = 0; i < orderByConditionFields.length; i++) {
3847                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3848                                    query.append(orderByConditionFields[i]);
3849    
3850                                    if ((i + 1) < orderByConditionFields.length) {
3851                                            if (orderByComparator.isAscending() ^ previous) {
3852                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3853                                            }
3854                                            else {
3855                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3856                                            }
3857                                    }
3858                                    else {
3859                                            if (orderByComparator.isAscending() ^ previous) {
3860                                                    query.append(WHERE_GREATER_THAN);
3861                                            }
3862                                            else {
3863                                                    query.append(WHERE_LESSER_THAN);
3864                                            }
3865                                    }
3866                            }
3867    
3868                            query.append(ORDER_BY_CLAUSE);
3869    
3870                            String[] orderByFields = orderByComparator.getOrderByFields();
3871    
3872                            for (int i = 0; i < orderByFields.length; i++) {
3873                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3874                                    query.append(orderByFields[i]);
3875    
3876                                    if ((i + 1) < orderByFields.length) {
3877                                            if (orderByComparator.isAscending() ^ previous) {
3878                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3879                                            }
3880                                            else {
3881                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3882                                            }
3883                                    }
3884                                    else {
3885                                            if (orderByComparator.isAscending() ^ previous) {
3886                                                    query.append(ORDER_BY_ASC);
3887                                            }
3888                                            else {
3889                                                    query.append(ORDER_BY_DESC);
3890                                            }
3891                                    }
3892                            }
3893                    }
3894                    else {
3895                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3896                    }
3897    
3898                    String sql = query.toString();
3899    
3900                    Query q = session.createQuery(sql);
3901    
3902                    q.setFirstResult(0);
3903                    q.setMaxResults(2);
3904    
3905                    QueryPos qPos = QueryPos.getInstance(q);
3906    
3907                    qPos.add(nodeId);
3908    
3909                    qPos.add(head);
3910    
3911                    if (orderByComparator != null) {
3912                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
3913    
3914                            for (Object value : values) {
3915                                    qPos.add(value);
3916                            }
3917                    }
3918    
3919                    List<WikiPage> list = q.list();
3920    
3921                    if (list.size() == 2) {
3922                            return list.get(1);
3923                    }
3924                    else {
3925                            return null;
3926                    }
3927            }
3928    
3929            /**
3930             * Removes all the wiki pages where nodeId = &#63; and head = &#63; from the database.
3931             *
3932             * @param nodeId the node ID
3933             * @param head the head
3934             * @throws SystemException if a system exception occurred
3935             */
3936            public void removeByN_H(long nodeId, boolean head)
3937                    throws SystemException {
3938                    for (WikiPage wikiPage : findByN_H(nodeId, head, QueryUtil.ALL_POS,
3939                                    QueryUtil.ALL_POS, null)) {
3940                            remove(wikiPage);
3941                    }
3942            }
3943    
3944            /**
3945             * Returns the number of wiki pages where nodeId = &#63; and head = &#63;.
3946             *
3947             * @param nodeId the node ID
3948             * @param head the head
3949             * @return the number of matching wiki pages
3950             * @throws SystemException if a system exception occurred
3951             */
3952            public int countByN_H(long nodeId, boolean head) throws SystemException {
3953                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_H;
3954    
3955                    Object[] finderArgs = new Object[] { nodeId, head };
3956    
3957                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3958                                    this);
3959    
3960                    if (count == null) {
3961                            StringBundler query = new StringBundler(3);
3962    
3963                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3964    
3965                            query.append(_FINDER_COLUMN_N_H_NODEID_2);
3966    
3967                            query.append(_FINDER_COLUMN_N_H_HEAD_2);
3968    
3969                            String sql = query.toString();
3970    
3971                            Session session = null;
3972    
3973                            try {
3974                                    session = openSession();
3975    
3976                                    Query q = session.createQuery(sql);
3977    
3978                                    QueryPos qPos = QueryPos.getInstance(q);
3979    
3980                                    qPos.add(nodeId);
3981    
3982                                    qPos.add(head);
3983    
3984                                    count = (Long)q.uniqueResult();
3985    
3986                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3987                            }
3988                            catch (Exception e) {
3989                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3990    
3991                                    throw processException(e);
3992                            }
3993                            finally {
3994                                    closeSession(session);
3995                            }
3996                    }
3997    
3998                    return count.intValue();
3999            }
4000    
4001            private static final String _FINDER_COLUMN_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
4002            private static final String _FINDER_COLUMN_N_H_HEAD_2 = "wikiPage.head = ?";
4003            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
4004                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
4005                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_P",
4006                            new String[] {
4007                                    Long.class.getName(), String.class.getName(),
4008                                    
4009                            Integer.class.getName(), Integer.class.getName(),
4010                                    OrderByComparator.class.getName()
4011                            });
4012            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
4013                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
4014                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_P",
4015                            new String[] { Long.class.getName(), String.class.getName() },
4016                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
4017                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK |
4018                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
4019                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
4020            public static final FinderPath FINDER_PATH_COUNT_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
4021                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
4022                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_P",
4023                            new String[] { Long.class.getName(), String.class.getName() });
4024    
4025            /**
4026             * Returns all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
4027             *
4028             * @param nodeId the node ID
4029             * @param parentTitle the parent title
4030             * @return the matching wiki pages
4031             * @throws SystemException if a system exception occurred
4032             */
4033            public List<WikiPage> findByN_P(long nodeId, String parentTitle)
4034                    throws SystemException {
4035                    return findByN_P(nodeId, parentTitle, QueryUtil.ALL_POS,
4036                            QueryUtil.ALL_POS, null);
4037            }
4038    
4039            /**
4040             * Returns a range of all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
4041             *
4042             * <p>
4043             * 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.
4044             * </p>
4045             *
4046             * @param nodeId the node ID
4047             * @param parentTitle the parent title
4048             * @param start the lower bound of the range of wiki pages
4049             * @param end the upper bound of the range of wiki pages (not inclusive)
4050             * @return the range of matching wiki pages
4051             * @throws SystemException if a system exception occurred
4052             */
4053            public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
4054                    int end) throws SystemException {
4055                    return findByN_P(nodeId, parentTitle, start, end, null);
4056            }
4057    
4058            /**
4059             * Returns an ordered range of all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
4060             *
4061             * <p>
4062             * 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.
4063             * </p>
4064             *
4065             * @param nodeId the node ID
4066             * @param parentTitle the parent title
4067             * @param start the lower bound of the range of wiki pages
4068             * @param end the upper bound of the range of wiki pages (not inclusive)
4069             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4070             * @return the ordered range of matching wiki pages
4071             * @throws SystemException if a system exception occurred
4072             */
4073            public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
4074                    int end, OrderByComparator orderByComparator) throws SystemException {
4075                    boolean pagination = true;
4076                    FinderPath finderPath = null;
4077                    Object[] finderArgs = null;
4078    
4079                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4080                                    (orderByComparator == null)) {
4081                            pagination = false;
4082                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P;
4083                            finderArgs = new Object[] { nodeId, parentTitle };
4084                    }
4085                    else {
4086                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_P;
4087                            finderArgs = new Object[] {
4088                                            nodeId, parentTitle,
4089                                            
4090                                            start, end, orderByComparator
4091                                    };
4092                    }
4093    
4094                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
4095                                    finderArgs, this);
4096    
4097                    if ((list != null) && !list.isEmpty()) {
4098                            for (WikiPage wikiPage : list) {
4099                                    if ((nodeId != wikiPage.getNodeId()) ||
4100                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle())) {
4101                                            list = null;
4102    
4103                                            break;
4104                                    }
4105                            }
4106                    }
4107    
4108                    if (list == null) {
4109                            StringBundler query = null;
4110    
4111                            if (orderByComparator != null) {
4112                                    query = new StringBundler(4 +
4113                                                    (orderByComparator.getOrderByFields().length * 3));
4114                            }
4115                            else {
4116                                    query = new StringBundler(4);
4117                            }
4118    
4119                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4120    
4121                            query.append(_FINDER_COLUMN_N_P_NODEID_2);
4122    
4123                            boolean bindParentTitle = false;
4124    
4125                            if (parentTitle == null) {
4126                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
4127                            }
4128                            else if (parentTitle.equals(StringPool.BLANK)) {
4129                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
4130                            }
4131                            else {
4132                                    bindParentTitle = true;
4133    
4134                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
4135                            }
4136    
4137                            if (orderByComparator != null) {
4138                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4139                                            orderByComparator);
4140                            }
4141                            else
4142                             if (pagination) {
4143                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4144                            }
4145    
4146                            String sql = query.toString();
4147    
4148                            Session session = null;
4149    
4150                            try {
4151                                    session = openSession();
4152    
4153                                    Query q = session.createQuery(sql);
4154    
4155                                    QueryPos qPos = QueryPos.getInstance(q);
4156    
4157                                    qPos.add(nodeId);
4158    
4159                                    if (bindParentTitle) {
4160                                            qPos.add(parentTitle.toLowerCase());
4161                                    }
4162    
4163                                    if (!pagination) {
4164                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
4165                                                            start, end, false);
4166    
4167                                            Collections.sort(list);
4168    
4169                                            list = new UnmodifiableList<WikiPage>(list);
4170                                    }
4171                                    else {
4172                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
4173                                                            start, end);
4174                                    }
4175    
4176                                    cacheResult(list);
4177    
4178                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4179                            }
4180                            catch (Exception e) {
4181                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4182    
4183                                    throw processException(e);
4184                            }
4185                            finally {
4186                                    closeSession(session);
4187                            }
4188                    }
4189    
4190                    return list;
4191            }
4192    
4193            /**
4194             * Returns the first wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
4195             *
4196             * @param nodeId the node ID
4197             * @param parentTitle the parent title
4198             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4199             * @return the first matching wiki page
4200             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4201             * @throws SystemException if a system exception occurred
4202             */
4203            public WikiPage findByN_P_First(long nodeId, String parentTitle,
4204                    OrderByComparator orderByComparator)
4205                    throws NoSuchPageException, SystemException {
4206                    WikiPage wikiPage = fetchByN_P_First(nodeId, parentTitle,
4207                                    orderByComparator);
4208    
4209                    if (wikiPage != null) {
4210                            return wikiPage;
4211                    }
4212    
4213                    StringBundler msg = new StringBundler(6);
4214    
4215                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4216    
4217                    msg.append("nodeId=");
4218                    msg.append(nodeId);
4219    
4220                    msg.append(", parentTitle=");
4221                    msg.append(parentTitle);
4222    
4223                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4224    
4225                    throw new NoSuchPageException(msg.toString());
4226            }
4227    
4228            /**
4229             * Returns the first wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
4230             *
4231             * @param nodeId the node ID
4232             * @param parentTitle the parent title
4233             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4234             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
4235             * @throws SystemException if a system exception occurred
4236             */
4237            public WikiPage fetchByN_P_First(long nodeId, String parentTitle,
4238                    OrderByComparator orderByComparator) throws SystemException {
4239                    List<WikiPage> list = findByN_P(nodeId, parentTitle, 0, 1,
4240                                    orderByComparator);
4241    
4242                    if (!list.isEmpty()) {
4243                            return list.get(0);
4244                    }
4245    
4246                    return null;
4247            }
4248    
4249            /**
4250             * Returns the last wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
4251             *
4252             * @param nodeId the node ID
4253             * @param parentTitle the parent title
4254             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4255             * @return the last matching wiki page
4256             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4257             * @throws SystemException if a system exception occurred
4258             */
4259            public WikiPage findByN_P_Last(long nodeId, String parentTitle,
4260                    OrderByComparator orderByComparator)
4261                    throws NoSuchPageException, SystemException {
4262                    WikiPage wikiPage = fetchByN_P_Last(nodeId, parentTitle,
4263                                    orderByComparator);
4264    
4265                    if (wikiPage != null) {
4266                            return wikiPage;
4267                    }
4268    
4269                    StringBundler msg = new StringBundler(6);
4270    
4271                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4272    
4273                    msg.append("nodeId=");
4274                    msg.append(nodeId);
4275    
4276                    msg.append(", parentTitle=");
4277                    msg.append(parentTitle);
4278    
4279                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4280    
4281                    throw new NoSuchPageException(msg.toString());
4282            }
4283    
4284            /**
4285             * Returns the last wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
4286             *
4287             * @param nodeId the node ID
4288             * @param parentTitle the parent title
4289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4290             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
4291             * @throws SystemException if a system exception occurred
4292             */
4293            public WikiPage fetchByN_P_Last(long nodeId, String parentTitle,
4294                    OrderByComparator orderByComparator) throws SystemException {
4295                    int count = countByN_P(nodeId, parentTitle);
4296    
4297                    List<WikiPage> list = findByN_P(nodeId, parentTitle, count - 1, count,
4298                                    orderByComparator);
4299    
4300                    if (!list.isEmpty()) {
4301                            return list.get(0);
4302                    }
4303    
4304                    return null;
4305            }
4306    
4307            /**
4308             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
4309             *
4310             * @param pageId the primary key of the current wiki page
4311             * @param nodeId the node ID
4312             * @param parentTitle the parent title
4313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4314             * @return the previous, current, and next wiki page
4315             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
4316             * @throws SystemException if a system exception occurred
4317             */
4318            public WikiPage[] findByN_P_PrevAndNext(long pageId, long nodeId,
4319                    String parentTitle, OrderByComparator orderByComparator)
4320                    throws NoSuchPageException, SystemException {
4321                    WikiPage wikiPage = findByPrimaryKey(pageId);
4322    
4323                    Session session = null;
4324    
4325                    try {
4326                            session = openSession();
4327    
4328                            WikiPage[] array = new WikiPageImpl[3];
4329    
4330                            array[0] = getByN_P_PrevAndNext(session, wikiPage, nodeId,
4331                                            parentTitle, orderByComparator, true);
4332    
4333                            array[1] = wikiPage;
4334    
4335                            array[2] = getByN_P_PrevAndNext(session, wikiPage, nodeId,
4336                                            parentTitle, orderByComparator, false);
4337    
4338                            return array;
4339                    }
4340                    catch (Exception e) {
4341                            throw processException(e);
4342                    }
4343                    finally {
4344                            closeSession(session);
4345                    }
4346            }
4347    
4348            protected WikiPage getByN_P_PrevAndNext(Session session, WikiPage wikiPage,
4349                    long nodeId, String parentTitle, OrderByComparator orderByComparator,
4350                    boolean previous) {
4351                    StringBundler query = null;
4352    
4353                    if (orderByComparator != null) {
4354                            query = new StringBundler(6 +
4355                                            (orderByComparator.getOrderByFields().length * 6));
4356                    }
4357                    else {
4358                            query = new StringBundler(3);
4359                    }
4360    
4361                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4362    
4363                    query.append(_FINDER_COLUMN_N_P_NODEID_2);
4364    
4365                    boolean bindParentTitle = false;
4366    
4367                    if (parentTitle == null) {
4368                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
4369                    }
4370                    else if (parentTitle.equals(StringPool.BLANK)) {
4371                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
4372                    }
4373                    else {
4374                            bindParentTitle = true;
4375    
4376                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
4377                    }
4378    
4379                    if (orderByComparator != null) {
4380                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4381    
4382                            if (orderByConditionFields.length > 0) {
4383                                    query.append(WHERE_AND);
4384                            }
4385    
4386                            for (int i = 0; i < orderByConditionFields.length; i++) {
4387                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4388                                    query.append(orderByConditionFields[i]);
4389    
4390                                    if ((i + 1) < orderByConditionFields.length) {
4391                                            if (orderByComparator.isAscending() ^ previous) {
4392                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4393                                            }
4394                                            else {
4395                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4396                                            }
4397                                    }
4398                                    else {
4399                                            if (orderByComparator.isAscending() ^ previous) {
4400                                                    query.append(WHERE_GREATER_THAN);
4401                                            }
4402                                            else {
4403                                                    query.append(WHERE_LESSER_THAN);
4404                                            }
4405                                    }
4406                            }
4407    
4408                            query.append(ORDER_BY_CLAUSE);
4409    
4410                            String[] orderByFields = orderByComparator.getOrderByFields();
4411    
4412                            for (int i = 0; i < orderByFields.length; i++) {
4413                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4414                                    query.append(orderByFields[i]);
4415    
4416                                    if ((i + 1) < orderByFields.length) {
4417                                            if (orderByComparator.isAscending() ^ previous) {
4418                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4419                                            }
4420                                            else {
4421                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4422                                            }
4423                                    }
4424                                    else {
4425                                            if (orderByComparator.isAscending() ^ previous) {
4426                                                    query.append(ORDER_BY_ASC);
4427                                            }
4428                                            else {
4429                                                    query.append(ORDER_BY_DESC);
4430                                            }
4431                                    }
4432                            }
4433                    }
4434                    else {
4435                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4436                    }
4437    
4438                    String sql = query.toString();
4439    
4440                    Query q = session.createQuery(sql);
4441    
4442                    q.setFirstResult(0);
4443                    q.setMaxResults(2);
4444    
4445                    QueryPos qPos = QueryPos.getInstance(q);
4446    
4447                    qPos.add(nodeId);
4448    
4449                    if (bindParentTitle) {
4450                            qPos.add(parentTitle.toLowerCase());
4451                    }
4452    
4453                    if (orderByComparator != null) {
4454                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
4455    
4456                            for (Object value : values) {
4457                                    qPos.add(value);
4458                            }
4459                    }
4460    
4461                    List<WikiPage> list = q.list();
4462    
4463                    if (list.size() == 2) {
4464                            return list.get(1);
4465                    }
4466                    else {
4467                            return null;
4468                    }
4469            }
4470    
4471            /**
4472             * Removes all the wiki pages where nodeId = &#63; and parentTitle = &#63; from the database.
4473             *
4474             * @param nodeId the node ID
4475             * @param parentTitle the parent title
4476             * @throws SystemException if a system exception occurred
4477             */
4478            public void removeByN_P(long nodeId, String parentTitle)
4479                    throws SystemException {
4480                    for (WikiPage wikiPage : findByN_P(nodeId, parentTitle,
4481                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4482                            remove(wikiPage);
4483                    }
4484            }
4485    
4486            /**
4487             * Returns the number of wiki pages where nodeId = &#63; and parentTitle = &#63;.
4488             *
4489             * @param nodeId the node ID
4490             * @param parentTitle the parent title
4491             * @return the number of matching wiki pages
4492             * @throws SystemException if a system exception occurred
4493             */
4494            public int countByN_P(long nodeId, String parentTitle)
4495                    throws SystemException {
4496                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_P;
4497    
4498                    Object[] finderArgs = new Object[] { nodeId, parentTitle };
4499    
4500                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4501                                    this);
4502    
4503                    if (count == null) {
4504                            StringBundler query = new StringBundler(3);
4505    
4506                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
4507    
4508                            query.append(_FINDER_COLUMN_N_P_NODEID_2);
4509    
4510                            boolean bindParentTitle = false;
4511    
4512                            if (parentTitle == null) {
4513                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
4514                            }
4515                            else if (parentTitle.equals(StringPool.BLANK)) {
4516                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
4517                            }
4518                            else {
4519                                    bindParentTitle = true;
4520    
4521                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
4522                            }
4523    
4524                            String sql = query.toString();
4525    
4526                            Session session = null;
4527    
4528                            try {
4529                                    session = openSession();
4530    
4531                                    Query q = session.createQuery(sql);
4532    
4533                                    QueryPos qPos = QueryPos.getInstance(q);
4534    
4535                                    qPos.add(nodeId);
4536    
4537                                    if (bindParentTitle) {
4538                                            qPos.add(parentTitle.toLowerCase());
4539                                    }
4540    
4541                                    count = (Long)q.uniqueResult();
4542    
4543                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4544                            }
4545                            catch (Exception e) {
4546                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4547    
4548                                    throw processException(e);
4549                            }
4550                            finally {
4551                                    closeSession(session);
4552                            }
4553                    }
4554    
4555                    return count.intValue();
4556            }
4557    
4558            private static final String _FINDER_COLUMN_N_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
4559            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
4560            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = ?";
4561            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = '')";
4562            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
4563                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
4564                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_R",
4565                            new String[] {
4566                                    Long.class.getName(), String.class.getName(),
4567                                    
4568                            Integer.class.getName(), Integer.class.getName(),
4569                                    OrderByComparator.class.getName()
4570                            });
4571            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
4572                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
4573                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_R",
4574                            new String[] { Long.class.getName(), String.class.getName() },
4575                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
4576                            WikiPageModelImpl.REDIRECTTITLE_COLUMN_BITMASK |
4577                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
4578                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
4579            public static final FinderPath FINDER_PATH_COUNT_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
4580                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
4581                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_R",
4582                            new String[] { Long.class.getName(), String.class.getName() });
4583    
4584            /**
4585             * Returns all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
4586             *
4587             * @param nodeId the node ID
4588             * @param redirectTitle the redirect title
4589             * @return the matching wiki pages
4590             * @throws SystemException if a system exception occurred
4591             */
4592            public List<WikiPage> findByN_R(long nodeId, String redirectTitle)
4593                    throws SystemException {
4594                    return findByN_R(nodeId, redirectTitle, QueryUtil.ALL_POS,
4595                            QueryUtil.ALL_POS, null);
4596            }
4597    
4598            /**
4599             * Returns a range of all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
4600             *
4601             * <p>
4602             * 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.
4603             * </p>
4604             *
4605             * @param nodeId the node ID
4606             * @param redirectTitle the redirect title
4607             * @param start the lower bound of the range of wiki pages
4608             * @param end the upper bound of the range of wiki pages (not inclusive)
4609             * @return the range of matching wiki pages
4610             * @throws SystemException if a system exception occurred
4611             */
4612            public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
4613                    int start, int end) throws SystemException {
4614                    return findByN_R(nodeId, redirectTitle, start, end, null);
4615            }
4616    
4617            /**
4618             * Returns an ordered range of all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
4619             *
4620             * <p>
4621             * 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.
4622             * </p>
4623             *
4624             * @param nodeId the node ID
4625             * @param redirectTitle the redirect title
4626             * @param start the lower bound of the range of wiki pages
4627             * @param end the upper bound of the range of wiki pages (not inclusive)
4628             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4629             * @return the ordered range of matching wiki pages
4630             * @throws SystemException if a system exception occurred
4631             */
4632            public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
4633                    int start, int end, OrderByComparator orderByComparator)
4634                    throws SystemException {
4635                    boolean pagination = true;
4636                    FinderPath finderPath = null;
4637                    Object[] finderArgs = null;
4638    
4639                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4640                                    (orderByComparator == null)) {
4641                            pagination = false;
4642                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R;
4643                            finderArgs = new Object[] { nodeId, redirectTitle };
4644                    }
4645                    else {
4646                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_R;
4647                            finderArgs = new Object[] {
4648                                            nodeId, redirectTitle,
4649                                            
4650                                            start, end, orderByComparator
4651                                    };
4652                    }
4653    
4654                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
4655                                    finderArgs, this);
4656    
4657                    if ((list != null) && !list.isEmpty()) {
4658                            for (WikiPage wikiPage : list) {
4659                                    if ((nodeId != wikiPage.getNodeId()) ||
4660                                                    !Validator.equals(redirectTitle,
4661                                                            wikiPage.getRedirectTitle())) {
4662                                            list = null;
4663    
4664                                            break;
4665                                    }
4666                            }
4667                    }
4668    
4669                    if (list == null) {
4670                            StringBundler query = null;
4671    
4672                            if (orderByComparator != null) {
4673                                    query = new StringBundler(4 +
4674                                                    (orderByComparator.getOrderByFields().length * 3));
4675                            }
4676                            else {
4677                                    query = new StringBundler(4);
4678                            }
4679    
4680                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4681    
4682                            query.append(_FINDER_COLUMN_N_R_NODEID_2);
4683    
4684                            boolean bindRedirectTitle = false;
4685    
4686                            if (redirectTitle == null) {
4687                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
4688                            }
4689                            else if (redirectTitle.equals(StringPool.BLANK)) {
4690                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
4691                            }
4692                            else {
4693                                    bindRedirectTitle = true;
4694    
4695                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
4696                            }
4697    
4698                            if (orderByComparator != null) {
4699                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4700                                            orderByComparator);
4701                            }
4702                            else
4703                             if (pagination) {
4704                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4705                            }
4706    
4707                            String sql = query.toString();
4708    
4709                            Session session = null;
4710    
4711                            try {
4712                                    session = openSession();
4713    
4714                                    Query q = session.createQuery(sql);
4715    
4716                                    QueryPos qPos = QueryPos.getInstance(q);
4717    
4718                                    qPos.add(nodeId);
4719    
4720                                    if (bindRedirectTitle) {
4721                                            qPos.add(redirectTitle.toLowerCase());
4722                                    }
4723    
4724                                    if (!pagination) {
4725                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
4726                                                            start, end, false);
4727    
4728                                            Collections.sort(list);
4729    
4730                                            list = new UnmodifiableList<WikiPage>(list);
4731                                    }
4732                                    else {
4733                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
4734                                                            start, end);
4735                                    }
4736    
4737                                    cacheResult(list);
4738    
4739                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4740                            }
4741                            catch (Exception e) {
4742                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4743    
4744                                    throw processException(e);
4745                            }
4746                            finally {
4747                                    closeSession(session);
4748                            }
4749                    }
4750    
4751                    return list;
4752            }
4753    
4754            /**
4755             * Returns the first wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
4756             *
4757             * @param nodeId the node ID
4758             * @param redirectTitle the redirect title
4759             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4760             * @return the first matching wiki page
4761             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4762             * @throws SystemException if a system exception occurred
4763             */
4764            public WikiPage findByN_R_First(long nodeId, String redirectTitle,
4765                    OrderByComparator orderByComparator)
4766                    throws NoSuchPageException, SystemException {
4767                    WikiPage wikiPage = fetchByN_R_First(nodeId, redirectTitle,
4768                                    orderByComparator);
4769    
4770                    if (wikiPage != null) {
4771                            return wikiPage;
4772                    }
4773    
4774                    StringBundler msg = new StringBundler(6);
4775    
4776                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4777    
4778                    msg.append("nodeId=");
4779                    msg.append(nodeId);
4780    
4781                    msg.append(", redirectTitle=");
4782                    msg.append(redirectTitle);
4783    
4784                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4785    
4786                    throw new NoSuchPageException(msg.toString());
4787            }
4788    
4789            /**
4790             * Returns the first wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
4791             *
4792             * @param nodeId the node ID
4793             * @param redirectTitle the redirect title
4794             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4795             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
4796             * @throws SystemException if a system exception occurred
4797             */
4798            public WikiPage fetchByN_R_First(long nodeId, String redirectTitle,
4799                    OrderByComparator orderByComparator) throws SystemException {
4800                    List<WikiPage> list = findByN_R(nodeId, redirectTitle, 0, 1,
4801                                    orderByComparator);
4802    
4803                    if (!list.isEmpty()) {
4804                            return list.get(0);
4805                    }
4806    
4807                    return null;
4808            }
4809    
4810            /**
4811             * Returns the last wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
4812             *
4813             * @param nodeId the node ID
4814             * @param redirectTitle the redirect title
4815             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4816             * @return the last matching wiki page
4817             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4818             * @throws SystemException if a system exception occurred
4819             */
4820            public WikiPage findByN_R_Last(long nodeId, String redirectTitle,
4821                    OrderByComparator orderByComparator)
4822                    throws NoSuchPageException, SystemException {
4823                    WikiPage wikiPage = fetchByN_R_Last(nodeId, redirectTitle,
4824                                    orderByComparator);
4825    
4826                    if (wikiPage != null) {
4827                            return wikiPage;
4828                    }
4829    
4830                    StringBundler msg = new StringBundler(6);
4831    
4832                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4833    
4834                    msg.append("nodeId=");
4835                    msg.append(nodeId);
4836    
4837                    msg.append(", redirectTitle=");
4838                    msg.append(redirectTitle);
4839    
4840                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4841    
4842                    throw new NoSuchPageException(msg.toString());
4843            }
4844    
4845            /**
4846             * Returns the last wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
4847             *
4848             * @param nodeId the node ID
4849             * @param redirectTitle the redirect title
4850             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4851             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
4852             * @throws SystemException if a system exception occurred
4853             */
4854            public WikiPage fetchByN_R_Last(long nodeId, String redirectTitle,
4855                    OrderByComparator orderByComparator) throws SystemException {
4856                    int count = countByN_R(nodeId, redirectTitle);
4857    
4858                    List<WikiPage> list = findByN_R(nodeId, redirectTitle, count - 1,
4859                                    count, orderByComparator);
4860    
4861                    if (!list.isEmpty()) {
4862                            return list.get(0);
4863                    }
4864    
4865                    return null;
4866            }
4867    
4868            /**
4869             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
4870             *
4871             * @param pageId the primary key of the current wiki page
4872             * @param nodeId the node ID
4873             * @param redirectTitle the redirect title
4874             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4875             * @return the previous, current, and next wiki page
4876             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
4877             * @throws SystemException if a system exception occurred
4878             */
4879            public WikiPage[] findByN_R_PrevAndNext(long pageId, long nodeId,
4880                    String redirectTitle, OrderByComparator orderByComparator)
4881                    throws NoSuchPageException, SystemException {
4882                    WikiPage wikiPage = findByPrimaryKey(pageId);
4883    
4884                    Session session = null;
4885    
4886                    try {
4887                            session = openSession();
4888    
4889                            WikiPage[] array = new WikiPageImpl[3];
4890    
4891                            array[0] = getByN_R_PrevAndNext(session, wikiPage, nodeId,
4892                                            redirectTitle, orderByComparator, true);
4893    
4894                            array[1] = wikiPage;
4895    
4896                            array[2] = getByN_R_PrevAndNext(session, wikiPage, nodeId,
4897                                            redirectTitle, orderByComparator, false);
4898    
4899                            return array;
4900                    }
4901                    catch (Exception e) {
4902                            throw processException(e);
4903                    }
4904                    finally {
4905                            closeSession(session);
4906                    }
4907            }
4908    
4909            protected WikiPage getByN_R_PrevAndNext(Session session, WikiPage wikiPage,
4910                    long nodeId, String redirectTitle, OrderByComparator orderByComparator,
4911                    boolean previous) {
4912                    StringBundler query = null;
4913    
4914                    if (orderByComparator != null) {
4915                            query = new StringBundler(6 +
4916                                            (orderByComparator.getOrderByFields().length * 6));
4917                    }
4918                    else {
4919                            query = new StringBundler(3);
4920                    }
4921    
4922                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4923    
4924                    query.append(_FINDER_COLUMN_N_R_NODEID_2);
4925    
4926                    boolean bindRedirectTitle = false;
4927    
4928                    if (redirectTitle == null) {
4929                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
4930                    }
4931                    else if (redirectTitle.equals(StringPool.BLANK)) {
4932                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
4933                    }
4934                    else {
4935                            bindRedirectTitle = true;
4936    
4937                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
4938                    }
4939    
4940                    if (orderByComparator != null) {
4941                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4942    
4943                            if (orderByConditionFields.length > 0) {
4944                                    query.append(WHERE_AND);
4945                            }
4946    
4947                            for (int i = 0; i < orderByConditionFields.length; i++) {
4948                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4949                                    query.append(orderByConditionFields[i]);
4950    
4951                                    if ((i + 1) < orderByConditionFields.length) {
4952                                            if (orderByComparator.isAscending() ^ previous) {
4953                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4954                                            }
4955                                            else {
4956                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4957                                            }
4958                                    }
4959                                    else {
4960                                            if (orderByComparator.isAscending() ^ previous) {
4961                                                    query.append(WHERE_GREATER_THAN);
4962                                            }
4963                                            else {
4964                                                    query.append(WHERE_LESSER_THAN);
4965                                            }
4966                                    }
4967                            }
4968    
4969                            query.append(ORDER_BY_CLAUSE);
4970    
4971                            String[] orderByFields = orderByComparator.getOrderByFields();
4972    
4973                            for (int i = 0; i < orderByFields.length; i++) {
4974                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4975                                    query.append(orderByFields[i]);
4976    
4977                                    if ((i + 1) < orderByFields.length) {
4978                                            if (orderByComparator.isAscending() ^ previous) {
4979                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4980                                            }
4981                                            else {
4982                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4983                                            }
4984                                    }
4985                                    else {
4986                                            if (orderByComparator.isAscending() ^ previous) {
4987                                                    query.append(ORDER_BY_ASC);
4988                                            }
4989                                            else {
4990                                                    query.append(ORDER_BY_DESC);
4991                                            }
4992                                    }
4993                            }
4994                    }
4995                    else {
4996                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4997                    }
4998    
4999                    String sql = query.toString();
5000    
5001                    Query q = session.createQuery(sql);
5002    
5003                    q.setFirstResult(0);
5004                    q.setMaxResults(2);
5005    
5006                    QueryPos qPos = QueryPos.getInstance(q);
5007    
5008                    qPos.add(nodeId);
5009    
5010                    if (bindRedirectTitle) {
5011                            qPos.add(redirectTitle.toLowerCase());
5012                    }
5013    
5014                    if (orderByComparator != null) {
5015                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
5016    
5017                            for (Object value : values) {
5018                                    qPos.add(value);
5019                            }
5020                    }
5021    
5022                    List<WikiPage> list = q.list();
5023    
5024                    if (list.size() == 2) {
5025                            return list.get(1);
5026                    }
5027                    else {
5028                            return null;
5029                    }
5030            }
5031    
5032            /**
5033             * Removes all the wiki pages where nodeId = &#63; and redirectTitle = &#63; from the database.
5034             *
5035             * @param nodeId the node ID
5036             * @param redirectTitle the redirect title
5037             * @throws SystemException if a system exception occurred
5038             */
5039            public void removeByN_R(long nodeId, String redirectTitle)
5040                    throws SystemException {
5041                    for (WikiPage wikiPage : findByN_R(nodeId, redirectTitle,
5042                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5043                            remove(wikiPage);
5044                    }
5045            }
5046    
5047            /**
5048             * Returns the number of wiki pages where nodeId = &#63; and redirectTitle = &#63;.
5049             *
5050             * @param nodeId the node ID
5051             * @param redirectTitle the redirect title
5052             * @return the number of matching wiki pages
5053             * @throws SystemException if a system exception occurred
5054             */
5055            public int countByN_R(long nodeId, String redirectTitle)
5056                    throws SystemException {
5057                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_R;
5058    
5059                    Object[] finderArgs = new Object[] { nodeId, redirectTitle };
5060    
5061                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5062                                    this);
5063    
5064                    if (count == null) {
5065                            StringBundler query = new StringBundler(3);
5066    
5067                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
5068    
5069                            query.append(_FINDER_COLUMN_N_R_NODEID_2);
5070    
5071                            boolean bindRedirectTitle = false;
5072    
5073                            if (redirectTitle == null) {
5074                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
5075                            }
5076                            else if (redirectTitle.equals(StringPool.BLANK)) {
5077                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
5078                            }
5079                            else {
5080                                    bindRedirectTitle = true;
5081    
5082                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
5083                            }
5084    
5085                            String sql = query.toString();
5086    
5087                            Session session = null;
5088    
5089                            try {
5090                                    session = openSession();
5091    
5092                                    Query q = session.createQuery(sql);
5093    
5094                                    QueryPos qPos = QueryPos.getInstance(q);
5095    
5096                                    qPos.add(nodeId);
5097    
5098                                    if (bindRedirectTitle) {
5099                                            qPos.add(redirectTitle.toLowerCase());
5100                                    }
5101    
5102                                    count = (Long)q.uniqueResult();
5103    
5104                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5105                            }
5106                            catch (Exception e) {
5107                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5108    
5109                                    throw processException(e);
5110                            }
5111                            finally {
5112                                    closeSession(session);
5113                            }
5114                    }
5115    
5116                    return count.intValue();
5117            }
5118    
5119            private static final String _FINDER_COLUMN_N_R_NODEID_2 = "wikiPage.nodeId = ? AND ";
5120            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_1 = "wikiPage.redirectTitle IS NULL";
5121            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_2 = "lower(wikiPage.redirectTitle) = ?";
5122            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_3 = "(wikiPage.redirectTitle IS NULL OR wikiPage.redirectTitle = '')";
5123            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5124                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
5125                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_S",
5126                            new String[] {
5127                                    Long.class.getName(), Integer.class.getName(),
5128                                    
5129                            Integer.class.getName(), Integer.class.getName(),
5130                                    OrderByComparator.class.getName()
5131                            });
5132            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5133                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
5134                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_S",
5135                            new String[] { Long.class.getName(), Integer.class.getName() },
5136                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
5137                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
5138                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
5139                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
5140            public static final FinderPath FINDER_PATH_COUNT_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5141                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
5142                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_S",
5143                            new String[] { Long.class.getName(), Integer.class.getName() });
5144    
5145            /**
5146             * Returns all the wiki pages where nodeId = &#63; and status = &#63;.
5147             *
5148             * @param nodeId the node ID
5149             * @param status the status
5150             * @return the matching wiki pages
5151             * @throws SystemException if a system exception occurred
5152             */
5153            public List<WikiPage> findByN_S(long nodeId, int status)
5154                    throws SystemException {
5155                    return findByN_S(nodeId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
5156                            null);
5157            }
5158    
5159            /**
5160             * Returns a range of all the wiki pages where nodeId = &#63; and status = &#63;.
5161             *
5162             * <p>
5163             * 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.
5164             * </p>
5165             *
5166             * @param nodeId the node ID
5167             * @param status the status
5168             * @param start the lower bound of the range of wiki pages
5169             * @param end the upper bound of the range of wiki pages (not inclusive)
5170             * @return the range of matching wiki pages
5171             * @throws SystemException if a system exception occurred
5172             */
5173            public List<WikiPage> findByN_S(long nodeId, int status, int start, int end)
5174                    throws SystemException {
5175                    return findByN_S(nodeId, status, start, end, null);
5176            }
5177    
5178            /**
5179             * Returns an ordered range of all the wiki pages where nodeId = &#63; and status = &#63;.
5180             *
5181             * <p>
5182             * 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.
5183             * </p>
5184             *
5185             * @param nodeId the node ID
5186             * @param status the status
5187             * @param start the lower bound of the range of wiki pages
5188             * @param end the upper bound of the range of wiki pages (not inclusive)
5189             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5190             * @return the ordered range of matching wiki pages
5191             * @throws SystemException if a system exception occurred
5192             */
5193            public List<WikiPage> findByN_S(long nodeId, int status, int start,
5194                    int end, OrderByComparator orderByComparator) throws SystemException {
5195                    boolean pagination = true;
5196                    FinderPath finderPath = null;
5197                    Object[] finderArgs = null;
5198    
5199                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5200                                    (orderByComparator == null)) {
5201                            pagination = false;
5202                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S;
5203                            finderArgs = new Object[] { nodeId, status };
5204                    }
5205                    else {
5206                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_S;
5207                            finderArgs = new Object[] {
5208                                            nodeId, status,
5209                                            
5210                                            start, end, orderByComparator
5211                                    };
5212                    }
5213    
5214                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
5215                                    finderArgs, this);
5216    
5217                    if ((list != null) && !list.isEmpty()) {
5218                            for (WikiPage wikiPage : list) {
5219                                    if ((nodeId != wikiPage.getNodeId()) ||
5220                                                    (status != wikiPage.getStatus())) {
5221                                            list = null;
5222    
5223                                            break;
5224                                    }
5225                            }
5226                    }
5227    
5228                    if (list == null) {
5229                            StringBundler query = null;
5230    
5231                            if (orderByComparator != null) {
5232                                    query = new StringBundler(4 +
5233                                                    (orderByComparator.getOrderByFields().length * 3));
5234                            }
5235                            else {
5236                                    query = new StringBundler(4);
5237                            }
5238    
5239                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5240    
5241                            query.append(_FINDER_COLUMN_N_S_NODEID_2);
5242    
5243                            query.append(_FINDER_COLUMN_N_S_STATUS_2);
5244    
5245                            if (orderByComparator != null) {
5246                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5247                                            orderByComparator);
5248                            }
5249                            else
5250                             if (pagination) {
5251                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5252                            }
5253    
5254                            String sql = query.toString();
5255    
5256                            Session session = null;
5257    
5258                            try {
5259                                    session = openSession();
5260    
5261                                    Query q = session.createQuery(sql);
5262    
5263                                    QueryPos qPos = QueryPos.getInstance(q);
5264    
5265                                    qPos.add(nodeId);
5266    
5267                                    qPos.add(status);
5268    
5269                                    if (!pagination) {
5270                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
5271                                                            start, end, false);
5272    
5273                                            Collections.sort(list);
5274    
5275                                            list = new UnmodifiableList<WikiPage>(list);
5276                                    }
5277                                    else {
5278                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
5279                                                            start, end);
5280                                    }
5281    
5282                                    cacheResult(list);
5283    
5284                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5285                            }
5286                            catch (Exception e) {
5287                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5288    
5289                                    throw processException(e);
5290                            }
5291                            finally {
5292                                    closeSession(session);
5293                            }
5294                    }
5295    
5296                    return list;
5297            }
5298    
5299            /**
5300             * Returns the first wiki page in the ordered set where nodeId = &#63; and status = &#63;.
5301             *
5302             * @param nodeId the node ID
5303             * @param status the status
5304             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5305             * @return the first matching wiki page
5306             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5307             * @throws SystemException if a system exception occurred
5308             */
5309            public WikiPage findByN_S_First(long nodeId, int status,
5310                    OrderByComparator orderByComparator)
5311                    throws NoSuchPageException, SystemException {
5312                    WikiPage wikiPage = fetchByN_S_First(nodeId, status, orderByComparator);
5313    
5314                    if (wikiPage != null) {
5315                            return wikiPage;
5316                    }
5317    
5318                    StringBundler msg = new StringBundler(6);
5319    
5320                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5321    
5322                    msg.append("nodeId=");
5323                    msg.append(nodeId);
5324    
5325                    msg.append(", status=");
5326                    msg.append(status);
5327    
5328                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5329    
5330                    throw new NoSuchPageException(msg.toString());
5331            }
5332    
5333            /**
5334             * Returns the first wiki page in the ordered set where nodeId = &#63; and status = &#63;.
5335             *
5336             * @param nodeId the node ID
5337             * @param status the status
5338             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5339             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
5340             * @throws SystemException if a system exception occurred
5341             */
5342            public WikiPage fetchByN_S_First(long nodeId, int status,
5343                    OrderByComparator orderByComparator) throws SystemException {
5344                    List<WikiPage> list = findByN_S(nodeId, status, 0, 1, orderByComparator);
5345    
5346                    if (!list.isEmpty()) {
5347                            return list.get(0);
5348                    }
5349    
5350                    return null;
5351            }
5352    
5353            /**
5354             * Returns the last wiki page in the ordered set where nodeId = &#63; and status = &#63;.
5355             *
5356             * @param nodeId the node ID
5357             * @param status the status
5358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5359             * @return the last matching wiki page
5360             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5361             * @throws SystemException if a system exception occurred
5362             */
5363            public WikiPage findByN_S_Last(long nodeId, int status,
5364                    OrderByComparator orderByComparator)
5365                    throws NoSuchPageException, SystemException {
5366                    WikiPage wikiPage = fetchByN_S_Last(nodeId, status, orderByComparator);
5367    
5368                    if (wikiPage != null) {
5369                            return wikiPage;
5370                    }
5371    
5372                    StringBundler msg = new StringBundler(6);
5373    
5374                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5375    
5376                    msg.append("nodeId=");
5377                    msg.append(nodeId);
5378    
5379                    msg.append(", status=");
5380                    msg.append(status);
5381    
5382                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5383    
5384                    throw new NoSuchPageException(msg.toString());
5385            }
5386    
5387            /**
5388             * Returns the last wiki page in the ordered set where nodeId = &#63; and status = &#63;.
5389             *
5390             * @param nodeId the node ID
5391             * @param status the status
5392             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5393             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
5394             * @throws SystemException if a system exception occurred
5395             */
5396            public WikiPage fetchByN_S_Last(long nodeId, int status,
5397                    OrderByComparator orderByComparator) throws SystemException {
5398                    int count = countByN_S(nodeId, status);
5399    
5400                    List<WikiPage> list = findByN_S(nodeId, status, count - 1, count,
5401                                    orderByComparator);
5402    
5403                    if (!list.isEmpty()) {
5404                            return list.get(0);
5405                    }
5406    
5407                    return null;
5408            }
5409    
5410            /**
5411             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and status = &#63;.
5412             *
5413             * @param pageId the primary key of the current wiki page
5414             * @param nodeId the node ID
5415             * @param status the status
5416             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5417             * @return the previous, current, and next wiki page
5418             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
5419             * @throws SystemException if a system exception occurred
5420             */
5421            public WikiPage[] findByN_S_PrevAndNext(long pageId, long nodeId,
5422                    int status, OrderByComparator orderByComparator)
5423                    throws NoSuchPageException, SystemException {
5424                    WikiPage wikiPage = findByPrimaryKey(pageId);
5425    
5426                    Session session = null;
5427    
5428                    try {
5429                            session = openSession();
5430    
5431                            WikiPage[] array = new WikiPageImpl[3];
5432    
5433                            array[0] = getByN_S_PrevAndNext(session, wikiPage, nodeId, status,
5434                                            orderByComparator, true);
5435    
5436                            array[1] = wikiPage;
5437    
5438                            array[2] = getByN_S_PrevAndNext(session, wikiPage, nodeId, status,
5439                                            orderByComparator, false);
5440    
5441                            return array;
5442                    }
5443                    catch (Exception e) {
5444                            throw processException(e);
5445                    }
5446                    finally {
5447                            closeSession(session);
5448                    }
5449            }
5450    
5451            protected WikiPage getByN_S_PrevAndNext(Session session, WikiPage wikiPage,
5452                    long nodeId, int status, OrderByComparator orderByComparator,
5453                    boolean previous) {
5454                    StringBundler query = null;
5455    
5456                    if (orderByComparator != null) {
5457                            query = new StringBundler(6 +
5458                                            (orderByComparator.getOrderByFields().length * 6));
5459                    }
5460                    else {
5461                            query = new StringBundler(3);
5462                    }
5463    
5464                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5465    
5466                    query.append(_FINDER_COLUMN_N_S_NODEID_2);
5467    
5468                    query.append(_FINDER_COLUMN_N_S_STATUS_2);
5469    
5470                    if (orderByComparator != null) {
5471                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5472    
5473                            if (orderByConditionFields.length > 0) {
5474                                    query.append(WHERE_AND);
5475                            }
5476    
5477                            for (int i = 0; i < orderByConditionFields.length; i++) {
5478                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5479                                    query.append(orderByConditionFields[i]);
5480    
5481                                    if ((i + 1) < orderByConditionFields.length) {
5482                                            if (orderByComparator.isAscending() ^ previous) {
5483                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5484                                            }
5485                                            else {
5486                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5487                                            }
5488                                    }
5489                                    else {
5490                                            if (orderByComparator.isAscending() ^ previous) {
5491                                                    query.append(WHERE_GREATER_THAN);
5492                                            }
5493                                            else {
5494                                                    query.append(WHERE_LESSER_THAN);
5495                                            }
5496                                    }
5497                            }
5498    
5499                            query.append(ORDER_BY_CLAUSE);
5500    
5501                            String[] orderByFields = orderByComparator.getOrderByFields();
5502    
5503                            for (int i = 0; i < orderByFields.length; i++) {
5504                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5505                                    query.append(orderByFields[i]);
5506    
5507                                    if ((i + 1) < orderByFields.length) {
5508                                            if (orderByComparator.isAscending() ^ previous) {
5509                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5510                                            }
5511                                            else {
5512                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5513                                            }
5514                                    }
5515                                    else {
5516                                            if (orderByComparator.isAscending() ^ previous) {
5517                                                    query.append(ORDER_BY_ASC);
5518                                            }
5519                                            else {
5520                                                    query.append(ORDER_BY_DESC);
5521                                            }
5522                                    }
5523                            }
5524                    }
5525                    else {
5526                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5527                    }
5528    
5529                    String sql = query.toString();
5530    
5531                    Query q = session.createQuery(sql);
5532    
5533                    q.setFirstResult(0);
5534                    q.setMaxResults(2);
5535    
5536                    QueryPos qPos = QueryPos.getInstance(q);
5537    
5538                    qPos.add(nodeId);
5539    
5540                    qPos.add(status);
5541    
5542                    if (orderByComparator != null) {
5543                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
5544    
5545                            for (Object value : values) {
5546                                    qPos.add(value);
5547                            }
5548                    }
5549    
5550                    List<WikiPage> list = q.list();
5551    
5552                    if (list.size() == 2) {
5553                            return list.get(1);
5554                    }
5555                    else {
5556                            return null;
5557                    }
5558            }
5559    
5560            /**
5561             * Removes all the wiki pages where nodeId = &#63; and status = &#63; from the database.
5562             *
5563             * @param nodeId the node ID
5564             * @param status the status
5565             * @throws SystemException if a system exception occurred
5566             */
5567            public void removeByN_S(long nodeId, int status) throws SystemException {
5568                    for (WikiPage wikiPage : findByN_S(nodeId, status, QueryUtil.ALL_POS,
5569                                    QueryUtil.ALL_POS, null)) {
5570                            remove(wikiPage);
5571                    }
5572            }
5573    
5574            /**
5575             * Returns the number of wiki pages where nodeId = &#63; and status = &#63;.
5576             *
5577             * @param nodeId the node ID
5578             * @param status the status
5579             * @return the number of matching wiki pages
5580             * @throws SystemException if a system exception occurred
5581             */
5582            public int countByN_S(long nodeId, int status) throws SystemException {
5583                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_S;
5584    
5585                    Object[] finderArgs = new Object[] { nodeId, status };
5586    
5587                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5588                                    this);
5589    
5590                    if (count == null) {
5591                            StringBundler query = new StringBundler(3);
5592    
5593                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
5594    
5595                            query.append(_FINDER_COLUMN_N_S_NODEID_2);
5596    
5597                            query.append(_FINDER_COLUMN_N_S_STATUS_2);
5598    
5599                            String sql = query.toString();
5600    
5601                            Session session = null;
5602    
5603                            try {
5604                                    session = openSession();
5605    
5606                                    Query q = session.createQuery(sql);
5607    
5608                                    QueryPos qPos = QueryPos.getInstance(q);
5609    
5610                                    qPos.add(nodeId);
5611    
5612                                    qPos.add(status);
5613    
5614                                    count = (Long)q.uniqueResult();
5615    
5616                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5617                            }
5618                            catch (Exception e) {
5619                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5620    
5621                                    throw processException(e);
5622                            }
5623                            finally {
5624                                    closeSession(session);
5625                            }
5626                    }
5627    
5628                    return count.intValue();
5629            }
5630    
5631            private static final String _FINDER_COLUMN_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
5632            private static final String _FINDER_COLUMN_N_S_STATUS_2 = "wikiPage.status = ?";
5633            public static final FinderPath FINDER_PATH_FETCH_BY_R_N_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5634                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
5635                            FINDER_CLASS_NAME_ENTITY, "fetchByR_N_V",
5636                            new String[] {
5637                                    Long.class.getName(), Long.class.getName(),
5638                                    Double.class.getName()
5639                            },
5640                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5641                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
5642                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
5643            public static final FinderPath FINDER_PATH_COUNT_BY_R_N_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5644                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
5645                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N_V",
5646                            new String[] {
5647                                    Long.class.getName(), Long.class.getName(),
5648                                    Double.class.getName()
5649                            });
5650    
5651            /**
5652             * 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.
5653             *
5654             * @param resourcePrimKey the resource prim key
5655             * @param nodeId the node ID
5656             * @param version the version
5657             * @return the matching wiki page
5658             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5659             * @throws SystemException if a system exception occurred
5660             */
5661            public WikiPage findByR_N_V(long resourcePrimKey, long nodeId,
5662                    double version) throws NoSuchPageException, SystemException {
5663                    WikiPage wikiPage = fetchByR_N_V(resourcePrimKey, nodeId, version);
5664    
5665                    if (wikiPage == null) {
5666                            StringBundler msg = new StringBundler(8);
5667    
5668                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5669    
5670                            msg.append("resourcePrimKey=");
5671                            msg.append(resourcePrimKey);
5672    
5673                            msg.append(", nodeId=");
5674                            msg.append(nodeId);
5675    
5676                            msg.append(", version=");
5677                            msg.append(version);
5678    
5679                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5680    
5681                            if (_log.isWarnEnabled()) {
5682                                    _log.warn(msg.toString());
5683                            }
5684    
5685                            throw new NoSuchPageException(msg.toString());
5686                    }
5687    
5688                    return wikiPage;
5689            }
5690    
5691            /**
5692             * 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.
5693             *
5694             * @param resourcePrimKey the resource prim key
5695             * @param nodeId the node ID
5696             * @param version the version
5697             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
5698             * @throws SystemException if a system exception occurred
5699             */
5700            public WikiPage fetchByR_N_V(long resourcePrimKey, long nodeId,
5701                    double version) throws SystemException {
5702                    return fetchByR_N_V(resourcePrimKey, nodeId, version, true);
5703            }
5704    
5705            /**
5706             * 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.
5707             *
5708             * @param resourcePrimKey the resource prim key
5709             * @param nodeId the node ID
5710             * @param version the version
5711             * @param retrieveFromCache whether to use the finder cache
5712             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
5713             * @throws SystemException if a system exception occurred
5714             */
5715            public WikiPage fetchByR_N_V(long resourcePrimKey, long nodeId,
5716                    double version, boolean retrieveFromCache) throws SystemException {
5717                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, version };
5718    
5719                    Object result = null;
5720    
5721                    if (retrieveFromCache) {
5722                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_R_N_V,
5723                                            finderArgs, this);
5724                    }
5725    
5726                    if (result instanceof WikiPage) {
5727                            WikiPage wikiPage = (WikiPage)result;
5728    
5729                            if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
5730                                            (nodeId != wikiPage.getNodeId()) ||
5731                                            (version != wikiPage.getVersion())) {
5732                                    result = null;
5733                            }
5734                    }
5735    
5736                    if (result == null) {
5737                            StringBundler query = new StringBundler(5);
5738    
5739                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5740    
5741                            query.append(_FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2);
5742    
5743                            query.append(_FINDER_COLUMN_R_N_V_NODEID_2);
5744    
5745                            query.append(_FINDER_COLUMN_R_N_V_VERSION_2);
5746    
5747                            String sql = query.toString();
5748    
5749                            Session session = null;
5750    
5751                            try {
5752                                    session = openSession();
5753    
5754                                    Query q = session.createQuery(sql);
5755    
5756                                    QueryPos qPos = QueryPos.getInstance(q);
5757    
5758                                    qPos.add(resourcePrimKey);
5759    
5760                                    qPos.add(nodeId);
5761    
5762                                    qPos.add(version);
5763    
5764                                    List<WikiPage> list = q.list();
5765    
5766                                    if (list.isEmpty()) {
5767                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
5768                                                    finderArgs, list);
5769                                    }
5770                                    else {
5771                                            WikiPage wikiPage = list.get(0);
5772    
5773                                            result = wikiPage;
5774    
5775                                            cacheResult(wikiPage);
5776    
5777                                            if ((wikiPage.getResourcePrimKey() != resourcePrimKey) ||
5778                                                            (wikiPage.getNodeId() != nodeId) ||
5779                                                            (wikiPage.getVersion() != version)) {
5780                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
5781                                                            finderArgs, wikiPage);
5782                                            }
5783                                    }
5784                            }
5785                            catch (Exception e) {
5786                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V,
5787                                            finderArgs);
5788    
5789                                    throw processException(e);
5790                            }
5791                            finally {
5792                                    closeSession(session);
5793                            }
5794                    }
5795    
5796                    if (result instanceof List<?>) {
5797                            return null;
5798                    }
5799                    else {
5800                            return (WikiPage)result;
5801                    }
5802            }
5803    
5804            /**
5805             * Removes the wiki page where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63; from the database.
5806             *
5807             * @param resourcePrimKey the resource prim key
5808             * @param nodeId the node ID
5809             * @param version the version
5810             * @return the wiki page that was removed
5811             * @throws SystemException if a system exception occurred
5812             */
5813            public WikiPage removeByR_N_V(long resourcePrimKey, long nodeId,
5814                    double version) throws NoSuchPageException, SystemException {
5815                    WikiPage wikiPage = findByR_N_V(resourcePrimKey, nodeId, version);
5816    
5817                    return remove(wikiPage);
5818            }
5819    
5820            /**
5821             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63;.
5822             *
5823             * @param resourcePrimKey the resource prim key
5824             * @param nodeId the node ID
5825             * @param version the version
5826             * @return the number of matching wiki pages
5827             * @throws SystemException if a system exception occurred
5828             */
5829            public int countByR_N_V(long resourcePrimKey, long nodeId, double version)
5830                    throws SystemException {
5831                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_N_V;
5832    
5833                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, version };
5834    
5835                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5836                                    this);
5837    
5838                    if (count == null) {
5839                            StringBundler query = new StringBundler(4);
5840    
5841                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
5842    
5843                            query.append(_FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2);
5844    
5845                            query.append(_FINDER_COLUMN_R_N_V_NODEID_2);
5846    
5847                            query.append(_FINDER_COLUMN_R_N_V_VERSION_2);
5848    
5849                            String sql = query.toString();
5850    
5851                            Session session = null;
5852    
5853                            try {
5854                                    session = openSession();
5855    
5856                                    Query q = session.createQuery(sql);
5857    
5858                                    QueryPos qPos = QueryPos.getInstance(q);
5859    
5860                                    qPos.add(resourcePrimKey);
5861    
5862                                    qPos.add(nodeId);
5863    
5864                                    qPos.add(version);
5865    
5866                                    count = (Long)q.uniqueResult();
5867    
5868                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5869                            }
5870                            catch (Exception e) {
5871                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5872    
5873                                    throw processException(e);
5874                            }
5875                            finally {
5876                                    closeSession(session);
5877                            }
5878                    }
5879    
5880                    return count.intValue();
5881            }
5882    
5883            private static final String _FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
5884            private static final String _FINDER_COLUMN_R_N_V_NODEID_2 = "wikiPage.nodeId = ? AND ";
5885            private static final String _FINDER_COLUMN_R_N_V_VERSION_2 = "wikiPage.version = ?";
5886            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5887                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
5888                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_N_H",
5889                            new String[] {
5890                                    Long.class.getName(), Long.class.getName(),
5891                                    Boolean.class.getName(),
5892                                    
5893                            Integer.class.getName(), Integer.class.getName(),
5894                                    OrderByComparator.class.getName()
5895                            });
5896            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5897                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
5898                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_N_H",
5899                            new String[] {
5900                                    Long.class.getName(), Long.class.getName(),
5901                                    Boolean.class.getName()
5902                            },
5903                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5904                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
5905                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
5906                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
5907                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
5908            public static final FinderPath FINDER_PATH_COUNT_BY_R_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
5909                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
5910                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N_H",
5911                            new String[] {
5912                                    Long.class.getName(), Long.class.getName(),
5913                                    Boolean.class.getName()
5914                            });
5915    
5916            /**
5917             * Returns all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
5918             *
5919             * @param resourcePrimKey the resource prim key
5920             * @param nodeId the node ID
5921             * @param head the head
5922             * @return the matching wiki pages
5923             * @throws SystemException if a system exception occurred
5924             */
5925            public List<WikiPage> findByR_N_H(long resourcePrimKey, long nodeId,
5926                    boolean head) throws SystemException {
5927                    return findByR_N_H(resourcePrimKey, nodeId, head, QueryUtil.ALL_POS,
5928                            QueryUtil.ALL_POS, null);
5929            }
5930    
5931            /**
5932             * Returns a range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
5933             *
5934             * <p>
5935             * 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.
5936             * </p>
5937             *
5938             * @param resourcePrimKey the resource prim key
5939             * @param nodeId the node ID
5940             * @param head the head
5941             * @param start the lower bound of the range of wiki pages
5942             * @param end the upper bound of the range of wiki pages (not inclusive)
5943             * @return the range of matching wiki pages
5944             * @throws SystemException if a system exception occurred
5945             */
5946            public List<WikiPage> findByR_N_H(long resourcePrimKey, long nodeId,
5947                    boolean head, int start, int end) throws SystemException {
5948                    return findByR_N_H(resourcePrimKey, nodeId, head, start, end, null);
5949            }
5950    
5951            /**
5952             * Returns an ordered range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
5953             *
5954             * <p>
5955             * 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.
5956             * </p>
5957             *
5958             * @param resourcePrimKey the resource prim key
5959             * @param nodeId the node ID
5960             * @param head the head
5961             * @param start the lower bound of the range of wiki pages
5962             * @param end the upper bound of the range of wiki pages (not inclusive)
5963             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5964             * @return the ordered range of matching wiki pages
5965             * @throws SystemException if a system exception occurred
5966             */
5967            public List<WikiPage> findByR_N_H(long resourcePrimKey, long nodeId,
5968                    boolean head, int start, int end, OrderByComparator orderByComparator)
5969                    throws SystemException {
5970                    boolean pagination = true;
5971                    FinderPath finderPath = null;
5972                    Object[] finderArgs = null;
5973    
5974                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5975                                    (orderByComparator == null)) {
5976                            pagination = false;
5977                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_H;
5978                            finderArgs = new Object[] { resourcePrimKey, nodeId, head };
5979                    }
5980                    else {
5981                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N_H;
5982                            finderArgs = new Object[] {
5983                                            resourcePrimKey, nodeId, head,
5984                                            
5985                                            start, end, orderByComparator
5986                                    };
5987                    }
5988    
5989                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
5990                                    finderArgs, this);
5991    
5992                    if ((list != null) && !list.isEmpty()) {
5993                            for (WikiPage wikiPage : list) {
5994                                    if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
5995                                                    (nodeId != wikiPage.getNodeId()) ||
5996                                                    (head != wikiPage.getHead())) {
5997                                            list = null;
5998    
5999                                            break;
6000                                    }
6001                            }
6002                    }
6003    
6004                    if (list == null) {
6005                            StringBundler query = null;
6006    
6007                            if (orderByComparator != null) {
6008                                    query = new StringBundler(5 +
6009                                                    (orderByComparator.getOrderByFields().length * 3));
6010                            }
6011                            else {
6012                                    query = new StringBundler(5);
6013                            }
6014    
6015                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6016    
6017                            query.append(_FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2);
6018    
6019                            query.append(_FINDER_COLUMN_R_N_H_NODEID_2);
6020    
6021                            query.append(_FINDER_COLUMN_R_N_H_HEAD_2);
6022    
6023                            if (orderByComparator != null) {
6024                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6025                                            orderByComparator);
6026                            }
6027                            else
6028                             if (pagination) {
6029                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6030                            }
6031    
6032                            String sql = query.toString();
6033    
6034                            Session session = null;
6035    
6036                            try {
6037                                    session = openSession();
6038    
6039                                    Query q = session.createQuery(sql);
6040    
6041                                    QueryPos qPos = QueryPos.getInstance(q);
6042    
6043                                    qPos.add(resourcePrimKey);
6044    
6045                                    qPos.add(nodeId);
6046    
6047                                    qPos.add(head);
6048    
6049                                    if (!pagination) {
6050                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
6051                                                            start, end, false);
6052    
6053                                            Collections.sort(list);
6054    
6055                                            list = new UnmodifiableList<WikiPage>(list);
6056                                    }
6057                                    else {
6058                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
6059                                                            start, end);
6060                                    }
6061    
6062                                    cacheResult(list);
6063    
6064                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6065                            }
6066                            catch (Exception e) {
6067                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6068    
6069                                    throw processException(e);
6070                            }
6071                            finally {
6072                                    closeSession(session);
6073                            }
6074                    }
6075    
6076                    return list;
6077            }
6078    
6079            /**
6080             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
6081             *
6082             * @param resourcePrimKey the resource prim key
6083             * @param nodeId the node ID
6084             * @param head the head
6085             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6086             * @return the first matching wiki page
6087             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6088             * @throws SystemException if a system exception occurred
6089             */
6090            public WikiPage findByR_N_H_First(long resourcePrimKey, long nodeId,
6091                    boolean head, OrderByComparator orderByComparator)
6092                    throws NoSuchPageException, SystemException {
6093                    WikiPage wikiPage = fetchByR_N_H_First(resourcePrimKey, nodeId, head,
6094                                    orderByComparator);
6095    
6096                    if (wikiPage != null) {
6097                            return wikiPage;
6098                    }
6099    
6100                    StringBundler msg = new StringBundler(8);
6101    
6102                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6103    
6104                    msg.append("resourcePrimKey=");
6105                    msg.append(resourcePrimKey);
6106    
6107                    msg.append(", nodeId=");
6108                    msg.append(nodeId);
6109    
6110                    msg.append(", head=");
6111                    msg.append(head);
6112    
6113                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6114    
6115                    throw new NoSuchPageException(msg.toString());
6116            }
6117    
6118            /**
6119             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
6120             *
6121             * @param resourcePrimKey the resource prim key
6122             * @param nodeId the node ID
6123             * @param head the head
6124             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6125             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
6126             * @throws SystemException if a system exception occurred
6127             */
6128            public WikiPage fetchByR_N_H_First(long resourcePrimKey, long nodeId,
6129                    boolean head, OrderByComparator orderByComparator)
6130                    throws SystemException {
6131                    List<WikiPage> list = findByR_N_H(resourcePrimKey, nodeId, head, 0, 1,
6132                                    orderByComparator);
6133    
6134                    if (!list.isEmpty()) {
6135                            return list.get(0);
6136                    }
6137    
6138                    return null;
6139            }
6140    
6141            /**
6142             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
6143             *
6144             * @param resourcePrimKey the resource prim key
6145             * @param nodeId the node ID
6146             * @param head the head
6147             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6148             * @return the last matching wiki page
6149             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6150             * @throws SystemException if a system exception occurred
6151             */
6152            public WikiPage findByR_N_H_Last(long resourcePrimKey, long nodeId,
6153                    boolean head, OrderByComparator orderByComparator)
6154                    throws NoSuchPageException, SystemException {
6155                    WikiPage wikiPage = fetchByR_N_H_Last(resourcePrimKey, nodeId, head,
6156                                    orderByComparator);
6157    
6158                    if (wikiPage != null) {
6159                            return wikiPage;
6160                    }
6161    
6162                    StringBundler msg = new StringBundler(8);
6163    
6164                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6165    
6166                    msg.append("resourcePrimKey=");
6167                    msg.append(resourcePrimKey);
6168    
6169                    msg.append(", nodeId=");
6170                    msg.append(nodeId);
6171    
6172                    msg.append(", head=");
6173                    msg.append(head);
6174    
6175                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6176    
6177                    throw new NoSuchPageException(msg.toString());
6178            }
6179    
6180            /**
6181             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
6182             *
6183             * @param resourcePrimKey the resource prim key
6184             * @param nodeId the node ID
6185             * @param head the head
6186             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6187             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
6188             * @throws SystemException if a system exception occurred
6189             */
6190            public WikiPage fetchByR_N_H_Last(long resourcePrimKey, long nodeId,
6191                    boolean head, OrderByComparator orderByComparator)
6192                    throws SystemException {
6193                    int count = countByR_N_H(resourcePrimKey, nodeId, head);
6194    
6195                    List<WikiPage> list = findByR_N_H(resourcePrimKey, nodeId, head,
6196                                    count - 1, count, orderByComparator);
6197    
6198                    if (!list.isEmpty()) {
6199                            return list.get(0);
6200                    }
6201    
6202                    return null;
6203            }
6204    
6205            /**
6206             * Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
6207             *
6208             * @param pageId the primary key of the current wiki page
6209             * @param resourcePrimKey the resource prim key
6210             * @param nodeId the node ID
6211             * @param head the head
6212             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6213             * @return the previous, current, and next wiki page
6214             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
6215             * @throws SystemException if a system exception occurred
6216             */
6217            public WikiPage[] findByR_N_H_PrevAndNext(long pageId,
6218                    long resourcePrimKey, long nodeId, boolean head,
6219                    OrderByComparator orderByComparator)
6220                    throws NoSuchPageException, SystemException {
6221                    WikiPage wikiPage = findByPrimaryKey(pageId);
6222    
6223                    Session session = null;
6224    
6225                    try {
6226                            session = openSession();
6227    
6228                            WikiPage[] array = new WikiPageImpl[3];
6229    
6230                            array[0] = getByR_N_H_PrevAndNext(session, wikiPage,
6231                                            resourcePrimKey, nodeId, head, orderByComparator, true);
6232    
6233                            array[1] = wikiPage;
6234    
6235                            array[2] = getByR_N_H_PrevAndNext(session, wikiPage,
6236                                            resourcePrimKey, nodeId, head, orderByComparator, false);
6237    
6238                            return array;
6239                    }
6240                    catch (Exception e) {
6241                            throw processException(e);
6242                    }
6243                    finally {
6244                            closeSession(session);
6245                    }
6246            }
6247    
6248            protected WikiPage getByR_N_H_PrevAndNext(Session session,
6249                    WikiPage wikiPage, long resourcePrimKey, long nodeId, boolean head,
6250                    OrderByComparator orderByComparator, boolean previous) {
6251                    StringBundler query = null;
6252    
6253                    if (orderByComparator != null) {
6254                            query = new StringBundler(6 +
6255                                            (orderByComparator.getOrderByFields().length * 6));
6256                    }
6257                    else {
6258                            query = new StringBundler(3);
6259                    }
6260    
6261                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6262    
6263                    query.append(_FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2);
6264    
6265                    query.append(_FINDER_COLUMN_R_N_H_NODEID_2);
6266    
6267                    query.append(_FINDER_COLUMN_R_N_H_HEAD_2);
6268    
6269                    if (orderByComparator != null) {
6270                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6271    
6272                            if (orderByConditionFields.length > 0) {
6273                                    query.append(WHERE_AND);
6274                            }
6275    
6276                            for (int i = 0; i < orderByConditionFields.length; i++) {
6277                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6278                                    query.append(orderByConditionFields[i]);
6279    
6280                                    if ((i + 1) < orderByConditionFields.length) {
6281                                            if (orderByComparator.isAscending() ^ previous) {
6282                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6283                                            }
6284                                            else {
6285                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6286                                            }
6287                                    }
6288                                    else {
6289                                            if (orderByComparator.isAscending() ^ previous) {
6290                                                    query.append(WHERE_GREATER_THAN);
6291                                            }
6292                                            else {
6293                                                    query.append(WHERE_LESSER_THAN);
6294                                            }
6295                                    }
6296                            }
6297    
6298                            query.append(ORDER_BY_CLAUSE);
6299    
6300                            String[] orderByFields = orderByComparator.getOrderByFields();
6301    
6302                            for (int i = 0; i < orderByFields.length; i++) {
6303                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6304                                    query.append(orderByFields[i]);
6305    
6306                                    if ((i + 1) < orderByFields.length) {
6307                                            if (orderByComparator.isAscending() ^ previous) {
6308                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6309                                            }
6310                                            else {
6311                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6312                                            }
6313                                    }
6314                                    else {
6315                                            if (orderByComparator.isAscending() ^ previous) {
6316                                                    query.append(ORDER_BY_ASC);
6317                                            }
6318                                            else {
6319                                                    query.append(ORDER_BY_DESC);
6320                                            }
6321                                    }
6322                            }
6323                    }
6324                    else {
6325                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6326                    }
6327    
6328                    String sql = query.toString();
6329    
6330                    Query q = session.createQuery(sql);
6331    
6332                    q.setFirstResult(0);
6333                    q.setMaxResults(2);
6334    
6335                    QueryPos qPos = QueryPos.getInstance(q);
6336    
6337                    qPos.add(resourcePrimKey);
6338    
6339                    qPos.add(nodeId);
6340    
6341                    qPos.add(head);
6342    
6343                    if (orderByComparator != null) {
6344                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
6345    
6346                            for (Object value : values) {
6347                                    qPos.add(value);
6348                            }
6349                    }
6350    
6351                    List<WikiPage> list = q.list();
6352    
6353                    if (list.size() == 2) {
6354                            return list.get(1);
6355                    }
6356                    else {
6357                            return null;
6358                    }
6359            }
6360    
6361            /**
6362             * Removes all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63; from the database.
6363             *
6364             * @param resourcePrimKey the resource prim key
6365             * @param nodeId the node ID
6366             * @param head the head
6367             * @throws SystemException if a system exception occurred
6368             */
6369            public void removeByR_N_H(long resourcePrimKey, long nodeId, boolean head)
6370                    throws SystemException {
6371                    for (WikiPage wikiPage : findByR_N_H(resourcePrimKey, nodeId, head,
6372                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6373                            remove(wikiPage);
6374                    }
6375            }
6376    
6377            /**
6378             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and head = &#63;.
6379             *
6380             * @param resourcePrimKey the resource prim key
6381             * @param nodeId the node ID
6382             * @param head the head
6383             * @return the number of matching wiki pages
6384             * @throws SystemException if a system exception occurred
6385             */
6386            public int countByR_N_H(long resourcePrimKey, long nodeId, boolean head)
6387                    throws SystemException {
6388                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_N_H;
6389    
6390                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, head };
6391    
6392                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6393                                    this);
6394    
6395                    if (count == null) {
6396                            StringBundler query = new StringBundler(4);
6397    
6398                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
6399    
6400                            query.append(_FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2);
6401    
6402                            query.append(_FINDER_COLUMN_R_N_H_NODEID_2);
6403    
6404                            query.append(_FINDER_COLUMN_R_N_H_HEAD_2);
6405    
6406                            String sql = query.toString();
6407    
6408                            Session session = null;
6409    
6410                            try {
6411                                    session = openSession();
6412    
6413                                    Query q = session.createQuery(sql);
6414    
6415                                    QueryPos qPos = QueryPos.getInstance(q);
6416    
6417                                    qPos.add(resourcePrimKey);
6418    
6419                                    qPos.add(nodeId);
6420    
6421                                    qPos.add(head);
6422    
6423                                    count = (Long)q.uniqueResult();
6424    
6425                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6426                            }
6427                            catch (Exception e) {
6428                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6429    
6430                                    throw processException(e);
6431                            }
6432                            finally {
6433                                    closeSession(session);
6434                            }
6435                    }
6436    
6437                    return count.intValue();
6438            }
6439    
6440            private static final String _FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
6441            private static final String _FINDER_COLUMN_R_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
6442            private static final String _FINDER_COLUMN_R_N_H_HEAD_2 = "wikiPage.head = ?";
6443            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6444                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
6445                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_N_S",
6446                            new String[] {
6447                                    Long.class.getName(), Long.class.getName(),
6448                                    Integer.class.getName(),
6449                                    
6450                            Integer.class.getName(), Integer.class.getName(),
6451                                    OrderByComparator.class.getName()
6452                            });
6453            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6454                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
6455                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_N_S",
6456                            new String[] {
6457                                    Long.class.getName(), Long.class.getName(),
6458                                    Integer.class.getName()
6459                            },
6460                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
6461                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
6462                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
6463                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
6464                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
6465            public static final FinderPath FINDER_PATH_COUNT_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
6466                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
6467                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N_S",
6468                            new String[] {
6469                                    Long.class.getName(), Long.class.getName(),
6470                                    Integer.class.getName()
6471                            });
6472    
6473            /**
6474             * Returns all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6475             *
6476             * @param resourcePrimKey the resource prim key
6477             * @param nodeId the node ID
6478             * @param status the status
6479             * @return the matching wiki pages
6480             * @throws SystemException if a system exception occurred
6481             */
6482            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
6483                    int status) throws SystemException {
6484                    return findByR_N_S(resourcePrimKey, nodeId, status, QueryUtil.ALL_POS,
6485                            QueryUtil.ALL_POS, null);
6486            }
6487    
6488            /**
6489             * Returns a range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6490             *
6491             * <p>
6492             * 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.
6493             * </p>
6494             *
6495             * @param resourcePrimKey the resource prim key
6496             * @param nodeId the node ID
6497             * @param status the status
6498             * @param start the lower bound of the range of wiki pages
6499             * @param end the upper bound of the range of wiki pages (not inclusive)
6500             * @return the range of matching wiki pages
6501             * @throws SystemException if a system exception occurred
6502             */
6503            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
6504                    int status, int start, int end) throws SystemException {
6505                    return findByR_N_S(resourcePrimKey, nodeId, status, start, end, null);
6506            }
6507    
6508            /**
6509             * Returns an ordered range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6510             *
6511             * <p>
6512             * 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.
6513             * </p>
6514             *
6515             * @param resourcePrimKey the resource prim key
6516             * @param nodeId the node ID
6517             * @param status the status
6518             * @param start the lower bound of the range of wiki pages
6519             * @param end the upper bound of the range of wiki pages (not inclusive)
6520             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6521             * @return the ordered range of matching wiki pages
6522             * @throws SystemException if a system exception occurred
6523             */
6524            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
6525                    int status, int start, int end, OrderByComparator orderByComparator)
6526                    throws SystemException {
6527                    boolean pagination = true;
6528                    FinderPath finderPath = null;
6529                    Object[] finderArgs = null;
6530    
6531                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6532                                    (orderByComparator == null)) {
6533                            pagination = false;
6534                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S;
6535                            finderArgs = new Object[] { resourcePrimKey, nodeId, status };
6536                    }
6537                    else {
6538                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N_S;
6539                            finderArgs = new Object[] {
6540                                            resourcePrimKey, nodeId, status,
6541                                            
6542                                            start, end, orderByComparator
6543                                    };
6544                    }
6545    
6546                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
6547                                    finderArgs, this);
6548    
6549                    if ((list != null) && !list.isEmpty()) {
6550                            for (WikiPage wikiPage : list) {
6551                                    if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
6552                                                    (nodeId != wikiPage.getNodeId()) ||
6553                                                    (status != wikiPage.getStatus())) {
6554                                            list = null;
6555    
6556                                            break;
6557                                    }
6558                            }
6559                    }
6560    
6561                    if (list == null) {
6562                            StringBundler query = null;
6563    
6564                            if (orderByComparator != null) {
6565                                    query = new StringBundler(5 +
6566                                                    (orderByComparator.getOrderByFields().length * 3));
6567                            }
6568                            else {
6569                                    query = new StringBundler(5);
6570                            }
6571    
6572                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6573    
6574                            query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
6575    
6576                            query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
6577    
6578                            query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
6579    
6580                            if (orderByComparator != null) {
6581                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6582                                            orderByComparator);
6583                            }
6584                            else
6585                             if (pagination) {
6586                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6587                            }
6588    
6589                            String sql = query.toString();
6590    
6591                            Session session = null;
6592    
6593                            try {
6594                                    session = openSession();
6595    
6596                                    Query q = session.createQuery(sql);
6597    
6598                                    QueryPos qPos = QueryPos.getInstance(q);
6599    
6600                                    qPos.add(resourcePrimKey);
6601    
6602                                    qPos.add(nodeId);
6603    
6604                                    qPos.add(status);
6605    
6606                                    if (!pagination) {
6607                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
6608                                                            start, end, false);
6609    
6610                                            Collections.sort(list);
6611    
6612                                            list = new UnmodifiableList<WikiPage>(list);
6613                                    }
6614                                    else {
6615                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
6616                                                            start, end);
6617                                    }
6618    
6619                                    cacheResult(list);
6620    
6621                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6622                            }
6623                            catch (Exception e) {
6624                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6625    
6626                                    throw processException(e);
6627                            }
6628                            finally {
6629                                    closeSession(session);
6630                            }
6631                    }
6632    
6633                    return list;
6634            }
6635    
6636            /**
6637             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6638             *
6639             * @param resourcePrimKey the resource prim key
6640             * @param nodeId the node ID
6641             * @param status the status
6642             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6643             * @return the first matching wiki page
6644             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6645             * @throws SystemException if a system exception occurred
6646             */
6647            public WikiPage findByR_N_S_First(long resourcePrimKey, long nodeId,
6648                    int status, OrderByComparator orderByComparator)
6649                    throws NoSuchPageException, SystemException {
6650                    WikiPage wikiPage = fetchByR_N_S_First(resourcePrimKey, nodeId, status,
6651                                    orderByComparator);
6652    
6653                    if (wikiPage != null) {
6654                            return wikiPage;
6655                    }
6656    
6657                    StringBundler msg = new StringBundler(8);
6658    
6659                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6660    
6661                    msg.append("resourcePrimKey=");
6662                    msg.append(resourcePrimKey);
6663    
6664                    msg.append(", nodeId=");
6665                    msg.append(nodeId);
6666    
6667                    msg.append(", status=");
6668                    msg.append(status);
6669    
6670                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6671    
6672                    throw new NoSuchPageException(msg.toString());
6673            }
6674    
6675            /**
6676             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6677             *
6678             * @param resourcePrimKey the resource prim key
6679             * @param nodeId the node ID
6680             * @param status the status
6681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6682             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
6683             * @throws SystemException if a system exception occurred
6684             */
6685            public WikiPage fetchByR_N_S_First(long resourcePrimKey, long nodeId,
6686                    int status, OrderByComparator orderByComparator)
6687                    throws SystemException {
6688                    List<WikiPage> list = findByR_N_S(resourcePrimKey, nodeId, status, 0,
6689                                    1, orderByComparator);
6690    
6691                    if (!list.isEmpty()) {
6692                            return list.get(0);
6693                    }
6694    
6695                    return null;
6696            }
6697    
6698            /**
6699             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6700             *
6701             * @param resourcePrimKey the resource prim key
6702             * @param nodeId the node ID
6703             * @param status the status
6704             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6705             * @return the last matching wiki page
6706             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6707             * @throws SystemException if a system exception occurred
6708             */
6709            public WikiPage findByR_N_S_Last(long resourcePrimKey, long nodeId,
6710                    int status, OrderByComparator orderByComparator)
6711                    throws NoSuchPageException, SystemException {
6712                    WikiPage wikiPage = fetchByR_N_S_Last(resourcePrimKey, nodeId, status,
6713                                    orderByComparator);
6714    
6715                    if (wikiPage != null) {
6716                            return wikiPage;
6717                    }
6718    
6719                    StringBundler msg = new StringBundler(8);
6720    
6721                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6722    
6723                    msg.append("resourcePrimKey=");
6724                    msg.append(resourcePrimKey);
6725    
6726                    msg.append(", nodeId=");
6727                    msg.append(nodeId);
6728    
6729                    msg.append(", status=");
6730                    msg.append(status);
6731    
6732                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6733    
6734                    throw new NoSuchPageException(msg.toString());
6735            }
6736    
6737            /**
6738             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6739             *
6740             * @param resourcePrimKey the resource prim key
6741             * @param nodeId the node ID
6742             * @param status the status
6743             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6744             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
6745             * @throws SystemException if a system exception occurred
6746             */
6747            public WikiPage fetchByR_N_S_Last(long resourcePrimKey, long nodeId,
6748                    int status, OrderByComparator orderByComparator)
6749                    throws SystemException {
6750                    int count = countByR_N_S(resourcePrimKey, nodeId, status);
6751    
6752                    List<WikiPage> list = findByR_N_S(resourcePrimKey, nodeId, status,
6753                                    count - 1, count, orderByComparator);
6754    
6755                    if (!list.isEmpty()) {
6756                            return list.get(0);
6757                    }
6758    
6759                    return null;
6760            }
6761    
6762            /**
6763             * Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6764             *
6765             * @param pageId the primary key of the current wiki page
6766             * @param resourcePrimKey the resource prim key
6767             * @param nodeId the node ID
6768             * @param status the status
6769             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6770             * @return the previous, current, and next wiki page
6771             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
6772             * @throws SystemException if a system exception occurred
6773             */
6774            public WikiPage[] findByR_N_S_PrevAndNext(long pageId,
6775                    long resourcePrimKey, long nodeId, int status,
6776                    OrderByComparator orderByComparator)
6777                    throws NoSuchPageException, SystemException {
6778                    WikiPage wikiPage = findByPrimaryKey(pageId);
6779    
6780                    Session session = null;
6781    
6782                    try {
6783                            session = openSession();
6784    
6785                            WikiPage[] array = new WikiPageImpl[3];
6786    
6787                            array[0] = getByR_N_S_PrevAndNext(session, wikiPage,
6788                                            resourcePrimKey, nodeId, status, orderByComparator, true);
6789    
6790                            array[1] = wikiPage;
6791    
6792                            array[2] = getByR_N_S_PrevAndNext(session, wikiPage,
6793                                            resourcePrimKey, nodeId, status, orderByComparator, false);
6794    
6795                            return array;
6796                    }
6797                    catch (Exception e) {
6798                            throw processException(e);
6799                    }
6800                    finally {
6801                            closeSession(session);
6802                    }
6803            }
6804    
6805            protected WikiPage getByR_N_S_PrevAndNext(Session session,
6806                    WikiPage wikiPage, long resourcePrimKey, long nodeId, int status,
6807                    OrderByComparator orderByComparator, boolean previous) {
6808                    StringBundler query = null;
6809    
6810                    if (orderByComparator != null) {
6811                            query = new StringBundler(6 +
6812                                            (orderByComparator.getOrderByFields().length * 6));
6813                    }
6814                    else {
6815                            query = new StringBundler(3);
6816                    }
6817    
6818                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6819    
6820                    query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
6821    
6822                    query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
6823    
6824                    query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
6825    
6826                    if (orderByComparator != null) {
6827                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6828    
6829                            if (orderByConditionFields.length > 0) {
6830                                    query.append(WHERE_AND);
6831                            }
6832    
6833                            for (int i = 0; i < orderByConditionFields.length; i++) {
6834                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6835                                    query.append(orderByConditionFields[i]);
6836    
6837                                    if ((i + 1) < orderByConditionFields.length) {
6838                                            if (orderByComparator.isAscending() ^ previous) {
6839                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6840                                            }
6841                                            else {
6842                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6843                                            }
6844                                    }
6845                                    else {
6846                                            if (orderByComparator.isAscending() ^ previous) {
6847                                                    query.append(WHERE_GREATER_THAN);
6848                                            }
6849                                            else {
6850                                                    query.append(WHERE_LESSER_THAN);
6851                                            }
6852                                    }
6853                            }
6854    
6855                            query.append(ORDER_BY_CLAUSE);
6856    
6857                            String[] orderByFields = orderByComparator.getOrderByFields();
6858    
6859                            for (int i = 0; i < orderByFields.length; i++) {
6860                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6861                                    query.append(orderByFields[i]);
6862    
6863                                    if ((i + 1) < orderByFields.length) {
6864                                            if (orderByComparator.isAscending() ^ previous) {
6865                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6866                                            }
6867                                            else {
6868                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6869                                            }
6870                                    }
6871                                    else {
6872                                            if (orderByComparator.isAscending() ^ previous) {
6873                                                    query.append(ORDER_BY_ASC);
6874                                            }
6875                                            else {
6876                                                    query.append(ORDER_BY_DESC);
6877                                            }
6878                                    }
6879                            }
6880                    }
6881                    else {
6882                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6883                    }
6884    
6885                    String sql = query.toString();
6886    
6887                    Query q = session.createQuery(sql);
6888    
6889                    q.setFirstResult(0);
6890                    q.setMaxResults(2);
6891    
6892                    QueryPos qPos = QueryPos.getInstance(q);
6893    
6894                    qPos.add(resourcePrimKey);
6895    
6896                    qPos.add(nodeId);
6897    
6898                    qPos.add(status);
6899    
6900                    if (orderByComparator != null) {
6901                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
6902    
6903                            for (Object value : values) {
6904                                    qPos.add(value);
6905                            }
6906                    }
6907    
6908                    List<WikiPage> list = q.list();
6909    
6910                    if (list.size() == 2) {
6911                            return list.get(1);
6912                    }
6913                    else {
6914                            return null;
6915                    }
6916            }
6917    
6918            /**
6919             * Removes all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63; from the database.
6920             *
6921             * @param resourcePrimKey the resource prim key
6922             * @param nodeId the node ID
6923             * @param status the status
6924             * @throws SystemException if a system exception occurred
6925             */
6926            public void removeByR_N_S(long resourcePrimKey, long nodeId, int status)
6927                    throws SystemException {
6928                    for (WikiPage wikiPage : findByR_N_S(resourcePrimKey, nodeId, status,
6929                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6930                            remove(wikiPage);
6931                    }
6932            }
6933    
6934            /**
6935             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6936             *
6937             * @param resourcePrimKey the resource prim key
6938             * @param nodeId the node ID
6939             * @param status the status
6940             * @return the number of matching wiki pages
6941             * @throws SystemException if a system exception occurred
6942             */
6943            public int countByR_N_S(long resourcePrimKey, long nodeId, int status)
6944                    throws SystemException {
6945                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_N_S;
6946    
6947                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, status };
6948    
6949                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6950                                    this);
6951    
6952                    if (count == null) {
6953                            StringBundler query = new StringBundler(4);
6954    
6955                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
6956    
6957                            query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
6958    
6959                            query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
6960    
6961                            query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
6962    
6963                            String sql = query.toString();
6964    
6965                            Session session = null;
6966    
6967                            try {
6968                                    session = openSession();
6969    
6970                                    Query q = session.createQuery(sql);
6971    
6972                                    QueryPos qPos = QueryPos.getInstance(q);
6973    
6974                                    qPos.add(resourcePrimKey);
6975    
6976                                    qPos.add(nodeId);
6977    
6978                                    qPos.add(status);
6979    
6980                                    count = (Long)q.uniqueResult();
6981    
6982                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6983                            }
6984                            catch (Exception e) {
6985                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6986    
6987                                    throw processException(e);
6988                            }
6989                            finally {
6990                                    closeSession(session);
6991                            }
6992                    }
6993    
6994                    return count.intValue();
6995            }
6996    
6997            private static final String _FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
6998            private static final String _FINDER_COLUMN_R_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
6999            private static final String _FINDER_COLUMN_R_N_S_STATUS_2 = "wikiPage.status = ?";
7000            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
7001                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
7002                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_H",
7003                            new String[] {
7004                                    Long.class.getName(), Long.class.getName(),
7005                                    Boolean.class.getName(),
7006                                    
7007                            Integer.class.getName(), Integer.class.getName(),
7008                                    OrderByComparator.class.getName()
7009                            });
7010            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
7011                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
7012                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_H",
7013                            new String[] {
7014                                    Long.class.getName(), Long.class.getName(),
7015                                    Boolean.class.getName()
7016                            },
7017                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
7018                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
7019                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
7020                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
7021                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
7022            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
7023                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
7024                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_H",
7025                            new String[] {
7026                                    Long.class.getName(), Long.class.getName(),
7027                                    Boolean.class.getName()
7028                            });
7029    
7030            /**
7031             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
7032             *
7033             * @param groupId the group ID
7034             * @param nodeId the node ID
7035             * @param head the head
7036             * @return the matching wiki pages
7037             * @throws SystemException if a system exception occurred
7038             */
7039            public List<WikiPage> findByG_N_H(long groupId, long nodeId, boolean head)
7040                    throws SystemException {
7041                    return findByG_N_H(groupId, nodeId, head, QueryUtil.ALL_POS,
7042                            QueryUtil.ALL_POS, null);
7043            }
7044    
7045            /**
7046             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
7047             *
7048             * <p>
7049             * 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.
7050             * </p>
7051             *
7052             * @param groupId the group ID
7053             * @param nodeId the node ID
7054             * @param head the head
7055             * @param start the lower bound of the range of wiki pages
7056             * @param end the upper bound of the range of wiki pages (not inclusive)
7057             * @return the range of matching wiki pages
7058             * @throws SystemException if a system exception occurred
7059             */
7060            public List<WikiPage> findByG_N_H(long groupId, long nodeId, boolean head,
7061                    int start, int end) throws SystemException {
7062                    return findByG_N_H(groupId, nodeId, head, start, end, null);
7063            }
7064    
7065            /**
7066             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
7067             *
7068             * <p>
7069             * 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.
7070             * </p>
7071             *
7072             * @param groupId the group ID
7073             * @param nodeId the node ID
7074             * @param head the head
7075             * @param start the lower bound of the range of wiki pages
7076             * @param end the upper bound of the range of wiki pages (not inclusive)
7077             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7078             * @return the ordered range of matching wiki pages
7079             * @throws SystemException if a system exception occurred
7080             */
7081            public List<WikiPage> findByG_N_H(long groupId, long nodeId, boolean head,
7082                    int start, int end, OrderByComparator orderByComparator)
7083                    throws SystemException {
7084                    boolean pagination = true;
7085                    FinderPath finderPath = null;
7086                    Object[] finderArgs = null;
7087    
7088                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7089                                    (orderByComparator == null)) {
7090                            pagination = false;
7091                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H;
7092                            finderArgs = new Object[] { groupId, nodeId, head };
7093                    }
7094                    else {
7095                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H;
7096                            finderArgs = new Object[] {
7097                                            groupId, nodeId, head,
7098                                            
7099                                            start, end, orderByComparator
7100                                    };
7101                    }
7102    
7103                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
7104                                    finderArgs, this);
7105    
7106                    if ((list != null) && !list.isEmpty()) {
7107                            for (WikiPage wikiPage : list) {
7108                                    if ((groupId != wikiPage.getGroupId()) ||
7109                                                    (nodeId != wikiPage.getNodeId()) ||
7110                                                    (head != wikiPage.getHead())) {
7111                                            list = null;
7112    
7113                                            break;
7114                                    }
7115                            }
7116                    }
7117    
7118                    if (list == null) {
7119                            StringBundler query = null;
7120    
7121                            if (orderByComparator != null) {
7122                                    query = new StringBundler(5 +
7123                                                    (orderByComparator.getOrderByFields().length * 3));
7124                            }
7125                            else {
7126                                    query = new StringBundler(5);
7127                            }
7128    
7129                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
7130    
7131                            query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
7132    
7133                            query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
7134    
7135                            query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
7136    
7137                            if (orderByComparator != null) {
7138                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7139                                            orderByComparator);
7140                            }
7141                            else
7142                             if (pagination) {
7143                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7144                            }
7145    
7146                            String sql = query.toString();
7147    
7148                            Session session = null;
7149    
7150                            try {
7151                                    session = openSession();
7152    
7153                                    Query q = session.createQuery(sql);
7154    
7155                                    QueryPos qPos = QueryPos.getInstance(q);
7156    
7157                                    qPos.add(groupId);
7158    
7159                                    qPos.add(nodeId);
7160    
7161                                    qPos.add(head);
7162    
7163                                    if (!pagination) {
7164                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
7165                                                            start, end, false);
7166    
7167                                            Collections.sort(list);
7168    
7169                                            list = new UnmodifiableList<WikiPage>(list);
7170                                    }
7171                                    else {
7172                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
7173                                                            start, end);
7174                                    }
7175    
7176                                    cacheResult(list);
7177    
7178                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7179                            }
7180                            catch (Exception e) {
7181                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7182    
7183                                    throw processException(e);
7184                            }
7185                            finally {
7186                                    closeSession(session);
7187                            }
7188                    }
7189    
7190                    return list;
7191            }
7192    
7193            /**
7194             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
7195             *
7196             * @param groupId the group ID
7197             * @param nodeId the node ID
7198             * @param head the head
7199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7200             * @return the first matching wiki page
7201             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7202             * @throws SystemException if a system exception occurred
7203             */
7204            public WikiPage findByG_N_H_First(long groupId, long nodeId, boolean head,
7205                    OrderByComparator orderByComparator)
7206                    throws NoSuchPageException, SystemException {
7207                    WikiPage wikiPage = fetchByG_N_H_First(groupId, nodeId, head,
7208                                    orderByComparator);
7209    
7210                    if (wikiPage != null) {
7211                            return wikiPage;
7212                    }
7213    
7214                    StringBundler msg = new StringBundler(8);
7215    
7216                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7217    
7218                    msg.append("groupId=");
7219                    msg.append(groupId);
7220    
7221                    msg.append(", nodeId=");
7222                    msg.append(nodeId);
7223    
7224                    msg.append(", head=");
7225                    msg.append(head);
7226    
7227                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7228    
7229                    throw new NoSuchPageException(msg.toString());
7230            }
7231    
7232            /**
7233             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
7234             *
7235             * @param groupId the group ID
7236             * @param nodeId the node ID
7237             * @param head the head
7238             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7239             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
7240             * @throws SystemException if a system exception occurred
7241             */
7242            public WikiPage fetchByG_N_H_First(long groupId, long nodeId, boolean head,
7243                    OrderByComparator orderByComparator) throws SystemException {
7244                    List<WikiPage> list = findByG_N_H(groupId, nodeId, head, 0, 1,
7245                                    orderByComparator);
7246    
7247                    if (!list.isEmpty()) {
7248                            return list.get(0);
7249                    }
7250    
7251                    return null;
7252            }
7253    
7254            /**
7255             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
7256             *
7257             * @param groupId the group ID
7258             * @param nodeId the node ID
7259             * @param head the head
7260             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7261             * @return the last matching wiki page
7262             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7263             * @throws SystemException if a system exception occurred
7264             */
7265            public WikiPage findByG_N_H_Last(long groupId, long nodeId, boolean head,
7266                    OrderByComparator orderByComparator)
7267                    throws NoSuchPageException, SystemException {
7268                    WikiPage wikiPage = fetchByG_N_H_Last(groupId, nodeId, head,
7269                                    orderByComparator);
7270    
7271                    if (wikiPage != null) {
7272                            return wikiPage;
7273                    }
7274    
7275                    StringBundler msg = new StringBundler(8);
7276    
7277                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7278    
7279                    msg.append("groupId=");
7280                    msg.append(groupId);
7281    
7282                    msg.append(", nodeId=");
7283                    msg.append(nodeId);
7284    
7285                    msg.append(", head=");
7286                    msg.append(head);
7287    
7288                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7289    
7290                    throw new NoSuchPageException(msg.toString());
7291            }
7292    
7293            /**
7294             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
7295             *
7296             * @param groupId the group ID
7297             * @param nodeId the node ID
7298             * @param head the head
7299             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7300             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
7301             * @throws SystemException if a system exception occurred
7302             */
7303            public WikiPage fetchByG_N_H_Last(long groupId, long nodeId, boolean head,
7304                    OrderByComparator orderByComparator) throws SystemException {
7305                    int count = countByG_N_H(groupId, nodeId, head);
7306    
7307                    List<WikiPage> list = findByG_N_H(groupId, nodeId, head, count - 1,
7308                                    count, orderByComparator);
7309    
7310                    if (!list.isEmpty()) {
7311                            return list.get(0);
7312                    }
7313    
7314                    return null;
7315            }
7316    
7317            /**
7318             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
7319             *
7320             * @param pageId the primary key of the current wiki page
7321             * @param groupId the group ID
7322             * @param nodeId the node ID
7323             * @param head the head
7324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7325             * @return the previous, current, and next wiki page
7326             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
7327             * @throws SystemException if a system exception occurred
7328             */
7329            public WikiPage[] findByG_N_H_PrevAndNext(long pageId, long groupId,
7330                    long nodeId, boolean head, OrderByComparator orderByComparator)
7331                    throws NoSuchPageException, SystemException {
7332                    WikiPage wikiPage = findByPrimaryKey(pageId);
7333    
7334                    Session session = null;
7335    
7336                    try {
7337                            session = openSession();
7338    
7339                            WikiPage[] array = new WikiPageImpl[3];
7340    
7341                            array[0] = getByG_N_H_PrevAndNext(session, wikiPage, groupId,
7342                                            nodeId, head, orderByComparator, true);
7343    
7344                            array[1] = wikiPage;
7345    
7346                            array[2] = getByG_N_H_PrevAndNext(session, wikiPage, groupId,
7347                                            nodeId, head, orderByComparator, false);
7348    
7349                            return array;
7350                    }
7351                    catch (Exception e) {
7352                            throw processException(e);
7353                    }
7354                    finally {
7355                            closeSession(session);
7356                    }
7357            }
7358    
7359            protected WikiPage getByG_N_H_PrevAndNext(Session session,
7360                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
7361                    OrderByComparator orderByComparator, boolean previous) {
7362                    StringBundler query = null;
7363    
7364                    if (orderByComparator != null) {
7365                            query = new StringBundler(6 +
7366                                            (orderByComparator.getOrderByFields().length * 6));
7367                    }
7368                    else {
7369                            query = new StringBundler(3);
7370                    }
7371    
7372                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
7373    
7374                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
7375    
7376                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
7377    
7378                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
7379    
7380                    if (orderByComparator != null) {
7381                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7382    
7383                            if (orderByConditionFields.length > 0) {
7384                                    query.append(WHERE_AND);
7385                            }
7386    
7387                            for (int i = 0; i < orderByConditionFields.length; i++) {
7388                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7389                                    query.append(orderByConditionFields[i]);
7390    
7391                                    if ((i + 1) < orderByConditionFields.length) {
7392                                            if (orderByComparator.isAscending() ^ previous) {
7393                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7394                                            }
7395                                            else {
7396                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7397                                            }
7398                                    }
7399                                    else {
7400                                            if (orderByComparator.isAscending() ^ previous) {
7401                                                    query.append(WHERE_GREATER_THAN);
7402                                            }
7403                                            else {
7404                                                    query.append(WHERE_LESSER_THAN);
7405                                            }
7406                                    }
7407                            }
7408    
7409                            query.append(ORDER_BY_CLAUSE);
7410    
7411                            String[] orderByFields = orderByComparator.getOrderByFields();
7412    
7413                            for (int i = 0; i < orderByFields.length; i++) {
7414                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7415                                    query.append(orderByFields[i]);
7416    
7417                                    if ((i + 1) < orderByFields.length) {
7418                                            if (orderByComparator.isAscending() ^ previous) {
7419                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7420                                            }
7421                                            else {
7422                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7423                                            }
7424                                    }
7425                                    else {
7426                                            if (orderByComparator.isAscending() ^ previous) {
7427                                                    query.append(ORDER_BY_ASC);
7428                                            }
7429                                            else {
7430                                                    query.append(ORDER_BY_DESC);
7431                                            }
7432                                    }
7433                            }
7434                    }
7435                    else {
7436                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7437                    }
7438    
7439                    String sql = query.toString();
7440    
7441                    Query q = session.createQuery(sql);
7442    
7443                    q.setFirstResult(0);
7444                    q.setMaxResults(2);
7445    
7446                    QueryPos qPos = QueryPos.getInstance(q);
7447    
7448                    qPos.add(groupId);
7449    
7450                    qPos.add(nodeId);
7451    
7452                    qPos.add(head);
7453    
7454                    if (orderByComparator != null) {
7455                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
7456    
7457                            for (Object value : values) {
7458                                    qPos.add(value);
7459                            }
7460                    }
7461    
7462                    List<WikiPage> list = q.list();
7463    
7464                    if (list.size() == 2) {
7465                            return list.get(1);
7466                    }
7467                    else {
7468                            return null;
7469                    }
7470            }
7471    
7472            /**
7473             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
7474             *
7475             * @param groupId the group ID
7476             * @param nodeId the node ID
7477             * @param head the head
7478             * @return the matching wiki pages that the user has permission to view
7479             * @throws SystemException if a system exception occurred
7480             */
7481            public List<WikiPage> filterFindByG_N_H(long groupId, long nodeId,
7482                    boolean head) throws SystemException {
7483                    return filterFindByG_N_H(groupId, nodeId, head, QueryUtil.ALL_POS,
7484                            QueryUtil.ALL_POS, null);
7485            }
7486    
7487            /**
7488             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
7489             *
7490             * <p>
7491             * 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.
7492             * </p>
7493             *
7494             * @param groupId the group ID
7495             * @param nodeId the node ID
7496             * @param head the head
7497             * @param start the lower bound of the range of wiki pages
7498             * @param end the upper bound of the range of wiki pages (not inclusive)
7499             * @return the range of matching wiki pages that the user has permission to view
7500             * @throws SystemException if a system exception occurred
7501             */
7502            public List<WikiPage> filterFindByG_N_H(long groupId, long nodeId,
7503                    boolean head, int start, int end) throws SystemException {
7504                    return filterFindByG_N_H(groupId, nodeId, head, start, end, null);
7505            }
7506    
7507            /**
7508             * 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;.
7509             *
7510             * <p>
7511             * 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.
7512             * </p>
7513             *
7514             * @param groupId the group ID
7515             * @param nodeId the node ID
7516             * @param head the head
7517             * @param start the lower bound of the range of wiki pages
7518             * @param end the upper bound of the range of wiki pages (not inclusive)
7519             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7520             * @return the ordered range of matching wiki pages that the user has permission to view
7521             * @throws SystemException if a system exception occurred
7522             */
7523            public List<WikiPage> filterFindByG_N_H(long groupId, long nodeId,
7524                    boolean head, int start, int end, OrderByComparator orderByComparator)
7525                    throws SystemException {
7526                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7527                            return findByG_N_H(groupId, nodeId, head, start, end,
7528                                    orderByComparator);
7529                    }
7530    
7531                    StringBundler query = null;
7532    
7533                    if (orderByComparator != null) {
7534                            query = new StringBundler(5 +
7535                                            (orderByComparator.getOrderByFields().length * 3));
7536                    }
7537                    else {
7538                            query = new StringBundler(5);
7539                    }
7540    
7541                    if (getDB().isSupportsInlineDistinct()) {
7542                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
7543                    }
7544                    else {
7545                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
7546                    }
7547    
7548                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
7549    
7550                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
7551    
7552                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
7553    
7554                    if (!getDB().isSupportsInlineDistinct()) {
7555                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
7556                    }
7557    
7558                    if (orderByComparator != null) {
7559                            if (getDB().isSupportsInlineDistinct()) {
7560                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7561                                            orderByComparator);
7562                            }
7563                            else {
7564                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7565                                            orderByComparator);
7566                            }
7567                    }
7568                    else {
7569                            if (getDB().isSupportsInlineDistinct()) {
7570                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7571                            }
7572                            else {
7573                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
7574                            }
7575                    }
7576    
7577                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7578                                    WikiPage.class.getName(),
7579                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7580    
7581                    Session session = null;
7582    
7583                    try {
7584                            session = openSession();
7585    
7586                            SQLQuery q = session.createSQLQuery(sql);
7587    
7588                            if (getDB().isSupportsInlineDistinct()) {
7589                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
7590                            }
7591                            else {
7592                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
7593                            }
7594    
7595                            QueryPos qPos = QueryPos.getInstance(q);
7596    
7597                            qPos.add(groupId);
7598    
7599                            qPos.add(nodeId);
7600    
7601                            qPos.add(head);
7602    
7603                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
7604                    }
7605                    catch (Exception e) {
7606                            throw processException(e);
7607                    }
7608                    finally {
7609                            closeSession(session);
7610                    }
7611            }
7612    
7613            /**
7614             * 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;.
7615             *
7616             * @param pageId the primary key of the current wiki page
7617             * @param groupId the group ID
7618             * @param nodeId the node ID
7619             * @param head the head
7620             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7621             * @return the previous, current, and next wiki page
7622             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
7623             * @throws SystemException if a system exception occurred
7624             */
7625            public WikiPage[] filterFindByG_N_H_PrevAndNext(long pageId, long groupId,
7626                    long nodeId, boolean head, OrderByComparator orderByComparator)
7627                    throws NoSuchPageException, SystemException {
7628                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7629                            return findByG_N_H_PrevAndNext(pageId, groupId, nodeId, head,
7630                                    orderByComparator);
7631                    }
7632    
7633                    WikiPage wikiPage = findByPrimaryKey(pageId);
7634    
7635                    Session session = null;
7636    
7637                    try {
7638                            session = openSession();
7639    
7640                            WikiPage[] array = new WikiPageImpl[3];
7641    
7642                            array[0] = filterGetByG_N_H_PrevAndNext(session, wikiPage, groupId,
7643                                            nodeId, head, orderByComparator, true);
7644    
7645                            array[1] = wikiPage;
7646    
7647                            array[2] = filterGetByG_N_H_PrevAndNext(session, wikiPage, groupId,
7648                                            nodeId, head, orderByComparator, false);
7649    
7650                            return array;
7651                    }
7652                    catch (Exception e) {
7653                            throw processException(e);
7654                    }
7655                    finally {
7656                            closeSession(session);
7657                    }
7658            }
7659    
7660            protected WikiPage filterGetByG_N_H_PrevAndNext(Session session,
7661                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
7662                    OrderByComparator orderByComparator, boolean previous) {
7663                    StringBundler query = null;
7664    
7665                    if (orderByComparator != null) {
7666                            query = new StringBundler(6 +
7667                                            (orderByComparator.getOrderByFields().length * 6));
7668                    }
7669                    else {
7670                            query = new StringBundler(3);
7671                    }
7672    
7673                    if (getDB().isSupportsInlineDistinct()) {
7674                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
7675                    }
7676                    else {
7677                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
7678                    }
7679    
7680                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
7681    
7682                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
7683    
7684                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
7685    
7686                    if (!getDB().isSupportsInlineDistinct()) {
7687                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
7688                    }
7689    
7690                    if (orderByComparator != null) {
7691                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7692    
7693                            if (orderByConditionFields.length > 0) {
7694                                    query.append(WHERE_AND);
7695                            }
7696    
7697                            for (int i = 0; i < orderByConditionFields.length; i++) {
7698                                    if (getDB().isSupportsInlineDistinct()) {
7699                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7700                                    }
7701                                    else {
7702                                            query.append(_ORDER_BY_ENTITY_TABLE);
7703                                    }
7704    
7705                                    query.append(orderByConditionFields[i]);
7706    
7707                                    if ((i + 1) < orderByConditionFields.length) {
7708                                            if (orderByComparator.isAscending() ^ previous) {
7709                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7710                                            }
7711                                            else {
7712                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7713                                            }
7714                                    }
7715                                    else {
7716                                            if (orderByComparator.isAscending() ^ previous) {
7717                                                    query.append(WHERE_GREATER_THAN);
7718                                            }
7719                                            else {
7720                                                    query.append(WHERE_LESSER_THAN);
7721                                            }
7722                                    }
7723                            }
7724    
7725                            query.append(ORDER_BY_CLAUSE);
7726    
7727                            String[] orderByFields = orderByComparator.getOrderByFields();
7728    
7729                            for (int i = 0; i < orderByFields.length; i++) {
7730                                    if (getDB().isSupportsInlineDistinct()) {
7731                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7732                                    }
7733                                    else {
7734                                            query.append(_ORDER_BY_ENTITY_TABLE);
7735                                    }
7736    
7737                                    query.append(orderByFields[i]);
7738    
7739                                    if ((i + 1) < orderByFields.length) {
7740                                            if (orderByComparator.isAscending() ^ previous) {
7741                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7742                                            }
7743                                            else {
7744                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7745                                            }
7746                                    }
7747                                    else {
7748                                            if (orderByComparator.isAscending() ^ previous) {
7749                                                    query.append(ORDER_BY_ASC);
7750                                            }
7751                                            else {
7752                                                    query.append(ORDER_BY_DESC);
7753                                            }
7754                                    }
7755                            }
7756                    }
7757                    else {
7758                            if (getDB().isSupportsInlineDistinct()) {
7759                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7760                            }
7761                            else {
7762                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
7763                            }
7764                    }
7765    
7766                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7767                                    WikiPage.class.getName(),
7768                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7769    
7770                    SQLQuery q = session.createSQLQuery(sql);
7771    
7772                    q.setFirstResult(0);
7773                    q.setMaxResults(2);
7774    
7775                    if (getDB().isSupportsInlineDistinct()) {
7776                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
7777                    }
7778                    else {
7779                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
7780                    }
7781    
7782                    QueryPos qPos = QueryPos.getInstance(q);
7783    
7784                    qPos.add(groupId);
7785    
7786                    qPos.add(nodeId);
7787    
7788                    qPos.add(head);
7789    
7790                    if (orderByComparator != null) {
7791                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
7792    
7793                            for (Object value : values) {
7794                                    qPos.add(value);
7795                            }
7796                    }
7797    
7798                    List<WikiPage> list = q.list();
7799    
7800                    if (list.size() == 2) {
7801                            return list.get(1);
7802                    }
7803                    else {
7804                            return null;
7805                    }
7806            }
7807    
7808            /**
7809             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; from the database.
7810             *
7811             * @param groupId the group ID
7812             * @param nodeId the node ID
7813             * @param head the head
7814             * @throws SystemException if a system exception occurred
7815             */
7816            public void removeByG_N_H(long groupId, long nodeId, boolean head)
7817                    throws SystemException {
7818                    for (WikiPage wikiPage : findByG_N_H(groupId, nodeId, head,
7819                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7820                            remove(wikiPage);
7821                    }
7822            }
7823    
7824            /**
7825             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
7826             *
7827             * @param groupId the group ID
7828             * @param nodeId the node ID
7829             * @param head the head
7830             * @return the number of matching wiki pages
7831             * @throws SystemException if a system exception occurred
7832             */
7833            public int countByG_N_H(long groupId, long nodeId, boolean head)
7834                    throws SystemException {
7835                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_H;
7836    
7837                    Object[] finderArgs = new Object[] { groupId, nodeId, head };
7838    
7839                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7840                                    this);
7841    
7842                    if (count == null) {
7843                            StringBundler query = new StringBundler(4);
7844    
7845                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
7846    
7847                            query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
7848    
7849                            query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
7850    
7851                            query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
7852    
7853                            String sql = query.toString();
7854    
7855                            Session session = null;
7856    
7857                            try {
7858                                    session = openSession();
7859    
7860                                    Query q = session.createQuery(sql);
7861    
7862                                    QueryPos qPos = QueryPos.getInstance(q);
7863    
7864                                    qPos.add(groupId);
7865    
7866                                    qPos.add(nodeId);
7867    
7868                                    qPos.add(head);
7869    
7870                                    count = (Long)q.uniqueResult();
7871    
7872                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7873                            }
7874                            catch (Exception e) {
7875                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7876    
7877                                    throw processException(e);
7878                            }
7879                            finally {
7880                                    closeSession(session);
7881                            }
7882                    }
7883    
7884                    return count.intValue();
7885            }
7886    
7887            /**
7888             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
7889             *
7890             * @param groupId the group ID
7891             * @param nodeId the node ID
7892             * @param head the head
7893             * @return the number of matching wiki pages that the user has permission to view
7894             * @throws SystemException if a system exception occurred
7895             */
7896            public int filterCountByG_N_H(long groupId, long nodeId, boolean head)
7897                    throws SystemException {
7898                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7899                            return countByG_N_H(groupId, nodeId, head);
7900                    }
7901    
7902                    StringBundler query = new StringBundler(4);
7903    
7904                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
7905    
7906                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
7907    
7908                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
7909    
7910                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
7911    
7912                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7913                                    WikiPage.class.getName(),
7914                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7915    
7916                    Session session = null;
7917    
7918                    try {
7919                            session = openSession();
7920    
7921                            SQLQuery q = session.createSQLQuery(sql);
7922    
7923                            q.addScalar(COUNT_COLUMN_NAME,
7924                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7925    
7926                            QueryPos qPos = QueryPos.getInstance(q);
7927    
7928                            qPos.add(groupId);
7929    
7930                            qPos.add(nodeId);
7931    
7932                            qPos.add(head);
7933    
7934                            Long count = (Long)q.uniqueResult();
7935    
7936                            return count.intValue();
7937                    }
7938                    catch (Exception e) {
7939                            throw processException(e);
7940                    }
7941                    finally {
7942                            closeSession(session);
7943                    }
7944            }
7945    
7946            private static final String _FINDER_COLUMN_G_N_H_GROUPID_2 = "wikiPage.groupId = ? AND ";
7947            private static final String _FINDER_COLUMN_G_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
7948            private static final String _FINDER_COLUMN_G_N_H_HEAD_2 = "wikiPage.head = ?";
7949            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
7950                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
7951                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_S",
7952                            new String[] {
7953                                    Long.class.getName(), Long.class.getName(),
7954                                    Integer.class.getName(),
7955                                    
7956                            Integer.class.getName(), Integer.class.getName(),
7957                                    OrderByComparator.class.getName()
7958                            });
7959            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
7960                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
7961                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_S",
7962                            new String[] {
7963                                    Long.class.getName(), Long.class.getName(),
7964                                    Integer.class.getName()
7965                            },
7966                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
7967                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
7968                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
7969                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
7970                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
7971            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
7972                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
7973                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_S",
7974                            new String[] {
7975                                    Long.class.getName(), Long.class.getName(),
7976                                    Integer.class.getName()
7977                            });
7978    
7979            /**
7980             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
7981             *
7982             * @param groupId the group ID
7983             * @param nodeId the node ID
7984             * @param status the status
7985             * @return the matching wiki pages
7986             * @throws SystemException if a system exception occurred
7987             */
7988            public List<WikiPage> findByG_N_S(long groupId, long nodeId, int status)
7989                    throws SystemException {
7990                    return findByG_N_S(groupId, nodeId, status, QueryUtil.ALL_POS,
7991                            QueryUtil.ALL_POS, null);
7992            }
7993    
7994            /**
7995             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
7996             *
7997             * <p>
7998             * 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.
7999             * </p>
8000             *
8001             * @param groupId the group ID
8002             * @param nodeId the node ID
8003             * @param status the status
8004             * @param start the lower bound of the range of wiki pages
8005             * @param end the upper bound of the range of wiki pages (not inclusive)
8006             * @return the range of matching wiki pages
8007             * @throws SystemException if a system exception occurred
8008             */
8009            public List<WikiPage> findByG_N_S(long groupId, long nodeId, int status,
8010                    int start, int end) throws SystemException {
8011                    return findByG_N_S(groupId, nodeId, status, start, end, null);
8012            }
8013    
8014            /**
8015             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
8016             *
8017             * <p>
8018             * 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.
8019             * </p>
8020             *
8021             * @param groupId the group ID
8022             * @param nodeId the node ID
8023             * @param status the status
8024             * @param start the lower bound of the range of wiki pages
8025             * @param end the upper bound of the range of wiki pages (not inclusive)
8026             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8027             * @return the ordered range of matching wiki pages
8028             * @throws SystemException if a system exception occurred
8029             */
8030            public List<WikiPage> findByG_N_S(long groupId, long nodeId, int status,
8031                    int start, int end, OrderByComparator orderByComparator)
8032                    throws SystemException {
8033                    boolean pagination = true;
8034                    FinderPath finderPath = null;
8035                    Object[] finderArgs = null;
8036    
8037                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8038                                    (orderByComparator == null)) {
8039                            pagination = false;
8040                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S;
8041                            finderArgs = new Object[] { groupId, nodeId, status };
8042                    }
8043                    else {
8044                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_S;
8045                            finderArgs = new Object[] {
8046                                            groupId, nodeId, status,
8047                                            
8048                                            start, end, orderByComparator
8049                                    };
8050                    }
8051    
8052                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
8053                                    finderArgs, this);
8054    
8055                    if ((list != null) && !list.isEmpty()) {
8056                            for (WikiPage wikiPage : list) {
8057                                    if ((groupId != wikiPage.getGroupId()) ||
8058                                                    (nodeId != wikiPage.getNodeId()) ||
8059                                                    (status != wikiPage.getStatus())) {
8060                                            list = null;
8061    
8062                                            break;
8063                                    }
8064                            }
8065                    }
8066    
8067                    if (list == null) {
8068                            StringBundler query = null;
8069    
8070                            if (orderByComparator != null) {
8071                                    query = new StringBundler(5 +
8072                                                    (orderByComparator.getOrderByFields().length * 3));
8073                            }
8074                            else {
8075                                    query = new StringBundler(5);
8076                            }
8077    
8078                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
8079    
8080                            query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
8081    
8082                            query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
8083    
8084                            query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
8085    
8086                            if (orderByComparator != null) {
8087                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8088                                            orderByComparator);
8089                            }
8090                            else
8091                             if (pagination) {
8092                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8093                            }
8094    
8095                            String sql = query.toString();
8096    
8097                            Session session = null;
8098    
8099                            try {
8100                                    session = openSession();
8101    
8102                                    Query q = session.createQuery(sql);
8103    
8104                                    QueryPos qPos = QueryPos.getInstance(q);
8105    
8106                                    qPos.add(groupId);
8107    
8108                                    qPos.add(nodeId);
8109    
8110                                    qPos.add(status);
8111    
8112                                    if (!pagination) {
8113                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
8114                                                            start, end, false);
8115    
8116                                            Collections.sort(list);
8117    
8118                                            list = new UnmodifiableList<WikiPage>(list);
8119                                    }
8120                                    else {
8121                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
8122                                                            start, end);
8123                                    }
8124    
8125                                    cacheResult(list);
8126    
8127                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8128                            }
8129                            catch (Exception e) {
8130                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8131    
8132                                    throw processException(e);
8133                            }
8134                            finally {
8135                                    closeSession(session);
8136                            }
8137                    }
8138    
8139                    return list;
8140            }
8141    
8142            /**
8143             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
8144             *
8145             * @param groupId the group ID
8146             * @param nodeId the node ID
8147             * @param status the status
8148             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8149             * @return the first matching wiki page
8150             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
8151             * @throws SystemException if a system exception occurred
8152             */
8153            public WikiPage findByG_N_S_First(long groupId, long nodeId, int status,
8154                    OrderByComparator orderByComparator)
8155                    throws NoSuchPageException, SystemException {
8156                    WikiPage wikiPage = fetchByG_N_S_First(groupId, nodeId, status,
8157                                    orderByComparator);
8158    
8159                    if (wikiPage != null) {
8160                            return wikiPage;
8161                    }
8162    
8163                    StringBundler msg = new StringBundler(8);
8164    
8165                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8166    
8167                    msg.append("groupId=");
8168                    msg.append(groupId);
8169    
8170                    msg.append(", nodeId=");
8171                    msg.append(nodeId);
8172    
8173                    msg.append(", status=");
8174                    msg.append(status);
8175    
8176                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8177    
8178                    throw new NoSuchPageException(msg.toString());
8179            }
8180    
8181            /**
8182             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
8183             *
8184             * @param groupId the group ID
8185             * @param nodeId the node ID
8186             * @param status the status
8187             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8188             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
8189             * @throws SystemException if a system exception occurred
8190             */
8191            public WikiPage fetchByG_N_S_First(long groupId, long nodeId, int status,
8192                    OrderByComparator orderByComparator) throws SystemException {
8193                    List<WikiPage> list = findByG_N_S(groupId, nodeId, status, 0, 1,
8194                                    orderByComparator);
8195    
8196                    if (!list.isEmpty()) {
8197                            return list.get(0);
8198                    }
8199    
8200                    return null;
8201            }
8202    
8203            /**
8204             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
8205             *
8206             * @param groupId the group ID
8207             * @param nodeId the node ID
8208             * @param status the status
8209             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8210             * @return the last matching wiki page
8211             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
8212             * @throws SystemException if a system exception occurred
8213             */
8214            public WikiPage findByG_N_S_Last(long groupId, long nodeId, int status,
8215                    OrderByComparator orderByComparator)
8216                    throws NoSuchPageException, SystemException {
8217                    WikiPage wikiPage = fetchByG_N_S_Last(groupId, nodeId, status,
8218                                    orderByComparator);
8219    
8220                    if (wikiPage != null) {
8221                            return wikiPage;
8222                    }
8223    
8224                    StringBundler msg = new StringBundler(8);
8225    
8226                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8227    
8228                    msg.append("groupId=");
8229                    msg.append(groupId);
8230    
8231                    msg.append(", nodeId=");
8232                    msg.append(nodeId);
8233    
8234                    msg.append(", status=");
8235                    msg.append(status);
8236    
8237                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8238    
8239                    throw new NoSuchPageException(msg.toString());
8240            }
8241    
8242            /**
8243             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
8244             *
8245             * @param groupId the group ID
8246             * @param nodeId the node ID
8247             * @param status the status
8248             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8249             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
8250             * @throws SystemException if a system exception occurred
8251             */
8252            public WikiPage fetchByG_N_S_Last(long groupId, long nodeId, int status,
8253                    OrderByComparator orderByComparator) throws SystemException {
8254                    int count = countByG_N_S(groupId, nodeId, status);
8255    
8256                    List<WikiPage> list = findByG_N_S(groupId, nodeId, status, count - 1,
8257                                    count, orderByComparator);
8258    
8259                    if (!list.isEmpty()) {
8260                            return list.get(0);
8261                    }
8262    
8263                    return null;
8264            }
8265    
8266            /**
8267             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
8268             *
8269             * @param pageId the primary key of the current wiki page
8270             * @param groupId the group ID
8271             * @param nodeId the node ID
8272             * @param status the status
8273             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8274             * @return the previous, current, and next wiki page
8275             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
8276             * @throws SystemException if a system exception occurred
8277             */
8278            public WikiPage[] findByG_N_S_PrevAndNext(long pageId, long groupId,
8279                    long nodeId, int status, OrderByComparator orderByComparator)
8280                    throws NoSuchPageException, SystemException {
8281                    WikiPage wikiPage = findByPrimaryKey(pageId);
8282    
8283                    Session session = null;
8284    
8285                    try {
8286                            session = openSession();
8287    
8288                            WikiPage[] array = new WikiPageImpl[3];
8289    
8290                            array[0] = getByG_N_S_PrevAndNext(session, wikiPage, groupId,
8291                                            nodeId, status, orderByComparator, true);
8292    
8293                            array[1] = wikiPage;
8294    
8295                            array[2] = getByG_N_S_PrevAndNext(session, wikiPage, groupId,
8296                                            nodeId, status, orderByComparator, false);
8297    
8298                            return array;
8299                    }
8300                    catch (Exception e) {
8301                            throw processException(e);
8302                    }
8303                    finally {
8304                            closeSession(session);
8305                    }
8306            }
8307    
8308            protected WikiPage getByG_N_S_PrevAndNext(Session session,
8309                    WikiPage wikiPage, long groupId, long nodeId, int status,
8310                    OrderByComparator orderByComparator, boolean previous) {
8311                    StringBundler query = null;
8312    
8313                    if (orderByComparator != null) {
8314                            query = new StringBundler(6 +
8315                                            (orderByComparator.getOrderByFields().length * 6));
8316                    }
8317                    else {
8318                            query = new StringBundler(3);
8319                    }
8320    
8321                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
8322    
8323                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
8324    
8325                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
8326    
8327                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
8328    
8329                    if (orderByComparator != null) {
8330                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8331    
8332                            if (orderByConditionFields.length > 0) {
8333                                    query.append(WHERE_AND);
8334                            }
8335    
8336                            for (int i = 0; i < orderByConditionFields.length; i++) {
8337                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8338                                    query.append(orderByConditionFields[i]);
8339    
8340                                    if ((i + 1) < orderByConditionFields.length) {
8341                                            if (orderByComparator.isAscending() ^ previous) {
8342                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8343                                            }
8344                                            else {
8345                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8346                                            }
8347                                    }
8348                                    else {
8349                                            if (orderByComparator.isAscending() ^ previous) {
8350                                                    query.append(WHERE_GREATER_THAN);
8351                                            }
8352                                            else {
8353                                                    query.append(WHERE_LESSER_THAN);
8354                                            }
8355                                    }
8356                            }
8357    
8358                            query.append(ORDER_BY_CLAUSE);
8359    
8360                            String[] orderByFields = orderByComparator.getOrderByFields();
8361    
8362                            for (int i = 0; i < orderByFields.length; i++) {
8363                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8364                                    query.append(orderByFields[i]);
8365    
8366                                    if ((i + 1) < orderByFields.length) {
8367                                            if (orderByComparator.isAscending() ^ previous) {
8368                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8369                                            }
8370                                            else {
8371                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8372                                            }
8373                                    }
8374                                    else {
8375                                            if (orderByComparator.isAscending() ^ previous) {
8376                                                    query.append(ORDER_BY_ASC);
8377                                            }
8378                                            else {
8379                                                    query.append(ORDER_BY_DESC);
8380                                            }
8381                                    }
8382                            }
8383                    }
8384                    else {
8385                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8386                    }
8387    
8388                    String sql = query.toString();
8389    
8390                    Query q = session.createQuery(sql);
8391    
8392                    q.setFirstResult(0);
8393                    q.setMaxResults(2);
8394    
8395                    QueryPos qPos = QueryPos.getInstance(q);
8396    
8397                    qPos.add(groupId);
8398    
8399                    qPos.add(nodeId);
8400    
8401                    qPos.add(status);
8402    
8403                    if (orderByComparator != null) {
8404                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
8405    
8406                            for (Object value : values) {
8407                                    qPos.add(value);
8408                            }
8409                    }
8410    
8411                    List<WikiPage> list = q.list();
8412    
8413                    if (list.size() == 2) {
8414                            return list.get(1);
8415                    }
8416                    else {
8417                            return null;
8418                    }
8419            }
8420    
8421            /**
8422             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
8423             *
8424             * @param groupId the group ID
8425             * @param nodeId the node ID
8426             * @param status the status
8427             * @return the matching wiki pages that the user has permission to view
8428             * @throws SystemException if a system exception occurred
8429             */
8430            public List<WikiPage> filterFindByG_N_S(long groupId, long nodeId,
8431                    int status) throws SystemException {
8432                    return filterFindByG_N_S(groupId, nodeId, status, QueryUtil.ALL_POS,
8433                            QueryUtil.ALL_POS, null);
8434            }
8435    
8436            /**
8437             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
8438             *
8439             * <p>
8440             * 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.
8441             * </p>
8442             *
8443             * @param groupId the group ID
8444             * @param nodeId the node ID
8445             * @param status the status
8446             * @param start the lower bound of the range of wiki pages
8447             * @param end the upper bound of the range of wiki pages (not inclusive)
8448             * @return the range of matching wiki pages that the user has permission to view
8449             * @throws SystemException if a system exception occurred
8450             */
8451            public List<WikiPage> filterFindByG_N_S(long groupId, long nodeId,
8452                    int status, int start, int end) throws SystemException {
8453                    return filterFindByG_N_S(groupId, nodeId, status, start, end, null);
8454            }
8455    
8456            /**
8457             * 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;.
8458             *
8459             * <p>
8460             * 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.
8461             * </p>
8462             *
8463             * @param groupId the group ID
8464             * @param nodeId the node ID
8465             * @param status the status
8466             * @param start the lower bound of the range of wiki pages
8467             * @param end the upper bound of the range of wiki pages (not inclusive)
8468             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8469             * @return the ordered range of matching wiki pages that the user has permission to view
8470             * @throws SystemException if a system exception occurred
8471             */
8472            public List<WikiPage> filterFindByG_N_S(long groupId, long nodeId,
8473                    int status, int start, int end, OrderByComparator orderByComparator)
8474                    throws SystemException {
8475                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8476                            return findByG_N_S(groupId, nodeId, status, start, end,
8477                                    orderByComparator);
8478                    }
8479    
8480                    StringBundler query = null;
8481    
8482                    if (orderByComparator != null) {
8483                            query = new StringBundler(5 +
8484                                            (orderByComparator.getOrderByFields().length * 3));
8485                    }
8486                    else {
8487                            query = new StringBundler(5);
8488                    }
8489    
8490                    if (getDB().isSupportsInlineDistinct()) {
8491                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
8492                    }
8493                    else {
8494                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
8495                    }
8496    
8497                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
8498    
8499                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
8500    
8501                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
8502    
8503                    if (!getDB().isSupportsInlineDistinct()) {
8504                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
8505                    }
8506    
8507                    if (orderByComparator != null) {
8508                            if (getDB().isSupportsInlineDistinct()) {
8509                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8510                                            orderByComparator);
8511                            }
8512                            else {
8513                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8514                                            orderByComparator);
8515                            }
8516                    }
8517                    else {
8518                            if (getDB().isSupportsInlineDistinct()) {
8519                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8520                            }
8521                            else {
8522                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
8523                            }
8524                    }
8525    
8526                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8527                                    WikiPage.class.getName(),
8528                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8529    
8530                    Session session = null;
8531    
8532                    try {
8533                            session = openSession();
8534    
8535                            SQLQuery q = session.createSQLQuery(sql);
8536    
8537                            if (getDB().isSupportsInlineDistinct()) {
8538                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
8539                            }
8540                            else {
8541                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
8542                            }
8543    
8544                            QueryPos qPos = QueryPos.getInstance(q);
8545    
8546                            qPos.add(groupId);
8547    
8548                            qPos.add(nodeId);
8549    
8550                            qPos.add(status);
8551    
8552                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
8553                    }
8554                    catch (Exception e) {
8555                            throw processException(e);
8556                    }
8557                    finally {
8558                            closeSession(session);
8559                    }
8560            }
8561    
8562            /**
8563             * 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;.
8564             *
8565             * @param pageId the primary key of the current wiki page
8566             * @param groupId the group ID
8567             * @param nodeId the node ID
8568             * @param status the status
8569             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8570             * @return the previous, current, and next wiki page
8571             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
8572             * @throws SystemException if a system exception occurred
8573             */
8574            public WikiPage[] filterFindByG_N_S_PrevAndNext(long pageId, long groupId,
8575                    long nodeId, int status, OrderByComparator orderByComparator)
8576                    throws NoSuchPageException, SystemException {
8577                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8578                            return findByG_N_S_PrevAndNext(pageId, groupId, nodeId, status,
8579                                    orderByComparator);
8580                    }
8581    
8582                    WikiPage wikiPage = findByPrimaryKey(pageId);
8583    
8584                    Session session = null;
8585    
8586                    try {
8587                            session = openSession();
8588    
8589                            WikiPage[] array = new WikiPageImpl[3];
8590    
8591                            array[0] = filterGetByG_N_S_PrevAndNext(session, wikiPage, groupId,
8592                                            nodeId, status, orderByComparator, true);
8593    
8594                            array[1] = wikiPage;
8595    
8596                            array[2] = filterGetByG_N_S_PrevAndNext(session, wikiPage, groupId,
8597                                            nodeId, status, orderByComparator, false);
8598    
8599                            return array;
8600                    }
8601                    catch (Exception e) {
8602                            throw processException(e);
8603                    }
8604                    finally {
8605                            closeSession(session);
8606                    }
8607            }
8608    
8609            protected WikiPage filterGetByG_N_S_PrevAndNext(Session session,
8610                    WikiPage wikiPage, long groupId, long nodeId, int status,
8611                    OrderByComparator orderByComparator, boolean previous) {
8612                    StringBundler query = null;
8613    
8614                    if (orderByComparator != null) {
8615                            query = new StringBundler(6 +
8616                                            (orderByComparator.getOrderByFields().length * 6));
8617                    }
8618                    else {
8619                            query = new StringBundler(3);
8620                    }
8621    
8622                    if (getDB().isSupportsInlineDistinct()) {
8623                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
8624                    }
8625                    else {
8626                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
8627                    }
8628    
8629                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
8630    
8631                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
8632    
8633                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
8634    
8635                    if (!getDB().isSupportsInlineDistinct()) {
8636                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
8637                    }
8638    
8639                    if (orderByComparator != null) {
8640                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8641    
8642                            if (orderByConditionFields.length > 0) {
8643                                    query.append(WHERE_AND);
8644                            }
8645    
8646                            for (int i = 0; i < orderByConditionFields.length; i++) {
8647                                    if (getDB().isSupportsInlineDistinct()) {
8648                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8649                                    }
8650                                    else {
8651                                            query.append(_ORDER_BY_ENTITY_TABLE);
8652                                    }
8653    
8654                                    query.append(orderByConditionFields[i]);
8655    
8656                                    if ((i + 1) < orderByConditionFields.length) {
8657                                            if (orderByComparator.isAscending() ^ previous) {
8658                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8659                                            }
8660                                            else {
8661                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8662                                            }
8663                                    }
8664                                    else {
8665                                            if (orderByComparator.isAscending() ^ previous) {
8666                                                    query.append(WHERE_GREATER_THAN);
8667                                            }
8668                                            else {
8669                                                    query.append(WHERE_LESSER_THAN);
8670                                            }
8671                                    }
8672                            }
8673    
8674                            query.append(ORDER_BY_CLAUSE);
8675    
8676                            String[] orderByFields = orderByComparator.getOrderByFields();
8677    
8678                            for (int i = 0; i < orderByFields.length; i++) {
8679                                    if (getDB().isSupportsInlineDistinct()) {
8680                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8681                                    }
8682                                    else {
8683                                            query.append(_ORDER_BY_ENTITY_TABLE);
8684                                    }
8685    
8686                                    query.append(orderByFields[i]);
8687    
8688                                    if ((i + 1) < orderByFields.length) {
8689                                            if (orderByComparator.isAscending() ^ previous) {
8690                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8691                                            }
8692                                            else {
8693                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8694                                            }
8695                                    }
8696                                    else {
8697                                            if (orderByComparator.isAscending() ^ previous) {
8698                                                    query.append(ORDER_BY_ASC);
8699                                            }
8700                                            else {
8701                                                    query.append(ORDER_BY_DESC);
8702                                            }
8703                                    }
8704                            }
8705                    }
8706                    else {
8707                            if (getDB().isSupportsInlineDistinct()) {
8708                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8709                            }
8710                            else {
8711                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
8712                            }
8713                    }
8714    
8715                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8716                                    WikiPage.class.getName(),
8717                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8718    
8719                    SQLQuery q = session.createSQLQuery(sql);
8720    
8721                    q.setFirstResult(0);
8722                    q.setMaxResults(2);
8723    
8724                    if (getDB().isSupportsInlineDistinct()) {
8725                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
8726                    }
8727                    else {
8728                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
8729                    }
8730    
8731                    QueryPos qPos = QueryPos.getInstance(q);
8732    
8733                    qPos.add(groupId);
8734    
8735                    qPos.add(nodeId);
8736    
8737                    qPos.add(status);
8738    
8739                    if (orderByComparator != null) {
8740                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
8741    
8742                            for (Object value : values) {
8743                                    qPos.add(value);
8744                            }
8745                    }
8746    
8747                    List<WikiPage> list = q.list();
8748    
8749                    if (list.size() == 2) {
8750                            return list.get(1);
8751                    }
8752                    else {
8753                            return null;
8754                    }
8755            }
8756    
8757            /**
8758             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63; from the database.
8759             *
8760             * @param groupId the group ID
8761             * @param nodeId the node ID
8762             * @param status the status
8763             * @throws SystemException if a system exception occurred
8764             */
8765            public void removeByG_N_S(long groupId, long nodeId, int status)
8766                    throws SystemException {
8767                    for (WikiPage wikiPage : findByG_N_S(groupId, nodeId, status,
8768                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8769                            remove(wikiPage);
8770                    }
8771            }
8772    
8773            /**
8774             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
8775             *
8776             * @param groupId the group ID
8777             * @param nodeId the node ID
8778             * @param status the status
8779             * @return the number of matching wiki pages
8780             * @throws SystemException if a system exception occurred
8781             */
8782            public int countByG_N_S(long groupId, long nodeId, int status)
8783                    throws SystemException {
8784                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_S;
8785    
8786                    Object[] finderArgs = new Object[] { groupId, nodeId, status };
8787    
8788                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8789                                    this);
8790    
8791                    if (count == null) {
8792                            StringBundler query = new StringBundler(4);
8793    
8794                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8795    
8796                            query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
8797    
8798                            query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
8799    
8800                            query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
8801    
8802                            String sql = query.toString();
8803    
8804                            Session session = null;
8805    
8806                            try {
8807                                    session = openSession();
8808    
8809                                    Query q = session.createQuery(sql);
8810    
8811                                    QueryPos qPos = QueryPos.getInstance(q);
8812    
8813                                    qPos.add(groupId);
8814    
8815                                    qPos.add(nodeId);
8816    
8817                                    qPos.add(status);
8818    
8819                                    count = (Long)q.uniqueResult();
8820    
8821                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8822                            }
8823                            catch (Exception e) {
8824                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8825    
8826                                    throw processException(e);
8827                            }
8828                            finally {
8829                                    closeSession(session);
8830                            }
8831                    }
8832    
8833                    return count.intValue();
8834            }
8835    
8836            /**
8837             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
8838             *
8839             * @param groupId the group ID
8840             * @param nodeId the node ID
8841             * @param status the status
8842             * @return the number of matching wiki pages that the user has permission to view
8843             * @throws SystemException if a system exception occurred
8844             */
8845            public int filterCountByG_N_S(long groupId, long nodeId, int status)
8846                    throws SystemException {
8847                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8848                            return countByG_N_S(groupId, nodeId, status);
8849                    }
8850    
8851                    StringBundler query = new StringBundler(4);
8852    
8853                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
8854    
8855                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
8856    
8857                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
8858    
8859                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
8860    
8861                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8862                                    WikiPage.class.getName(),
8863                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8864    
8865                    Session session = null;
8866    
8867                    try {
8868                            session = openSession();
8869    
8870                            SQLQuery q = session.createSQLQuery(sql);
8871    
8872                            q.addScalar(COUNT_COLUMN_NAME,
8873                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8874    
8875                            QueryPos qPos = QueryPos.getInstance(q);
8876    
8877                            qPos.add(groupId);
8878    
8879                            qPos.add(nodeId);
8880    
8881                            qPos.add(status);
8882    
8883                            Long count = (Long)q.uniqueResult();
8884    
8885                            return count.intValue();
8886                    }
8887                    catch (Exception e) {
8888                            throw processException(e);
8889                    }
8890                    finally {
8891                            closeSession(session);
8892                    }
8893            }
8894    
8895            private static final String _FINDER_COLUMN_G_N_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
8896            private static final String _FINDER_COLUMN_G_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
8897            private static final String _FINDER_COLUMN_G_N_S_STATUS_2 = "wikiPage.status = ?";
8898            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
8899                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
8900                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_N_S",
8901                            new String[] {
8902                                    Long.class.getName(), Long.class.getName(),
8903                                    Integer.class.getName(),
8904                                    
8905                            Integer.class.getName(), Integer.class.getName(),
8906                                    OrderByComparator.class.getName()
8907                            });
8908            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
8909                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
8910                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_N_S",
8911                            new String[] {
8912                                    Long.class.getName(), Long.class.getName(),
8913                                    Integer.class.getName()
8914                            },
8915                            WikiPageModelImpl.USERID_COLUMN_BITMASK |
8916                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
8917                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
8918                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
8919                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
8920            public static final FinderPath FINDER_PATH_COUNT_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
8921                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
8922                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_N_S",
8923                            new String[] {
8924                                    Long.class.getName(), Long.class.getName(),
8925                                    Integer.class.getName()
8926                            });
8927    
8928            /**
8929             * Returns all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
8930             *
8931             * @param userId the user ID
8932             * @param nodeId the node ID
8933             * @param status the status
8934             * @return the matching wiki pages
8935             * @throws SystemException if a system exception occurred
8936             */
8937            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status)
8938                    throws SystemException {
8939                    return findByU_N_S(userId, nodeId, status, QueryUtil.ALL_POS,
8940                            QueryUtil.ALL_POS, null);
8941            }
8942    
8943            /**
8944             * Returns a range of all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
8945             *
8946             * <p>
8947             * 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.
8948             * </p>
8949             *
8950             * @param userId the user ID
8951             * @param nodeId the node ID
8952             * @param status the status
8953             * @param start the lower bound of the range of wiki pages
8954             * @param end the upper bound of the range of wiki pages (not inclusive)
8955             * @return the range of matching wiki pages
8956             * @throws SystemException if a system exception occurred
8957             */
8958            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status,
8959                    int start, int end) throws SystemException {
8960                    return findByU_N_S(userId, nodeId, status, start, end, null);
8961            }
8962    
8963            /**
8964             * Returns an ordered range of all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
8965             *
8966             * <p>
8967             * 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.
8968             * </p>
8969             *
8970             * @param userId the user ID
8971             * @param nodeId the node ID
8972             * @param status the status
8973             * @param start the lower bound of the range of wiki pages
8974             * @param end the upper bound of the range of wiki pages (not inclusive)
8975             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8976             * @return the ordered range of matching wiki pages
8977             * @throws SystemException if a system exception occurred
8978             */
8979            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status,
8980                    int start, int end, OrderByComparator orderByComparator)
8981                    throws SystemException {
8982                    boolean pagination = true;
8983                    FinderPath finderPath = null;
8984                    Object[] finderArgs = null;
8985    
8986                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8987                                    (orderByComparator == null)) {
8988                            pagination = false;
8989                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S;
8990                            finderArgs = new Object[] { userId, nodeId, status };
8991                    }
8992                    else {
8993                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_N_S;
8994                            finderArgs = new Object[] {
8995                                            userId, nodeId, status,
8996                                            
8997                                            start, end, orderByComparator
8998                                    };
8999                    }
9000    
9001                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
9002                                    finderArgs, this);
9003    
9004                    if ((list != null) && !list.isEmpty()) {
9005                            for (WikiPage wikiPage : list) {
9006                                    if ((userId != wikiPage.getUserId()) ||
9007                                                    (nodeId != wikiPage.getNodeId()) ||
9008                                                    (status != wikiPage.getStatus())) {
9009                                            list = null;
9010    
9011                                            break;
9012                                    }
9013                            }
9014                    }
9015    
9016                    if (list == null) {
9017                            StringBundler query = null;
9018    
9019                            if (orderByComparator != null) {
9020                                    query = new StringBundler(5 +
9021                                                    (orderByComparator.getOrderByFields().length * 3));
9022                            }
9023                            else {
9024                                    query = new StringBundler(5);
9025                            }
9026    
9027                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
9028    
9029                            query.append(_FINDER_COLUMN_U_N_S_USERID_2);
9030    
9031                            query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
9032    
9033                            query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
9034    
9035                            if (orderByComparator != null) {
9036                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9037                                            orderByComparator);
9038                            }
9039                            else
9040                             if (pagination) {
9041                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9042                            }
9043    
9044                            String sql = query.toString();
9045    
9046                            Session session = null;
9047    
9048                            try {
9049                                    session = openSession();
9050    
9051                                    Query q = session.createQuery(sql);
9052    
9053                                    QueryPos qPos = QueryPos.getInstance(q);
9054    
9055                                    qPos.add(userId);
9056    
9057                                    qPos.add(nodeId);
9058    
9059                                    qPos.add(status);
9060    
9061                                    if (!pagination) {
9062                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
9063                                                            start, end, false);
9064    
9065                                            Collections.sort(list);
9066    
9067                                            list = new UnmodifiableList<WikiPage>(list);
9068                                    }
9069                                    else {
9070                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
9071                                                            start, end);
9072                                    }
9073    
9074                                    cacheResult(list);
9075    
9076                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9077                            }
9078                            catch (Exception e) {
9079                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9080    
9081                                    throw processException(e);
9082                            }
9083                            finally {
9084                                    closeSession(session);
9085                            }
9086                    }
9087    
9088                    return list;
9089            }
9090    
9091            /**
9092             * Returns the first wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
9093             *
9094             * @param userId the user ID
9095             * @param nodeId the node ID
9096             * @param status the status
9097             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9098             * @return the first matching wiki page
9099             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9100             * @throws SystemException if a system exception occurred
9101             */
9102            public WikiPage findByU_N_S_First(long userId, long nodeId, int status,
9103                    OrderByComparator orderByComparator)
9104                    throws NoSuchPageException, SystemException {
9105                    WikiPage wikiPage = fetchByU_N_S_First(userId, nodeId, status,
9106                                    orderByComparator);
9107    
9108                    if (wikiPage != null) {
9109                            return wikiPage;
9110                    }
9111    
9112                    StringBundler msg = new StringBundler(8);
9113    
9114                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9115    
9116                    msg.append("userId=");
9117                    msg.append(userId);
9118    
9119                    msg.append(", nodeId=");
9120                    msg.append(nodeId);
9121    
9122                    msg.append(", status=");
9123                    msg.append(status);
9124    
9125                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9126    
9127                    throw new NoSuchPageException(msg.toString());
9128            }
9129    
9130            /**
9131             * Returns the first wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
9132             *
9133             * @param userId the user ID
9134             * @param nodeId the node ID
9135             * @param status the status
9136             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9137             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
9138             * @throws SystemException if a system exception occurred
9139             */
9140            public WikiPage fetchByU_N_S_First(long userId, long nodeId, int status,
9141                    OrderByComparator orderByComparator) throws SystemException {
9142                    List<WikiPage> list = findByU_N_S(userId, nodeId, status, 0, 1,
9143                                    orderByComparator);
9144    
9145                    if (!list.isEmpty()) {
9146                            return list.get(0);
9147                    }
9148    
9149                    return null;
9150            }
9151    
9152            /**
9153             * Returns the last wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
9154             *
9155             * @param userId the user ID
9156             * @param nodeId the node ID
9157             * @param status the status
9158             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9159             * @return the last matching wiki page
9160             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9161             * @throws SystemException if a system exception occurred
9162             */
9163            public WikiPage findByU_N_S_Last(long userId, long nodeId, int status,
9164                    OrderByComparator orderByComparator)
9165                    throws NoSuchPageException, SystemException {
9166                    WikiPage wikiPage = fetchByU_N_S_Last(userId, nodeId, status,
9167                                    orderByComparator);
9168    
9169                    if (wikiPage != null) {
9170                            return wikiPage;
9171                    }
9172    
9173                    StringBundler msg = new StringBundler(8);
9174    
9175                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9176    
9177                    msg.append("userId=");
9178                    msg.append(userId);
9179    
9180                    msg.append(", nodeId=");
9181                    msg.append(nodeId);
9182    
9183                    msg.append(", status=");
9184                    msg.append(status);
9185    
9186                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9187    
9188                    throw new NoSuchPageException(msg.toString());
9189            }
9190    
9191            /**
9192             * Returns the last wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
9193             *
9194             * @param userId the user ID
9195             * @param nodeId the node ID
9196             * @param status the status
9197             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9198             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
9199             * @throws SystemException if a system exception occurred
9200             */
9201            public WikiPage fetchByU_N_S_Last(long userId, long nodeId, int status,
9202                    OrderByComparator orderByComparator) throws SystemException {
9203                    int count = countByU_N_S(userId, nodeId, status);
9204    
9205                    List<WikiPage> list = findByU_N_S(userId, nodeId, status, count - 1,
9206                                    count, orderByComparator);
9207    
9208                    if (!list.isEmpty()) {
9209                            return list.get(0);
9210                    }
9211    
9212                    return null;
9213            }
9214    
9215            /**
9216             * Returns the wiki pages before and after the current wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
9217             *
9218             * @param pageId the primary key of the current wiki page
9219             * @param userId the user ID
9220             * @param nodeId the node ID
9221             * @param status the status
9222             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9223             * @return the previous, current, and next wiki page
9224             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
9225             * @throws SystemException if a system exception occurred
9226             */
9227            public WikiPage[] findByU_N_S_PrevAndNext(long pageId, long userId,
9228                    long nodeId, int status, OrderByComparator orderByComparator)
9229                    throws NoSuchPageException, SystemException {
9230                    WikiPage wikiPage = findByPrimaryKey(pageId);
9231    
9232                    Session session = null;
9233    
9234                    try {
9235                            session = openSession();
9236    
9237                            WikiPage[] array = new WikiPageImpl[3];
9238    
9239                            array[0] = getByU_N_S_PrevAndNext(session, wikiPage, userId,
9240                                            nodeId, status, orderByComparator, true);
9241    
9242                            array[1] = wikiPage;
9243    
9244                            array[2] = getByU_N_S_PrevAndNext(session, wikiPage, userId,
9245                                            nodeId, status, orderByComparator, false);
9246    
9247                            return array;
9248                    }
9249                    catch (Exception e) {
9250                            throw processException(e);
9251                    }
9252                    finally {
9253                            closeSession(session);
9254                    }
9255            }
9256    
9257            protected WikiPage getByU_N_S_PrevAndNext(Session session,
9258                    WikiPage wikiPage, long userId, long nodeId, int status,
9259                    OrderByComparator orderByComparator, boolean previous) {
9260                    StringBundler query = null;
9261    
9262                    if (orderByComparator != null) {
9263                            query = new StringBundler(6 +
9264                                            (orderByComparator.getOrderByFields().length * 6));
9265                    }
9266                    else {
9267                            query = new StringBundler(3);
9268                    }
9269    
9270                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
9271    
9272                    query.append(_FINDER_COLUMN_U_N_S_USERID_2);
9273    
9274                    query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
9275    
9276                    query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
9277    
9278                    if (orderByComparator != null) {
9279                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9280    
9281                            if (orderByConditionFields.length > 0) {
9282                                    query.append(WHERE_AND);
9283                            }
9284    
9285                            for (int i = 0; i < orderByConditionFields.length; i++) {
9286                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9287                                    query.append(orderByConditionFields[i]);
9288    
9289                                    if ((i + 1) < orderByConditionFields.length) {
9290                                            if (orderByComparator.isAscending() ^ previous) {
9291                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9292                                            }
9293                                            else {
9294                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9295                                            }
9296                                    }
9297                                    else {
9298                                            if (orderByComparator.isAscending() ^ previous) {
9299                                                    query.append(WHERE_GREATER_THAN);
9300                                            }
9301                                            else {
9302                                                    query.append(WHERE_LESSER_THAN);
9303                                            }
9304                                    }
9305                            }
9306    
9307                            query.append(ORDER_BY_CLAUSE);
9308    
9309                            String[] orderByFields = orderByComparator.getOrderByFields();
9310    
9311                            for (int i = 0; i < orderByFields.length; i++) {
9312                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9313                                    query.append(orderByFields[i]);
9314    
9315                                    if ((i + 1) < orderByFields.length) {
9316                                            if (orderByComparator.isAscending() ^ previous) {
9317                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9318                                            }
9319                                            else {
9320                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9321                                            }
9322                                    }
9323                                    else {
9324                                            if (orderByComparator.isAscending() ^ previous) {
9325                                                    query.append(ORDER_BY_ASC);
9326                                            }
9327                                            else {
9328                                                    query.append(ORDER_BY_DESC);
9329                                            }
9330                                    }
9331                            }
9332                    }
9333                    else {
9334                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9335                    }
9336    
9337                    String sql = query.toString();
9338    
9339                    Query q = session.createQuery(sql);
9340    
9341                    q.setFirstResult(0);
9342                    q.setMaxResults(2);
9343    
9344                    QueryPos qPos = QueryPos.getInstance(q);
9345    
9346                    qPos.add(userId);
9347    
9348                    qPos.add(nodeId);
9349    
9350                    qPos.add(status);
9351    
9352                    if (orderByComparator != null) {
9353                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
9354    
9355                            for (Object value : values) {
9356                                    qPos.add(value);
9357                            }
9358                    }
9359    
9360                    List<WikiPage> list = q.list();
9361    
9362                    if (list.size() == 2) {
9363                            return list.get(1);
9364                    }
9365                    else {
9366                            return null;
9367                    }
9368            }
9369    
9370            /**
9371             * Removes all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63; from the database.
9372             *
9373             * @param userId the user ID
9374             * @param nodeId the node ID
9375             * @param status the status
9376             * @throws SystemException if a system exception occurred
9377             */
9378            public void removeByU_N_S(long userId, long nodeId, int status)
9379                    throws SystemException {
9380                    for (WikiPage wikiPage : findByU_N_S(userId, nodeId, status,
9381                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9382                            remove(wikiPage);
9383                    }
9384            }
9385    
9386            /**
9387             * Returns the number of wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
9388             *
9389             * @param userId the user ID
9390             * @param nodeId the node ID
9391             * @param status the status
9392             * @return the number of matching wiki pages
9393             * @throws SystemException if a system exception occurred
9394             */
9395            public int countByU_N_S(long userId, long nodeId, int status)
9396                    throws SystemException {
9397                    FinderPath finderPath = FINDER_PATH_COUNT_BY_U_N_S;
9398    
9399                    Object[] finderArgs = new Object[] { userId, nodeId, status };
9400    
9401                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9402                                    this);
9403    
9404                    if (count == null) {
9405                            StringBundler query = new StringBundler(4);
9406    
9407                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
9408    
9409                            query.append(_FINDER_COLUMN_U_N_S_USERID_2);
9410    
9411                            query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
9412    
9413                            query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
9414    
9415                            String sql = query.toString();
9416    
9417                            Session session = null;
9418    
9419                            try {
9420                                    session = openSession();
9421    
9422                                    Query q = session.createQuery(sql);
9423    
9424                                    QueryPos qPos = QueryPos.getInstance(q);
9425    
9426                                    qPos.add(userId);
9427    
9428                                    qPos.add(nodeId);
9429    
9430                                    qPos.add(status);
9431    
9432                                    count = (Long)q.uniqueResult();
9433    
9434                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9435                            }
9436                            catch (Exception e) {
9437                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9438    
9439                                    throw processException(e);
9440                            }
9441                            finally {
9442                                    closeSession(session);
9443                            }
9444                    }
9445    
9446                    return count.intValue();
9447            }
9448    
9449            private static final String _FINDER_COLUMN_U_N_S_USERID_2 = "wikiPage.userId = ? AND ";
9450            private static final String _FINDER_COLUMN_U_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
9451            private static final String _FINDER_COLUMN_U_N_S_STATUS_2 = "wikiPage.status = ?";
9452            public static final FinderPath FINDER_PATH_FETCH_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
9453                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
9454                            FINDER_CLASS_NAME_ENTITY, "fetchByN_T_V",
9455                            new String[] {
9456                                    Long.class.getName(), String.class.getName(),
9457                                    Double.class.getName()
9458                            },
9459                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
9460                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
9461                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
9462            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
9463                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
9464                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T_V",
9465                            new String[] {
9466                                    Long.class.getName(), String.class.getName(),
9467                                    Double.class.getName()
9468                            });
9469    
9470            /**
9471             * 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.
9472             *
9473             * @param nodeId the node ID
9474             * @param title the title
9475             * @param version the version
9476             * @return the matching wiki page
9477             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9478             * @throws SystemException if a system exception occurred
9479             */
9480            public WikiPage findByN_T_V(long nodeId, String title, double version)
9481                    throws NoSuchPageException, SystemException {
9482                    WikiPage wikiPage = fetchByN_T_V(nodeId, title, version);
9483    
9484                    if (wikiPage == null) {
9485                            StringBundler msg = new StringBundler(8);
9486    
9487                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9488    
9489                            msg.append("nodeId=");
9490                            msg.append(nodeId);
9491    
9492                            msg.append(", title=");
9493                            msg.append(title);
9494    
9495                            msg.append(", version=");
9496                            msg.append(version);
9497    
9498                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9499    
9500                            if (_log.isWarnEnabled()) {
9501                                    _log.warn(msg.toString());
9502                            }
9503    
9504                            throw new NoSuchPageException(msg.toString());
9505                    }
9506    
9507                    return wikiPage;
9508            }
9509    
9510            /**
9511             * 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.
9512             *
9513             * @param nodeId the node ID
9514             * @param title the title
9515             * @param version the version
9516             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
9517             * @throws SystemException if a system exception occurred
9518             */
9519            public WikiPage fetchByN_T_V(long nodeId, String title, double version)
9520                    throws SystemException {
9521                    return fetchByN_T_V(nodeId, title, version, true);
9522            }
9523    
9524            /**
9525             * 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.
9526             *
9527             * @param nodeId the node ID
9528             * @param title the title
9529             * @param version the version
9530             * @param retrieveFromCache whether to use the finder cache
9531             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
9532             * @throws SystemException if a system exception occurred
9533             */
9534            public WikiPage fetchByN_T_V(long nodeId, String title, double version,
9535                    boolean retrieveFromCache) throws SystemException {
9536                    Object[] finderArgs = new Object[] { nodeId, title, version };
9537    
9538                    Object result = null;
9539    
9540                    if (retrieveFromCache) {
9541                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_N_T_V,
9542                                            finderArgs, this);
9543                    }
9544    
9545                    if (result instanceof WikiPage) {
9546                            WikiPage wikiPage = (WikiPage)result;
9547    
9548                            if ((nodeId != wikiPage.getNodeId()) ||
9549                                            !Validator.equals(title, wikiPage.getTitle()) ||
9550                                            (version != wikiPage.getVersion())) {
9551                                    result = null;
9552                            }
9553                    }
9554    
9555                    if (result == null) {
9556                            StringBundler query = new StringBundler(5);
9557    
9558                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
9559    
9560                            query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
9561    
9562                            boolean bindTitle = false;
9563    
9564                            if (title == null) {
9565                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
9566                            }
9567                            else if (title.equals(StringPool.BLANK)) {
9568                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
9569                            }
9570                            else {
9571                                    bindTitle = true;
9572    
9573                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
9574                            }
9575    
9576                            query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
9577    
9578                            String sql = query.toString();
9579    
9580                            Session session = null;
9581    
9582                            try {
9583                                    session = openSession();
9584    
9585                                    Query q = session.createQuery(sql);
9586    
9587                                    QueryPos qPos = QueryPos.getInstance(q);
9588    
9589                                    qPos.add(nodeId);
9590    
9591                                    if (bindTitle) {
9592                                            qPos.add(title.toLowerCase());
9593                                    }
9594    
9595                                    qPos.add(version);
9596    
9597                                    List<WikiPage> list = q.list();
9598    
9599                                    if (list.isEmpty()) {
9600                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
9601                                                    finderArgs, list);
9602                                    }
9603                                    else {
9604                                            WikiPage wikiPage = list.get(0);
9605    
9606                                            result = wikiPage;
9607    
9608                                            cacheResult(wikiPage);
9609    
9610                                            if ((wikiPage.getNodeId() != nodeId) ||
9611                                                            (wikiPage.getTitle() == null) ||
9612                                                            !wikiPage.getTitle().equals(title) ||
9613                                                            (wikiPage.getVersion() != version)) {
9614                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
9615                                                            finderArgs, wikiPage);
9616                                            }
9617                                    }
9618                            }
9619                            catch (Exception e) {
9620                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V,
9621                                            finderArgs);
9622    
9623                                    throw processException(e);
9624                            }
9625                            finally {
9626                                    closeSession(session);
9627                            }
9628                    }
9629    
9630                    if (result instanceof List<?>) {
9631                            return null;
9632                    }
9633                    else {
9634                            return (WikiPage)result;
9635                    }
9636            }
9637    
9638            /**
9639             * Removes the wiki page where nodeId = &#63; and title = &#63; and version = &#63; from the database.
9640             *
9641             * @param nodeId the node ID
9642             * @param title the title
9643             * @param version the version
9644             * @return the wiki page that was removed
9645             * @throws SystemException if a system exception occurred
9646             */
9647            public WikiPage removeByN_T_V(long nodeId, String title, double version)
9648                    throws NoSuchPageException, SystemException {
9649                    WikiPage wikiPage = findByN_T_V(nodeId, title, version);
9650    
9651                    return remove(wikiPage);
9652            }
9653    
9654            /**
9655             * Returns the number of wiki pages where nodeId = &#63; and title = &#63; and version = &#63;.
9656             *
9657             * @param nodeId the node ID
9658             * @param title the title
9659             * @param version the version
9660             * @return the number of matching wiki pages
9661             * @throws SystemException if a system exception occurred
9662             */
9663            public int countByN_T_V(long nodeId, String title, double version)
9664                    throws SystemException {
9665                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_T_V;
9666    
9667                    Object[] finderArgs = new Object[] { nodeId, title, version };
9668    
9669                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9670                                    this);
9671    
9672                    if (count == null) {
9673                            StringBundler query = new StringBundler(4);
9674    
9675                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
9676    
9677                            query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
9678    
9679                            boolean bindTitle = false;
9680    
9681                            if (title == null) {
9682                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
9683                            }
9684                            else if (title.equals(StringPool.BLANK)) {
9685                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
9686                            }
9687                            else {
9688                                    bindTitle = true;
9689    
9690                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
9691                            }
9692    
9693                            query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
9694    
9695                            String sql = query.toString();
9696    
9697                            Session session = null;
9698    
9699                            try {
9700                                    session = openSession();
9701    
9702                                    Query q = session.createQuery(sql);
9703    
9704                                    QueryPos qPos = QueryPos.getInstance(q);
9705    
9706                                    qPos.add(nodeId);
9707    
9708                                    if (bindTitle) {
9709                                            qPos.add(title.toLowerCase());
9710                                    }
9711    
9712                                    qPos.add(version);
9713    
9714                                    count = (Long)q.uniqueResult();
9715    
9716                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9717                            }
9718                            catch (Exception e) {
9719                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9720    
9721                                    throw processException(e);
9722                            }
9723                            finally {
9724                                    closeSession(session);
9725                            }
9726                    }
9727    
9728                    return count.intValue();
9729            }
9730    
9731            private static final String _FINDER_COLUMN_N_T_V_NODEID_2 = "wikiPage.nodeId = ? AND ";
9732            private static final String _FINDER_COLUMN_N_T_V_TITLE_1 = "wikiPage.title IS NULL AND ";
9733            private static final String _FINDER_COLUMN_N_T_V_TITLE_2 = "lower(wikiPage.title) = ? AND ";
9734            private static final String _FINDER_COLUMN_N_T_V_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = '') AND ";
9735            private static final String _FINDER_COLUMN_N_T_V_VERSION_2 = "wikiPage.version = ?";
9736            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
9737                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
9738                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_T_H",
9739                            new String[] {
9740                                    Long.class.getName(), String.class.getName(),
9741                                    Boolean.class.getName(),
9742                                    
9743                            Integer.class.getName(), Integer.class.getName(),
9744                                    OrderByComparator.class.getName()
9745                            });
9746            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
9747                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
9748                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_T_H",
9749                            new String[] {
9750                                    Long.class.getName(), String.class.getName(),
9751                                    Boolean.class.getName()
9752                            },
9753                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
9754                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
9755                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
9756                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
9757            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
9758                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
9759                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T_H",
9760                            new String[] {
9761                                    Long.class.getName(), String.class.getName(),
9762                                    Boolean.class.getName()
9763                            });
9764    
9765            /**
9766             * Returns all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
9767             *
9768             * @param nodeId the node ID
9769             * @param title the title
9770             * @param head the head
9771             * @return the matching wiki pages
9772             * @throws SystemException if a system exception occurred
9773             */
9774            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head)
9775                    throws SystemException {
9776                    return findByN_T_H(nodeId, title, head, QueryUtil.ALL_POS,
9777                            QueryUtil.ALL_POS, null);
9778            }
9779    
9780            /**
9781             * Returns a range of all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
9782             *
9783             * <p>
9784             * 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.
9785             * </p>
9786             *
9787             * @param nodeId the node ID
9788             * @param title the title
9789             * @param head the head
9790             * @param start the lower bound of the range of wiki pages
9791             * @param end the upper bound of the range of wiki pages (not inclusive)
9792             * @return the range of matching wiki pages
9793             * @throws SystemException if a system exception occurred
9794             */
9795            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
9796                    int start, int end) throws SystemException {
9797                    return findByN_T_H(nodeId, title, head, start, end, null);
9798            }
9799    
9800            /**
9801             * Returns an ordered range of all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
9802             *
9803             * <p>
9804             * 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.
9805             * </p>
9806             *
9807             * @param nodeId the node ID
9808             * @param title the title
9809             * @param head the head
9810             * @param start the lower bound of the range of wiki pages
9811             * @param end the upper bound of the range of wiki pages (not inclusive)
9812             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9813             * @return the ordered range of matching wiki pages
9814             * @throws SystemException if a system exception occurred
9815             */
9816            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
9817                    int start, int end, OrderByComparator orderByComparator)
9818                    throws SystemException {
9819                    boolean pagination = true;
9820                    FinderPath finderPath = null;
9821                    Object[] finderArgs = null;
9822    
9823                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9824                                    (orderByComparator == null)) {
9825                            pagination = false;
9826                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H;
9827                            finderArgs = new Object[] { nodeId, title, head };
9828                    }
9829                    else {
9830                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_H;
9831                            finderArgs = new Object[] {
9832                                            nodeId, title, head,
9833                                            
9834                                            start, end, orderByComparator
9835                                    };
9836                    }
9837    
9838                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
9839                                    finderArgs, this);
9840    
9841                    if ((list != null) && !list.isEmpty()) {
9842                            for (WikiPage wikiPage : list) {
9843                                    if ((nodeId != wikiPage.getNodeId()) ||
9844                                                    !Validator.equals(title, wikiPage.getTitle()) ||
9845                                                    (head != wikiPage.getHead())) {
9846                                            list = null;
9847    
9848                                            break;
9849                                    }
9850                            }
9851                    }
9852    
9853                    if (list == null) {
9854                            StringBundler query = null;
9855    
9856                            if (orderByComparator != null) {
9857                                    query = new StringBundler(5 +
9858                                                    (orderByComparator.getOrderByFields().length * 3));
9859                            }
9860                            else {
9861                                    query = new StringBundler(5);
9862                            }
9863    
9864                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
9865    
9866                            query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
9867    
9868                            boolean bindTitle = false;
9869    
9870                            if (title == null) {
9871                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
9872                            }
9873                            else if (title.equals(StringPool.BLANK)) {
9874                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
9875                            }
9876                            else {
9877                                    bindTitle = true;
9878    
9879                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
9880                            }
9881    
9882                            query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
9883    
9884                            if (orderByComparator != null) {
9885                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9886                                            orderByComparator);
9887                            }
9888                            else
9889                             if (pagination) {
9890                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9891                            }
9892    
9893                            String sql = query.toString();
9894    
9895                            Session session = null;
9896    
9897                            try {
9898                                    session = openSession();
9899    
9900                                    Query q = session.createQuery(sql);
9901    
9902                                    QueryPos qPos = QueryPos.getInstance(q);
9903    
9904                                    qPos.add(nodeId);
9905    
9906                                    if (bindTitle) {
9907                                            qPos.add(title.toLowerCase());
9908                                    }
9909    
9910                                    qPos.add(head);
9911    
9912                                    if (!pagination) {
9913                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
9914                                                            start, end, false);
9915    
9916                                            Collections.sort(list);
9917    
9918                                            list = new UnmodifiableList<WikiPage>(list);
9919                                    }
9920                                    else {
9921                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
9922                                                            start, end);
9923                                    }
9924    
9925                                    cacheResult(list);
9926    
9927                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9928                            }
9929                            catch (Exception e) {
9930                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9931    
9932                                    throw processException(e);
9933                            }
9934                            finally {
9935                                    closeSession(session);
9936                            }
9937                    }
9938    
9939                    return list;
9940            }
9941    
9942            /**
9943             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
9944             *
9945             * @param nodeId the node ID
9946             * @param title the title
9947             * @param head the head
9948             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9949             * @return the first matching wiki page
9950             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9951             * @throws SystemException if a system exception occurred
9952             */
9953            public WikiPage findByN_T_H_First(long nodeId, String title, boolean head,
9954                    OrderByComparator orderByComparator)
9955                    throws NoSuchPageException, SystemException {
9956                    WikiPage wikiPage = fetchByN_T_H_First(nodeId, title, head,
9957                                    orderByComparator);
9958    
9959                    if (wikiPage != null) {
9960                            return wikiPage;
9961                    }
9962    
9963                    StringBundler msg = new StringBundler(8);
9964    
9965                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9966    
9967                    msg.append("nodeId=");
9968                    msg.append(nodeId);
9969    
9970                    msg.append(", title=");
9971                    msg.append(title);
9972    
9973                    msg.append(", head=");
9974                    msg.append(head);
9975    
9976                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9977    
9978                    throw new NoSuchPageException(msg.toString());
9979            }
9980    
9981            /**
9982             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
9983             *
9984             * @param nodeId the node ID
9985             * @param title the title
9986             * @param head the head
9987             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9988             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
9989             * @throws SystemException if a system exception occurred
9990             */
9991            public WikiPage fetchByN_T_H_First(long nodeId, String title, boolean head,
9992                    OrderByComparator orderByComparator) throws SystemException {
9993                    List<WikiPage> list = findByN_T_H(nodeId, title, head, 0, 1,
9994                                    orderByComparator);
9995    
9996                    if (!list.isEmpty()) {
9997                            return list.get(0);
9998                    }
9999    
10000                    return null;
10001            }
10002    
10003            /**
10004             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
10005             *
10006             * @param nodeId the node ID
10007             * @param title the title
10008             * @param head the head
10009             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10010             * @return the last matching wiki page
10011             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
10012             * @throws SystemException if a system exception occurred
10013             */
10014            public WikiPage findByN_T_H_Last(long nodeId, String title, boolean head,
10015                    OrderByComparator orderByComparator)
10016                    throws NoSuchPageException, SystemException {
10017                    WikiPage wikiPage = fetchByN_T_H_Last(nodeId, title, head,
10018                                    orderByComparator);
10019    
10020                    if (wikiPage != null) {
10021                            return wikiPage;
10022                    }
10023    
10024                    StringBundler msg = new StringBundler(8);
10025    
10026                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10027    
10028                    msg.append("nodeId=");
10029                    msg.append(nodeId);
10030    
10031                    msg.append(", title=");
10032                    msg.append(title);
10033    
10034                    msg.append(", head=");
10035                    msg.append(head);
10036    
10037                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10038    
10039                    throw new NoSuchPageException(msg.toString());
10040            }
10041    
10042            /**
10043             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
10044             *
10045             * @param nodeId the node ID
10046             * @param title the title
10047             * @param head the head
10048             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10049             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
10050             * @throws SystemException if a system exception occurred
10051             */
10052            public WikiPage fetchByN_T_H_Last(long nodeId, String title, boolean head,
10053                    OrderByComparator orderByComparator) throws SystemException {
10054                    int count = countByN_T_H(nodeId, title, head);
10055    
10056                    List<WikiPage> list = findByN_T_H(nodeId, title, head, count - 1,
10057                                    count, orderByComparator);
10058    
10059                    if (!list.isEmpty()) {
10060                            return list.get(0);
10061                    }
10062    
10063                    return null;
10064            }
10065    
10066            /**
10067             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
10068             *
10069             * @param pageId the primary key of the current wiki page
10070             * @param nodeId the node ID
10071             * @param title the title
10072             * @param head the head
10073             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10074             * @return the previous, current, and next wiki page
10075             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
10076             * @throws SystemException if a system exception occurred
10077             */
10078            public WikiPage[] findByN_T_H_PrevAndNext(long pageId, long nodeId,
10079                    String title, boolean head, OrderByComparator orderByComparator)
10080                    throws NoSuchPageException, SystemException {
10081                    WikiPage wikiPage = findByPrimaryKey(pageId);
10082    
10083                    Session session = null;
10084    
10085                    try {
10086                            session = openSession();
10087    
10088                            WikiPage[] array = new WikiPageImpl[3];
10089    
10090                            array[0] = getByN_T_H_PrevAndNext(session, wikiPage, nodeId, title,
10091                                            head, orderByComparator, true);
10092    
10093                            array[1] = wikiPage;
10094    
10095                            array[2] = getByN_T_H_PrevAndNext(session, wikiPage, nodeId, title,
10096                                            head, orderByComparator, false);
10097    
10098                            return array;
10099                    }
10100                    catch (Exception e) {
10101                            throw processException(e);
10102                    }
10103                    finally {
10104                            closeSession(session);
10105                    }
10106            }
10107    
10108            protected WikiPage getByN_T_H_PrevAndNext(Session session,
10109                    WikiPage wikiPage, long nodeId, String title, boolean head,
10110                    OrderByComparator orderByComparator, boolean previous) {
10111                    StringBundler query = null;
10112    
10113                    if (orderByComparator != null) {
10114                            query = new StringBundler(6 +
10115                                            (orderByComparator.getOrderByFields().length * 6));
10116                    }
10117                    else {
10118                            query = new StringBundler(3);
10119                    }
10120    
10121                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
10122    
10123                    query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
10124    
10125                    boolean bindTitle = false;
10126    
10127                    if (title == null) {
10128                            query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
10129                    }
10130                    else if (title.equals(StringPool.BLANK)) {
10131                            query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
10132                    }
10133                    else {
10134                            bindTitle = true;
10135    
10136                            query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
10137                    }
10138    
10139                    query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
10140    
10141                    if (orderByComparator != null) {
10142                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10143    
10144                            if (orderByConditionFields.length > 0) {
10145                                    query.append(WHERE_AND);
10146                            }
10147    
10148                            for (int i = 0; i < orderByConditionFields.length; i++) {
10149                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10150                                    query.append(orderByConditionFields[i]);
10151    
10152                                    if ((i + 1) < orderByConditionFields.length) {
10153                                            if (orderByComparator.isAscending() ^ previous) {
10154                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10155                                            }
10156                                            else {
10157                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10158                                            }
10159                                    }
10160                                    else {
10161                                            if (orderByComparator.isAscending() ^ previous) {
10162                                                    query.append(WHERE_GREATER_THAN);
10163                                            }
10164                                            else {
10165                                                    query.append(WHERE_LESSER_THAN);
10166                                            }
10167                                    }
10168                            }
10169    
10170                            query.append(ORDER_BY_CLAUSE);
10171    
10172                            String[] orderByFields = orderByComparator.getOrderByFields();
10173    
10174                            for (int i = 0; i < orderByFields.length; i++) {
10175                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10176                                    query.append(orderByFields[i]);
10177    
10178                                    if ((i + 1) < orderByFields.length) {
10179                                            if (orderByComparator.isAscending() ^ previous) {
10180                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10181                                            }
10182                                            else {
10183                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10184                                            }
10185                                    }
10186                                    else {
10187                                            if (orderByComparator.isAscending() ^ previous) {
10188                                                    query.append(ORDER_BY_ASC);
10189                                            }
10190                                            else {
10191                                                    query.append(ORDER_BY_DESC);
10192                                            }
10193                                    }
10194                            }
10195                    }
10196                    else {
10197                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10198                    }
10199    
10200                    String sql = query.toString();
10201    
10202                    Query q = session.createQuery(sql);
10203    
10204                    q.setFirstResult(0);
10205                    q.setMaxResults(2);
10206    
10207                    QueryPos qPos = QueryPos.getInstance(q);
10208    
10209                    qPos.add(nodeId);
10210    
10211                    if (bindTitle) {
10212                            qPos.add(title.toLowerCase());
10213                    }
10214    
10215                    qPos.add(head);
10216    
10217                    if (orderByComparator != null) {
10218                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
10219    
10220                            for (Object value : values) {
10221                                    qPos.add(value);
10222                            }
10223                    }
10224    
10225                    List<WikiPage> list = q.list();
10226    
10227                    if (list.size() == 2) {
10228                            return list.get(1);
10229                    }
10230                    else {
10231                            return null;
10232                    }
10233            }
10234    
10235            /**
10236             * Removes all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63; from the database.
10237             *
10238             * @param nodeId the node ID
10239             * @param title the title
10240             * @param head the head
10241             * @throws SystemException if a system exception occurred
10242             */
10243            public void removeByN_T_H(long nodeId, String title, boolean head)
10244                    throws SystemException {
10245                    for (WikiPage wikiPage : findByN_T_H(nodeId, title, head,
10246                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10247                            remove(wikiPage);
10248                    }
10249            }
10250    
10251            /**
10252             * Returns the number of wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
10253             *
10254             * @param nodeId the node ID
10255             * @param title the title
10256             * @param head the head
10257             * @return the number of matching wiki pages
10258             * @throws SystemException if a system exception occurred
10259             */
10260            public int countByN_T_H(long nodeId, String title, boolean head)
10261                    throws SystemException {
10262                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_T_H;
10263    
10264                    Object[] finderArgs = new Object[] { nodeId, title, head };
10265    
10266                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10267                                    this);
10268    
10269                    if (count == null) {
10270                            StringBundler query = new StringBundler(4);
10271    
10272                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
10273    
10274                            query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
10275    
10276                            boolean bindTitle = false;
10277    
10278                            if (title == null) {
10279                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
10280                            }
10281                            else if (title.equals(StringPool.BLANK)) {
10282                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
10283                            }
10284                            else {
10285                                    bindTitle = true;
10286    
10287                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
10288                            }
10289    
10290                            query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
10291    
10292                            String sql = query.toString();
10293    
10294                            Session session = null;
10295    
10296                            try {
10297                                    session = openSession();
10298    
10299                                    Query q = session.createQuery(sql);
10300    
10301                                    QueryPos qPos = QueryPos.getInstance(q);
10302    
10303                                    qPos.add(nodeId);
10304    
10305                                    if (bindTitle) {
10306                                            qPos.add(title.toLowerCase());
10307                                    }
10308    
10309                                    qPos.add(head);
10310    
10311                                    count = (Long)q.uniqueResult();
10312    
10313                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10314                            }
10315                            catch (Exception e) {
10316                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10317    
10318                                    throw processException(e);
10319                            }
10320                            finally {
10321                                    closeSession(session);
10322                            }
10323                    }
10324    
10325                    return count.intValue();
10326            }
10327    
10328            private static final String _FINDER_COLUMN_N_T_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
10329            private static final String _FINDER_COLUMN_N_T_H_TITLE_1 = "wikiPage.title IS NULL AND ";
10330            private static final String _FINDER_COLUMN_N_T_H_TITLE_2 = "lower(wikiPage.title) = ? AND ";
10331            private static final String _FINDER_COLUMN_N_T_H_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = '') AND ";
10332            private static final String _FINDER_COLUMN_N_T_H_HEAD_2 = "wikiPage.head = ?";
10333            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10334                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
10335                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_T_S",
10336                            new String[] {
10337                                    Long.class.getName(), String.class.getName(),
10338                                    Integer.class.getName(),
10339                                    
10340                            Integer.class.getName(), Integer.class.getName(),
10341                                    OrderByComparator.class.getName()
10342                            });
10343            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10344                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
10345                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_T_S",
10346                            new String[] {
10347                                    Long.class.getName(), String.class.getName(),
10348                                    Integer.class.getName()
10349                            },
10350                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
10351                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
10352                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
10353                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
10354            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10355                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
10356                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T_S",
10357                            new String[] {
10358                                    Long.class.getName(), String.class.getName(),
10359                                    Integer.class.getName()
10360                            });
10361    
10362            /**
10363             * Returns all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
10364             *
10365             * @param nodeId the node ID
10366             * @param title the title
10367             * @param status the status
10368             * @return the matching wiki pages
10369             * @throws SystemException if a system exception occurred
10370             */
10371            public List<WikiPage> findByN_T_S(long nodeId, String title, int status)
10372                    throws SystemException {
10373                    return findByN_T_S(nodeId, title, status, QueryUtil.ALL_POS,
10374                            QueryUtil.ALL_POS, null);
10375            }
10376    
10377            /**
10378             * Returns a range of all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
10379             *
10380             * <p>
10381             * 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.
10382             * </p>
10383             *
10384             * @param nodeId the node ID
10385             * @param title the title
10386             * @param status the status
10387             * @param start the lower bound of the range of wiki pages
10388             * @param end the upper bound of the range of wiki pages (not inclusive)
10389             * @return the range of matching wiki pages
10390             * @throws SystemException if a system exception occurred
10391             */
10392            public List<WikiPage> findByN_T_S(long nodeId, String title, int status,
10393                    int start, int end) throws SystemException {
10394                    return findByN_T_S(nodeId, title, status, start, end, null);
10395            }
10396    
10397            /**
10398             * Returns an ordered range of all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
10399             *
10400             * <p>
10401             * 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.
10402             * </p>
10403             *
10404             * @param nodeId the node ID
10405             * @param title the title
10406             * @param status the status
10407             * @param start the lower bound of the range of wiki pages
10408             * @param end the upper bound of the range of wiki pages (not inclusive)
10409             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10410             * @return the ordered range of matching wiki pages
10411             * @throws SystemException if a system exception occurred
10412             */
10413            public List<WikiPage> findByN_T_S(long nodeId, String title, int status,
10414                    int start, int end, OrderByComparator orderByComparator)
10415                    throws SystemException {
10416                    boolean pagination = true;
10417                    FinderPath finderPath = null;
10418                    Object[] finderArgs = null;
10419    
10420                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10421                                    (orderByComparator == null)) {
10422                            pagination = false;
10423                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S;
10424                            finderArgs = new Object[] { nodeId, title, status };
10425                    }
10426                    else {
10427                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_S;
10428                            finderArgs = new Object[] {
10429                                            nodeId, title, status,
10430                                            
10431                                            start, end, orderByComparator
10432                                    };
10433                    }
10434    
10435                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
10436                                    finderArgs, this);
10437    
10438                    if ((list != null) && !list.isEmpty()) {
10439                            for (WikiPage wikiPage : list) {
10440                                    if ((nodeId != wikiPage.getNodeId()) ||
10441                                                    !Validator.equals(title, wikiPage.getTitle()) ||
10442                                                    (status != wikiPage.getStatus())) {
10443                                            list = null;
10444    
10445                                            break;
10446                                    }
10447                            }
10448                    }
10449    
10450                    if (list == null) {
10451                            StringBundler query = null;
10452    
10453                            if (orderByComparator != null) {
10454                                    query = new StringBundler(5 +
10455                                                    (orderByComparator.getOrderByFields().length * 3));
10456                            }
10457                            else {
10458                                    query = new StringBundler(5);
10459                            }
10460    
10461                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
10462    
10463                            query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
10464    
10465                            boolean bindTitle = false;
10466    
10467                            if (title == null) {
10468                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
10469                            }
10470                            else if (title.equals(StringPool.BLANK)) {
10471                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
10472                            }
10473                            else {
10474                                    bindTitle = true;
10475    
10476                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
10477                            }
10478    
10479                            query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
10480    
10481                            if (orderByComparator != null) {
10482                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10483                                            orderByComparator);
10484                            }
10485                            else
10486                             if (pagination) {
10487                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10488                            }
10489    
10490                            String sql = query.toString();
10491    
10492                            Session session = null;
10493    
10494                            try {
10495                                    session = openSession();
10496    
10497                                    Query q = session.createQuery(sql);
10498    
10499                                    QueryPos qPos = QueryPos.getInstance(q);
10500    
10501                                    qPos.add(nodeId);
10502    
10503                                    if (bindTitle) {
10504                                            qPos.add(title.toLowerCase());
10505                                    }
10506    
10507                                    qPos.add(status);
10508    
10509                                    if (!pagination) {
10510                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
10511                                                            start, end, false);
10512    
10513                                            Collections.sort(list);
10514    
10515                                            list = new UnmodifiableList<WikiPage>(list);
10516                                    }
10517                                    else {
10518                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
10519                                                            start, end);
10520                                    }
10521    
10522                                    cacheResult(list);
10523    
10524                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10525                            }
10526                            catch (Exception e) {
10527                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10528    
10529                                    throw processException(e);
10530                            }
10531                            finally {
10532                                    closeSession(session);
10533                            }
10534                    }
10535    
10536                    return list;
10537            }
10538    
10539            /**
10540             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
10541             *
10542             * @param nodeId the node ID
10543             * @param title the title
10544             * @param status the status
10545             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10546             * @return the first matching wiki page
10547             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
10548             * @throws SystemException if a system exception occurred
10549             */
10550            public WikiPage findByN_T_S_First(long nodeId, String title, int status,
10551                    OrderByComparator orderByComparator)
10552                    throws NoSuchPageException, SystemException {
10553                    WikiPage wikiPage = fetchByN_T_S_First(nodeId, title, status,
10554                                    orderByComparator);
10555    
10556                    if (wikiPage != null) {
10557                            return wikiPage;
10558                    }
10559    
10560                    StringBundler msg = new StringBundler(8);
10561    
10562                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10563    
10564                    msg.append("nodeId=");
10565                    msg.append(nodeId);
10566    
10567                    msg.append(", title=");
10568                    msg.append(title);
10569    
10570                    msg.append(", status=");
10571                    msg.append(status);
10572    
10573                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10574    
10575                    throw new NoSuchPageException(msg.toString());
10576            }
10577    
10578            /**
10579             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
10580             *
10581             * @param nodeId the node ID
10582             * @param title the title
10583             * @param status the status
10584             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10585             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
10586             * @throws SystemException if a system exception occurred
10587             */
10588            public WikiPage fetchByN_T_S_First(long nodeId, String title, int status,
10589                    OrderByComparator orderByComparator) throws SystemException {
10590                    List<WikiPage> list = findByN_T_S(nodeId, title, status, 0, 1,
10591                                    orderByComparator);
10592    
10593                    if (!list.isEmpty()) {
10594                            return list.get(0);
10595                    }
10596    
10597                    return null;
10598            }
10599    
10600            /**
10601             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
10602             *
10603             * @param nodeId the node ID
10604             * @param title the title
10605             * @param status the status
10606             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10607             * @return the last matching wiki page
10608             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
10609             * @throws SystemException if a system exception occurred
10610             */
10611            public WikiPage findByN_T_S_Last(long nodeId, String title, int status,
10612                    OrderByComparator orderByComparator)
10613                    throws NoSuchPageException, SystemException {
10614                    WikiPage wikiPage = fetchByN_T_S_Last(nodeId, title, status,
10615                                    orderByComparator);
10616    
10617                    if (wikiPage != null) {
10618                            return wikiPage;
10619                    }
10620    
10621                    StringBundler msg = new StringBundler(8);
10622    
10623                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10624    
10625                    msg.append("nodeId=");
10626                    msg.append(nodeId);
10627    
10628                    msg.append(", title=");
10629                    msg.append(title);
10630    
10631                    msg.append(", status=");
10632                    msg.append(status);
10633    
10634                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10635    
10636                    throw new NoSuchPageException(msg.toString());
10637            }
10638    
10639            /**
10640             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
10641             *
10642             * @param nodeId the node ID
10643             * @param title the title
10644             * @param status the status
10645             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10646             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
10647             * @throws SystemException if a system exception occurred
10648             */
10649            public WikiPage fetchByN_T_S_Last(long nodeId, String title, int status,
10650                    OrderByComparator orderByComparator) throws SystemException {
10651                    int count = countByN_T_S(nodeId, title, status);
10652    
10653                    List<WikiPage> list = findByN_T_S(nodeId, title, status, count - 1,
10654                                    count, orderByComparator);
10655    
10656                    if (!list.isEmpty()) {
10657                            return list.get(0);
10658                    }
10659    
10660                    return null;
10661            }
10662    
10663            /**
10664             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
10665             *
10666             * @param pageId the primary key of the current wiki page
10667             * @param nodeId the node ID
10668             * @param title the title
10669             * @param status the status
10670             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10671             * @return the previous, current, and next wiki page
10672             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
10673             * @throws SystemException if a system exception occurred
10674             */
10675            public WikiPage[] findByN_T_S_PrevAndNext(long pageId, long nodeId,
10676                    String title, int status, OrderByComparator orderByComparator)
10677                    throws NoSuchPageException, SystemException {
10678                    WikiPage wikiPage = findByPrimaryKey(pageId);
10679    
10680                    Session session = null;
10681    
10682                    try {
10683                            session = openSession();
10684    
10685                            WikiPage[] array = new WikiPageImpl[3];
10686    
10687                            array[0] = getByN_T_S_PrevAndNext(session, wikiPage, nodeId, title,
10688                                            status, orderByComparator, true);
10689    
10690                            array[1] = wikiPage;
10691    
10692                            array[2] = getByN_T_S_PrevAndNext(session, wikiPage, nodeId, title,
10693                                            status, orderByComparator, false);
10694    
10695                            return array;
10696                    }
10697                    catch (Exception e) {
10698                            throw processException(e);
10699                    }
10700                    finally {
10701                            closeSession(session);
10702                    }
10703            }
10704    
10705            protected WikiPage getByN_T_S_PrevAndNext(Session session,
10706                    WikiPage wikiPage, long nodeId, String title, int status,
10707                    OrderByComparator orderByComparator, boolean previous) {
10708                    StringBundler query = null;
10709    
10710                    if (orderByComparator != null) {
10711                            query = new StringBundler(6 +
10712                                            (orderByComparator.getOrderByFields().length * 6));
10713                    }
10714                    else {
10715                            query = new StringBundler(3);
10716                    }
10717    
10718                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
10719    
10720                    query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
10721    
10722                    boolean bindTitle = false;
10723    
10724                    if (title == null) {
10725                            query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
10726                    }
10727                    else if (title.equals(StringPool.BLANK)) {
10728                            query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
10729                    }
10730                    else {
10731                            bindTitle = true;
10732    
10733                            query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
10734                    }
10735    
10736                    query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
10737    
10738                    if (orderByComparator != null) {
10739                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10740    
10741                            if (orderByConditionFields.length > 0) {
10742                                    query.append(WHERE_AND);
10743                            }
10744    
10745                            for (int i = 0; i < orderByConditionFields.length; i++) {
10746                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10747                                    query.append(orderByConditionFields[i]);
10748    
10749                                    if ((i + 1) < orderByConditionFields.length) {
10750                                            if (orderByComparator.isAscending() ^ previous) {
10751                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10752                                            }
10753                                            else {
10754                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10755                                            }
10756                                    }
10757                                    else {
10758                                            if (orderByComparator.isAscending() ^ previous) {
10759                                                    query.append(WHERE_GREATER_THAN);
10760                                            }
10761                                            else {
10762                                                    query.append(WHERE_LESSER_THAN);
10763                                            }
10764                                    }
10765                            }
10766    
10767                            query.append(ORDER_BY_CLAUSE);
10768    
10769                            String[] orderByFields = orderByComparator.getOrderByFields();
10770    
10771                            for (int i = 0; i < orderByFields.length; i++) {
10772                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10773                                    query.append(orderByFields[i]);
10774    
10775                                    if ((i + 1) < orderByFields.length) {
10776                                            if (orderByComparator.isAscending() ^ previous) {
10777                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10778                                            }
10779                                            else {
10780                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10781                                            }
10782                                    }
10783                                    else {
10784                                            if (orderByComparator.isAscending() ^ previous) {
10785                                                    query.append(ORDER_BY_ASC);
10786                                            }
10787                                            else {
10788                                                    query.append(ORDER_BY_DESC);
10789                                            }
10790                                    }
10791                            }
10792                    }
10793                    else {
10794                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10795                    }
10796    
10797                    String sql = query.toString();
10798    
10799                    Query q = session.createQuery(sql);
10800    
10801                    q.setFirstResult(0);
10802                    q.setMaxResults(2);
10803    
10804                    QueryPos qPos = QueryPos.getInstance(q);
10805    
10806                    qPos.add(nodeId);
10807    
10808                    if (bindTitle) {
10809                            qPos.add(title.toLowerCase());
10810                    }
10811    
10812                    qPos.add(status);
10813    
10814                    if (orderByComparator != null) {
10815                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
10816    
10817                            for (Object value : values) {
10818                                    qPos.add(value);
10819                            }
10820                    }
10821    
10822                    List<WikiPage> list = q.list();
10823    
10824                    if (list.size() == 2) {
10825                            return list.get(1);
10826                    }
10827                    else {
10828                            return null;
10829                    }
10830            }
10831    
10832            /**
10833             * Removes all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63; from the database.
10834             *
10835             * @param nodeId the node ID
10836             * @param title the title
10837             * @param status the status
10838             * @throws SystemException if a system exception occurred
10839             */
10840            public void removeByN_T_S(long nodeId, String title, int status)
10841                    throws SystemException {
10842                    for (WikiPage wikiPage : findByN_T_S(nodeId, title, status,
10843                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10844                            remove(wikiPage);
10845                    }
10846            }
10847    
10848            /**
10849             * Returns the number of wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
10850             *
10851             * @param nodeId the node ID
10852             * @param title the title
10853             * @param status the status
10854             * @return the number of matching wiki pages
10855             * @throws SystemException if a system exception occurred
10856             */
10857            public int countByN_T_S(long nodeId, String title, int status)
10858                    throws SystemException {
10859                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_T_S;
10860    
10861                    Object[] finderArgs = new Object[] { nodeId, title, status };
10862    
10863                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10864                                    this);
10865    
10866                    if (count == null) {
10867                            StringBundler query = new StringBundler(4);
10868    
10869                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
10870    
10871                            query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
10872    
10873                            boolean bindTitle = false;
10874    
10875                            if (title == null) {
10876                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
10877                            }
10878                            else if (title.equals(StringPool.BLANK)) {
10879                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
10880                            }
10881                            else {
10882                                    bindTitle = true;
10883    
10884                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
10885                            }
10886    
10887                            query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
10888    
10889                            String sql = query.toString();
10890    
10891                            Session session = null;
10892    
10893                            try {
10894                                    session = openSession();
10895    
10896                                    Query q = session.createQuery(sql);
10897    
10898                                    QueryPos qPos = QueryPos.getInstance(q);
10899    
10900                                    qPos.add(nodeId);
10901    
10902                                    if (bindTitle) {
10903                                            qPos.add(title.toLowerCase());
10904                                    }
10905    
10906                                    qPos.add(status);
10907    
10908                                    count = (Long)q.uniqueResult();
10909    
10910                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10911                            }
10912                            catch (Exception e) {
10913                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10914    
10915                                    throw processException(e);
10916                            }
10917                            finally {
10918                                    closeSession(session);
10919                            }
10920                    }
10921    
10922                    return count.intValue();
10923            }
10924    
10925            private static final String _FINDER_COLUMN_N_T_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
10926            private static final String _FINDER_COLUMN_N_T_S_TITLE_1 = "wikiPage.title IS NULL AND ";
10927            private static final String _FINDER_COLUMN_N_T_S_TITLE_2 = "lower(wikiPage.title) = ? AND ";
10928            private static final String _FINDER_COLUMN_N_T_S_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = '') AND ";
10929            private static final String _FINDER_COLUMN_N_T_S_STATUS_2 = "wikiPage.status = ?";
10930            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10931                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
10932                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_P",
10933                            new String[] {
10934                                    Long.class.getName(), Boolean.class.getName(),
10935                                    String.class.getName(),
10936                                    
10937                            Integer.class.getName(), Integer.class.getName(),
10938                                    OrderByComparator.class.getName()
10939                            });
10940            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10941                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
10942                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_P",
10943                            new String[] {
10944                                    Long.class.getName(), Boolean.class.getName(),
10945                                    String.class.getName()
10946                            },
10947                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
10948                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
10949                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK |
10950                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
10951                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
10952            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
10953                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
10954                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_P",
10955                            new String[] {
10956                                    Long.class.getName(), Boolean.class.getName(),
10957                                    String.class.getName()
10958                            });
10959    
10960            /**
10961             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
10962             *
10963             * @param nodeId the node ID
10964             * @param head the head
10965             * @param parentTitle the parent title
10966             * @return the matching wiki pages
10967             * @throws SystemException if a system exception occurred
10968             */
10969            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
10970                    String parentTitle) throws SystemException {
10971                    return findByN_H_P(nodeId, head, parentTitle, QueryUtil.ALL_POS,
10972                            QueryUtil.ALL_POS, null);
10973            }
10974    
10975            /**
10976             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
10977             *
10978             * <p>
10979             * 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.
10980             * </p>
10981             *
10982             * @param nodeId the node ID
10983             * @param head the head
10984             * @param parentTitle the parent title
10985             * @param start the lower bound of the range of wiki pages
10986             * @param end the upper bound of the range of wiki pages (not inclusive)
10987             * @return the range of matching wiki pages
10988             * @throws SystemException if a system exception occurred
10989             */
10990            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
10991                    String parentTitle, int start, int end) throws SystemException {
10992                    return findByN_H_P(nodeId, head, parentTitle, start, end, null);
10993            }
10994    
10995            /**
10996             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
10997             *
10998             * <p>
10999             * 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.
11000             * </p>
11001             *
11002             * @param nodeId the node ID
11003             * @param head the head
11004             * @param parentTitle the parent title
11005             * @param start the lower bound of the range of wiki pages
11006             * @param end the upper bound of the range of wiki pages (not inclusive)
11007             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11008             * @return the ordered range of matching wiki pages
11009             * @throws SystemException if a system exception occurred
11010             */
11011            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
11012                    String parentTitle, int start, int end,
11013                    OrderByComparator orderByComparator) throws SystemException {
11014                    boolean pagination = true;
11015                    FinderPath finderPath = null;
11016                    Object[] finderArgs = null;
11017    
11018                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11019                                    (orderByComparator == null)) {
11020                            pagination = false;
11021                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P;
11022                            finderArgs = new Object[] { nodeId, head, parentTitle };
11023                    }
11024                    else {
11025                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P;
11026                            finderArgs = new Object[] {
11027                                            nodeId, head, parentTitle,
11028                                            
11029                                            start, end, orderByComparator
11030                                    };
11031                    }
11032    
11033                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
11034                                    finderArgs, this);
11035    
11036                    if ((list != null) && !list.isEmpty()) {
11037                            for (WikiPage wikiPage : list) {
11038                                    if ((nodeId != wikiPage.getNodeId()) ||
11039                                                    (head != wikiPage.getHead()) ||
11040                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle())) {
11041                                            list = null;
11042    
11043                                            break;
11044                                    }
11045                            }
11046                    }
11047    
11048                    if (list == null) {
11049                            StringBundler query = null;
11050    
11051                            if (orderByComparator != null) {
11052                                    query = new StringBundler(5 +
11053                                                    (orderByComparator.getOrderByFields().length * 3));
11054                            }
11055                            else {
11056                                    query = new StringBundler(5);
11057                            }
11058    
11059                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
11060    
11061                            query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
11062    
11063                            query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
11064    
11065                            boolean bindParentTitle = false;
11066    
11067                            if (parentTitle == null) {
11068                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
11069                            }
11070                            else if (parentTitle.equals(StringPool.BLANK)) {
11071                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
11072                            }
11073                            else {
11074                                    bindParentTitle = true;
11075    
11076                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
11077                            }
11078    
11079                            if (orderByComparator != null) {
11080                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11081                                            orderByComparator);
11082                            }
11083                            else
11084                             if (pagination) {
11085                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11086                            }
11087    
11088                            String sql = query.toString();
11089    
11090                            Session session = null;
11091    
11092                            try {
11093                                    session = openSession();
11094    
11095                                    Query q = session.createQuery(sql);
11096    
11097                                    QueryPos qPos = QueryPos.getInstance(q);
11098    
11099                                    qPos.add(nodeId);
11100    
11101                                    qPos.add(head);
11102    
11103                                    if (bindParentTitle) {
11104                                            qPos.add(parentTitle.toLowerCase());
11105                                    }
11106    
11107                                    if (!pagination) {
11108                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
11109                                                            start, end, false);
11110    
11111                                            Collections.sort(list);
11112    
11113                                            list = new UnmodifiableList<WikiPage>(list);
11114                                    }
11115                                    else {
11116                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
11117                                                            start, end);
11118                                    }
11119    
11120                                    cacheResult(list);
11121    
11122                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11123                            }
11124                            catch (Exception e) {
11125                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11126    
11127                                    throw processException(e);
11128                            }
11129                            finally {
11130                                    closeSession(session);
11131                            }
11132                    }
11133    
11134                    return list;
11135            }
11136    
11137            /**
11138             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
11139             *
11140             * @param nodeId the node ID
11141             * @param head the head
11142             * @param parentTitle the parent title
11143             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11144             * @return the first matching wiki page
11145             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
11146             * @throws SystemException if a system exception occurred
11147             */
11148            public WikiPage findByN_H_P_First(long nodeId, boolean head,
11149                    String parentTitle, OrderByComparator orderByComparator)
11150                    throws NoSuchPageException, SystemException {
11151                    WikiPage wikiPage = fetchByN_H_P_First(nodeId, head, parentTitle,
11152                                    orderByComparator);
11153    
11154                    if (wikiPage != null) {
11155                            return wikiPage;
11156                    }
11157    
11158                    StringBundler msg = new StringBundler(8);
11159    
11160                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11161    
11162                    msg.append("nodeId=");
11163                    msg.append(nodeId);
11164    
11165                    msg.append(", head=");
11166                    msg.append(head);
11167    
11168                    msg.append(", parentTitle=");
11169                    msg.append(parentTitle);
11170    
11171                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11172    
11173                    throw new NoSuchPageException(msg.toString());
11174            }
11175    
11176            /**
11177             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
11178             *
11179             * @param nodeId the node ID
11180             * @param head the head
11181             * @param parentTitle the parent title
11182             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11183             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
11184             * @throws SystemException if a system exception occurred
11185             */
11186            public WikiPage fetchByN_H_P_First(long nodeId, boolean head,
11187                    String parentTitle, OrderByComparator orderByComparator)
11188                    throws SystemException {
11189                    List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, 0, 1,
11190                                    orderByComparator);
11191    
11192                    if (!list.isEmpty()) {
11193                            return list.get(0);
11194                    }
11195    
11196                    return null;
11197            }
11198    
11199            /**
11200             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
11201             *
11202             * @param nodeId the node ID
11203             * @param head the head
11204             * @param parentTitle the parent title
11205             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11206             * @return the last matching wiki page
11207             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
11208             * @throws SystemException if a system exception occurred
11209             */
11210            public WikiPage findByN_H_P_Last(long nodeId, boolean head,
11211                    String parentTitle, OrderByComparator orderByComparator)
11212                    throws NoSuchPageException, SystemException {
11213                    WikiPage wikiPage = fetchByN_H_P_Last(nodeId, head, parentTitle,
11214                                    orderByComparator);
11215    
11216                    if (wikiPage != null) {
11217                            return wikiPage;
11218                    }
11219    
11220                    StringBundler msg = new StringBundler(8);
11221    
11222                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11223    
11224                    msg.append("nodeId=");
11225                    msg.append(nodeId);
11226    
11227                    msg.append(", head=");
11228                    msg.append(head);
11229    
11230                    msg.append(", parentTitle=");
11231                    msg.append(parentTitle);
11232    
11233                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11234    
11235                    throw new NoSuchPageException(msg.toString());
11236            }
11237    
11238            /**
11239             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
11240             *
11241             * @param nodeId the node ID
11242             * @param head the head
11243             * @param parentTitle the parent title
11244             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11245             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
11246             * @throws SystemException if a system exception occurred
11247             */
11248            public WikiPage fetchByN_H_P_Last(long nodeId, boolean head,
11249                    String parentTitle, OrderByComparator orderByComparator)
11250                    throws SystemException {
11251                    int count = countByN_H_P(nodeId, head, parentTitle);
11252    
11253                    List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, count - 1,
11254                                    count, orderByComparator);
11255    
11256                    if (!list.isEmpty()) {
11257                            return list.get(0);
11258                    }
11259    
11260                    return null;
11261            }
11262    
11263            /**
11264             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
11265             *
11266             * @param pageId the primary key of the current wiki page
11267             * @param nodeId the node ID
11268             * @param head the head
11269             * @param parentTitle the parent title
11270             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11271             * @return the previous, current, and next wiki page
11272             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
11273             * @throws SystemException if a system exception occurred
11274             */
11275            public WikiPage[] findByN_H_P_PrevAndNext(long pageId, long nodeId,
11276                    boolean head, String parentTitle, OrderByComparator orderByComparator)
11277                    throws NoSuchPageException, SystemException {
11278                    WikiPage wikiPage = findByPrimaryKey(pageId);
11279    
11280                    Session session = null;
11281    
11282                    try {
11283                            session = openSession();
11284    
11285                            WikiPage[] array = new WikiPageImpl[3];
11286    
11287                            array[0] = getByN_H_P_PrevAndNext(session, wikiPage, nodeId, head,
11288                                            parentTitle, orderByComparator, true);
11289    
11290                            array[1] = wikiPage;
11291    
11292                            array[2] = getByN_H_P_PrevAndNext(session, wikiPage, nodeId, head,
11293                                            parentTitle, orderByComparator, false);
11294    
11295                            return array;
11296                    }
11297                    catch (Exception e) {
11298                            throw processException(e);
11299                    }
11300                    finally {
11301                            closeSession(session);
11302                    }
11303            }
11304    
11305            protected WikiPage getByN_H_P_PrevAndNext(Session session,
11306                    WikiPage wikiPage, long nodeId, boolean head, String parentTitle,
11307                    OrderByComparator orderByComparator, boolean previous) {
11308                    StringBundler query = null;
11309    
11310                    if (orderByComparator != null) {
11311                            query = new StringBundler(6 +
11312                                            (orderByComparator.getOrderByFields().length * 6));
11313                    }
11314                    else {
11315                            query = new StringBundler(3);
11316                    }
11317    
11318                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
11319    
11320                    query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
11321    
11322                    query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
11323    
11324                    boolean bindParentTitle = false;
11325    
11326                    if (parentTitle == null) {
11327                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
11328                    }
11329                    else if (parentTitle.equals(StringPool.BLANK)) {
11330                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
11331                    }
11332                    else {
11333                            bindParentTitle = true;
11334    
11335                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
11336                    }
11337    
11338                    if (orderByComparator != null) {
11339                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11340    
11341                            if (orderByConditionFields.length > 0) {
11342                                    query.append(WHERE_AND);
11343                            }
11344    
11345                            for (int i = 0; i < orderByConditionFields.length; i++) {
11346                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11347                                    query.append(orderByConditionFields[i]);
11348    
11349                                    if ((i + 1) < orderByConditionFields.length) {
11350                                            if (orderByComparator.isAscending() ^ previous) {
11351                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11352                                            }
11353                                            else {
11354                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11355                                            }
11356                                    }
11357                                    else {
11358                                            if (orderByComparator.isAscending() ^ previous) {
11359                                                    query.append(WHERE_GREATER_THAN);
11360                                            }
11361                                            else {
11362                                                    query.append(WHERE_LESSER_THAN);
11363                                            }
11364                                    }
11365                            }
11366    
11367                            query.append(ORDER_BY_CLAUSE);
11368    
11369                            String[] orderByFields = orderByComparator.getOrderByFields();
11370    
11371                            for (int i = 0; i < orderByFields.length; i++) {
11372                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11373                                    query.append(orderByFields[i]);
11374    
11375                                    if ((i + 1) < orderByFields.length) {
11376                                            if (orderByComparator.isAscending() ^ previous) {
11377                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11378                                            }
11379                                            else {
11380                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11381                                            }
11382                                    }
11383                                    else {
11384                                            if (orderByComparator.isAscending() ^ previous) {
11385                                                    query.append(ORDER_BY_ASC);
11386                                            }
11387                                            else {
11388                                                    query.append(ORDER_BY_DESC);
11389                                            }
11390                                    }
11391                            }
11392                    }
11393                    else {
11394                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11395                    }
11396    
11397                    String sql = query.toString();
11398    
11399                    Query q = session.createQuery(sql);
11400    
11401                    q.setFirstResult(0);
11402                    q.setMaxResults(2);
11403    
11404                    QueryPos qPos = QueryPos.getInstance(q);
11405    
11406                    qPos.add(nodeId);
11407    
11408                    qPos.add(head);
11409    
11410                    if (bindParentTitle) {
11411                            qPos.add(parentTitle.toLowerCase());
11412                    }
11413    
11414                    if (orderByComparator != null) {
11415                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
11416    
11417                            for (Object value : values) {
11418                                    qPos.add(value);
11419                            }
11420                    }
11421    
11422                    List<WikiPage> list = q.list();
11423    
11424                    if (list.size() == 2) {
11425                            return list.get(1);
11426                    }
11427                    else {
11428                            return null;
11429                    }
11430            }
11431    
11432            /**
11433             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; from the database.
11434             *
11435             * @param nodeId the node ID
11436             * @param head the head
11437             * @param parentTitle the parent title
11438             * @throws SystemException if a system exception occurred
11439             */
11440            public void removeByN_H_P(long nodeId, boolean head, String parentTitle)
11441                    throws SystemException {
11442                    for (WikiPage wikiPage : findByN_H_P(nodeId, head, parentTitle,
11443                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11444                            remove(wikiPage);
11445                    }
11446            }
11447    
11448            /**
11449             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
11450             *
11451             * @param nodeId the node ID
11452             * @param head the head
11453             * @param parentTitle the parent title
11454             * @return the number of matching wiki pages
11455             * @throws SystemException if a system exception occurred
11456             */
11457            public int countByN_H_P(long nodeId, boolean head, String parentTitle)
11458                    throws SystemException {
11459                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_H_P;
11460    
11461                    Object[] finderArgs = new Object[] { nodeId, head, parentTitle };
11462    
11463                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11464                                    this);
11465    
11466                    if (count == null) {
11467                            StringBundler query = new StringBundler(4);
11468    
11469                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
11470    
11471                            query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
11472    
11473                            query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
11474    
11475                            boolean bindParentTitle = false;
11476    
11477                            if (parentTitle == null) {
11478                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
11479                            }
11480                            else if (parentTitle.equals(StringPool.BLANK)) {
11481                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
11482                            }
11483                            else {
11484                                    bindParentTitle = true;
11485    
11486                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
11487                            }
11488    
11489                            String sql = query.toString();
11490    
11491                            Session session = null;
11492    
11493                            try {
11494                                    session = openSession();
11495    
11496                                    Query q = session.createQuery(sql);
11497    
11498                                    QueryPos qPos = QueryPos.getInstance(q);
11499    
11500                                    qPos.add(nodeId);
11501    
11502                                    qPos.add(head);
11503    
11504                                    if (bindParentTitle) {
11505                                            qPos.add(parentTitle.toLowerCase());
11506                                    }
11507    
11508                                    count = (Long)q.uniqueResult();
11509    
11510                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11511                            }
11512                            catch (Exception e) {
11513                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11514    
11515                                    throw processException(e);
11516                            }
11517                            finally {
11518                                    closeSession(session);
11519                            }
11520                    }
11521    
11522                    return count.intValue();
11523            }
11524    
11525            private static final String _FINDER_COLUMN_N_H_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
11526            private static final String _FINDER_COLUMN_N_H_P_HEAD_2 = "wikiPage.head = ? AND ";
11527            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
11528            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = ?";
11529            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = '')";
11530            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
11531                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
11532                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_S",
11533                            new String[] {
11534                                    Long.class.getName(), Boolean.class.getName(),
11535                                    Integer.class.getName(),
11536                                    
11537                            Integer.class.getName(), Integer.class.getName(),
11538                                    OrderByComparator.class.getName()
11539                            });
11540            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
11541                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
11542                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_S",
11543                            new String[] {
11544                                    Long.class.getName(), Boolean.class.getName(),
11545                                    Integer.class.getName()
11546                            },
11547                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
11548                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
11549                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
11550                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
11551                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
11552            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
11553                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
11554                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_S",
11555                            new String[] {
11556                                    Long.class.getName(), Boolean.class.getName(),
11557                                    Integer.class.getName()
11558                            });
11559    
11560            /**
11561             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
11562             *
11563             * @param nodeId the node ID
11564             * @param head the head
11565             * @param status the status
11566             * @return the matching wiki pages
11567             * @throws SystemException if a system exception occurred
11568             */
11569            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status)
11570                    throws SystemException {
11571                    return findByN_H_S(nodeId, head, status, QueryUtil.ALL_POS,
11572                            QueryUtil.ALL_POS, null);
11573            }
11574    
11575            /**
11576             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
11577             *
11578             * <p>
11579             * 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.
11580             * </p>
11581             *
11582             * @param nodeId the node ID
11583             * @param head the head
11584             * @param status the status
11585             * @param start the lower bound of the range of wiki pages
11586             * @param end the upper bound of the range of wiki pages (not inclusive)
11587             * @return the range of matching wiki pages
11588             * @throws SystemException if a system exception occurred
11589             */
11590            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status,
11591                    int start, int end) throws SystemException {
11592                    return findByN_H_S(nodeId, head, status, start, end, null);
11593            }
11594    
11595            /**
11596             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
11597             *
11598             * <p>
11599             * 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.
11600             * </p>
11601             *
11602             * @param nodeId the node ID
11603             * @param head the head
11604             * @param status the status
11605             * @param start the lower bound of the range of wiki pages
11606             * @param end the upper bound of the range of wiki pages (not inclusive)
11607             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11608             * @return the ordered range of matching wiki pages
11609             * @throws SystemException if a system exception occurred
11610             */
11611            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status,
11612                    int start, int end, OrderByComparator orderByComparator)
11613                    throws SystemException {
11614                    boolean pagination = true;
11615                    FinderPath finderPath = null;
11616                    Object[] finderArgs = null;
11617    
11618                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11619                                    (orderByComparator == null)) {
11620                            pagination = false;
11621                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S;
11622                            finderArgs = new Object[] { nodeId, head, status };
11623                    }
11624                    else {
11625                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_S;
11626                            finderArgs = new Object[] {
11627                                            nodeId, head, status,
11628                                            
11629                                            start, end, orderByComparator
11630                                    };
11631                    }
11632    
11633                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
11634                                    finderArgs, this);
11635    
11636                    if ((list != null) && !list.isEmpty()) {
11637                            for (WikiPage wikiPage : list) {
11638                                    if ((nodeId != wikiPage.getNodeId()) ||
11639                                                    (head != wikiPage.getHead()) ||
11640                                                    (status != wikiPage.getStatus())) {
11641                                            list = null;
11642    
11643                                            break;
11644                                    }
11645                            }
11646                    }
11647    
11648                    if (list == null) {
11649                            StringBundler query = null;
11650    
11651                            if (orderByComparator != null) {
11652                                    query = new StringBundler(5 +
11653                                                    (orderByComparator.getOrderByFields().length * 3));
11654                            }
11655                            else {
11656                                    query = new StringBundler(5);
11657                            }
11658    
11659                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
11660    
11661                            query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
11662    
11663                            query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
11664    
11665                            query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
11666    
11667                            if (orderByComparator != null) {
11668                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11669                                            orderByComparator);
11670                            }
11671                            else
11672                             if (pagination) {
11673                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11674                            }
11675    
11676                            String sql = query.toString();
11677    
11678                            Session session = null;
11679    
11680                            try {
11681                                    session = openSession();
11682    
11683                                    Query q = session.createQuery(sql);
11684    
11685                                    QueryPos qPos = QueryPos.getInstance(q);
11686    
11687                                    qPos.add(nodeId);
11688    
11689                                    qPos.add(head);
11690    
11691                                    qPos.add(status);
11692    
11693                                    if (!pagination) {
11694                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
11695                                                            start, end, false);
11696    
11697                                            Collections.sort(list);
11698    
11699                                            list = new UnmodifiableList<WikiPage>(list);
11700                                    }
11701                                    else {
11702                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
11703                                                            start, end);
11704                                    }
11705    
11706                                    cacheResult(list);
11707    
11708                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11709                            }
11710                            catch (Exception e) {
11711                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11712    
11713                                    throw processException(e);
11714                            }
11715                            finally {
11716                                    closeSession(session);
11717                            }
11718                    }
11719    
11720                    return list;
11721            }
11722    
11723            /**
11724             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
11725             *
11726             * @param nodeId the node ID
11727             * @param head the head
11728             * @param status the status
11729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11730             * @return the first matching wiki page
11731             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
11732             * @throws SystemException if a system exception occurred
11733             */
11734            public WikiPage findByN_H_S_First(long nodeId, boolean head, int status,
11735                    OrderByComparator orderByComparator)
11736                    throws NoSuchPageException, SystemException {
11737                    WikiPage wikiPage = fetchByN_H_S_First(nodeId, head, status,
11738                                    orderByComparator);
11739    
11740                    if (wikiPage != null) {
11741                            return wikiPage;
11742                    }
11743    
11744                    StringBundler msg = new StringBundler(8);
11745    
11746                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11747    
11748                    msg.append("nodeId=");
11749                    msg.append(nodeId);
11750    
11751                    msg.append(", head=");
11752                    msg.append(head);
11753    
11754                    msg.append(", status=");
11755                    msg.append(status);
11756    
11757                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11758    
11759                    throw new NoSuchPageException(msg.toString());
11760            }
11761    
11762            /**
11763             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
11764             *
11765             * @param nodeId the node ID
11766             * @param head the head
11767             * @param status the status
11768             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11769             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
11770             * @throws SystemException if a system exception occurred
11771             */
11772            public WikiPage fetchByN_H_S_First(long nodeId, boolean head, int status,
11773                    OrderByComparator orderByComparator) throws SystemException {
11774                    List<WikiPage> list = findByN_H_S(nodeId, head, status, 0, 1,
11775                                    orderByComparator);
11776    
11777                    if (!list.isEmpty()) {
11778                            return list.get(0);
11779                    }
11780    
11781                    return null;
11782            }
11783    
11784            /**
11785             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
11786             *
11787             * @param nodeId the node ID
11788             * @param head the head
11789             * @param status the status
11790             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11791             * @return the last matching wiki page
11792             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
11793             * @throws SystemException if a system exception occurred
11794             */
11795            public WikiPage findByN_H_S_Last(long nodeId, boolean head, int status,
11796                    OrderByComparator orderByComparator)
11797                    throws NoSuchPageException, SystemException {
11798                    WikiPage wikiPage = fetchByN_H_S_Last(nodeId, head, status,
11799                                    orderByComparator);
11800    
11801                    if (wikiPage != null) {
11802                            return wikiPage;
11803                    }
11804    
11805                    StringBundler msg = new StringBundler(8);
11806    
11807                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11808    
11809                    msg.append("nodeId=");
11810                    msg.append(nodeId);
11811    
11812                    msg.append(", head=");
11813                    msg.append(head);
11814    
11815                    msg.append(", status=");
11816                    msg.append(status);
11817    
11818                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11819    
11820                    throw new NoSuchPageException(msg.toString());
11821            }
11822    
11823            /**
11824             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
11825             *
11826             * @param nodeId the node ID
11827             * @param head the head
11828             * @param status the status
11829             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11830             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
11831             * @throws SystemException if a system exception occurred
11832             */
11833            public WikiPage fetchByN_H_S_Last(long nodeId, boolean head, int status,
11834                    OrderByComparator orderByComparator) throws SystemException {
11835                    int count = countByN_H_S(nodeId, head, status);
11836    
11837                    List<WikiPage> list = findByN_H_S(nodeId, head, status, count - 1,
11838                                    count, orderByComparator);
11839    
11840                    if (!list.isEmpty()) {
11841                            return list.get(0);
11842                    }
11843    
11844                    return null;
11845            }
11846    
11847            /**
11848             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
11849             *
11850             * @param pageId the primary key of the current wiki page
11851             * @param nodeId the node ID
11852             * @param head the head
11853             * @param status the status
11854             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11855             * @return the previous, current, and next wiki page
11856             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
11857             * @throws SystemException if a system exception occurred
11858             */
11859            public WikiPage[] findByN_H_S_PrevAndNext(long pageId, long nodeId,
11860                    boolean head, int status, OrderByComparator orderByComparator)
11861                    throws NoSuchPageException, SystemException {
11862                    WikiPage wikiPage = findByPrimaryKey(pageId);
11863    
11864                    Session session = null;
11865    
11866                    try {
11867                            session = openSession();
11868    
11869                            WikiPage[] array = new WikiPageImpl[3];
11870    
11871                            array[0] = getByN_H_S_PrevAndNext(session, wikiPage, nodeId, head,
11872                                            status, orderByComparator, true);
11873    
11874                            array[1] = wikiPage;
11875    
11876                            array[2] = getByN_H_S_PrevAndNext(session, wikiPage, nodeId, head,
11877                                            status, orderByComparator, false);
11878    
11879                            return array;
11880                    }
11881                    catch (Exception e) {
11882                            throw processException(e);
11883                    }
11884                    finally {
11885                            closeSession(session);
11886                    }
11887            }
11888    
11889            protected WikiPage getByN_H_S_PrevAndNext(Session session,
11890                    WikiPage wikiPage, long nodeId, boolean head, int status,
11891                    OrderByComparator orderByComparator, boolean previous) {
11892                    StringBundler query = null;
11893    
11894                    if (orderByComparator != null) {
11895                            query = new StringBundler(6 +
11896                                            (orderByComparator.getOrderByFields().length * 6));
11897                    }
11898                    else {
11899                            query = new StringBundler(3);
11900                    }
11901    
11902                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
11903    
11904                    query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
11905    
11906                    query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
11907    
11908                    query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
11909    
11910                    if (orderByComparator != null) {
11911                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11912    
11913                            if (orderByConditionFields.length > 0) {
11914                                    query.append(WHERE_AND);
11915                            }
11916    
11917                            for (int i = 0; i < orderByConditionFields.length; i++) {
11918                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11919                                    query.append(orderByConditionFields[i]);
11920    
11921                                    if ((i + 1) < orderByConditionFields.length) {
11922                                            if (orderByComparator.isAscending() ^ previous) {
11923                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11924                                            }
11925                                            else {
11926                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11927                                            }
11928                                    }
11929                                    else {
11930                                            if (orderByComparator.isAscending() ^ previous) {
11931                                                    query.append(WHERE_GREATER_THAN);
11932                                            }
11933                                            else {
11934                                                    query.append(WHERE_LESSER_THAN);
11935                                            }
11936                                    }
11937                            }
11938    
11939                            query.append(ORDER_BY_CLAUSE);
11940    
11941                            String[] orderByFields = orderByComparator.getOrderByFields();
11942    
11943                            for (int i = 0; i < orderByFields.length; i++) {
11944                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11945                                    query.append(orderByFields[i]);
11946    
11947                                    if ((i + 1) < orderByFields.length) {
11948                                            if (orderByComparator.isAscending() ^ previous) {
11949                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11950                                            }
11951                                            else {
11952                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11953                                            }
11954                                    }
11955                                    else {
11956                                            if (orderByComparator.isAscending() ^ previous) {
11957                                                    query.append(ORDER_BY_ASC);
11958                                            }
11959                                            else {
11960                                                    query.append(ORDER_BY_DESC);
11961                                            }
11962                                    }
11963                            }
11964                    }
11965                    else {
11966                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11967                    }
11968    
11969                    String sql = query.toString();
11970    
11971                    Query q = session.createQuery(sql);
11972    
11973                    q.setFirstResult(0);
11974                    q.setMaxResults(2);
11975    
11976                    QueryPos qPos = QueryPos.getInstance(q);
11977    
11978                    qPos.add(nodeId);
11979    
11980                    qPos.add(head);
11981    
11982                    qPos.add(status);
11983    
11984                    if (orderByComparator != null) {
11985                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
11986    
11987                            for (Object value : values) {
11988                                    qPos.add(value);
11989                            }
11990                    }
11991    
11992                    List<WikiPage> list = q.list();
11993    
11994                    if (list.size() == 2) {
11995                            return list.get(1);
11996                    }
11997                    else {
11998                            return null;
11999                    }
12000            }
12001    
12002            /**
12003             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63; from the database.
12004             *
12005             * @param nodeId the node ID
12006             * @param head the head
12007             * @param status the status
12008             * @throws SystemException if a system exception occurred
12009             */
12010            public void removeByN_H_S(long nodeId, boolean head, int status)
12011                    throws SystemException {
12012                    for (WikiPage wikiPage : findByN_H_S(nodeId, head, status,
12013                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12014                            remove(wikiPage);
12015                    }
12016            }
12017    
12018            /**
12019             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
12020             *
12021             * @param nodeId the node ID
12022             * @param head the head
12023             * @param status the status
12024             * @return the number of matching wiki pages
12025             * @throws SystemException if a system exception occurred
12026             */
12027            public int countByN_H_S(long nodeId, boolean head, int status)
12028                    throws SystemException {
12029                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_H_S;
12030    
12031                    Object[] finderArgs = new Object[] { nodeId, head, status };
12032    
12033                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12034                                    this);
12035    
12036                    if (count == null) {
12037                            StringBundler query = new StringBundler(4);
12038    
12039                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
12040    
12041                            query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
12042    
12043                            query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
12044    
12045                            query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
12046    
12047                            String sql = query.toString();
12048    
12049                            Session session = null;
12050    
12051                            try {
12052                                    session = openSession();
12053    
12054                                    Query q = session.createQuery(sql);
12055    
12056                                    QueryPos qPos = QueryPos.getInstance(q);
12057    
12058                                    qPos.add(nodeId);
12059    
12060                                    qPos.add(head);
12061    
12062                                    qPos.add(status);
12063    
12064                                    count = (Long)q.uniqueResult();
12065    
12066                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12067                            }
12068                            catch (Exception e) {
12069                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12070    
12071                                    throw processException(e);
12072                            }
12073                            finally {
12074                                    closeSession(session);
12075                            }
12076                    }
12077    
12078                    return count.intValue();
12079            }
12080    
12081            private static final String _FINDER_COLUMN_N_H_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
12082            private static final String _FINDER_COLUMN_N_H_S_HEAD_2 = "wikiPage.head = ? AND ";
12083            private static final String _FINDER_COLUMN_N_H_S_STATUS_2 = "wikiPage.status = ?";
12084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
12085                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
12086                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_N_S",
12087                            new String[] {
12088                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
12089                                    Integer.class.getName(),
12090                                    
12091                            Integer.class.getName(), Integer.class.getName(),
12092                                    OrderByComparator.class.getName()
12093                            });
12094            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S =
12095                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
12096                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
12097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_N_S",
12098                            new String[] {
12099                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
12100                                    Integer.class.getName()
12101                            },
12102                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
12103                            WikiPageModelImpl.USERID_COLUMN_BITMASK |
12104                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
12105                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
12106                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
12107                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
12108            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
12109                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
12110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_N_S",
12111                            new String[] {
12112                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
12113                                    Integer.class.getName()
12114                            });
12115    
12116            /**
12117             * Returns all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
12118             *
12119             * @param groupId the group ID
12120             * @param userId the user ID
12121             * @param nodeId the node ID
12122             * @param status the status
12123             * @return the matching wiki pages
12124             * @throws SystemException if a system exception occurred
12125             */
12126            public List<WikiPage> findByG_U_N_S(long groupId, long userId, long nodeId,
12127                    int status) throws SystemException {
12128                    return findByG_U_N_S(groupId, userId, nodeId, status,
12129                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12130            }
12131    
12132            /**
12133             * Returns a range of all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
12134             *
12135             * <p>
12136             * 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.
12137             * </p>
12138             *
12139             * @param groupId the group ID
12140             * @param userId the user ID
12141             * @param nodeId the node ID
12142             * @param status the status
12143             * @param start the lower bound of the range of wiki pages
12144             * @param end the upper bound of the range of wiki pages (not inclusive)
12145             * @return the range of matching wiki pages
12146             * @throws SystemException if a system exception occurred
12147             */
12148            public List<WikiPage> findByG_U_N_S(long groupId, long userId, long nodeId,
12149                    int status, int start, int end) throws SystemException {
12150                    return findByG_U_N_S(groupId, userId, nodeId, status, start, end, null);
12151            }
12152    
12153            /**
12154             * Returns an ordered range of all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
12155             *
12156             * <p>
12157             * 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.
12158             * </p>
12159             *
12160             * @param groupId the group ID
12161             * @param userId the user ID
12162             * @param nodeId the node ID
12163             * @param status the status
12164             * @param start the lower bound of the range of wiki pages
12165             * @param end the upper bound of the range of wiki pages (not inclusive)
12166             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12167             * @return the ordered range of matching wiki pages
12168             * @throws SystemException if a system exception occurred
12169             */
12170            public List<WikiPage> findByG_U_N_S(long groupId, long userId, long nodeId,
12171                    int status, int start, int end, OrderByComparator orderByComparator)
12172                    throws SystemException {
12173                    boolean pagination = true;
12174                    FinderPath finderPath = null;
12175                    Object[] finderArgs = null;
12176    
12177                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12178                                    (orderByComparator == null)) {
12179                            pagination = false;
12180                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S;
12181                            finderArgs = new Object[] { groupId, userId, nodeId, status };
12182                    }
12183                    else {
12184                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_N_S;
12185                            finderArgs = new Object[] {
12186                                            groupId, userId, nodeId, status,
12187                                            
12188                                            start, end, orderByComparator
12189                                    };
12190                    }
12191    
12192                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
12193                                    finderArgs, this);
12194    
12195                    if ((list != null) && !list.isEmpty()) {
12196                            for (WikiPage wikiPage : list) {
12197                                    if ((groupId != wikiPage.getGroupId()) ||
12198                                                    (userId != wikiPage.getUserId()) ||
12199                                                    (nodeId != wikiPage.getNodeId()) ||
12200                                                    (status != wikiPage.getStatus())) {
12201                                            list = null;
12202    
12203                                            break;
12204                                    }
12205                            }
12206                    }
12207    
12208                    if (list == null) {
12209                            StringBundler query = null;
12210    
12211                            if (orderByComparator != null) {
12212                                    query = new StringBundler(6 +
12213                                                    (orderByComparator.getOrderByFields().length * 3));
12214                            }
12215                            else {
12216                                    query = new StringBundler(6);
12217                            }
12218    
12219                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
12220    
12221                            query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
12222    
12223                            query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
12224    
12225                            query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
12226    
12227                            query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
12228    
12229                            if (orderByComparator != null) {
12230                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12231                                            orderByComparator);
12232                            }
12233                            else
12234                             if (pagination) {
12235                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12236                            }
12237    
12238                            String sql = query.toString();
12239    
12240                            Session session = null;
12241    
12242                            try {
12243                                    session = openSession();
12244    
12245                                    Query q = session.createQuery(sql);
12246    
12247                                    QueryPos qPos = QueryPos.getInstance(q);
12248    
12249                                    qPos.add(groupId);
12250    
12251                                    qPos.add(userId);
12252    
12253                                    qPos.add(nodeId);
12254    
12255                                    qPos.add(status);
12256    
12257                                    if (!pagination) {
12258                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
12259                                                            start, end, false);
12260    
12261                                            Collections.sort(list);
12262    
12263                                            list = new UnmodifiableList<WikiPage>(list);
12264                                    }
12265                                    else {
12266                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
12267                                                            start, end);
12268                                    }
12269    
12270                                    cacheResult(list);
12271    
12272                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12273                            }
12274                            catch (Exception e) {
12275                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12276    
12277                                    throw processException(e);
12278                            }
12279                            finally {
12280                                    closeSession(session);
12281                            }
12282                    }
12283    
12284                    return list;
12285            }
12286    
12287            /**
12288             * Returns the first wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
12289             *
12290             * @param groupId the group ID
12291             * @param userId the user ID
12292             * @param nodeId the node ID
12293             * @param status the status
12294             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12295             * @return the first matching wiki page
12296             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
12297             * @throws SystemException if a system exception occurred
12298             */
12299            public WikiPage findByG_U_N_S_First(long groupId, long userId, long nodeId,
12300                    int status, OrderByComparator orderByComparator)
12301                    throws NoSuchPageException, SystemException {
12302                    WikiPage wikiPage = fetchByG_U_N_S_First(groupId, userId, nodeId,
12303                                    status, orderByComparator);
12304    
12305                    if (wikiPage != null) {
12306                            return wikiPage;
12307                    }
12308    
12309                    StringBundler msg = new StringBundler(10);
12310    
12311                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12312    
12313                    msg.append("groupId=");
12314                    msg.append(groupId);
12315    
12316                    msg.append(", userId=");
12317                    msg.append(userId);
12318    
12319                    msg.append(", nodeId=");
12320                    msg.append(nodeId);
12321    
12322                    msg.append(", status=");
12323                    msg.append(status);
12324    
12325                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12326    
12327                    throw new NoSuchPageException(msg.toString());
12328            }
12329    
12330            /**
12331             * Returns the first wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
12332             *
12333             * @param groupId the group ID
12334             * @param userId the user ID
12335             * @param nodeId the node ID
12336             * @param status the status
12337             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12338             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
12339             * @throws SystemException if a system exception occurred
12340             */
12341            public WikiPage fetchByG_U_N_S_First(long groupId, long userId,
12342                    long nodeId, int status, OrderByComparator orderByComparator)
12343                    throws SystemException {
12344                    List<WikiPage> list = findByG_U_N_S(groupId, userId, nodeId, status, 0,
12345                                    1, orderByComparator);
12346    
12347                    if (!list.isEmpty()) {
12348                            return list.get(0);
12349                    }
12350    
12351                    return null;
12352            }
12353    
12354            /**
12355             * Returns the last wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
12356             *
12357             * @param groupId the group ID
12358             * @param userId the user ID
12359             * @param nodeId the node ID
12360             * @param status the status
12361             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12362             * @return the last matching wiki page
12363             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
12364             * @throws SystemException if a system exception occurred
12365             */
12366            public WikiPage findByG_U_N_S_Last(long groupId, long userId, long nodeId,
12367                    int status, OrderByComparator orderByComparator)
12368                    throws NoSuchPageException, SystemException {
12369                    WikiPage wikiPage = fetchByG_U_N_S_Last(groupId, userId, nodeId,
12370                                    status, orderByComparator);
12371    
12372                    if (wikiPage != null) {
12373                            return wikiPage;
12374                    }
12375    
12376                    StringBundler msg = new StringBundler(10);
12377    
12378                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12379    
12380                    msg.append("groupId=");
12381                    msg.append(groupId);
12382    
12383                    msg.append(", userId=");
12384                    msg.append(userId);
12385    
12386                    msg.append(", nodeId=");
12387                    msg.append(nodeId);
12388    
12389                    msg.append(", status=");
12390                    msg.append(status);
12391    
12392                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12393    
12394                    throw new NoSuchPageException(msg.toString());
12395            }
12396    
12397            /**
12398             * Returns the last wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
12399             *
12400             * @param groupId the group ID
12401             * @param userId the user ID
12402             * @param nodeId the node ID
12403             * @param status the status
12404             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12405             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
12406             * @throws SystemException if a system exception occurred
12407             */
12408            public WikiPage fetchByG_U_N_S_Last(long groupId, long userId, long nodeId,
12409                    int status, OrderByComparator orderByComparator)
12410                    throws SystemException {
12411                    int count = countByG_U_N_S(groupId, userId, nodeId, status);
12412    
12413                    List<WikiPage> list = findByG_U_N_S(groupId, userId, nodeId, status,
12414                                    count - 1, count, orderByComparator);
12415    
12416                    if (!list.isEmpty()) {
12417                            return list.get(0);
12418                    }
12419    
12420                    return null;
12421            }
12422    
12423            /**
12424             * 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;.
12425             *
12426             * @param pageId the primary key of the current wiki page
12427             * @param groupId the group ID
12428             * @param userId the user ID
12429             * @param nodeId the node ID
12430             * @param status the status
12431             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12432             * @return the previous, current, and next wiki page
12433             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
12434             * @throws SystemException if a system exception occurred
12435             */
12436            public WikiPage[] findByG_U_N_S_PrevAndNext(long pageId, long groupId,
12437                    long userId, long nodeId, int status,
12438                    OrderByComparator orderByComparator)
12439                    throws NoSuchPageException, SystemException {
12440                    WikiPage wikiPage = findByPrimaryKey(pageId);
12441    
12442                    Session session = null;
12443    
12444                    try {
12445                            session = openSession();
12446    
12447                            WikiPage[] array = new WikiPageImpl[3];
12448    
12449                            array[0] = getByG_U_N_S_PrevAndNext(session, wikiPage, groupId,
12450                                            userId, nodeId, status, orderByComparator, true);
12451    
12452                            array[1] = wikiPage;
12453    
12454                            array[2] = getByG_U_N_S_PrevAndNext(session, wikiPage, groupId,
12455                                            userId, nodeId, status, orderByComparator, false);
12456    
12457                            return array;
12458                    }
12459                    catch (Exception e) {
12460                            throw processException(e);
12461                    }
12462                    finally {
12463                            closeSession(session);
12464                    }
12465            }
12466    
12467            protected WikiPage getByG_U_N_S_PrevAndNext(Session session,
12468                    WikiPage wikiPage, long groupId, long userId, long nodeId, int status,
12469                    OrderByComparator orderByComparator, boolean previous) {
12470                    StringBundler query = null;
12471    
12472                    if (orderByComparator != null) {
12473                            query = new StringBundler(6 +
12474                                            (orderByComparator.getOrderByFields().length * 6));
12475                    }
12476                    else {
12477                            query = new StringBundler(3);
12478                    }
12479    
12480                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
12481    
12482                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
12483    
12484                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
12485    
12486                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
12487    
12488                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
12489    
12490                    if (orderByComparator != null) {
12491                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12492    
12493                            if (orderByConditionFields.length > 0) {
12494                                    query.append(WHERE_AND);
12495                            }
12496    
12497                            for (int i = 0; i < orderByConditionFields.length; i++) {
12498                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12499                                    query.append(orderByConditionFields[i]);
12500    
12501                                    if ((i + 1) < orderByConditionFields.length) {
12502                                            if (orderByComparator.isAscending() ^ previous) {
12503                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12504                                            }
12505                                            else {
12506                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12507                                            }
12508                                    }
12509                                    else {
12510                                            if (orderByComparator.isAscending() ^ previous) {
12511                                                    query.append(WHERE_GREATER_THAN);
12512                                            }
12513                                            else {
12514                                                    query.append(WHERE_LESSER_THAN);
12515                                            }
12516                                    }
12517                            }
12518    
12519                            query.append(ORDER_BY_CLAUSE);
12520    
12521                            String[] orderByFields = orderByComparator.getOrderByFields();
12522    
12523                            for (int i = 0; i < orderByFields.length; i++) {
12524                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12525                                    query.append(orderByFields[i]);
12526    
12527                                    if ((i + 1) < orderByFields.length) {
12528                                            if (orderByComparator.isAscending() ^ previous) {
12529                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12530                                            }
12531                                            else {
12532                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12533                                            }
12534                                    }
12535                                    else {
12536                                            if (orderByComparator.isAscending() ^ previous) {
12537                                                    query.append(ORDER_BY_ASC);
12538                                            }
12539                                            else {
12540                                                    query.append(ORDER_BY_DESC);
12541                                            }
12542                                    }
12543                            }
12544                    }
12545                    else {
12546                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12547                    }
12548    
12549                    String sql = query.toString();
12550    
12551                    Query q = session.createQuery(sql);
12552    
12553                    q.setFirstResult(0);
12554                    q.setMaxResults(2);
12555    
12556                    QueryPos qPos = QueryPos.getInstance(q);
12557    
12558                    qPos.add(groupId);
12559    
12560                    qPos.add(userId);
12561    
12562                    qPos.add(nodeId);
12563    
12564                    qPos.add(status);
12565    
12566                    if (orderByComparator != null) {
12567                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
12568    
12569                            for (Object value : values) {
12570                                    qPos.add(value);
12571                            }
12572                    }
12573    
12574                    List<WikiPage> list = q.list();
12575    
12576                    if (list.size() == 2) {
12577                            return list.get(1);
12578                    }
12579                    else {
12580                            return null;
12581                    }
12582            }
12583    
12584            /**
12585             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
12586             *
12587             * @param groupId the group ID
12588             * @param userId the user ID
12589             * @param nodeId the node ID
12590             * @param status the status
12591             * @return the matching wiki pages that the user has permission to view
12592             * @throws SystemException if a system exception occurred
12593             */
12594            public List<WikiPage> filterFindByG_U_N_S(long groupId, long userId,
12595                    long nodeId, int status) throws SystemException {
12596                    return filterFindByG_U_N_S(groupId, userId, nodeId, status,
12597                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12598            }
12599    
12600            /**
12601             * 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;.
12602             *
12603             * <p>
12604             * 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.
12605             * </p>
12606             *
12607             * @param groupId the group ID
12608             * @param userId the user ID
12609             * @param nodeId the node ID
12610             * @param status the status
12611             * @param start the lower bound of the range of wiki pages
12612             * @param end the upper bound of the range of wiki pages (not inclusive)
12613             * @return the range of matching wiki pages that the user has permission to view
12614             * @throws SystemException if a system exception occurred
12615             */
12616            public List<WikiPage> filterFindByG_U_N_S(long groupId, long userId,
12617                    long nodeId, int status, int start, int end) throws SystemException {
12618                    return filterFindByG_U_N_S(groupId, userId, nodeId, status, start, end,
12619                            null);
12620            }
12621    
12622            /**
12623             * 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;.
12624             *
12625             * <p>
12626             * 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.
12627             * </p>
12628             *
12629             * @param groupId the group ID
12630             * @param userId the user ID
12631             * @param nodeId the node ID
12632             * @param status the status
12633             * @param start the lower bound of the range of wiki pages
12634             * @param end the upper bound of the range of wiki pages (not inclusive)
12635             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12636             * @return the ordered range of matching wiki pages that the user has permission to view
12637             * @throws SystemException if a system exception occurred
12638             */
12639            public List<WikiPage> filterFindByG_U_N_S(long groupId, long userId,
12640                    long nodeId, int status, int start, int end,
12641                    OrderByComparator orderByComparator) throws SystemException {
12642                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12643                            return findByG_U_N_S(groupId, userId, nodeId, status, start, end,
12644                                    orderByComparator);
12645                    }
12646    
12647                    StringBundler query = null;
12648    
12649                    if (orderByComparator != null) {
12650                            query = new StringBundler(6 +
12651                                            (orderByComparator.getOrderByFields().length * 3));
12652                    }
12653                    else {
12654                            query = new StringBundler(6);
12655                    }
12656    
12657                    if (getDB().isSupportsInlineDistinct()) {
12658                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
12659                    }
12660                    else {
12661                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
12662                    }
12663    
12664                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
12665    
12666                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
12667    
12668                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
12669    
12670                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
12671    
12672                    if (!getDB().isSupportsInlineDistinct()) {
12673                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
12674                    }
12675    
12676                    if (orderByComparator != null) {
12677                            if (getDB().isSupportsInlineDistinct()) {
12678                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12679                                            orderByComparator);
12680                            }
12681                            else {
12682                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12683                                            orderByComparator);
12684                            }
12685                    }
12686                    else {
12687                            if (getDB().isSupportsInlineDistinct()) {
12688                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12689                            }
12690                            else {
12691                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
12692                            }
12693                    }
12694    
12695                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12696                                    WikiPage.class.getName(),
12697                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12698    
12699                    Session session = null;
12700    
12701                    try {
12702                            session = openSession();
12703    
12704                            SQLQuery q = session.createSQLQuery(sql);
12705    
12706                            if (getDB().isSupportsInlineDistinct()) {
12707                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
12708                            }
12709                            else {
12710                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
12711                            }
12712    
12713                            QueryPos qPos = QueryPos.getInstance(q);
12714    
12715                            qPos.add(groupId);
12716    
12717                            qPos.add(userId);
12718    
12719                            qPos.add(nodeId);
12720    
12721                            qPos.add(status);
12722    
12723                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
12724                    }
12725                    catch (Exception e) {
12726                            throw processException(e);
12727                    }
12728                    finally {
12729                            closeSession(session);
12730                    }
12731            }
12732    
12733            /**
12734             * 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;.
12735             *
12736             * @param pageId the primary key of the current wiki page
12737             * @param groupId the group ID
12738             * @param userId the user ID
12739             * @param nodeId the node ID
12740             * @param status the status
12741             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12742             * @return the previous, current, and next wiki page
12743             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
12744             * @throws SystemException if a system exception occurred
12745             */
12746            public WikiPage[] filterFindByG_U_N_S_PrevAndNext(long pageId,
12747                    long groupId, long userId, long nodeId, int status,
12748                    OrderByComparator orderByComparator)
12749                    throws NoSuchPageException, SystemException {
12750                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12751                            return findByG_U_N_S_PrevAndNext(pageId, groupId, userId, nodeId,
12752                                    status, orderByComparator);
12753                    }
12754    
12755                    WikiPage wikiPage = findByPrimaryKey(pageId);
12756    
12757                    Session session = null;
12758    
12759                    try {
12760                            session = openSession();
12761    
12762                            WikiPage[] array = new WikiPageImpl[3];
12763    
12764                            array[0] = filterGetByG_U_N_S_PrevAndNext(session, wikiPage,
12765                                            groupId, userId, nodeId, status, orderByComparator, true);
12766    
12767                            array[1] = wikiPage;
12768    
12769                            array[2] = filterGetByG_U_N_S_PrevAndNext(session, wikiPage,
12770                                            groupId, userId, nodeId, status, orderByComparator, false);
12771    
12772                            return array;
12773                    }
12774                    catch (Exception e) {
12775                            throw processException(e);
12776                    }
12777                    finally {
12778                            closeSession(session);
12779                    }
12780            }
12781    
12782            protected WikiPage filterGetByG_U_N_S_PrevAndNext(Session session,
12783                    WikiPage wikiPage, long groupId, long userId, long nodeId, int status,
12784                    OrderByComparator orderByComparator, boolean previous) {
12785                    StringBundler query = null;
12786    
12787                    if (orderByComparator != null) {
12788                            query = new StringBundler(6 +
12789                                            (orderByComparator.getOrderByFields().length * 6));
12790                    }
12791                    else {
12792                            query = new StringBundler(3);
12793                    }
12794    
12795                    if (getDB().isSupportsInlineDistinct()) {
12796                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
12797                    }
12798                    else {
12799                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
12800                    }
12801    
12802                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
12803    
12804                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
12805    
12806                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
12807    
12808                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
12809    
12810                    if (!getDB().isSupportsInlineDistinct()) {
12811                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
12812                    }
12813    
12814                    if (orderByComparator != null) {
12815                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12816    
12817                            if (orderByConditionFields.length > 0) {
12818                                    query.append(WHERE_AND);
12819                            }
12820    
12821                            for (int i = 0; i < orderByConditionFields.length; i++) {
12822                                    if (getDB().isSupportsInlineDistinct()) {
12823                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12824                                    }
12825                                    else {
12826                                            query.append(_ORDER_BY_ENTITY_TABLE);
12827                                    }
12828    
12829                                    query.append(orderByConditionFields[i]);
12830    
12831                                    if ((i + 1) < orderByConditionFields.length) {
12832                                            if (orderByComparator.isAscending() ^ previous) {
12833                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12834                                            }
12835                                            else {
12836                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12837                                            }
12838                                    }
12839                                    else {
12840                                            if (orderByComparator.isAscending() ^ previous) {
12841                                                    query.append(WHERE_GREATER_THAN);
12842                                            }
12843                                            else {
12844                                                    query.append(WHERE_LESSER_THAN);
12845                                            }
12846                                    }
12847                            }
12848    
12849                            query.append(ORDER_BY_CLAUSE);
12850    
12851                            String[] orderByFields = orderByComparator.getOrderByFields();
12852    
12853                            for (int i = 0; i < orderByFields.length; i++) {
12854                                    if (getDB().isSupportsInlineDistinct()) {
12855                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12856                                    }
12857                                    else {
12858                                            query.append(_ORDER_BY_ENTITY_TABLE);
12859                                    }
12860    
12861                                    query.append(orderByFields[i]);
12862    
12863                                    if ((i + 1) < orderByFields.length) {
12864                                            if (orderByComparator.isAscending() ^ previous) {
12865                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12866                                            }
12867                                            else {
12868                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12869                                            }
12870                                    }
12871                                    else {
12872                                            if (orderByComparator.isAscending() ^ previous) {
12873                                                    query.append(ORDER_BY_ASC);
12874                                            }
12875                                            else {
12876                                                    query.append(ORDER_BY_DESC);
12877                                            }
12878                                    }
12879                            }
12880                    }
12881                    else {
12882                            if (getDB().isSupportsInlineDistinct()) {
12883                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12884                            }
12885                            else {
12886                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
12887                            }
12888                    }
12889    
12890                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12891                                    WikiPage.class.getName(),
12892                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12893    
12894                    SQLQuery q = session.createSQLQuery(sql);
12895    
12896                    q.setFirstResult(0);
12897                    q.setMaxResults(2);
12898    
12899                    if (getDB().isSupportsInlineDistinct()) {
12900                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
12901                    }
12902                    else {
12903                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
12904                    }
12905    
12906                    QueryPos qPos = QueryPos.getInstance(q);
12907    
12908                    qPos.add(groupId);
12909    
12910                    qPos.add(userId);
12911    
12912                    qPos.add(nodeId);
12913    
12914                    qPos.add(status);
12915    
12916                    if (orderByComparator != null) {
12917                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
12918    
12919                            for (Object value : values) {
12920                                    qPos.add(value);
12921                            }
12922                    }
12923    
12924                    List<WikiPage> list = q.list();
12925    
12926                    if (list.size() == 2) {
12927                            return list.get(1);
12928                    }
12929                    else {
12930                            return null;
12931                    }
12932            }
12933    
12934            /**
12935             * Removes all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63; from the database.
12936             *
12937             * @param groupId the group ID
12938             * @param userId the user ID
12939             * @param nodeId the node ID
12940             * @param status the status
12941             * @throws SystemException if a system exception occurred
12942             */
12943            public void removeByG_U_N_S(long groupId, long userId, long nodeId,
12944                    int status) throws SystemException {
12945                    for (WikiPage wikiPage : findByG_U_N_S(groupId, userId, nodeId, status,
12946                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12947                            remove(wikiPage);
12948                    }
12949            }
12950    
12951            /**
12952             * Returns the number of wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
12953             *
12954             * @param groupId the group ID
12955             * @param userId the user ID
12956             * @param nodeId the node ID
12957             * @param status the status
12958             * @return the number of matching wiki pages
12959             * @throws SystemException if a system exception occurred
12960             */
12961            public int countByG_U_N_S(long groupId, long userId, long nodeId, int status)
12962                    throws SystemException {
12963                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_N_S;
12964    
12965                    Object[] finderArgs = new Object[] { groupId, userId, nodeId, status };
12966    
12967                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12968                                    this);
12969    
12970                    if (count == null) {
12971                            StringBundler query = new StringBundler(5);
12972    
12973                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
12974    
12975                            query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
12976    
12977                            query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
12978    
12979                            query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
12980    
12981                            query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
12982    
12983                            String sql = query.toString();
12984    
12985                            Session session = null;
12986    
12987                            try {
12988                                    session = openSession();
12989    
12990                                    Query q = session.createQuery(sql);
12991    
12992                                    QueryPos qPos = QueryPos.getInstance(q);
12993    
12994                                    qPos.add(groupId);
12995    
12996                                    qPos.add(userId);
12997    
12998                                    qPos.add(nodeId);
12999    
13000                                    qPos.add(status);
13001    
13002                                    count = (Long)q.uniqueResult();
13003    
13004                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13005                            }
13006                            catch (Exception e) {
13007                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13008    
13009                                    throw processException(e);
13010                            }
13011                            finally {
13012                                    closeSession(session);
13013                            }
13014                    }
13015    
13016                    return count.intValue();
13017            }
13018    
13019            /**
13020             * 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;.
13021             *
13022             * @param groupId the group ID
13023             * @param userId the user ID
13024             * @param nodeId the node ID
13025             * @param status the status
13026             * @return the number of matching wiki pages that the user has permission to view
13027             * @throws SystemException if a system exception occurred
13028             */
13029            public int filterCountByG_U_N_S(long groupId, long userId, long nodeId,
13030                    int status) throws SystemException {
13031                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13032                            return countByG_U_N_S(groupId, userId, nodeId, status);
13033                    }
13034    
13035                    StringBundler query = new StringBundler(5);
13036    
13037                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
13038    
13039                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
13040    
13041                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
13042    
13043                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
13044    
13045                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
13046    
13047                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13048                                    WikiPage.class.getName(),
13049                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13050    
13051                    Session session = null;
13052    
13053                    try {
13054                            session = openSession();
13055    
13056                            SQLQuery q = session.createSQLQuery(sql);
13057    
13058                            q.addScalar(COUNT_COLUMN_NAME,
13059                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13060    
13061                            QueryPos qPos = QueryPos.getInstance(q);
13062    
13063                            qPos.add(groupId);
13064    
13065                            qPos.add(userId);
13066    
13067                            qPos.add(nodeId);
13068    
13069                            qPos.add(status);
13070    
13071                            Long count = (Long)q.uniqueResult();
13072    
13073                            return count.intValue();
13074                    }
13075                    catch (Exception e) {
13076                            throw processException(e);
13077                    }
13078                    finally {
13079                            closeSession(session);
13080                    }
13081            }
13082    
13083            private static final String _FINDER_COLUMN_G_U_N_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
13084            private static final String _FINDER_COLUMN_G_U_N_S_USERID_2 = "wikiPage.userId = ? AND ";
13085            private static final String _FINDER_COLUMN_G_U_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
13086            private static final String _FINDER_COLUMN_G_U_N_S_STATUS_2 = "wikiPage.status = ?";
13087            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
13088                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
13089                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_T_H",
13090                            new String[] {
13091                                    Long.class.getName(), Long.class.getName(),
13092                                    String.class.getName(), Boolean.class.getName(),
13093                                    
13094                            Integer.class.getName(), Integer.class.getName(),
13095                                    OrderByComparator.class.getName()
13096                            });
13097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H =
13098                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
13099                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
13100                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_T_H",
13101                            new String[] {
13102                                    Long.class.getName(), Long.class.getName(),
13103                                    String.class.getName(), Boolean.class.getName()
13104                            },
13105                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
13106                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
13107                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
13108                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
13109                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
13110            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
13111                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
13112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_T_H",
13113                            new String[] {
13114                                    Long.class.getName(), Long.class.getName(),
13115                                    String.class.getName(), Boolean.class.getName()
13116                            });
13117    
13118            /**
13119             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
13120             *
13121             * @param groupId the group ID
13122             * @param nodeId the node ID
13123             * @param title the title
13124             * @param head the head
13125             * @return the matching wiki pages
13126             * @throws SystemException if a system exception occurred
13127             */
13128            public List<WikiPage> findByG_N_T_H(long groupId, long nodeId,
13129                    String title, boolean head) throws SystemException {
13130                    return findByG_N_T_H(groupId, nodeId, title, head, QueryUtil.ALL_POS,
13131                            QueryUtil.ALL_POS, null);
13132            }
13133    
13134            /**
13135             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
13136             *
13137             * <p>
13138             * 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.
13139             * </p>
13140             *
13141             * @param groupId the group ID
13142             * @param nodeId the node ID
13143             * @param title the title
13144             * @param head the head
13145             * @param start the lower bound of the range of wiki pages
13146             * @param end the upper bound of the range of wiki pages (not inclusive)
13147             * @return the range of matching wiki pages
13148             * @throws SystemException if a system exception occurred
13149             */
13150            public List<WikiPage> findByG_N_T_H(long groupId, long nodeId,
13151                    String title, boolean head, int start, int end)
13152                    throws SystemException {
13153                    return findByG_N_T_H(groupId, nodeId, title, head, start, end, null);
13154            }
13155    
13156            /**
13157             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
13158             *
13159             * <p>
13160             * 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.
13161             * </p>
13162             *
13163             * @param groupId the group ID
13164             * @param nodeId the node ID
13165             * @param title the title
13166             * @param head the head
13167             * @param start the lower bound of the range of wiki pages
13168             * @param end the upper bound of the range of wiki pages (not inclusive)
13169             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13170             * @return the ordered range of matching wiki pages
13171             * @throws SystemException if a system exception occurred
13172             */
13173            public List<WikiPage> findByG_N_T_H(long groupId, long nodeId,
13174                    String title, boolean head, int start, int end,
13175                    OrderByComparator orderByComparator) throws SystemException {
13176                    boolean pagination = true;
13177                    FinderPath finderPath = null;
13178                    Object[] finderArgs = null;
13179    
13180                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13181                                    (orderByComparator == null)) {
13182                            pagination = false;
13183                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H;
13184                            finderArgs = new Object[] { groupId, nodeId, title, head };
13185                    }
13186                    else {
13187                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_T_H;
13188                            finderArgs = new Object[] {
13189                                            groupId, nodeId, title, head,
13190                                            
13191                                            start, end, orderByComparator
13192                                    };
13193                    }
13194    
13195                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
13196                                    finderArgs, this);
13197    
13198                    if ((list != null) && !list.isEmpty()) {
13199                            for (WikiPage wikiPage : list) {
13200                                    if ((groupId != wikiPage.getGroupId()) ||
13201                                                    (nodeId != wikiPage.getNodeId()) ||
13202                                                    !Validator.equals(title, wikiPage.getTitle()) ||
13203                                                    (head != wikiPage.getHead())) {
13204                                            list = null;
13205    
13206                                            break;
13207                                    }
13208                            }
13209                    }
13210    
13211                    if (list == null) {
13212                            StringBundler query = null;
13213    
13214                            if (orderByComparator != null) {
13215                                    query = new StringBundler(6 +
13216                                                    (orderByComparator.getOrderByFields().length * 3));
13217                            }
13218                            else {
13219                                    query = new StringBundler(6);
13220                            }
13221    
13222                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
13223    
13224                            query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
13225    
13226                            query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
13227    
13228                            boolean bindTitle = false;
13229    
13230                            if (title == null) {
13231                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
13232                            }
13233                            else if (title.equals(StringPool.BLANK)) {
13234                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
13235                            }
13236                            else {
13237                                    bindTitle = true;
13238    
13239                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
13240                            }
13241    
13242                            query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
13243    
13244                            if (orderByComparator != null) {
13245                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13246                                            orderByComparator);
13247                            }
13248                            else
13249                             if (pagination) {
13250                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13251                            }
13252    
13253                            String sql = query.toString();
13254    
13255                            Session session = null;
13256    
13257                            try {
13258                                    session = openSession();
13259    
13260                                    Query q = session.createQuery(sql);
13261    
13262                                    QueryPos qPos = QueryPos.getInstance(q);
13263    
13264                                    qPos.add(groupId);
13265    
13266                                    qPos.add(nodeId);
13267    
13268                                    if (bindTitle) {
13269                                            qPos.add(title.toLowerCase());
13270                                    }
13271    
13272                                    qPos.add(head);
13273    
13274                                    if (!pagination) {
13275                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
13276                                                            start, end, false);
13277    
13278                                            Collections.sort(list);
13279    
13280                                            list = new UnmodifiableList<WikiPage>(list);
13281                                    }
13282                                    else {
13283                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
13284                                                            start, end);
13285                                    }
13286    
13287                                    cacheResult(list);
13288    
13289                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13290                            }
13291                            catch (Exception e) {
13292                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13293    
13294                                    throw processException(e);
13295                            }
13296                            finally {
13297                                    closeSession(session);
13298                            }
13299                    }
13300    
13301                    return list;
13302            }
13303    
13304            /**
13305             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
13306             *
13307             * @param groupId the group ID
13308             * @param nodeId the node ID
13309             * @param title the title
13310             * @param head the head
13311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13312             * @return the first matching wiki page
13313             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
13314             * @throws SystemException if a system exception occurred
13315             */
13316            public WikiPage findByG_N_T_H_First(long groupId, long nodeId,
13317                    String title, boolean head, OrderByComparator orderByComparator)
13318                    throws NoSuchPageException, SystemException {
13319                    WikiPage wikiPage = fetchByG_N_T_H_First(groupId, nodeId, title, head,
13320                                    orderByComparator);
13321    
13322                    if (wikiPage != null) {
13323                            return wikiPage;
13324                    }
13325    
13326                    StringBundler msg = new StringBundler(10);
13327    
13328                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13329    
13330                    msg.append("groupId=");
13331                    msg.append(groupId);
13332    
13333                    msg.append(", nodeId=");
13334                    msg.append(nodeId);
13335    
13336                    msg.append(", title=");
13337                    msg.append(title);
13338    
13339                    msg.append(", head=");
13340                    msg.append(head);
13341    
13342                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13343    
13344                    throw new NoSuchPageException(msg.toString());
13345            }
13346    
13347            /**
13348             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
13349             *
13350             * @param groupId the group ID
13351             * @param nodeId the node ID
13352             * @param title the title
13353             * @param head the head
13354             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13355             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
13356             * @throws SystemException if a system exception occurred
13357             */
13358            public WikiPage fetchByG_N_T_H_First(long groupId, long nodeId,
13359                    String title, boolean head, OrderByComparator orderByComparator)
13360                    throws SystemException {
13361                    List<WikiPage> list = findByG_N_T_H(groupId, nodeId, title, head, 0, 1,
13362                                    orderByComparator);
13363    
13364                    if (!list.isEmpty()) {
13365                            return list.get(0);
13366                    }
13367    
13368                    return null;
13369            }
13370    
13371            /**
13372             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
13373             *
13374             * @param groupId the group ID
13375             * @param nodeId the node ID
13376             * @param title the title
13377             * @param head the head
13378             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13379             * @return the last matching wiki page
13380             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
13381             * @throws SystemException if a system exception occurred
13382             */
13383            public WikiPage findByG_N_T_H_Last(long groupId, long nodeId, String title,
13384                    boolean head, OrderByComparator orderByComparator)
13385                    throws NoSuchPageException, SystemException {
13386                    WikiPage wikiPage = fetchByG_N_T_H_Last(groupId, nodeId, title, head,
13387                                    orderByComparator);
13388    
13389                    if (wikiPage != null) {
13390                            return wikiPage;
13391                    }
13392    
13393                    StringBundler msg = new StringBundler(10);
13394    
13395                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13396    
13397                    msg.append("groupId=");
13398                    msg.append(groupId);
13399    
13400                    msg.append(", nodeId=");
13401                    msg.append(nodeId);
13402    
13403                    msg.append(", title=");
13404                    msg.append(title);
13405    
13406                    msg.append(", head=");
13407                    msg.append(head);
13408    
13409                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13410    
13411                    throw new NoSuchPageException(msg.toString());
13412            }
13413    
13414            /**
13415             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
13416             *
13417             * @param groupId the group ID
13418             * @param nodeId the node ID
13419             * @param title the title
13420             * @param head the head
13421             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13422             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
13423             * @throws SystemException if a system exception occurred
13424             */
13425            public WikiPage fetchByG_N_T_H_Last(long groupId, long nodeId,
13426                    String title, boolean head, OrderByComparator orderByComparator)
13427                    throws SystemException {
13428                    int count = countByG_N_T_H(groupId, nodeId, title, head);
13429    
13430                    List<WikiPage> list = findByG_N_T_H(groupId, nodeId, title, head,
13431                                    count - 1, count, orderByComparator);
13432    
13433                    if (!list.isEmpty()) {
13434                            return list.get(0);
13435                    }
13436    
13437                    return null;
13438            }
13439    
13440            /**
13441             * 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;.
13442             *
13443             * @param pageId the primary key of the current wiki page
13444             * @param groupId the group ID
13445             * @param nodeId the node ID
13446             * @param title the title
13447             * @param head the head
13448             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13449             * @return the previous, current, and next wiki page
13450             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
13451             * @throws SystemException if a system exception occurred
13452             */
13453            public WikiPage[] findByG_N_T_H_PrevAndNext(long pageId, long groupId,
13454                    long nodeId, String title, boolean head,
13455                    OrderByComparator orderByComparator)
13456                    throws NoSuchPageException, SystemException {
13457                    WikiPage wikiPage = findByPrimaryKey(pageId);
13458    
13459                    Session session = null;
13460    
13461                    try {
13462                            session = openSession();
13463    
13464                            WikiPage[] array = new WikiPageImpl[3];
13465    
13466                            array[0] = getByG_N_T_H_PrevAndNext(session, wikiPage, groupId,
13467                                            nodeId, title, head, orderByComparator, true);
13468    
13469                            array[1] = wikiPage;
13470    
13471                            array[2] = getByG_N_T_H_PrevAndNext(session, wikiPage, groupId,
13472                                            nodeId, title, head, orderByComparator, false);
13473    
13474                            return array;
13475                    }
13476                    catch (Exception e) {
13477                            throw processException(e);
13478                    }
13479                    finally {
13480                            closeSession(session);
13481                    }
13482            }
13483    
13484            protected WikiPage getByG_N_T_H_PrevAndNext(Session session,
13485                    WikiPage wikiPage, long groupId, long nodeId, String title,
13486                    boolean head, OrderByComparator orderByComparator, boolean previous) {
13487                    StringBundler query = null;
13488    
13489                    if (orderByComparator != null) {
13490                            query = new StringBundler(6 +
13491                                            (orderByComparator.getOrderByFields().length * 6));
13492                    }
13493                    else {
13494                            query = new StringBundler(3);
13495                    }
13496    
13497                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
13498    
13499                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
13500    
13501                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
13502    
13503                    boolean bindTitle = false;
13504    
13505                    if (title == null) {
13506                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
13507                    }
13508                    else if (title.equals(StringPool.BLANK)) {
13509                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
13510                    }
13511                    else {
13512                            bindTitle = true;
13513    
13514                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
13515                    }
13516    
13517                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
13518    
13519                    if (orderByComparator != null) {
13520                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13521    
13522                            if (orderByConditionFields.length > 0) {
13523                                    query.append(WHERE_AND);
13524                            }
13525    
13526                            for (int i = 0; i < orderByConditionFields.length; i++) {
13527                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13528                                    query.append(orderByConditionFields[i]);
13529    
13530                                    if ((i + 1) < orderByConditionFields.length) {
13531                                            if (orderByComparator.isAscending() ^ previous) {
13532                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13533                                            }
13534                                            else {
13535                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13536                                            }
13537                                    }
13538                                    else {
13539                                            if (orderByComparator.isAscending() ^ previous) {
13540                                                    query.append(WHERE_GREATER_THAN);
13541                                            }
13542                                            else {
13543                                                    query.append(WHERE_LESSER_THAN);
13544                                            }
13545                                    }
13546                            }
13547    
13548                            query.append(ORDER_BY_CLAUSE);
13549    
13550                            String[] orderByFields = orderByComparator.getOrderByFields();
13551    
13552                            for (int i = 0; i < orderByFields.length; i++) {
13553                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13554                                    query.append(orderByFields[i]);
13555    
13556                                    if ((i + 1) < orderByFields.length) {
13557                                            if (orderByComparator.isAscending() ^ previous) {
13558                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13559                                            }
13560                                            else {
13561                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13562                                            }
13563                                    }
13564                                    else {
13565                                            if (orderByComparator.isAscending() ^ previous) {
13566                                                    query.append(ORDER_BY_ASC);
13567                                            }
13568                                            else {
13569                                                    query.append(ORDER_BY_DESC);
13570                                            }
13571                                    }
13572                            }
13573                    }
13574                    else {
13575                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13576                    }
13577    
13578                    String sql = query.toString();
13579    
13580                    Query q = session.createQuery(sql);
13581    
13582                    q.setFirstResult(0);
13583                    q.setMaxResults(2);
13584    
13585                    QueryPos qPos = QueryPos.getInstance(q);
13586    
13587                    qPos.add(groupId);
13588    
13589                    qPos.add(nodeId);
13590    
13591                    if (bindTitle) {
13592                            qPos.add(title.toLowerCase());
13593                    }
13594    
13595                    qPos.add(head);
13596    
13597                    if (orderByComparator != null) {
13598                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
13599    
13600                            for (Object value : values) {
13601                                    qPos.add(value);
13602                            }
13603                    }
13604    
13605                    List<WikiPage> list = q.list();
13606    
13607                    if (list.size() == 2) {
13608                            return list.get(1);
13609                    }
13610                    else {
13611                            return null;
13612                    }
13613            }
13614    
13615            /**
13616             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
13617             *
13618             * @param groupId the group ID
13619             * @param nodeId the node ID
13620             * @param title the title
13621             * @param head the head
13622             * @return the matching wiki pages that the user has permission to view
13623             * @throws SystemException if a system exception occurred
13624             */
13625            public List<WikiPage> filterFindByG_N_T_H(long groupId, long nodeId,
13626                    String title, boolean head) throws SystemException {
13627                    return filterFindByG_N_T_H(groupId, nodeId, title, head,
13628                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13629            }
13630    
13631            /**
13632             * 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;.
13633             *
13634             * <p>
13635             * 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.
13636             * </p>
13637             *
13638             * @param groupId the group ID
13639             * @param nodeId the node ID
13640             * @param title the title
13641             * @param head the head
13642             * @param start the lower bound of the range of wiki pages
13643             * @param end the upper bound of the range of wiki pages (not inclusive)
13644             * @return the range of matching wiki pages that the user has permission to view
13645             * @throws SystemException if a system exception occurred
13646             */
13647            public List<WikiPage> filterFindByG_N_T_H(long groupId, long nodeId,
13648                    String title, boolean head, int start, int end)
13649                    throws SystemException {
13650                    return filterFindByG_N_T_H(groupId, nodeId, title, head, start, end,
13651                            null);
13652            }
13653    
13654            /**
13655             * 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;.
13656             *
13657             * <p>
13658             * 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.
13659             * </p>
13660             *
13661             * @param groupId the group ID
13662             * @param nodeId the node ID
13663             * @param title the title
13664             * @param head the head
13665             * @param start the lower bound of the range of wiki pages
13666             * @param end the upper bound of the range of wiki pages (not inclusive)
13667             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13668             * @return the ordered range of matching wiki pages that the user has permission to view
13669             * @throws SystemException if a system exception occurred
13670             */
13671            public List<WikiPage> filterFindByG_N_T_H(long groupId, long nodeId,
13672                    String title, boolean head, int start, int end,
13673                    OrderByComparator orderByComparator) throws SystemException {
13674                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13675                            return findByG_N_T_H(groupId, nodeId, title, head, start, end,
13676                                    orderByComparator);
13677                    }
13678    
13679                    StringBundler query = null;
13680    
13681                    if (orderByComparator != null) {
13682                            query = new StringBundler(6 +
13683                                            (orderByComparator.getOrderByFields().length * 3));
13684                    }
13685                    else {
13686                            query = new StringBundler(6);
13687                    }
13688    
13689                    if (getDB().isSupportsInlineDistinct()) {
13690                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
13691                    }
13692                    else {
13693                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
13694                    }
13695    
13696                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
13697    
13698                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
13699    
13700                    boolean bindTitle = false;
13701    
13702                    if (title == null) {
13703                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
13704                    }
13705                    else if (title.equals(StringPool.BLANK)) {
13706                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
13707                    }
13708                    else {
13709                            bindTitle = true;
13710    
13711                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
13712                    }
13713    
13714                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
13715    
13716                    if (!getDB().isSupportsInlineDistinct()) {
13717                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
13718                    }
13719    
13720                    if (orderByComparator != null) {
13721                            if (getDB().isSupportsInlineDistinct()) {
13722                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13723                                            orderByComparator);
13724                            }
13725                            else {
13726                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13727                                            orderByComparator);
13728                            }
13729                    }
13730                    else {
13731                            if (getDB().isSupportsInlineDistinct()) {
13732                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13733                            }
13734                            else {
13735                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
13736                            }
13737                    }
13738    
13739                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13740                                    WikiPage.class.getName(),
13741                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13742    
13743                    Session session = null;
13744    
13745                    try {
13746                            session = openSession();
13747    
13748                            SQLQuery q = session.createSQLQuery(sql);
13749    
13750                            if (getDB().isSupportsInlineDistinct()) {
13751                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
13752                            }
13753                            else {
13754                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
13755                            }
13756    
13757                            QueryPos qPos = QueryPos.getInstance(q);
13758    
13759                            qPos.add(groupId);
13760    
13761                            qPos.add(nodeId);
13762    
13763                            if (bindTitle) {
13764                                    qPos.add(title.toLowerCase());
13765                            }
13766    
13767                            qPos.add(head);
13768    
13769                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
13770                    }
13771                    catch (Exception e) {
13772                            throw processException(e);
13773                    }
13774                    finally {
13775                            closeSession(session);
13776                    }
13777            }
13778    
13779            /**
13780             * 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;.
13781             *
13782             * @param pageId the primary key of the current wiki page
13783             * @param groupId the group ID
13784             * @param nodeId the node ID
13785             * @param title the title
13786             * @param head the head
13787             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13788             * @return the previous, current, and next wiki page
13789             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
13790             * @throws SystemException if a system exception occurred
13791             */
13792            public WikiPage[] filterFindByG_N_T_H_PrevAndNext(long pageId,
13793                    long groupId, long nodeId, String title, boolean head,
13794                    OrderByComparator orderByComparator)
13795                    throws NoSuchPageException, SystemException {
13796                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13797                            return findByG_N_T_H_PrevAndNext(pageId, groupId, nodeId, title,
13798                                    head, orderByComparator);
13799                    }
13800    
13801                    WikiPage wikiPage = findByPrimaryKey(pageId);
13802    
13803                    Session session = null;
13804    
13805                    try {
13806                            session = openSession();
13807    
13808                            WikiPage[] array = new WikiPageImpl[3];
13809    
13810                            array[0] = filterGetByG_N_T_H_PrevAndNext(session, wikiPage,
13811                                            groupId, nodeId, title, head, orderByComparator, true);
13812    
13813                            array[1] = wikiPage;
13814    
13815                            array[2] = filterGetByG_N_T_H_PrevAndNext(session, wikiPage,
13816                                            groupId, nodeId, title, head, orderByComparator, false);
13817    
13818                            return array;
13819                    }
13820                    catch (Exception e) {
13821                            throw processException(e);
13822                    }
13823                    finally {
13824                            closeSession(session);
13825                    }
13826            }
13827    
13828            protected WikiPage filterGetByG_N_T_H_PrevAndNext(Session session,
13829                    WikiPage wikiPage, long groupId, long nodeId, String title,
13830                    boolean head, OrderByComparator orderByComparator, boolean previous) {
13831                    StringBundler query = null;
13832    
13833                    if (orderByComparator != null) {
13834                            query = new StringBundler(6 +
13835                                            (orderByComparator.getOrderByFields().length * 6));
13836                    }
13837                    else {
13838                            query = new StringBundler(3);
13839                    }
13840    
13841                    if (getDB().isSupportsInlineDistinct()) {
13842                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
13843                    }
13844                    else {
13845                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
13846                    }
13847    
13848                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
13849    
13850                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
13851    
13852                    boolean bindTitle = false;
13853    
13854                    if (title == null) {
13855                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
13856                    }
13857                    else if (title.equals(StringPool.BLANK)) {
13858                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
13859                    }
13860                    else {
13861                            bindTitle = true;
13862    
13863                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
13864                    }
13865    
13866                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
13867    
13868                    if (!getDB().isSupportsInlineDistinct()) {
13869                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
13870                    }
13871    
13872                    if (orderByComparator != null) {
13873                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13874    
13875                            if (orderByConditionFields.length > 0) {
13876                                    query.append(WHERE_AND);
13877                            }
13878    
13879                            for (int i = 0; i < orderByConditionFields.length; i++) {
13880                                    if (getDB().isSupportsInlineDistinct()) {
13881                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13882                                    }
13883                                    else {
13884                                            query.append(_ORDER_BY_ENTITY_TABLE);
13885                                    }
13886    
13887                                    query.append(orderByConditionFields[i]);
13888    
13889                                    if ((i + 1) < orderByConditionFields.length) {
13890                                            if (orderByComparator.isAscending() ^ previous) {
13891                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13892                                            }
13893                                            else {
13894                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13895                                            }
13896                                    }
13897                                    else {
13898                                            if (orderByComparator.isAscending() ^ previous) {
13899                                                    query.append(WHERE_GREATER_THAN);
13900                                            }
13901                                            else {
13902                                                    query.append(WHERE_LESSER_THAN);
13903                                            }
13904                                    }
13905                            }
13906    
13907                            query.append(ORDER_BY_CLAUSE);
13908    
13909                            String[] orderByFields = orderByComparator.getOrderByFields();
13910    
13911                            for (int i = 0; i < orderByFields.length; i++) {
13912                                    if (getDB().isSupportsInlineDistinct()) {
13913                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13914                                    }
13915                                    else {
13916                                            query.append(_ORDER_BY_ENTITY_TABLE);
13917                                    }
13918    
13919                                    query.append(orderByFields[i]);
13920    
13921                                    if ((i + 1) < orderByFields.length) {
13922                                            if (orderByComparator.isAscending() ^ previous) {
13923                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13924                                            }
13925                                            else {
13926                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13927                                            }
13928                                    }
13929                                    else {
13930                                            if (orderByComparator.isAscending() ^ previous) {
13931                                                    query.append(ORDER_BY_ASC);
13932                                            }
13933                                            else {
13934                                                    query.append(ORDER_BY_DESC);
13935                                            }
13936                                    }
13937                            }
13938                    }
13939                    else {
13940                            if (getDB().isSupportsInlineDistinct()) {
13941                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13942                            }
13943                            else {
13944                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
13945                            }
13946                    }
13947    
13948                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13949                                    WikiPage.class.getName(),
13950                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13951    
13952                    SQLQuery q = session.createSQLQuery(sql);
13953    
13954                    q.setFirstResult(0);
13955                    q.setMaxResults(2);
13956    
13957                    if (getDB().isSupportsInlineDistinct()) {
13958                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
13959                    }
13960                    else {
13961                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
13962                    }
13963    
13964                    QueryPos qPos = QueryPos.getInstance(q);
13965    
13966                    qPos.add(groupId);
13967    
13968                    qPos.add(nodeId);
13969    
13970                    if (bindTitle) {
13971                            qPos.add(title.toLowerCase());
13972                    }
13973    
13974                    qPos.add(head);
13975    
13976                    if (orderByComparator != null) {
13977                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
13978    
13979                            for (Object value : values) {
13980                                    qPos.add(value);
13981                            }
13982                    }
13983    
13984                    List<WikiPage> list = q.list();
13985    
13986                    if (list.size() == 2) {
13987                            return list.get(1);
13988                    }
13989                    else {
13990                            return null;
13991                    }
13992            }
13993    
13994            /**
13995             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63; from the database.
13996             *
13997             * @param groupId the group ID
13998             * @param nodeId the node ID
13999             * @param title the title
14000             * @param head the head
14001             * @throws SystemException if a system exception occurred
14002             */
14003            public void removeByG_N_T_H(long groupId, long nodeId, String title,
14004                    boolean head) throws SystemException {
14005                    for (WikiPage wikiPage : findByG_N_T_H(groupId, nodeId, title, head,
14006                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14007                            remove(wikiPage);
14008                    }
14009            }
14010    
14011            /**
14012             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
14013             *
14014             * @param groupId the group ID
14015             * @param nodeId the node ID
14016             * @param title the title
14017             * @param head the head
14018             * @return the number of matching wiki pages
14019             * @throws SystemException if a system exception occurred
14020             */
14021            public int countByG_N_T_H(long groupId, long nodeId, String title,
14022                    boolean head) throws SystemException {
14023                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_T_H;
14024    
14025                    Object[] finderArgs = new Object[] { groupId, nodeId, title, head };
14026    
14027                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14028                                    this);
14029    
14030                    if (count == null) {
14031                            StringBundler query = new StringBundler(5);
14032    
14033                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
14034    
14035                            query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
14036    
14037                            query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
14038    
14039                            boolean bindTitle = false;
14040    
14041                            if (title == null) {
14042                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
14043                            }
14044                            else if (title.equals(StringPool.BLANK)) {
14045                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
14046                            }
14047                            else {
14048                                    bindTitle = true;
14049    
14050                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
14051                            }
14052    
14053                            query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
14054    
14055                            String sql = query.toString();
14056    
14057                            Session session = null;
14058    
14059                            try {
14060                                    session = openSession();
14061    
14062                                    Query q = session.createQuery(sql);
14063    
14064                                    QueryPos qPos = QueryPos.getInstance(q);
14065    
14066                                    qPos.add(groupId);
14067    
14068                                    qPos.add(nodeId);
14069    
14070                                    if (bindTitle) {
14071                                            qPos.add(title.toLowerCase());
14072                                    }
14073    
14074                                    qPos.add(head);
14075    
14076                                    count = (Long)q.uniqueResult();
14077    
14078                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14079                            }
14080                            catch (Exception e) {
14081                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14082    
14083                                    throw processException(e);
14084                            }
14085                            finally {
14086                                    closeSession(session);
14087                            }
14088                    }
14089    
14090                    return count.intValue();
14091            }
14092    
14093            /**
14094             * 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;.
14095             *
14096             * @param groupId the group ID
14097             * @param nodeId the node ID
14098             * @param title the title
14099             * @param head the head
14100             * @return the number of matching wiki pages that the user has permission to view
14101             * @throws SystemException if a system exception occurred
14102             */
14103            public int filterCountByG_N_T_H(long groupId, long nodeId, String title,
14104                    boolean head) throws SystemException {
14105                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14106                            return countByG_N_T_H(groupId, nodeId, title, head);
14107                    }
14108    
14109                    StringBundler query = new StringBundler(5);
14110    
14111                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
14112    
14113                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
14114    
14115                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
14116    
14117                    boolean bindTitle = false;
14118    
14119                    if (title == null) {
14120                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
14121                    }
14122                    else if (title.equals(StringPool.BLANK)) {
14123                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
14124                    }
14125                    else {
14126                            bindTitle = true;
14127    
14128                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
14129                    }
14130    
14131                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
14132    
14133                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14134                                    WikiPage.class.getName(),
14135                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14136    
14137                    Session session = null;
14138    
14139                    try {
14140                            session = openSession();
14141    
14142                            SQLQuery q = session.createSQLQuery(sql);
14143    
14144                            q.addScalar(COUNT_COLUMN_NAME,
14145                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14146    
14147                            QueryPos qPos = QueryPos.getInstance(q);
14148    
14149                            qPos.add(groupId);
14150    
14151                            qPos.add(nodeId);
14152    
14153                            if (bindTitle) {
14154                                    qPos.add(title.toLowerCase());
14155                            }
14156    
14157                            qPos.add(head);
14158    
14159                            Long count = (Long)q.uniqueResult();
14160    
14161                            return count.intValue();
14162                    }
14163                    catch (Exception e) {
14164                            throw processException(e);
14165                    }
14166                    finally {
14167                            closeSession(session);
14168                    }
14169            }
14170    
14171            private static final String _FINDER_COLUMN_G_N_T_H_GROUPID_2 = "wikiPage.groupId = ? AND ";
14172            private static final String _FINDER_COLUMN_G_N_T_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
14173            private static final String _FINDER_COLUMN_G_N_T_H_TITLE_1 = "wikiPage.title IS NULL AND ";
14174            private static final String _FINDER_COLUMN_G_N_T_H_TITLE_2 = "lower(wikiPage.title) = ? AND ";
14175            private static final String _FINDER_COLUMN_G_N_T_H_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = '') AND ";
14176            private static final String _FINDER_COLUMN_G_N_T_H_HEAD_2 = "wikiPage.head = ?";
14177            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
14178                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
14179                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_H_S",
14180                            new String[] {
14181                                    Long.class.getName(), Long.class.getName(),
14182                                    Boolean.class.getName(), Integer.class.getName(),
14183                                    
14184                            Integer.class.getName(), Integer.class.getName(),
14185                                    OrderByComparator.class.getName()
14186                            });
14187            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S =
14188                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
14189                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
14190                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_H_S",
14191                            new String[] {
14192                                    Long.class.getName(), Long.class.getName(),
14193                                    Boolean.class.getName(), Integer.class.getName()
14194                            },
14195                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
14196                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
14197                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
14198                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
14199                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
14200                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
14201            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
14202                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
14203                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_H_S",
14204                            new String[] {
14205                                    Long.class.getName(), Long.class.getName(),
14206                                    Boolean.class.getName(), Integer.class.getName()
14207                            });
14208    
14209            /**
14210             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
14211             *
14212             * @param groupId the group ID
14213             * @param nodeId the node ID
14214             * @param head the head
14215             * @param status the status
14216             * @return the matching wiki pages
14217             * @throws SystemException if a system exception occurred
14218             */
14219            public List<WikiPage> findByG_N_H_S(long groupId, long nodeId,
14220                    boolean head, int status) throws SystemException {
14221                    return findByG_N_H_S(groupId, nodeId, head, status, QueryUtil.ALL_POS,
14222                            QueryUtil.ALL_POS, null);
14223            }
14224    
14225            /**
14226             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
14227             *
14228             * <p>
14229             * 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.
14230             * </p>
14231             *
14232             * @param groupId the group ID
14233             * @param nodeId the node ID
14234             * @param head the head
14235             * @param status the status
14236             * @param start the lower bound of the range of wiki pages
14237             * @param end the upper bound of the range of wiki pages (not inclusive)
14238             * @return the range of matching wiki pages
14239             * @throws SystemException if a system exception occurred
14240             */
14241            public List<WikiPage> findByG_N_H_S(long groupId, long nodeId,
14242                    boolean head, int status, int start, int end) throws SystemException {
14243                    return findByG_N_H_S(groupId, nodeId, head, status, start, end, null);
14244            }
14245    
14246            /**
14247             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
14248             *
14249             * <p>
14250             * 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.
14251             * </p>
14252             *
14253             * @param groupId the group ID
14254             * @param nodeId the node ID
14255             * @param head the head
14256             * @param status the status
14257             * @param start the lower bound of the range of wiki pages
14258             * @param end the upper bound of the range of wiki pages (not inclusive)
14259             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14260             * @return the ordered range of matching wiki pages
14261             * @throws SystemException if a system exception occurred
14262             */
14263            public List<WikiPage> findByG_N_H_S(long groupId, long nodeId,
14264                    boolean head, int status, int start, int end,
14265                    OrderByComparator orderByComparator) throws SystemException {
14266                    boolean pagination = true;
14267                    FinderPath finderPath = null;
14268                    Object[] finderArgs = null;
14269    
14270                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14271                                    (orderByComparator == null)) {
14272                            pagination = false;
14273                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S;
14274                            finderArgs = new Object[] { groupId, nodeId, head, status };
14275                    }
14276                    else {
14277                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_S;
14278                            finderArgs = new Object[] {
14279                                            groupId, nodeId, head, status,
14280                                            
14281                                            start, end, orderByComparator
14282                                    };
14283                    }
14284    
14285                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
14286                                    finderArgs, this);
14287    
14288                    if ((list != null) && !list.isEmpty()) {
14289                            for (WikiPage wikiPage : list) {
14290                                    if ((groupId != wikiPage.getGroupId()) ||
14291                                                    (nodeId != wikiPage.getNodeId()) ||
14292                                                    (head != wikiPage.getHead()) ||
14293                                                    (status != wikiPage.getStatus())) {
14294                                            list = null;
14295    
14296                                            break;
14297                                    }
14298                            }
14299                    }
14300    
14301                    if (list == null) {
14302                            StringBundler query = null;
14303    
14304                            if (orderByComparator != null) {
14305                                    query = new StringBundler(6 +
14306                                                    (orderByComparator.getOrderByFields().length * 3));
14307                            }
14308                            else {
14309                                    query = new StringBundler(6);
14310                            }
14311    
14312                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
14313    
14314                            query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
14315    
14316                            query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
14317    
14318                            query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
14319    
14320                            query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
14321    
14322                            if (orderByComparator != null) {
14323                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14324                                            orderByComparator);
14325                            }
14326                            else
14327                             if (pagination) {
14328                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
14329                            }
14330    
14331                            String sql = query.toString();
14332    
14333                            Session session = null;
14334    
14335                            try {
14336                                    session = openSession();
14337    
14338                                    Query q = session.createQuery(sql);
14339    
14340                                    QueryPos qPos = QueryPos.getInstance(q);
14341    
14342                                    qPos.add(groupId);
14343    
14344                                    qPos.add(nodeId);
14345    
14346                                    qPos.add(head);
14347    
14348                                    qPos.add(status);
14349    
14350                                    if (!pagination) {
14351                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
14352                                                            start, end, false);
14353    
14354                                            Collections.sort(list);
14355    
14356                                            list = new UnmodifiableList<WikiPage>(list);
14357                                    }
14358                                    else {
14359                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
14360                                                            start, end);
14361                                    }
14362    
14363                                    cacheResult(list);
14364    
14365                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14366                            }
14367                            catch (Exception e) {
14368                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14369    
14370                                    throw processException(e);
14371                            }
14372                            finally {
14373                                    closeSession(session);
14374                            }
14375                    }
14376    
14377                    return list;
14378            }
14379    
14380            /**
14381             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
14382             *
14383             * @param groupId the group ID
14384             * @param nodeId the node ID
14385             * @param head the head
14386             * @param status the status
14387             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14388             * @return the first matching wiki page
14389             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
14390             * @throws SystemException if a system exception occurred
14391             */
14392            public WikiPage findByG_N_H_S_First(long groupId, long nodeId,
14393                    boolean head, int status, OrderByComparator orderByComparator)
14394                    throws NoSuchPageException, SystemException {
14395                    WikiPage wikiPage = fetchByG_N_H_S_First(groupId, nodeId, head, status,
14396                                    orderByComparator);
14397    
14398                    if (wikiPage != null) {
14399                            return wikiPage;
14400                    }
14401    
14402                    StringBundler msg = new StringBundler(10);
14403    
14404                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14405    
14406                    msg.append("groupId=");
14407                    msg.append(groupId);
14408    
14409                    msg.append(", nodeId=");
14410                    msg.append(nodeId);
14411    
14412                    msg.append(", head=");
14413                    msg.append(head);
14414    
14415                    msg.append(", status=");
14416                    msg.append(status);
14417    
14418                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14419    
14420                    throw new NoSuchPageException(msg.toString());
14421            }
14422    
14423            /**
14424             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
14425             *
14426             * @param groupId the group ID
14427             * @param nodeId the node ID
14428             * @param head the head
14429             * @param status the status
14430             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14431             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
14432             * @throws SystemException if a system exception occurred
14433             */
14434            public WikiPage fetchByG_N_H_S_First(long groupId, long nodeId,
14435                    boolean head, int status, OrderByComparator orderByComparator)
14436                    throws SystemException {
14437                    List<WikiPage> list = findByG_N_H_S(groupId, nodeId, head, status, 0,
14438                                    1, orderByComparator);
14439    
14440                    if (!list.isEmpty()) {
14441                            return list.get(0);
14442                    }
14443    
14444                    return null;
14445            }
14446    
14447            /**
14448             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
14449             *
14450             * @param groupId the group ID
14451             * @param nodeId the node ID
14452             * @param head the head
14453             * @param status the status
14454             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14455             * @return the last matching wiki page
14456             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
14457             * @throws SystemException if a system exception occurred
14458             */
14459            public WikiPage findByG_N_H_S_Last(long groupId, long nodeId, boolean head,
14460                    int status, OrderByComparator orderByComparator)
14461                    throws NoSuchPageException, SystemException {
14462                    WikiPage wikiPage = fetchByG_N_H_S_Last(groupId, nodeId, head, status,
14463                                    orderByComparator);
14464    
14465                    if (wikiPage != null) {
14466                            return wikiPage;
14467                    }
14468    
14469                    StringBundler msg = new StringBundler(10);
14470    
14471                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14472    
14473                    msg.append("groupId=");
14474                    msg.append(groupId);
14475    
14476                    msg.append(", nodeId=");
14477                    msg.append(nodeId);
14478    
14479                    msg.append(", head=");
14480                    msg.append(head);
14481    
14482                    msg.append(", status=");
14483                    msg.append(status);
14484    
14485                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14486    
14487                    throw new NoSuchPageException(msg.toString());
14488            }
14489    
14490            /**
14491             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
14492             *
14493             * @param groupId the group ID
14494             * @param nodeId the node ID
14495             * @param head the head
14496             * @param status the status
14497             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14498             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
14499             * @throws SystemException if a system exception occurred
14500             */
14501            public WikiPage fetchByG_N_H_S_Last(long groupId, long nodeId,
14502                    boolean head, int status, OrderByComparator orderByComparator)
14503                    throws SystemException {
14504                    int count = countByG_N_H_S(groupId, nodeId, head, status);
14505    
14506                    List<WikiPage> list = findByG_N_H_S(groupId, nodeId, head, status,
14507                                    count - 1, count, orderByComparator);
14508    
14509                    if (!list.isEmpty()) {
14510                            return list.get(0);
14511                    }
14512    
14513                    return null;
14514            }
14515    
14516            /**
14517             * 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;.
14518             *
14519             * @param pageId the primary key of the current wiki page
14520             * @param groupId the group ID
14521             * @param nodeId the node ID
14522             * @param head the head
14523             * @param status the status
14524             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14525             * @return the previous, current, and next wiki page
14526             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
14527             * @throws SystemException if a system exception occurred
14528             */
14529            public WikiPage[] findByG_N_H_S_PrevAndNext(long pageId, long groupId,
14530                    long nodeId, boolean head, int status,
14531                    OrderByComparator orderByComparator)
14532                    throws NoSuchPageException, SystemException {
14533                    WikiPage wikiPage = findByPrimaryKey(pageId);
14534    
14535                    Session session = null;
14536    
14537                    try {
14538                            session = openSession();
14539    
14540                            WikiPage[] array = new WikiPageImpl[3];
14541    
14542                            array[0] = getByG_N_H_S_PrevAndNext(session, wikiPage, groupId,
14543                                            nodeId, head, status, orderByComparator, true);
14544    
14545                            array[1] = wikiPage;
14546    
14547                            array[2] = getByG_N_H_S_PrevAndNext(session, wikiPage, groupId,
14548                                            nodeId, head, status, orderByComparator, false);
14549    
14550                            return array;
14551                    }
14552                    catch (Exception e) {
14553                            throw processException(e);
14554                    }
14555                    finally {
14556                            closeSession(session);
14557                    }
14558            }
14559    
14560            protected WikiPage getByG_N_H_S_PrevAndNext(Session session,
14561                    WikiPage wikiPage, long groupId, long nodeId, boolean head, int status,
14562                    OrderByComparator orderByComparator, boolean previous) {
14563                    StringBundler query = null;
14564    
14565                    if (orderByComparator != null) {
14566                            query = new StringBundler(6 +
14567                                            (orderByComparator.getOrderByFields().length * 6));
14568                    }
14569                    else {
14570                            query = new StringBundler(3);
14571                    }
14572    
14573                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
14574    
14575                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
14576    
14577                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
14578    
14579                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
14580    
14581                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
14582    
14583                    if (orderByComparator != null) {
14584                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14585    
14586                            if (orderByConditionFields.length > 0) {
14587                                    query.append(WHERE_AND);
14588                            }
14589    
14590                            for (int i = 0; i < orderByConditionFields.length; i++) {
14591                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14592                                    query.append(orderByConditionFields[i]);
14593    
14594                                    if ((i + 1) < orderByConditionFields.length) {
14595                                            if (orderByComparator.isAscending() ^ previous) {
14596                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14597                                            }
14598                                            else {
14599                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14600                                            }
14601                                    }
14602                                    else {
14603                                            if (orderByComparator.isAscending() ^ previous) {
14604                                                    query.append(WHERE_GREATER_THAN);
14605                                            }
14606                                            else {
14607                                                    query.append(WHERE_LESSER_THAN);
14608                                            }
14609                                    }
14610                            }
14611    
14612                            query.append(ORDER_BY_CLAUSE);
14613    
14614                            String[] orderByFields = orderByComparator.getOrderByFields();
14615    
14616                            for (int i = 0; i < orderByFields.length; i++) {
14617                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14618                                    query.append(orderByFields[i]);
14619    
14620                                    if ((i + 1) < orderByFields.length) {
14621                                            if (orderByComparator.isAscending() ^ previous) {
14622                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14623                                            }
14624                                            else {
14625                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14626                                            }
14627                                    }
14628                                    else {
14629                                            if (orderByComparator.isAscending() ^ previous) {
14630                                                    query.append(ORDER_BY_ASC);
14631                                            }
14632                                            else {
14633                                                    query.append(ORDER_BY_DESC);
14634                                            }
14635                                    }
14636                            }
14637                    }
14638                    else {
14639                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
14640                    }
14641    
14642                    String sql = query.toString();
14643    
14644                    Query q = session.createQuery(sql);
14645    
14646                    q.setFirstResult(0);
14647                    q.setMaxResults(2);
14648    
14649                    QueryPos qPos = QueryPos.getInstance(q);
14650    
14651                    qPos.add(groupId);
14652    
14653                    qPos.add(nodeId);
14654    
14655                    qPos.add(head);
14656    
14657                    qPos.add(status);
14658    
14659                    if (orderByComparator != null) {
14660                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
14661    
14662                            for (Object value : values) {
14663                                    qPos.add(value);
14664                            }
14665                    }
14666    
14667                    List<WikiPage> list = q.list();
14668    
14669                    if (list.size() == 2) {
14670                            return list.get(1);
14671                    }
14672                    else {
14673                            return null;
14674                    }
14675            }
14676    
14677            /**
14678             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
14679             *
14680             * @param groupId the group ID
14681             * @param nodeId the node ID
14682             * @param head the head
14683             * @param status the status
14684             * @return the matching wiki pages that the user has permission to view
14685             * @throws SystemException if a system exception occurred
14686             */
14687            public List<WikiPage> filterFindByG_N_H_S(long groupId, long nodeId,
14688                    boolean head, int status) throws SystemException {
14689                    return filterFindByG_N_H_S(groupId, nodeId, head, status,
14690                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14691            }
14692    
14693            /**
14694             * 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;.
14695             *
14696             * <p>
14697             * 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.
14698             * </p>
14699             *
14700             * @param groupId the group ID
14701             * @param nodeId the node ID
14702             * @param head the head
14703             * @param status the status
14704             * @param start the lower bound of the range of wiki pages
14705             * @param end the upper bound of the range of wiki pages (not inclusive)
14706             * @return the range of matching wiki pages that the user has permission to view
14707             * @throws SystemException if a system exception occurred
14708             */
14709            public List<WikiPage> filterFindByG_N_H_S(long groupId, long nodeId,
14710                    boolean head, int status, int start, int end) throws SystemException {
14711                    return filterFindByG_N_H_S(groupId, nodeId, head, status, start, end,
14712                            null);
14713            }
14714    
14715            /**
14716             * 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;.
14717             *
14718             * <p>
14719             * 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.
14720             * </p>
14721             *
14722             * @param groupId the group ID
14723             * @param nodeId the node ID
14724             * @param head the head
14725             * @param status the status
14726             * @param start the lower bound of the range of wiki pages
14727             * @param end the upper bound of the range of wiki pages (not inclusive)
14728             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14729             * @return the ordered range of matching wiki pages that the user has permission to view
14730             * @throws SystemException if a system exception occurred
14731             */
14732            public List<WikiPage> filterFindByG_N_H_S(long groupId, long nodeId,
14733                    boolean head, int status, int start, int end,
14734                    OrderByComparator orderByComparator) throws SystemException {
14735                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14736                            return findByG_N_H_S(groupId, nodeId, head, status, start, end,
14737                                    orderByComparator);
14738                    }
14739    
14740                    StringBundler query = null;
14741    
14742                    if (orderByComparator != null) {
14743                            query = new StringBundler(6 +
14744                                            (orderByComparator.getOrderByFields().length * 3));
14745                    }
14746                    else {
14747                            query = new StringBundler(6);
14748                    }
14749    
14750                    if (getDB().isSupportsInlineDistinct()) {
14751                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
14752                    }
14753                    else {
14754                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
14755                    }
14756    
14757                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
14758    
14759                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
14760    
14761                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
14762    
14763                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
14764    
14765                    if (!getDB().isSupportsInlineDistinct()) {
14766                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
14767                    }
14768    
14769                    if (orderByComparator != null) {
14770                            if (getDB().isSupportsInlineDistinct()) {
14771                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14772                                            orderByComparator);
14773                            }
14774                            else {
14775                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14776                                            orderByComparator);
14777                            }
14778                    }
14779                    else {
14780                            if (getDB().isSupportsInlineDistinct()) {
14781                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
14782                            }
14783                            else {
14784                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
14785                            }
14786                    }
14787    
14788                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14789                                    WikiPage.class.getName(),
14790                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14791    
14792                    Session session = null;
14793    
14794                    try {
14795                            session = openSession();
14796    
14797                            SQLQuery q = session.createSQLQuery(sql);
14798    
14799                            if (getDB().isSupportsInlineDistinct()) {
14800                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
14801                            }
14802                            else {
14803                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
14804                            }
14805    
14806                            QueryPos qPos = QueryPos.getInstance(q);
14807    
14808                            qPos.add(groupId);
14809    
14810                            qPos.add(nodeId);
14811    
14812                            qPos.add(head);
14813    
14814                            qPos.add(status);
14815    
14816                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
14817                    }
14818                    catch (Exception e) {
14819                            throw processException(e);
14820                    }
14821                    finally {
14822                            closeSession(session);
14823                    }
14824            }
14825    
14826            /**
14827             * 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;.
14828             *
14829             * @param pageId the primary key of the current wiki page
14830             * @param groupId the group ID
14831             * @param nodeId the node ID
14832             * @param head the head
14833             * @param status the status
14834             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14835             * @return the previous, current, and next wiki page
14836             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
14837             * @throws SystemException if a system exception occurred
14838             */
14839            public WikiPage[] filterFindByG_N_H_S_PrevAndNext(long pageId,
14840                    long groupId, long nodeId, boolean head, int status,
14841                    OrderByComparator orderByComparator)
14842                    throws NoSuchPageException, SystemException {
14843                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14844                            return findByG_N_H_S_PrevAndNext(pageId, groupId, nodeId, head,
14845                                    status, orderByComparator);
14846                    }
14847    
14848                    WikiPage wikiPage = findByPrimaryKey(pageId);
14849    
14850                    Session session = null;
14851    
14852                    try {
14853                            session = openSession();
14854    
14855                            WikiPage[] array = new WikiPageImpl[3];
14856    
14857                            array[0] = filterGetByG_N_H_S_PrevAndNext(session, wikiPage,
14858                                            groupId, nodeId, head, status, orderByComparator, true);
14859    
14860                            array[1] = wikiPage;
14861    
14862                            array[2] = filterGetByG_N_H_S_PrevAndNext(session, wikiPage,
14863                                            groupId, nodeId, head, status, orderByComparator, false);
14864    
14865                            return array;
14866                    }
14867                    catch (Exception e) {
14868                            throw processException(e);
14869                    }
14870                    finally {
14871                            closeSession(session);
14872                    }
14873            }
14874    
14875            protected WikiPage filterGetByG_N_H_S_PrevAndNext(Session session,
14876                    WikiPage wikiPage, long groupId, long nodeId, boolean head, int status,
14877                    OrderByComparator orderByComparator, boolean previous) {
14878                    StringBundler query = null;
14879    
14880                    if (orderByComparator != null) {
14881                            query = new StringBundler(6 +
14882                                            (orderByComparator.getOrderByFields().length * 6));
14883                    }
14884                    else {
14885                            query = new StringBundler(3);
14886                    }
14887    
14888                    if (getDB().isSupportsInlineDistinct()) {
14889                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
14890                    }
14891                    else {
14892                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
14893                    }
14894    
14895                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
14896    
14897                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
14898    
14899                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
14900    
14901                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
14902    
14903                    if (!getDB().isSupportsInlineDistinct()) {
14904                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
14905                    }
14906    
14907                    if (orderByComparator != null) {
14908                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14909    
14910                            if (orderByConditionFields.length > 0) {
14911                                    query.append(WHERE_AND);
14912                            }
14913    
14914                            for (int i = 0; i < orderByConditionFields.length; i++) {
14915                                    if (getDB().isSupportsInlineDistinct()) {
14916                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14917                                    }
14918                                    else {
14919                                            query.append(_ORDER_BY_ENTITY_TABLE);
14920                                    }
14921    
14922                                    query.append(orderByConditionFields[i]);
14923    
14924                                    if ((i + 1) < orderByConditionFields.length) {
14925                                            if (orderByComparator.isAscending() ^ previous) {
14926                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14927                                            }
14928                                            else {
14929                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14930                                            }
14931                                    }
14932                                    else {
14933                                            if (orderByComparator.isAscending() ^ previous) {
14934                                                    query.append(WHERE_GREATER_THAN);
14935                                            }
14936                                            else {
14937                                                    query.append(WHERE_LESSER_THAN);
14938                                            }
14939                                    }
14940                            }
14941    
14942                            query.append(ORDER_BY_CLAUSE);
14943    
14944                            String[] orderByFields = orderByComparator.getOrderByFields();
14945    
14946                            for (int i = 0; i < orderByFields.length; i++) {
14947                                    if (getDB().isSupportsInlineDistinct()) {
14948                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14949                                    }
14950                                    else {
14951                                            query.append(_ORDER_BY_ENTITY_TABLE);
14952                                    }
14953    
14954                                    query.append(orderByFields[i]);
14955    
14956                                    if ((i + 1) < orderByFields.length) {
14957                                            if (orderByComparator.isAscending() ^ previous) {
14958                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14959                                            }
14960                                            else {
14961                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14962                                            }
14963                                    }
14964                                    else {
14965                                            if (orderByComparator.isAscending() ^ previous) {
14966                                                    query.append(ORDER_BY_ASC);
14967                                            }
14968                                            else {
14969                                                    query.append(ORDER_BY_DESC);
14970                                            }
14971                                    }
14972                            }
14973                    }
14974                    else {
14975                            if (getDB().isSupportsInlineDistinct()) {
14976                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
14977                            }
14978                            else {
14979                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
14980                            }
14981                    }
14982    
14983                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14984                                    WikiPage.class.getName(),
14985                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14986    
14987                    SQLQuery q = session.createSQLQuery(sql);
14988    
14989                    q.setFirstResult(0);
14990                    q.setMaxResults(2);
14991    
14992                    if (getDB().isSupportsInlineDistinct()) {
14993                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
14994                    }
14995                    else {
14996                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
14997                    }
14998    
14999                    QueryPos qPos = QueryPos.getInstance(q);
15000    
15001                    qPos.add(groupId);
15002    
15003                    qPos.add(nodeId);
15004    
15005                    qPos.add(head);
15006    
15007                    qPos.add(status);
15008    
15009                    if (orderByComparator != null) {
15010                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
15011    
15012                            for (Object value : values) {
15013                                    qPos.add(value);
15014                            }
15015                    }
15016    
15017                    List<WikiPage> list = q.list();
15018    
15019                    if (list.size() == 2) {
15020                            return list.get(1);
15021                    }
15022                    else {
15023                            return null;
15024                    }
15025            }
15026    
15027            /**
15028             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63; from the database.
15029             *
15030             * @param groupId the group ID
15031             * @param nodeId the node ID
15032             * @param head the head
15033             * @param status the status
15034             * @throws SystemException if a system exception occurred
15035             */
15036            public void removeByG_N_H_S(long groupId, long nodeId, boolean head,
15037                    int status) throws SystemException {
15038                    for (WikiPage wikiPage : findByG_N_H_S(groupId, nodeId, head, status,
15039                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15040                            remove(wikiPage);
15041                    }
15042            }
15043    
15044            /**
15045             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
15046             *
15047             * @param groupId the group ID
15048             * @param nodeId the node ID
15049             * @param head the head
15050             * @param status the status
15051             * @return the number of matching wiki pages
15052             * @throws SystemException if a system exception occurred
15053             */
15054            public int countByG_N_H_S(long groupId, long nodeId, boolean head,
15055                    int status) throws SystemException {
15056                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_H_S;
15057    
15058                    Object[] finderArgs = new Object[] { groupId, nodeId, head, status };
15059    
15060                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15061                                    this);
15062    
15063                    if (count == null) {
15064                            StringBundler query = new StringBundler(5);
15065    
15066                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15067    
15068                            query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
15069    
15070                            query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
15071    
15072                            query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
15073    
15074                            query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
15075    
15076                            String sql = query.toString();
15077    
15078                            Session session = null;
15079    
15080                            try {
15081                                    session = openSession();
15082    
15083                                    Query q = session.createQuery(sql);
15084    
15085                                    QueryPos qPos = QueryPos.getInstance(q);
15086    
15087                                    qPos.add(groupId);
15088    
15089                                    qPos.add(nodeId);
15090    
15091                                    qPos.add(head);
15092    
15093                                    qPos.add(status);
15094    
15095                                    count = (Long)q.uniqueResult();
15096    
15097                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15098                            }
15099                            catch (Exception e) {
15100                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15101    
15102                                    throw processException(e);
15103                            }
15104                            finally {
15105                                    closeSession(session);
15106                            }
15107                    }
15108    
15109                    return count.intValue();
15110            }
15111    
15112            /**
15113             * 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;.
15114             *
15115             * @param groupId the group ID
15116             * @param nodeId the node ID
15117             * @param head the head
15118             * @param status the status
15119             * @return the number of matching wiki pages that the user has permission to view
15120             * @throws SystemException if a system exception occurred
15121             */
15122            public int filterCountByG_N_H_S(long groupId, long nodeId, boolean head,
15123                    int status) throws SystemException {
15124                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15125                            return countByG_N_H_S(groupId, nodeId, head, status);
15126                    }
15127    
15128                    StringBundler query = new StringBundler(5);
15129    
15130                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
15131    
15132                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
15133    
15134                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
15135    
15136                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
15137    
15138                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
15139    
15140                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15141                                    WikiPage.class.getName(),
15142                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15143    
15144                    Session session = null;
15145    
15146                    try {
15147                            session = openSession();
15148    
15149                            SQLQuery q = session.createSQLQuery(sql);
15150    
15151                            q.addScalar(COUNT_COLUMN_NAME,
15152                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15153    
15154                            QueryPos qPos = QueryPos.getInstance(q);
15155    
15156                            qPos.add(groupId);
15157    
15158                            qPos.add(nodeId);
15159    
15160                            qPos.add(head);
15161    
15162                            qPos.add(status);
15163    
15164                            Long count = (Long)q.uniqueResult();
15165    
15166                            return count.intValue();
15167                    }
15168                    catch (Exception e) {
15169                            throw processException(e);
15170                    }
15171                    finally {
15172                            closeSession(session);
15173                    }
15174            }
15175    
15176            private static final String _FINDER_COLUMN_G_N_H_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
15177            private static final String _FINDER_COLUMN_G_N_H_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
15178            private static final String _FINDER_COLUMN_G_N_H_S_HEAD_2 = "wikiPage.head = ? AND ";
15179            private static final String _FINDER_COLUMN_G_N_H_S_STATUS_2 = "wikiPage.status = ?";
15180            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
15181                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
15182                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_P_S",
15183                            new String[] {
15184                                    Long.class.getName(), Boolean.class.getName(),
15185                                    String.class.getName(), Integer.class.getName(),
15186                                    
15187                            Integer.class.getName(), Integer.class.getName(),
15188                                    OrderByComparator.class.getName()
15189                            });
15190            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S =
15191                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
15192                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
15193                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_P_S",
15194                            new String[] {
15195                                    Long.class.getName(), Boolean.class.getName(),
15196                                    String.class.getName(), Integer.class.getName()
15197                            },
15198                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
15199                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
15200                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK |
15201                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
15202                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
15203                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
15204            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
15205                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
15206                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_P_S",
15207                            new String[] {
15208                                    Long.class.getName(), Boolean.class.getName(),
15209                                    String.class.getName(), Integer.class.getName()
15210                            });
15211    
15212            /**
15213             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15214             *
15215             * @param nodeId the node ID
15216             * @param head the head
15217             * @param parentTitle the parent title
15218             * @param status the status
15219             * @return the matching wiki pages
15220             * @throws SystemException if a system exception occurred
15221             */
15222            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
15223                    String parentTitle, int status) throws SystemException {
15224                    return findByN_H_P_S(nodeId, head, parentTitle, status,
15225                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15226            }
15227    
15228            /**
15229             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15230             *
15231             * <p>
15232             * 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.
15233             * </p>
15234             *
15235             * @param nodeId the node ID
15236             * @param head the head
15237             * @param parentTitle the parent title
15238             * @param status the status
15239             * @param start the lower bound of the range of wiki pages
15240             * @param end the upper bound of the range of wiki pages (not inclusive)
15241             * @return the range of matching wiki pages
15242             * @throws SystemException if a system exception occurred
15243             */
15244            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
15245                    String parentTitle, int status, int start, int end)
15246                    throws SystemException {
15247                    return findByN_H_P_S(nodeId, head, parentTitle, status, start, end, null);
15248            }
15249    
15250            /**
15251             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15252             *
15253             * <p>
15254             * 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.
15255             * </p>
15256             *
15257             * @param nodeId the node ID
15258             * @param head the head
15259             * @param parentTitle the parent title
15260             * @param status the status
15261             * @param start the lower bound of the range of wiki pages
15262             * @param end the upper bound of the range of wiki pages (not inclusive)
15263             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15264             * @return the ordered range of matching wiki pages
15265             * @throws SystemException if a system exception occurred
15266             */
15267            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
15268                    String parentTitle, int status, int start, int end,
15269                    OrderByComparator orderByComparator) throws SystemException {
15270                    boolean pagination = true;
15271                    FinderPath finderPath = null;
15272                    Object[] finderArgs = null;
15273    
15274                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15275                                    (orderByComparator == null)) {
15276                            pagination = false;
15277                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S;
15278                            finderArgs = new Object[] { nodeId, head, parentTitle, status };
15279                    }
15280                    else {
15281                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P_S;
15282                            finderArgs = new Object[] {
15283                                            nodeId, head, parentTitle, status,
15284                                            
15285                                            start, end, orderByComparator
15286                                    };
15287                    }
15288    
15289                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
15290                                    finderArgs, this);
15291    
15292                    if ((list != null) && !list.isEmpty()) {
15293                            for (WikiPage wikiPage : list) {
15294                                    if ((nodeId != wikiPage.getNodeId()) ||
15295                                                    (head != wikiPage.getHead()) ||
15296                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle()) ||
15297                                                    (status != wikiPage.getStatus())) {
15298                                            list = null;
15299    
15300                                            break;
15301                                    }
15302                            }
15303                    }
15304    
15305                    if (list == null) {
15306                            StringBundler query = null;
15307    
15308                            if (orderByComparator != null) {
15309                                    query = new StringBundler(6 +
15310                                                    (orderByComparator.getOrderByFields().length * 3));
15311                            }
15312                            else {
15313                                    query = new StringBundler(6);
15314                            }
15315    
15316                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
15317    
15318                            query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
15319    
15320                            query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
15321    
15322                            boolean bindParentTitle = false;
15323    
15324                            if (parentTitle == null) {
15325                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
15326                            }
15327                            else if (parentTitle.equals(StringPool.BLANK)) {
15328                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
15329                            }
15330                            else {
15331                                    bindParentTitle = true;
15332    
15333                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
15334                            }
15335    
15336                            query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
15337    
15338                            if (orderByComparator != null) {
15339                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15340                                            orderByComparator);
15341                            }
15342                            else
15343                             if (pagination) {
15344                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
15345                            }
15346    
15347                            String sql = query.toString();
15348    
15349                            Session session = null;
15350    
15351                            try {
15352                                    session = openSession();
15353    
15354                                    Query q = session.createQuery(sql);
15355    
15356                                    QueryPos qPos = QueryPos.getInstance(q);
15357    
15358                                    qPos.add(nodeId);
15359    
15360                                    qPos.add(head);
15361    
15362                                    if (bindParentTitle) {
15363                                            qPos.add(parentTitle.toLowerCase());
15364                                    }
15365    
15366                                    qPos.add(status);
15367    
15368                                    if (!pagination) {
15369                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
15370                                                            start, end, false);
15371    
15372                                            Collections.sort(list);
15373    
15374                                            list = new UnmodifiableList<WikiPage>(list);
15375                                    }
15376                                    else {
15377                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
15378                                                            start, end);
15379                                    }
15380    
15381                                    cacheResult(list);
15382    
15383                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15384                            }
15385                            catch (Exception e) {
15386                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15387    
15388                                    throw processException(e);
15389                            }
15390                            finally {
15391                                    closeSession(session);
15392                            }
15393                    }
15394    
15395                    return list;
15396            }
15397    
15398            /**
15399             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15400             *
15401             * @param nodeId the node ID
15402             * @param head the head
15403             * @param parentTitle the parent title
15404             * @param status the status
15405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15406             * @return the first matching wiki page
15407             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
15408             * @throws SystemException if a system exception occurred
15409             */
15410            public WikiPage findByN_H_P_S_First(long nodeId, boolean head,
15411                    String parentTitle, int status, OrderByComparator orderByComparator)
15412                    throws NoSuchPageException, SystemException {
15413                    WikiPage wikiPage = fetchByN_H_P_S_First(nodeId, head, parentTitle,
15414                                    status, orderByComparator);
15415    
15416                    if (wikiPage != null) {
15417                            return wikiPage;
15418                    }
15419    
15420                    StringBundler msg = new StringBundler(10);
15421    
15422                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15423    
15424                    msg.append("nodeId=");
15425                    msg.append(nodeId);
15426    
15427                    msg.append(", head=");
15428                    msg.append(head);
15429    
15430                    msg.append(", parentTitle=");
15431                    msg.append(parentTitle);
15432    
15433                    msg.append(", status=");
15434                    msg.append(status);
15435    
15436                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15437    
15438                    throw new NoSuchPageException(msg.toString());
15439            }
15440    
15441            /**
15442             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15443             *
15444             * @param nodeId the node ID
15445             * @param head the head
15446             * @param parentTitle the parent title
15447             * @param status the status
15448             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15449             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
15450             * @throws SystemException if a system exception occurred
15451             */
15452            public WikiPage fetchByN_H_P_S_First(long nodeId, boolean head,
15453                    String parentTitle, int status, OrderByComparator orderByComparator)
15454                    throws SystemException {
15455                    List<WikiPage> list = findByN_H_P_S(nodeId, head, parentTitle, status,
15456                                    0, 1, orderByComparator);
15457    
15458                    if (!list.isEmpty()) {
15459                            return list.get(0);
15460                    }
15461    
15462                    return null;
15463            }
15464    
15465            /**
15466             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15467             *
15468             * @param nodeId the node ID
15469             * @param head the head
15470             * @param parentTitle the parent title
15471             * @param status the status
15472             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15473             * @return the last matching wiki page
15474             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
15475             * @throws SystemException if a system exception occurred
15476             */
15477            public WikiPage findByN_H_P_S_Last(long nodeId, boolean head,
15478                    String parentTitle, int status, OrderByComparator orderByComparator)
15479                    throws NoSuchPageException, SystemException {
15480                    WikiPage wikiPage = fetchByN_H_P_S_Last(nodeId, head, parentTitle,
15481                                    status, orderByComparator);
15482    
15483                    if (wikiPage != null) {
15484                            return wikiPage;
15485                    }
15486    
15487                    StringBundler msg = new StringBundler(10);
15488    
15489                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15490    
15491                    msg.append("nodeId=");
15492                    msg.append(nodeId);
15493    
15494                    msg.append(", head=");
15495                    msg.append(head);
15496    
15497                    msg.append(", parentTitle=");
15498                    msg.append(parentTitle);
15499    
15500                    msg.append(", status=");
15501                    msg.append(status);
15502    
15503                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15504    
15505                    throw new NoSuchPageException(msg.toString());
15506            }
15507    
15508            /**
15509             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15510             *
15511             * @param nodeId the node ID
15512             * @param head the head
15513             * @param parentTitle the parent title
15514             * @param status the status
15515             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15516             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
15517             * @throws SystemException if a system exception occurred
15518             */
15519            public WikiPage fetchByN_H_P_S_Last(long nodeId, boolean head,
15520                    String parentTitle, int status, OrderByComparator orderByComparator)
15521                    throws SystemException {
15522                    int count = countByN_H_P_S(nodeId, head, parentTitle, status);
15523    
15524                    List<WikiPage> list = findByN_H_P_S(nodeId, head, parentTitle, status,
15525                                    count - 1, count, orderByComparator);
15526    
15527                    if (!list.isEmpty()) {
15528                            return list.get(0);
15529                    }
15530    
15531                    return null;
15532            }
15533    
15534            /**
15535             * 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;.
15536             *
15537             * @param pageId the primary key of the current wiki page
15538             * @param nodeId the node ID
15539             * @param head the head
15540             * @param parentTitle the parent title
15541             * @param status the status
15542             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15543             * @return the previous, current, and next wiki page
15544             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
15545             * @throws SystemException if a system exception occurred
15546             */
15547            public WikiPage[] findByN_H_P_S_PrevAndNext(long pageId, long nodeId,
15548                    boolean head, String parentTitle, int status,
15549                    OrderByComparator orderByComparator)
15550                    throws NoSuchPageException, SystemException {
15551                    WikiPage wikiPage = findByPrimaryKey(pageId);
15552    
15553                    Session session = null;
15554    
15555                    try {
15556                            session = openSession();
15557    
15558                            WikiPage[] array = new WikiPageImpl[3];
15559    
15560                            array[0] = getByN_H_P_S_PrevAndNext(session, wikiPage, nodeId,
15561                                            head, parentTitle, status, orderByComparator, true);
15562    
15563                            array[1] = wikiPage;
15564    
15565                            array[2] = getByN_H_P_S_PrevAndNext(session, wikiPage, nodeId,
15566                                            head, parentTitle, status, orderByComparator, false);
15567    
15568                            return array;
15569                    }
15570                    catch (Exception e) {
15571                            throw processException(e);
15572                    }
15573                    finally {
15574                            closeSession(session);
15575                    }
15576            }
15577    
15578            protected WikiPage getByN_H_P_S_PrevAndNext(Session session,
15579                    WikiPage wikiPage, long nodeId, boolean head, String parentTitle,
15580                    int status, OrderByComparator orderByComparator, boolean previous) {
15581                    StringBundler query = null;
15582    
15583                    if (orderByComparator != null) {
15584                            query = new StringBundler(6 +
15585                                            (orderByComparator.getOrderByFields().length * 6));
15586                    }
15587                    else {
15588                            query = new StringBundler(3);
15589                    }
15590    
15591                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
15592    
15593                    query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
15594    
15595                    query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
15596    
15597                    boolean bindParentTitle = false;
15598    
15599                    if (parentTitle == null) {
15600                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
15601                    }
15602                    else if (parentTitle.equals(StringPool.BLANK)) {
15603                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
15604                    }
15605                    else {
15606                            bindParentTitle = true;
15607    
15608                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
15609                    }
15610    
15611                    query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
15612    
15613                    if (orderByComparator != null) {
15614                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15615    
15616                            if (orderByConditionFields.length > 0) {
15617                                    query.append(WHERE_AND);
15618                            }
15619    
15620                            for (int i = 0; i < orderByConditionFields.length; i++) {
15621                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15622                                    query.append(orderByConditionFields[i]);
15623    
15624                                    if ((i + 1) < orderByConditionFields.length) {
15625                                            if (orderByComparator.isAscending() ^ previous) {
15626                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15627                                            }
15628                                            else {
15629                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15630                                            }
15631                                    }
15632                                    else {
15633                                            if (orderByComparator.isAscending() ^ previous) {
15634                                                    query.append(WHERE_GREATER_THAN);
15635                                            }
15636                                            else {
15637                                                    query.append(WHERE_LESSER_THAN);
15638                                            }
15639                                    }
15640                            }
15641    
15642                            query.append(ORDER_BY_CLAUSE);
15643    
15644                            String[] orderByFields = orderByComparator.getOrderByFields();
15645    
15646                            for (int i = 0; i < orderByFields.length; i++) {
15647                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15648                                    query.append(orderByFields[i]);
15649    
15650                                    if ((i + 1) < orderByFields.length) {
15651                                            if (orderByComparator.isAscending() ^ previous) {
15652                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15653                                            }
15654                                            else {
15655                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15656                                            }
15657                                    }
15658                                    else {
15659                                            if (orderByComparator.isAscending() ^ previous) {
15660                                                    query.append(ORDER_BY_ASC);
15661                                            }
15662                                            else {
15663                                                    query.append(ORDER_BY_DESC);
15664                                            }
15665                                    }
15666                            }
15667                    }
15668                    else {
15669                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
15670                    }
15671    
15672                    String sql = query.toString();
15673    
15674                    Query q = session.createQuery(sql);
15675    
15676                    q.setFirstResult(0);
15677                    q.setMaxResults(2);
15678    
15679                    QueryPos qPos = QueryPos.getInstance(q);
15680    
15681                    qPos.add(nodeId);
15682    
15683                    qPos.add(head);
15684    
15685                    if (bindParentTitle) {
15686                            qPos.add(parentTitle.toLowerCase());
15687                    }
15688    
15689                    qPos.add(status);
15690    
15691                    if (orderByComparator != null) {
15692                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
15693    
15694                            for (Object value : values) {
15695                                    qPos.add(value);
15696                            }
15697                    }
15698    
15699                    List<WikiPage> list = q.list();
15700    
15701                    if (list.size() == 2) {
15702                            return list.get(1);
15703                    }
15704                    else {
15705                            return null;
15706                    }
15707            }
15708    
15709            /**
15710             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63; from the database.
15711             *
15712             * @param nodeId the node ID
15713             * @param head the head
15714             * @param parentTitle the parent title
15715             * @param status the status
15716             * @throws SystemException if a system exception occurred
15717             */
15718            public void removeByN_H_P_S(long nodeId, boolean head, String parentTitle,
15719                    int status) throws SystemException {
15720                    for (WikiPage wikiPage : findByN_H_P_S(nodeId, head, parentTitle,
15721                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15722                            remove(wikiPage);
15723                    }
15724            }
15725    
15726            /**
15727             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15728             *
15729             * @param nodeId the node ID
15730             * @param head the head
15731             * @param parentTitle the parent title
15732             * @param status the status
15733             * @return the number of matching wiki pages
15734             * @throws SystemException if a system exception occurred
15735             */
15736            public int countByN_H_P_S(long nodeId, boolean head, String parentTitle,
15737                    int status) throws SystemException {
15738                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_H_P_S;
15739    
15740                    Object[] finderArgs = new Object[] { nodeId, head, parentTitle, status };
15741    
15742                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15743                                    this);
15744    
15745                    if (count == null) {
15746                            StringBundler query = new StringBundler(5);
15747    
15748                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15749    
15750                            query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
15751    
15752                            query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
15753    
15754                            boolean bindParentTitle = false;
15755    
15756                            if (parentTitle == null) {
15757                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
15758                            }
15759                            else if (parentTitle.equals(StringPool.BLANK)) {
15760                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
15761                            }
15762                            else {
15763                                    bindParentTitle = true;
15764    
15765                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
15766                            }
15767    
15768                            query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
15769    
15770                            String sql = query.toString();
15771    
15772                            Session session = null;
15773    
15774                            try {
15775                                    session = openSession();
15776    
15777                                    Query q = session.createQuery(sql);
15778    
15779                                    QueryPos qPos = QueryPos.getInstance(q);
15780    
15781                                    qPos.add(nodeId);
15782    
15783                                    qPos.add(head);
15784    
15785                                    if (bindParentTitle) {
15786                                            qPos.add(parentTitle.toLowerCase());
15787                                    }
15788    
15789                                    qPos.add(status);
15790    
15791                                    count = (Long)q.uniqueResult();
15792    
15793                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15794                            }
15795                            catch (Exception e) {
15796                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15797    
15798                                    throw processException(e);
15799                            }
15800                            finally {
15801                                    closeSession(session);
15802                            }
15803                    }
15804    
15805                    return count.intValue();
15806            }
15807    
15808            private static final String _FINDER_COLUMN_N_H_P_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
15809            private static final String _FINDER_COLUMN_N_H_P_S_HEAD_2 = "wikiPage.head = ? AND ";
15810            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL AND ";
15811            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = ? AND ";
15812            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = '') AND ";
15813            private static final String _FINDER_COLUMN_N_H_P_S_STATUS_2 = "wikiPage.status = ?";
15814            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_P_S =
15815                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
15816                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
15817                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_H_P_S",
15818                            new String[] {
15819                                    Long.class.getName(), Long.class.getName(),
15820                                    Boolean.class.getName(), String.class.getName(),
15821                                    Integer.class.getName(),
15822                                    
15823                            Integer.class.getName(), Integer.class.getName(),
15824                                    OrderByComparator.class.getName()
15825                            });
15826            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S =
15827                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
15828                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
15829                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_H_P_S",
15830                            new String[] {
15831                                    Long.class.getName(), Long.class.getName(),
15832                                    Boolean.class.getName(), String.class.getName(),
15833                                    Integer.class.getName()
15834                            },
15835                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
15836                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
15837                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
15838                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK |
15839                            WikiPageModelImpl.STATUS_COLUMN_BITMASK |
15840                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
15841                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
15842            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
15843                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
15844                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_H_P_S",
15845                            new String[] {
15846                                    Long.class.getName(), Long.class.getName(),
15847                                    Boolean.class.getName(), String.class.getName(),
15848                                    Integer.class.getName()
15849                            });
15850    
15851            /**
15852             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15853             *
15854             * @param groupId the group ID
15855             * @param nodeId the node ID
15856             * @param head the head
15857             * @param parentTitle the parent title
15858             * @param status the status
15859             * @return the matching wiki pages
15860             * @throws SystemException if a system exception occurred
15861             */
15862            public List<WikiPage> findByG_N_H_P_S(long groupId, long nodeId,
15863                    boolean head, String parentTitle, int status) throws SystemException {
15864                    return findByG_N_H_P_S(groupId, nodeId, head, parentTitle, status,
15865                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15866            }
15867    
15868            /**
15869             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15870             *
15871             * <p>
15872             * 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.
15873             * </p>
15874             *
15875             * @param groupId the group ID
15876             * @param nodeId the node ID
15877             * @param head the head
15878             * @param parentTitle the parent title
15879             * @param status the status
15880             * @param start the lower bound of the range of wiki pages
15881             * @param end the upper bound of the range of wiki pages (not inclusive)
15882             * @return the range of matching wiki pages
15883             * @throws SystemException if a system exception occurred
15884             */
15885            public List<WikiPage> findByG_N_H_P_S(long groupId, long nodeId,
15886                    boolean head, String parentTitle, int status, int start, int end)
15887                    throws SystemException {
15888                    return findByG_N_H_P_S(groupId, nodeId, head, parentTitle, status,
15889                            start, end, null);
15890            }
15891    
15892            /**
15893             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
15894             *
15895             * <p>
15896             * 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.
15897             * </p>
15898             *
15899             * @param groupId the group ID
15900             * @param nodeId the node ID
15901             * @param head the head
15902             * @param parentTitle the parent title
15903             * @param status the status
15904             * @param start the lower bound of the range of wiki pages
15905             * @param end the upper bound of the range of wiki pages (not inclusive)
15906             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15907             * @return the ordered range of matching wiki pages
15908             * @throws SystemException if a system exception occurred
15909             */
15910            public List<WikiPage> findByG_N_H_P_S(long groupId, long nodeId,
15911                    boolean head, String parentTitle, int status, int start, int end,
15912                    OrderByComparator orderByComparator) throws SystemException {
15913                    boolean pagination = true;
15914                    FinderPath finderPath = null;
15915                    Object[] finderArgs = null;
15916    
15917                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15918                                    (orderByComparator == null)) {
15919                            pagination = false;
15920                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S;
15921                            finderArgs = new Object[] { groupId, nodeId, head, parentTitle, status };
15922                    }
15923                    else {
15924                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_P_S;
15925                            finderArgs = new Object[] {
15926                                            groupId, nodeId, head, parentTitle, status,
15927                                            
15928                                            start, end, orderByComparator
15929                                    };
15930                    }
15931    
15932                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
15933                                    finderArgs, this);
15934    
15935                    if ((list != null) && !list.isEmpty()) {
15936                            for (WikiPage wikiPage : list) {
15937                                    if ((groupId != wikiPage.getGroupId()) ||
15938                                                    (nodeId != wikiPage.getNodeId()) ||
15939                                                    (head != wikiPage.getHead()) ||
15940                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle()) ||
15941                                                    (status != wikiPage.getStatus())) {
15942                                            list = null;
15943    
15944                                            break;
15945                                    }
15946                            }
15947                    }
15948    
15949                    if (list == null) {
15950                            StringBundler query = null;
15951    
15952                            if (orderByComparator != null) {
15953                                    query = new StringBundler(7 +
15954                                                    (orderByComparator.getOrderByFields().length * 3));
15955                            }
15956                            else {
15957                                    query = new StringBundler(7);
15958                            }
15959    
15960                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
15961    
15962                            query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
15963    
15964                            query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
15965    
15966                            query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
15967    
15968                            boolean bindParentTitle = false;
15969    
15970                            if (parentTitle == null) {
15971                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
15972                            }
15973                            else if (parentTitle.equals(StringPool.BLANK)) {
15974                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
15975                            }
15976                            else {
15977                                    bindParentTitle = true;
15978    
15979                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
15980                            }
15981    
15982                            query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
15983    
15984                            if (orderByComparator != null) {
15985                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15986                                            orderByComparator);
15987                            }
15988                            else
15989                             if (pagination) {
15990                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
15991                            }
15992    
15993                            String sql = query.toString();
15994    
15995                            Session session = null;
15996    
15997                            try {
15998                                    session = openSession();
15999    
16000                                    Query q = session.createQuery(sql);
16001    
16002                                    QueryPos qPos = QueryPos.getInstance(q);
16003    
16004                                    qPos.add(groupId);
16005    
16006                                    qPos.add(nodeId);
16007    
16008                                    qPos.add(head);
16009    
16010                                    if (bindParentTitle) {
16011                                            qPos.add(parentTitle.toLowerCase());
16012                                    }
16013    
16014                                    qPos.add(status);
16015    
16016                                    if (!pagination) {
16017                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
16018                                                            start, end, false);
16019    
16020                                            Collections.sort(list);
16021    
16022                                            list = new UnmodifiableList<WikiPage>(list);
16023                                    }
16024                                    else {
16025                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
16026                                                            start, end);
16027                                    }
16028    
16029                                    cacheResult(list);
16030    
16031                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16032                            }
16033                            catch (Exception e) {
16034                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16035    
16036                                    throw processException(e);
16037                            }
16038                            finally {
16039                                    closeSession(session);
16040                            }
16041                    }
16042    
16043                    return list;
16044            }
16045    
16046            /**
16047             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
16048             *
16049             * @param groupId the group ID
16050             * @param nodeId the node ID
16051             * @param head the head
16052             * @param parentTitle the parent title
16053             * @param status the status
16054             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16055             * @return the first matching wiki page
16056             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
16057             * @throws SystemException if a system exception occurred
16058             */
16059            public WikiPage findByG_N_H_P_S_First(long groupId, long nodeId,
16060                    boolean head, String parentTitle, int status,
16061                    OrderByComparator orderByComparator)
16062                    throws NoSuchPageException, SystemException {
16063                    WikiPage wikiPage = fetchByG_N_H_P_S_First(groupId, nodeId, head,
16064                                    parentTitle, status, orderByComparator);
16065    
16066                    if (wikiPage != null) {
16067                            return wikiPage;
16068                    }
16069    
16070                    StringBundler msg = new StringBundler(12);
16071    
16072                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16073    
16074                    msg.append("groupId=");
16075                    msg.append(groupId);
16076    
16077                    msg.append(", nodeId=");
16078                    msg.append(nodeId);
16079    
16080                    msg.append(", head=");
16081                    msg.append(head);
16082    
16083                    msg.append(", parentTitle=");
16084                    msg.append(parentTitle);
16085    
16086                    msg.append(", status=");
16087                    msg.append(status);
16088    
16089                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16090    
16091                    throw new NoSuchPageException(msg.toString());
16092            }
16093    
16094            /**
16095             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
16096             *
16097             * @param groupId the group ID
16098             * @param nodeId the node ID
16099             * @param head the head
16100             * @param parentTitle the parent title
16101             * @param status the status
16102             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16103             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
16104             * @throws SystemException if a system exception occurred
16105             */
16106            public WikiPage fetchByG_N_H_P_S_First(long groupId, long nodeId,
16107                    boolean head, String parentTitle, int status,
16108                    OrderByComparator orderByComparator) throws SystemException {
16109                    List<WikiPage> list = findByG_N_H_P_S(groupId, nodeId, head,
16110                                    parentTitle, status, 0, 1, orderByComparator);
16111    
16112                    if (!list.isEmpty()) {
16113                            return list.get(0);
16114                    }
16115    
16116                    return null;
16117            }
16118    
16119            /**
16120             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
16121             *
16122             * @param groupId the group ID
16123             * @param nodeId the node ID
16124             * @param head the head
16125             * @param parentTitle the parent title
16126             * @param status the status
16127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16128             * @return the last matching wiki page
16129             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
16130             * @throws SystemException if a system exception occurred
16131             */
16132            public WikiPage findByG_N_H_P_S_Last(long groupId, long nodeId,
16133                    boolean head, String parentTitle, int status,
16134                    OrderByComparator orderByComparator)
16135                    throws NoSuchPageException, SystemException {
16136                    WikiPage wikiPage = fetchByG_N_H_P_S_Last(groupId, nodeId, head,
16137                                    parentTitle, status, orderByComparator);
16138    
16139                    if (wikiPage != null) {
16140                            return wikiPage;
16141                    }
16142    
16143                    StringBundler msg = new StringBundler(12);
16144    
16145                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16146    
16147                    msg.append("groupId=");
16148                    msg.append(groupId);
16149    
16150                    msg.append(", nodeId=");
16151                    msg.append(nodeId);
16152    
16153                    msg.append(", head=");
16154                    msg.append(head);
16155    
16156                    msg.append(", parentTitle=");
16157                    msg.append(parentTitle);
16158    
16159                    msg.append(", status=");
16160                    msg.append(status);
16161    
16162                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16163    
16164                    throw new NoSuchPageException(msg.toString());
16165            }
16166    
16167            /**
16168             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
16169             *
16170             * @param groupId the group ID
16171             * @param nodeId the node ID
16172             * @param head the head
16173             * @param parentTitle the parent title
16174             * @param status the status
16175             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16176             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
16177             * @throws SystemException if a system exception occurred
16178             */
16179            public WikiPage fetchByG_N_H_P_S_Last(long groupId, long nodeId,
16180                    boolean head, String parentTitle, int status,
16181                    OrderByComparator orderByComparator) throws SystemException {
16182                    int count = countByG_N_H_P_S(groupId, nodeId, head, parentTitle, status);
16183    
16184                    List<WikiPage> list = findByG_N_H_P_S(groupId, nodeId, head,
16185                                    parentTitle, status, count - 1, count, orderByComparator);
16186    
16187                    if (!list.isEmpty()) {
16188                            return list.get(0);
16189                    }
16190    
16191                    return null;
16192            }
16193    
16194            /**
16195             * 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;.
16196             *
16197             * @param pageId the primary key of the current wiki page
16198             * @param groupId the group ID
16199             * @param nodeId the node ID
16200             * @param head the head
16201             * @param parentTitle the parent title
16202             * @param status the status
16203             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16204             * @return the previous, current, and next wiki page
16205             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
16206             * @throws SystemException if a system exception occurred
16207             */
16208            public WikiPage[] findByG_N_H_P_S_PrevAndNext(long pageId, long groupId,
16209                    long nodeId, boolean head, String parentTitle, int status,
16210                    OrderByComparator orderByComparator)
16211                    throws NoSuchPageException, SystemException {
16212                    WikiPage wikiPage = findByPrimaryKey(pageId);
16213    
16214                    Session session = null;
16215    
16216                    try {
16217                            session = openSession();
16218    
16219                            WikiPage[] array = new WikiPageImpl[3];
16220    
16221                            array[0] = getByG_N_H_P_S_PrevAndNext(session, wikiPage, groupId,
16222                                            nodeId, head, parentTitle, status, orderByComparator, true);
16223    
16224                            array[1] = wikiPage;
16225    
16226                            array[2] = getByG_N_H_P_S_PrevAndNext(session, wikiPage, groupId,
16227                                            nodeId, head, parentTitle, status, orderByComparator, false);
16228    
16229                            return array;
16230                    }
16231                    catch (Exception e) {
16232                            throw processException(e);
16233                    }
16234                    finally {
16235                            closeSession(session);
16236                    }
16237            }
16238    
16239            protected WikiPage getByG_N_H_P_S_PrevAndNext(Session session,
16240                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
16241                    String parentTitle, int status, OrderByComparator orderByComparator,
16242                    boolean previous) {
16243                    StringBundler query = null;
16244    
16245                    if (orderByComparator != null) {
16246                            query = new StringBundler(6 +
16247                                            (orderByComparator.getOrderByFields().length * 6));
16248                    }
16249                    else {
16250                            query = new StringBundler(3);
16251                    }
16252    
16253                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
16254    
16255                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
16256    
16257                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
16258    
16259                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
16260    
16261                    boolean bindParentTitle = false;
16262    
16263                    if (parentTitle == null) {
16264                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
16265                    }
16266                    else if (parentTitle.equals(StringPool.BLANK)) {
16267                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
16268                    }
16269                    else {
16270                            bindParentTitle = true;
16271    
16272                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
16273                    }
16274    
16275                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
16276    
16277                    if (orderByComparator != null) {
16278                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16279    
16280                            if (orderByConditionFields.length > 0) {
16281                                    query.append(WHERE_AND);
16282                            }
16283    
16284                            for (int i = 0; i < orderByConditionFields.length; i++) {
16285                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16286                                    query.append(orderByConditionFields[i]);
16287    
16288                                    if ((i + 1) < orderByConditionFields.length) {
16289                                            if (orderByComparator.isAscending() ^ previous) {
16290                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16291                                            }
16292                                            else {
16293                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16294                                            }
16295                                    }
16296                                    else {
16297                                            if (orderByComparator.isAscending() ^ previous) {
16298                                                    query.append(WHERE_GREATER_THAN);
16299                                            }
16300                                            else {
16301                                                    query.append(WHERE_LESSER_THAN);
16302                                            }
16303                                    }
16304                            }
16305    
16306                            query.append(ORDER_BY_CLAUSE);
16307    
16308                            String[] orderByFields = orderByComparator.getOrderByFields();
16309    
16310                            for (int i = 0; i < orderByFields.length; i++) {
16311                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16312                                    query.append(orderByFields[i]);
16313    
16314                                    if ((i + 1) < orderByFields.length) {
16315                                            if (orderByComparator.isAscending() ^ previous) {
16316                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16317                                            }
16318                                            else {
16319                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16320                                            }
16321                                    }
16322                                    else {
16323                                            if (orderByComparator.isAscending() ^ previous) {
16324                                                    query.append(ORDER_BY_ASC);
16325                                            }
16326                                            else {
16327                                                    query.append(ORDER_BY_DESC);
16328                                            }
16329                                    }
16330                            }
16331                    }
16332                    else {
16333                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
16334                    }
16335    
16336                    String sql = query.toString();
16337    
16338                    Query q = session.createQuery(sql);
16339    
16340                    q.setFirstResult(0);
16341                    q.setMaxResults(2);
16342    
16343                    QueryPos qPos = QueryPos.getInstance(q);
16344    
16345                    qPos.add(groupId);
16346    
16347                    qPos.add(nodeId);
16348    
16349                    qPos.add(head);
16350    
16351                    if (bindParentTitle) {
16352                            qPos.add(parentTitle.toLowerCase());
16353                    }
16354    
16355                    qPos.add(status);
16356    
16357                    if (orderByComparator != null) {
16358                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
16359    
16360                            for (Object value : values) {
16361                                    qPos.add(value);
16362                            }
16363                    }
16364    
16365                    List<WikiPage> list = q.list();
16366    
16367                    if (list.size() == 2) {
16368                            return list.get(1);
16369                    }
16370                    else {
16371                            return null;
16372                    }
16373            }
16374    
16375            /**
16376             * 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;.
16377             *
16378             * @param groupId the group ID
16379             * @param nodeId the node ID
16380             * @param head the head
16381             * @param parentTitle the parent title
16382             * @param status the status
16383             * @return the matching wiki pages that the user has permission to view
16384             * @throws SystemException if a system exception occurred
16385             */
16386            public List<WikiPage> filterFindByG_N_H_P_S(long groupId, long nodeId,
16387                    boolean head, String parentTitle, int status) throws SystemException {
16388                    return filterFindByG_N_H_P_S(groupId, nodeId, head, parentTitle,
16389                            status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16390            }
16391    
16392            /**
16393             * 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;.
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 parentTitle the parent title
16403             * @param status the status
16404             * @param start the lower bound of the range of wiki pages
16405             * @param end the upper bound of the range of wiki pages (not inclusive)
16406             * @return the range of matching wiki pages that the user has permission to view
16407             * @throws SystemException if a system exception occurred
16408             */
16409            public List<WikiPage> filterFindByG_N_H_P_S(long groupId, long nodeId,
16410                    boolean head, String parentTitle, int status, int start, int end)
16411                    throws SystemException {
16412                    return filterFindByG_N_H_P_S(groupId, nodeId, head, parentTitle,
16413                            status, start, end, null);
16414            }
16415    
16416            /**
16417             * 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;.
16418             *
16419             * <p>
16420             * 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.
16421             * </p>
16422             *
16423             * @param groupId the group ID
16424             * @param nodeId the node ID
16425             * @param head the head
16426             * @param parentTitle the parent title
16427             * @param status the status
16428             * @param start the lower bound of the range of wiki pages
16429             * @param end the upper bound of the range of wiki pages (not inclusive)
16430             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16431             * @return the ordered range of matching wiki pages that the user has permission to view
16432             * @throws SystemException if a system exception occurred
16433             */
16434            public List<WikiPage> filterFindByG_N_H_P_S(long groupId, long nodeId,
16435                    boolean head, String parentTitle, int status, int start, int end,
16436                    OrderByComparator orderByComparator) throws SystemException {
16437                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16438                            return findByG_N_H_P_S(groupId, nodeId, head, parentTitle, status,
16439                                    start, end, orderByComparator);
16440                    }
16441    
16442                    StringBundler query = null;
16443    
16444                    if (orderByComparator != null) {
16445                            query = new StringBundler(7 +
16446                                            (orderByComparator.getOrderByFields().length * 3));
16447                    }
16448                    else {
16449                            query = new StringBundler(7);
16450                    }
16451    
16452                    if (getDB().isSupportsInlineDistinct()) {
16453                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
16454                    }
16455                    else {
16456                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
16457                    }
16458    
16459                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
16460    
16461                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
16462    
16463                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
16464    
16465                    boolean bindParentTitle = false;
16466    
16467                    if (parentTitle == null) {
16468                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
16469                    }
16470                    else if (parentTitle.equals(StringPool.BLANK)) {
16471                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
16472                    }
16473                    else {
16474                            bindParentTitle = true;
16475    
16476                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
16477                    }
16478    
16479                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
16480    
16481                    if (!getDB().isSupportsInlineDistinct()) {
16482                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
16483                    }
16484    
16485                    if (orderByComparator != null) {
16486                            if (getDB().isSupportsInlineDistinct()) {
16487                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16488                                            orderByComparator);
16489                            }
16490                            else {
16491                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16492                                            orderByComparator);
16493                            }
16494                    }
16495                    else {
16496                            if (getDB().isSupportsInlineDistinct()) {
16497                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
16498                            }
16499                            else {
16500                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
16501                            }
16502                    }
16503    
16504                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16505                                    WikiPage.class.getName(),
16506                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16507    
16508                    Session session = null;
16509    
16510                    try {
16511                            session = openSession();
16512    
16513                            SQLQuery q = session.createSQLQuery(sql);
16514    
16515                            if (getDB().isSupportsInlineDistinct()) {
16516                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
16517                            }
16518                            else {
16519                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
16520                            }
16521    
16522                            QueryPos qPos = QueryPos.getInstance(q);
16523    
16524                            qPos.add(groupId);
16525    
16526                            qPos.add(nodeId);
16527    
16528                            qPos.add(head);
16529    
16530                            if (bindParentTitle) {
16531                                    qPos.add(parentTitle.toLowerCase());
16532                            }
16533    
16534                            qPos.add(status);
16535    
16536                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
16537                    }
16538                    catch (Exception e) {
16539                            throw processException(e);
16540                    }
16541                    finally {
16542                            closeSession(session);
16543                    }
16544            }
16545    
16546            /**
16547             * 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;.
16548             *
16549             * @param pageId the primary key of the current wiki page
16550             * @param groupId the group ID
16551             * @param nodeId the node ID
16552             * @param head the head
16553             * @param parentTitle the parent title
16554             * @param status the status
16555             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16556             * @return the previous, current, and next wiki page
16557             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
16558             * @throws SystemException if a system exception occurred
16559             */
16560            public WikiPage[] filterFindByG_N_H_P_S_PrevAndNext(long pageId,
16561                    long groupId, long nodeId, boolean head, String parentTitle,
16562                    int status, OrderByComparator orderByComparator)
16563                    throws NoSuchPageException, SystemException {
16564                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16565                            return findByG_N_H_P_S_PrevAndNext(pageId, groupId, nodeId, head,
16566                                    parentTitle, status, orderByComparator);
16567                    }
16568    
16569                    WikiPage wikiPage = findByPrimaryKey(pageId);
16570    
16571                    Session session = null;
16572    
16573                    try {
16574                            session = openSession();
16575    
16576                            WikiPage[] array = new WikiPageImpl[3];
16577    
16578                            array[0] = filterGetByG_N_H_P_S_PrevAndNext(session, wikiPage,
16579                                            groupId, nodeId, head, parentTitle, status,
16580                                            orderByComparator, true);
16581    
16582                            array[1] = wikiPage;
16583    
16584                            array[2] = filterGetByG_N_H_P_S_PrevAndNext(session, wikiPage,
16585                                            groupId, nodeId, head, parentTitle, status,
16586                                            orderByComparator, false);
16587    
16588                            return array;
16589                    }
16590                    catch (Exception e) {
16591                            throw processException(e);
16592                    }
16593                    finally {
16594                            closeSession(session);
16595                    }
16596            }
16597    
16598            protected WikiPage filterGetByG_N_H_P_S_PrevAndNext(Session session,
16599                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
16600                    String parentTitle, int status, OrderByComparator orderByComparator,
16601                    boolean previous) {
16602                    StringBundler query = null;
16603    
16604                    if (orderByComparator != null) {
16605                            query = new StringBundler(6 +
16606                                            (orderByComparator.getOrderByFields().length * 6));
16607                    }
16608                    else {
16609                            query = new StringBundler(3);
16610                    }
16611    
16612                    if (getDB().isSupportsInlineDistinct()) {
16613                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
16614                    }
16615                    else {
16616                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
16617                    }
16618    
16619                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
16620    
16621                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
16622    
16623                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
16624    
16625                    boolean bindParentTitle = false;
16626    
16627                    if (parentTitle == null) {
16628                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
16629                    }
16630                    else if (parentTitle.equals(StringPool.BLANK)) {
16631                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
16632                    }
16633                    else {
16634                            bindParentTitle = true;
16635    
16636                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
16637                    }
16638    
16639                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
16640    
16641                    if (!getDB().isSupportsInlineDistinct()) {
16642                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
16643                    }
16644    
16645                    if (orderByComparator != null) {
16646                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16647    
16648                            if (orderByConditionFields.length > 0) {
16649                                    query.append(WHERE_AND);
16650                            }
16651    
16652                            for (int i = 0; i < orderByConditionFields.length; i++) {
16653                                    if (getDB().isSupportsInlineDistinct()) {
16654                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16655                                    }
16656                                    else {
16657                                            query.append(_ORDER_BY_ENTITY_TABLE);
16658                                    }
16659    
16660                                    query.append(orderByConditionFields[i]);
16661    
16662                                    if ((i + 1) < orderByConditionFields.length) {
16663                                            if (orderByComparator.isAscending() ^ previous) {
16664                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16665                                            }
16666                                            else {
16667                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16668                                            }
16669                                    }
16670                                    else {
16671                                            if (orderByComparator.isAscending() ^ previous) {
16672                                                    query.append(WHERE_GREATER_THAN);
16673                                            }
16674                                            else {
16675                                                    query.append(WHERE_LESSER_THAN);
16676                                            }
16677                                    }
16678                            }
16679    
16680                            query.append(ORDER_BY_CLAUSE);
16681    
16682                            String[] orderByFields = orderByComparator.getOrderByFields();
16683    
16684                            for (int i = 0; i < orderByFields.length; i++) {
16685                                    if (getDB().isSupportsInlineDistinct()) {
16686                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16687                                    }
16688                                    else {
16689                                            query.append(_ORDER_BY_ENTITY_TABLE);
16690                                    }
16691    
16692                                    query.append(orderByFields[i]);
16693    
16694                                    if ((i + 1) < orderByFields.length) {
16695                                            if (orderByComparator.isAscending() ^ previous) {
16696                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16697                                            }
16698                                            else {
16699                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16700                                            }
16701                                    }
16702                                    else {
16703                                            if (orderByComparator.isAscending() ^ previous) {
16704                                                    query.append(ORDER_BY_ASC);
16705                                            }
16706                                            else {
16707                                                    query.append(ORDER_BY_DESC);
16708                                            }
16709                                    }
16710                            }
16711                    }
16712                    else {
16713                            if (getDB().isSupportsInlineDistinct()) {
16714                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
16715                            }
16716                            else {
16717                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
16718                            }
16719                    }
16720    
16721                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16722                                    WikiPage.class.getName(),
16723                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16724    
16725                    SQLQuery q = session.createSQLQuery(sql);
16726    
16727                    q.setFirstResult(0);
16728                    q.setMaxResults(2);
16729    
16730                    if (getDB().isSupportsInlineDistinct()) {
16731                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
16732                    }
16733                    else {
16734                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
16735                    }
16736    
16737                    QueryPos qPos = QueryPos.getInstance(q);
16738    
16739                    qPos.add(groupId);
16740    
16741                    qPos.add(nodeId);
16742    
16743                    qPos.add(head);
16744    
16745                    if (bindParentTitle) {
16746                            qPos.add(parentTitle.toLowerCase());
16747                    }
16748    
16749                    qPos.add(status);
16750    
16751                    if (orderByComparator != null) {
16752                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
16753    
16754                            for (Object value : values) {
16755                                    qPos.add(value);
16756                            }
16757                    }
16758    
16759                    List<WikiPage> list = q.list();
16760    
16761                    if (list.size() == 2) {
16762                            return list.get(1);
16763                    }
16764                    else {
16765                            return null;
16766                    }
16767            }
16768    
16769            /**
16770             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63; from the database.
16771             *
16772             * @param groupId the group ID
16773             * @param nodeId the node ID
16774             * @param head the head
16775             * @param parentTitle the parent title
16776             * @param status the status
16777             * @throws SystemException if a system exception occurred
16778             */
16779            public void removeByG_N_H_P_S(long groupId, long nodeId, boolean head,
16780                    String parentTitle, int status) throws SystemException {
16781                    for (WikiPage wikiPage : findByG_N_H_P_S(groupId, nodeId, head,
16782                                    parentTitle, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16783                            remove(wikiPage);
16784                    }
16785            }
16786    
16787            /**
16788             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
16789             *
16790             * @param groupId the group ID
16791             * @param nodeId the node ID
16792             * @param head the head
16793             * @param parentTitle the parent title
16794             * @param status the status
16795             * @return the number of matching wiki pages
16796             * @throws SystemException if a system exception occurred
16797             */
16798            public int countByG_N_H_P_S(long groupId, long nodeId, boolean head,
16799                    String parentTitle, int status) throws SystemException {
16800                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N_H_P_S;
16801    
16802                    Object[] finderArgs = new Object[] {
16803                                    groupId, nodeId, head, parentTitle, status
16804                            };
16805    
16806                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16807                                    this);
16808    
16809                    if (count == null) {
16810                            StringBundler query = new StringBundler(6);
16811    
16812                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
16813    
16814                            query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
16815    
16816                            query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
16817    
16818                            query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
16819    
16820                            boolean bindParentTitle = false;
16821    
16822                            if (parentTitle == null) {
16823                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
16824                            }
16825                            else if (parentTitle.equals(StringPool.BLANK)) {
16826                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
16827                            }
16828                            else {
16829                                    bindParentTitle = true;
16830    
16831                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
16832                            }
16833    
16834                            query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
16835    
16836                            String sql = query.toString();
16837    
16838                            Session session = null;
16839    
16840                            try {
16841                                    session = openSession();
16842    
16843                                    Query q = session.createQuery(sql);
16844    
16845                                    QueryPos qPos = QueryPos.getInstance(q);
16846    
16847                                    qPos.add(groupId);
16848    
16849                                    qPos.add(nodeId);
16850    
16851                                    qPos.add(head);
16852    
16853                                    if (bindParentTitle) {
16854                                            qPos.add(parentTitle.toLowerCase());
16855                                    }
16856    
16857                                    qPos.add(status);
16858    
16859                                    count = (Long)q.uniqueResult();
16860    
16861                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16862                            }
16863                            catch (Exception e) {
16864                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16865    
16866                                    throw processException(e);
16867                            }
16868                            finally {
16869                                    closeSession(session);
16870                            }
16871                    }
16872    
16873                    return count.intValue();
16874            }
16875    
16876            /**
16877             * 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;.
16878             *
16879             * @param groupId the group ID
16880             * @param nodeId the node ID
16881             * @param head the head
16882             * @param parentTitle the parent title
16883             * @param status the status
16884             * @return the number of matching wiki pages that the user has permission to view
16885             * @throws SystemException if a system exception occurred
16886             */
16887            public int filterCountByG_N_H_P_S(long groupId, long nodeId, boolean head,
16888                    String parentTitle, int status) throws SystemException {
16889                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16890                            return countByG_N_H_P_S(groupId, nodeId, head, parentTitle, status);
16891                    }
16892    
16893                    StringBundler query = new StringBundler(6);
16894    
16895                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
16896    
16897                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
16898    
16899                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
16900    
16901                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
16902    
16903                    boolean bindParentTitle = false;
16904    
16905                    if (parentTitle == null) {
16906                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
16907                    }
16908                    else if (parentTitle.equals(StringPool.BLANK)) {
16909                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
16910                    }
16911                    else {
16912                            bindParentTitle = true;
16913    
16914                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
16915                    }
16916    
16917                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
16918    
16919                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16920                                    WikiPage.class.getName(),
16921                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16922    
16923                    Session session = null;
16924    
16925                    try {
16926                            session = openSession();
16927    
16928                            SQLQuery q = session.createSQLQuery(sql);
16929    
16930                            q.addScalar(COUNT_COLUMN_NAME,
16931                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16932    
16933                            QueryPos qPos = QueryPos.getInstance(q);
16934    
16935                            qPos.add(groupId);
16936    
16937                            qPos.add(nodeId);
16938    
16939                            qPos.add(head);
16940    
16941                            if (bindParentTitle) {
16942                                    qPos.add(parentTitle.toLowerCase());
16943                            }
16944    
16945                            qPos.add(status);
16946    
16947                            Long count = (Long)q.uniqueResult();
16948    
16949                            return count.intValue();
16950                    }
16951                    catch (Exception e) {
16952                            throw processException(e);
16953                    }
16954                    finally {
16955                            closeSession(session);
16956                    }
16957            }
16958    
16959            private static final String _FINDER_COLUMN_G_N_H_P_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
16960            private static final String _FINDER_COLUMN_G_N_H_P_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16961            private static final String _FINDER_COLUMN_G_N_H_P_S_HEAD_2 = "wikiPage.head = ? AND ";
16962            private static final String _FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL AND ";
16963            private static final String _FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = ? AND ";
16964            private static final String _FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = '') AND ";
16965            private static final String _FINDER_COLUMN_G_N_H_P_S_STATUS_2 = "wikiPage.status = ?";
16966    
16967            /**
16968             * Caches the wiki page in the entity cache if it is enabled.
16969             *
16970             * @param wikiPage the wiki page
16971             */
16972            public void cacheResult(WikiPage wikiPage) {
16973                    EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
16974                            WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
16975    
16976                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
16977                            new Object[] { wikiPage.getUuid(), wikiPage.getGroupId() }, wikiPage);
16978    
16979                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
16980                            new Object[] {
16981                                    wikiPage.getResourcePrimKey(), wikiPage.getNodeId(),
16982                                    wikiPage.getVersion()
16983                            }, wikiPage);
16984    
16985                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
16986                            new Object[] {
16987                                    wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion()
16988                            }, wikiPage);
16989    
16990                    wikiPage.resetOriginalValues();
16991            }
16992    
16993            /**
16994             * Caches the wiki pages in the entity cache if it is enabled.
16995             *
16996             * @param wikiPages the wiki pages
16997             */
16998            public void cacheResult(List<WikiPage> wikiPages) {
16999                    for (WikiPage wikiPage : wikiPages) {
17000                            if (EntityCacheUtil.getResult(
17001                                                    WikiPageModelImpl.ENTITY_CACHE_ENABLED,
17002                                                    WikiPageImpl.class, wikiPage.getPrimaryKey()) == null) {
17003                                    cacheResult(wikiPage);
17004                            }
17005                            else {
17006                                    wikiPage.resetOriginalValues();
17007                            }
17008                    }
17009            }
17010    
17011            /**
17012             * Clears the cache for all wiki pages.
17013             *
17014             * <p>
17015             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
17016             * </p>
17017             */
17018            @Override
17019            public void clearCache() {
17020                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
17021                            CacheRegistryUtil.clear(WikiPageImpl.class.getName());
17022                    }
17023    
17024                    EntityCacheUtil.clearCache(WikiPageImpl.class.getName());
17025    
17026                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
17027                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17028                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17029            }
17030    
17031            /**
17032             * Clears the cache for the wiki page.
17033             *
17034             * <p>
17035             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
17036             * </p>
17037             */
17038            @Override
17039            public void clearCache(WikiPage wikiPage) {
17040                    EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
17041                            WikiPageImpl.class, wikiPage.getPrimaryKey());
17042    
17043                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17044                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17045    
17046                    clearUniqueFindersCache(wikiPage);
17047            }
17048    
17049            @Override
17050            public void clearCache(List<WikiPage> wikiPages) {
17051                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17052                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17053    
17054                    for (WikiPage wikiPage : wikiPages) {
17055                            EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
17056                                    WikiPageImpl.class, wikiPage.getPrimaryKey());
17057    
17058                            clearUniqueFindersCache(wikiPage);
17059                    }
17060            }
17061    
17062            protected void cacheUniqueFindersCache(WikiPage wikiPage) {
17063                    if (wikiPage.isNew()) {
17064                            Object[] args = new Object[] {
17065                                            wikiPage.getUuid(), wikiPage.getGroupId()
17066                                    };
17067    
17068                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
17069                                    Long.valueOf(1));
17070                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
17071                                    wikiPage);
17072    
17073                            args = new Object[] {
17074                                            wikiPage.getResourcePrimKey(), wikiPage.getNodeId(),
17075                                            wikiPage.getVersion()
17076                                    };
17077    
17078                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N_V, args,
17079                                    Long.valueOf(1));
17080                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V, args, wikiPage);
17081    
17082                            args = new Object[] {
17083                                            wikiPage.getNodeId(), wikiPage.getTitle(),
17084                                            wikiPage.getVersion()
17085                                    };
17086    
17087                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_V, args,
17088                                    Long.valueOf(1));
17089                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V, args, wikiPage);
17090                    }
17091                    else {
17092                            WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
17093    
17094                            if ((wikiPageModelImpl.getColumnBitmask() &
17095                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
17096                                    Object[] args = new Object[] {
17097                                                    wikiPage.getUuid(), wikiPage.getGroupId()
17098                                            };
17099    
17100                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
17101                                            Long.valueOf(1));
17102                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
17103                                            wikiPage);
17104                            }
17105    
17106                            if ((wikiPageModelImpl.getColumnBitmask() &
17107                                            FINDER_PATH_FETCH_BY_R_N_V.getColumnBitmask()) != 0) {
17108                                    Object[] args = new Object[] {
17109                                                    wikiPage.getResourcePrimKey(), wikiPage.getNodeId(),
17110                                                    wikiPage.getVersion()
17111                                            };
17112    
17113                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N_V, args,
17114                                            Long.valueOf(1));
17115                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V, args,
17116                                            wikiPage);
17117                            }
17118    
17119                            if ((wikiPageModelImpl.getColumnBitmask() &
17120                                            FINDER_PATH_FETCH_BY_N_T_V.getColumnBitmask()) != 0) {
17121                                    Object[] args = new Object[] {
17122                                                    wikiPage.getNodeId(), wikiPage.getTitle(),
17123                                                    wikiPage.getVersion()
17124                                            };
17125    
17126                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_V, args,
17127                                            Long.valueOf(1));
17128                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V, args,
17129                                            wikiPage);
17130                            }
17131                    }
17132            }
17133    
17134            protected void clearUniqueFindersCache(WikiPage wikiPage) {
17135                    WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
17136    
17137                    Object[] args = new Object[] { wikiPage.getUuid(), wikiPage.getGroupId() };
17138    
17139                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
17140                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
17141    
17142                    if ((wikiPageModelImpl.getColumnBitmask() &
17143                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
17144                            args = new Object[] {
17145                                            wikiPageModelImpl.getOriginalUuid(),
17146                                            wikiPageModelImpl.getOriginalGroupId()
17147                                    };
17148    
17149                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
17150                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
17151                    }
17152    
17153                    args = new Object[] {
17154                                    wikiPage.getResourcePrimKey(), wikiPage.getNodeId(),
17155                                    wikiPage.getVersion()
17156                            };
17157    
17158                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_V, args);
17159                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V, args);
17160    
17161                    if ((wikiPageModelImpl.getColumnBitmask() &
17162                                    FINDER_PATH_FETCH_BY_R_N_V.getColumnBitmask()) != 0) {
17163                            args = new Object[] {
17164                                            wikiPageModelImpl.getOriginalResourcePrimKey(),
17165                                            wikiPageModelImpl.getOriginalNodeId(),
17166                                            wikiPageModelImpl.getOriginalVersion()
17167                                    };
17168    
17169                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_V, args);
17170                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V, args);
17171                    }
17172    
17173                    args = new Object[] {
17174                                    wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion()
17175                            };
17176    
17177                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_V, args);
17178                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V, args);
17179    
17180                    if ((wikiPageModelImpl.getColumnBitmask() &
17181                                    FINDER_PATH_FETCH_BY_N_T_V.getColumnBitmask()) != 0) {
17182                            args = new Object[] {
17183                                            wikiPageModelImpl.getOriginalNodeId(),
17184                                            wikiPageModelImpl.getOriginalTitle(),
17185                                            wikiPageModelImpl.getOriginalVersion()
17186                                    };
17187    
17188                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_V, args);
17189                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V, args);
17190                    }
17191            }
17192    
17193            /**
17194             * Creates a new wiki page with the primary key. Does not add the wiki page to the database.
17195             *
17196             * @param pageId the primary key for the new wiki page
17197             * @return the new wiki page
17198             */
17199            public WikiPage create(long pageId) {
17200                    WikiPage wikiPage = new WikiPageImpl();
17201    
17202                    wikiPage.setNew(true);
17203                    wikiPage.setPrimaryKey(pageId);
17204    
17205                    String uuid = PortalUUIDUtil.generate();
17206    
17207                    wikiPage.setUuid(uuid);
17208    
17209                    return wikiPage;
17210            }
17211    
17212            /**
17213             * Removes the wiki page with the primary key from the database. Also notifies the appropriate model listeners.
17214             *
17215             * @param pageId the primary key of the wiki page
17216             * @return the wiki page that was removed
17217             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
17218             * @throws SystemException if a system exception occurred
17219             */
17220            public WikiPage remove(long pageId)
17221                    throws NoSuchPageException, SystemException {
17222                    return remove((Serializable)pageId);
17223            }
17224    
17225            /**
17226             * Removes the wiki page with the primary key from the database. Also notifies the appropriate model listeners.
17227             *
17228             * @param primaryKey the primary key of the wiki page
17229             * @return the wiki page that was removed
17230             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
17231             * @throws SystemException if a system exception occurred
17232             */
17233            @Override
17234            public WikiPage remove(Serializable primaryKey)
17235                    throws NoSuchPageException, SystemException {
17236                    Session session = null;
17237    
17238                    try {
17239                            session = openSession();
17240    
17241                            WikiPage wikiPage = (WikiPage)session.get(WikiPageImpl.class,
17242                                            primaryKey);
17243    
17244                            if (wikiPage == null) {
17245                                    if (_log.isWarnEnabled()) {
17246                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
17247                                    }
17248    
17249                                    throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
17250                                            primaryKey);
17251                            }
17252    
17253                            return remove(wikiPage);
17254                    }
17255                    catch (NoSuchPageException nsee) {
17256                            throw nsee;
17257                    }
17258                    catch (Exception e) {
17259                            throw processException(e);
17260                    }
17261                    finally {
17262                            closeSession(session);
17263                    }
17264            }
17265    
17266            @Override
17267            protected WikiPage removeImpl(WikiPage wikiPage) throws SystemException {
17268                    wikiPage = toUnwrappedModel(wikiPage);
17269    
17270                    Session session = null;
17271    
17272                    try {
17273                            session = openSession();
17274    
17275                            if (!session.contains(wikiPage)) {
17276                                    wikiPage = (WikiPage)session.get(WikiPageImpl.class,
17277                                                    wikiPage.getPrimaryKeyObj());
17278                            }
17279    
17280                            if (wikiPage != null) {
17281                                    session.delete(wikiPage);
17282                            }
17283                    }
17284                    catch (Exception e) {
17285                            throw processException(e);
17286                    }
17287                    finally {
17288                            closeSession(session);
17289                    }
17290    
17291                    if (wikiPage != null) {
17292                            clearCache(wikiPage);
17293                    }
17294    
17295                    return wikiPage;
17296            }
17297    
17298            @Override
17299            public WikiPage updateImpl(com.liferay.portlet.wiki.model.WikiPage wikiPage)
17300                    throws SystemException {
17301                    wikiPage = toUnwrappedModel(wikiPage);
17302    
17303                    boolean isNew = wikiPage.isNew();
17304    
17305                    WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
17306    
17307                    if (Validator.isNull(wikiPage.getUuid())) {
17308                            String uuid = PortalUUIDUtil.generate();
17309    
17310                            wikiPage.setUuid(uuid);
17311                    }
17312    
17313                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
17314    
17315                    if (userId > 0) {
17316                            long companyId = wikiPage.getCompanyId();
17317    
17318                            long groupId = wikiPage.getGroupId();
17319    
17320                            long pageId = 0;
17321    
17322                            if (!isNew) {
17323                                    pageId = wikiPage.getPrimaryKey();
17324                            }
17325    
17326                            try {
17327                                    wikiPage.setTitle(SanitizerUtil.sanitize(companyId, groupId,
17328                                                    userId,
17329                                                    com.liferay.portlet.wiki.model.WikiPage.class.getName(),
17330                                                    pageId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
17331                                                    wikiPage.getTitle(), null));
17332                            }
17333                            catch (SanitizerException se) {
17334                                    throw new SystemException(se);
17335                            }
17336                    }
17337    
17338                    Session session = null;
17339    
17340                    try {
17341                            session = openSession();
17342    
17343                            if (wikiPage.isNew()) {
17344                                    session.save(wikiPage);
17345    
17346                                    wikiPage.setNew(false);
17347                            }
17348                            else {
17349                                    session.merge(wikiPage);
17350                            }
17351                    }
17352                    catch (Exception e) {
17353                            throw processException(e);
17354                    }
17355                    finally {
17356                            closeSession(session);
17357                    }
17358    
17359                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17360    
17361                    if (isNew || !WikiPageModelImpl.COLUMN_BITMASK_ENABLED) {
17362                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17363                    }
17364    
17365                    else {
17366                            if ((wikiPageModelImpl.getColumnBitmask() &
17367                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
17368                                    Object[] args = new Object[] { wikiPageModelImpl.getOriginalUuid() };
17369    
17370                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
17371                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
17372                                            args);
17373    
17374                                    args = new Object[] { wikiPageModelImpl.getUuid() };
17375    
17376                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
17377                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
17378                                            args);
17379                            }
17380    
17381                            if ((wikiPageModelImpl.getColumnBitmask() &
17382                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
17383                                    Object[] args = new Object[] {
17384                                                    wikiPageModelImpl.getOriginalUuid(),
17385                                                    wikiPageModelImpl.getOriginalCompanyId()
17386                                            };
17387    
17388                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
17389                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
17390                                            args);
17391    
17392                                    args = new Object[] {
17393                                                    wikiPageModelImpl.getUuid(),
17394                                                    wikiPageModelImpl.getCompanyId()
17395                                            };
17396    
17397                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
17398                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
17399                                            args);
17400                            }
17401    
17402                            if ((wikiPageModelImpl.getColumnBitmask() &
17403                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID.getColumnBitmask()) != 0) {
17404                                    Object[] args = new Object[] {
17405                                                    wikiPageModelImpl.getOriginalNodeId()
17406                                            };
17407    
17408                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NODEID, args);
17409                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID,
17410                                            args);
17411    
17412                                    args = new Object[] { wikiPageModelImpl.getNodeId() };
17413    
17414                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NODEID, args);
17415                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID,
17416                                            args);
17417                            }
17418    
17419                            if ((wikiPageModelImpl.getColumnBitmask() &
17420                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT.getColumnBitmask()) != 0) {
17421                                    Object[] args = new Object[] {
17422                                                    wikiPageModelImpl.getOriginalFormat()
17423                                            };
17424    
17425                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FORMAT, args);
17426                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT,
17427                                            args);
17428    
17429                                    args = new Object[] { wikiPageModelImpl.getFormat() };
17430    
17431                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FORMAT, args);
17432                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT,
17433                                            args);
17434                            }
17435    
17436                            if ((wikiPageModelImpl.getColumnBitmask() &
17437                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N.getColumnBitmask()) != 0) {
17438                                    Object[] args = new Object[] {
17439                                                    wikiPageModelImpl.getOriginalResourcePrimKey(),
17440                                                    wikiPageModelImpl.getOriginalNodeId()
17441                                            };
17442    
17443                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N, args);
17444                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N,
17445                                            args);
17446    
17447                                    args = new Object[] {
17448                                                    wikiPageModelImpl.getResourcePrimKey(),
17449                                                    wikiPageModelImpl.getNodeId()
17450                                            };
17451    
17452                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N, args);
17453                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N,
17454                                            args);
17455                            }
17456    
17457                            if ((wikiPageModelImpl.getColumnBitmask() &
17458                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T.getColumnBitmask()) != 0) {
17459                                    Object[] args = new Object[] {
17460                                                    wikiPageModelImpl.getOriginalNodeId(),
17461                                                    wikiPageModelImpl.getOriginalTitle()
17462                                            };
17463    
17464                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T, args);
17465                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T,
17466                                            args);
17467    
17468                                    args = new Object[] {
17469                                                    wikiPageModelImpl.getNodeId(),
17470                                                    wikiPageModelImpl.getTitle()
17471                                            };
17472    
17473                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T, args);
17474                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T,
17475                                            args);
17476                            }
17477    
17478                            if ((wikiPageModelImpl.getColumnBitmask() &
17479                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H.getColumnBitmask()) != 0) {
17480                                    Object[] args = new Object[] {
17481                                                    wikiPageModelImpl.getOriginalNodeId(),
17482                                                    wikiPageModelImpl.getOriginalHead()
17483                                            };
17484    
17485                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H, args);
17486                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H,
17487                                            args);
17488    
17489                                    args = new Object[] {
17490                                                    wikiPageModelImpl.getNodeId(),
17491                                                    wikiPageModelImpl.getHead()
17492                                            };
17493    
17494                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H, args);
17495                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H,
17496                                            args);
17497                            }
17498    
17499                            if ((wikiPageModelImpl.getColumnBitmask() &
17500                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P.getColumnBitmask()) != 0) {
17501                                    Object[] args = new Object[] {
17502                                                    wikiPageModelImpl.getOriginalNodeId(),
17503                                                    wikiPageModelImpl.getOriginalParentTitle()
17504                                            };
17505    
17506                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_P, args);
17507                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P,
17508                                            args);
17509    
17510                                    args = new Object[] {
17511                                                    wikiPageModelImpl.getNodeId(),
17512                                                    wikiPageModelImpl.getParentTitle()
17513                                            };
17514    
17515                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_P, args);
17516                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P,
17517                                            args);
17518                            }
17519    
17520                            if ((wikiPageModelImpl.getColumnBitmask() &
17521                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R.getColumnBitmask()) != 0) {
17522                                    Object[] args = new Object[] {
17523                                                    wikiPageModelImpl.getOriginalNodeId(),
17524                                                    wikiPageModelImpl.getOriginalRedirectTitle()
17525                                            };
17526    
17527                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_R, args);
17528                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R,
17529                                            args);
17530    
17531                                    args = new Object[] {
17532                                                    wikiPageModelImpl.getNodeId(),
17533                                                    wikiPageModelImpl.getRedirectTitle()
17534                                            };
17535    
17536                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_R, args);
17537                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R,
17538                                            args);
17539                            }
17540    
17541                            if ((wikiPageModelImpl.getColumnBitmask() &
17542                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S.getColumnBitmask()) != 0) {
17543                                    Object[] args = new Object[] {
17544                                                    wikiPageModelImpl.getOriginalNodeId(),
17545                                                    wikiPageModelImpl.getOriginalStatus()
17546                                            };
17547    
17548                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_S, args);
17549                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S,
17550                                            args);
17551    
17552                                    args = new Object[] {
17553                                                    wikiPageModelImpl.getNodeId(),
17554                                                    wikiPageModelImpl.getStatus()
17555                                            };
17556    
17557                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_S, args);
17558                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S,
17559                                            args);
17560                            }
17561    
17562                            if ((wikiPageModelImpl.getColumnBitmask() &
17563                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_H.getColumnBitmask()) != 0) {
17564                                    Object[] args = new Object[] {
17565                                                    wikiPageModelImpl.getOriginalResourcePrimKey(),
17566                                                    wikiPageModelImpl.getOriginalNodeId(),
17567                                                    wikiPageModelImpl.getOriginalHead()
17568                                            };
17569    
17570                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_H, args);
17571                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_H,
17572                                            args);
17573    
17574                                    args = new Object[] {
17575                                                    wikiPageModelImpl.getResourcePrimKey(),
17576                                                    wikiPageModelImpl.getNodeId(),
17577                                                    wikiPageModelImpl.getHead()
17578                                            };
17579    
17580                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_H, args);
17581                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_H,
17582                                            args);
17583                            }
17584    
17585                            if ((wikiPageModelImpl.getColumnBitmask() &
17586                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S.getColumnBitmask()) != 0) {
17587                                    Object[] args = new Object[] {
17588                                                    wikiPageModelImpl.getOriginalResourcePrimKey(),
17589                                                    wikiPageModelImpl.getOriginalNodeId(),
17590                                                    wikiPageModelImpl.getOriginalStatus()
17591                                            };
17592    
17593                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_S, args);
17594                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S,
17595                                            args);
17596    
17597                                    args = new Object[] {
17598                                                    wikiPageModelImpl.getResourcePrimKey(),
17599                                                    wikiPageModelImpl.getNodeId(),
17600                                                    wikiPageModelImpl.getStatus()
17601                                            };
17602    
17603                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_S, args);
17604                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S,
17605                                            args);
17606                            }
17607    
17608                            if ((wikiPageModelImpl.getColumnBitmask() &
17609                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H.getColumnBitmask()) != 0) {
17610                                    Object[] args = new Object[] {
17611                                                    wikiPageModelImpl.getOriginalGroupId(),
17612                                                    wikiPageModelImpl.getOriginalNodeId(),
17613                                                    wikiPageModelImpl.getOriginalHead()
17614                                            };
17615    
17616                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H, args);
17617                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H,
17618                                            args);
17619    
17620                                    args = new Object[] {
17621                                                    wikiPageModelImpl.getGroupId(),
17622                                                    wikiPageModelImpl.getNodeId(),
17623                                                    wikiPageModelImpl.getHead()
17624                                            };
17625    
17626                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H, args);
17627                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H,
17628                                            args);
17629                            }
17630    
17631                            if ((wikiPageModelImpl.getColumnBitmask() &
17632                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S.getColumnBitmask()) != 0) {
17633                                    Object[] args = new Object[] {
17634                                                    wikiPageModelImpl.getOriginalGroupId(),
17635                                                    wikiPageModelImpl.getOriginalNodeId(),
17636                                                    wikiPageModelImpl.getOriginalStatus()
17637                                            };
17638    
17639                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_S, args);
17640                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S,
17641                                            args);
17642    
17643                                    args = new Object[] {
17644                                                    wikiPageModelImpl.getGroupId(),
17645                                                    wikiPageModelImpl.getNodeId(),
17646                                                    wikiPageModelImpl.getStatus()
17647                                            };
17648    
17649                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_S, args);
17650                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S,
17651                                            args);
17652                            }
17653    
17654                            if ((wikiPageModelImpl.getColumnBitmask() &
17655                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S.getColumnBitmask()) != 0) {
17656                                    Object[] args = new Object[] {
17657                                                    wikiPageModelImpl.getOriginalUserId(),
17658                                                    wikiPageModelImpl.getOriginalNodeId(),
17659                                                    wikiPageModelImpl.getOriginalStatus()
17660                                            };
17661    
17662                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_N_S, args);
17663                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S,
17664                                            args);
17665    
17666                                    args = new Object[] {
17667                                                    wikiPageModelImpl.getUserId(),
17668                                                    wikiPageModelImpl.getNodeId(),
17669                                                    wikiPageModelImpl.getStatus()
17670                                            };
17671    
17672                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_N_S, args);
17673                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S,
17674                                            args);
17675                            }
17676    
17677                            if ((wikiPageModelImpl.getColumnBitmask() &
17678                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H.getColumnBitmask()) != 0) {
17679                                    Object[] args = new Object[] {
17680                                                    wikiPageModelImpl.getOriginalNodeId(),
17681                                                    wikiPageModelImpl.getOriginalTitle(),
17682                                                    wikiPageModelImpl.getOriginalHead()
17683                                            };
17684    
17685                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_H, args);
17686                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H,
17687                                            args);
17688    
17689                                    args = new Object[] {
17690                                                    wikiPageModelImpl.getNodeId(),
17691                                                    wikiPageModelImpl.getTitle(),
17692                                                    wikiPageModelImpl.getHead()
17693                                            };
17694    
17695                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_H, args);
17696                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H,
17697                                            args);
17698                            }
17699    
17700                            if ((wikiPageModelImpl.getColumnBitmask() &
17701                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S.getColumnBitmask()) != 0) {
17702                                    Object[] args = new Object[] {
17703                                                    wikiPageModelImpl.getOriginalNodeId(),
17704                                                    wikiPageModelImpl.getOriginalTitle(),
17705                                                    wikiPageModelImpl.getOriginalStatus()
17706                                            };
17707    
17708                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_S, args);
17709                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S,
17710                                            args);
17711    
17712                                    args = new Object[] {
17713                                                    wikiPageModelImpl.getNodeId(),
17714                                                    wikiPageModelImpl.getTitle(),
17715                                                    wikiPageModelImpl.getStatus()
17716                                            };
17717    
17718                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_S, args);
17719                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S,
17720                                            args);
17721                            }
17722    
17723                            if ((wikiPageModelImpl.getColumnBitmask() &
17724                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P.getColumnBitmask()) != 0) {
17725                                    Object[] args = new Object[] {
17726                                                    wikiPageModelImpl.getOriginalNodeId(),
17727                                                    wikiPageModelImpl.getOriginalHead(),
17728                                                    wikiPageModelImpl.getOriginalParentTitle()
17729                                            };
17730    
17731                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P, args);
17732                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P,
17733                                            args);
17734    
17735                                    args = new Object[] {
17736                                                    wikiPageModelImpl.getNodeId(),
17737                                                    wikiPageModelImpl.getHead(),
17738                                                    wikiPageModelImpl.getParentTitle()
17739                                            };
17740    
17741                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P, args);
17742                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P,
17743                                            args);
17744                            }
17745    
17746                            if ((wikiPageModelImpl.getColumnBitmask() &
17747                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S.getColumnBitmask()) != 0) {
17748                                    Object[] args = new Object[] {
17749                                                    wikiPageModelImpl.getOriginalNodeId(),
17750                                                    wikiPageModelImpl.getOriginalHead(),
17751                                                    wikiPageModelImpl.getOriginalStatus()
17752                                            };
17753    
17754                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_S, args);
17755                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S,
17756                                            args);
17757    
17758                                    args = new Object[] {
17759                                                    wikiPageModelImpl.getNodeId(),
17760                                                    wikiPageModelImpl.getHead(),
17761                                                    wikiPageModelImpl.getStatus()
17762                                            };
17763    
17764                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_S, args);
17765                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S,
17766                                            args);
17767                            }
17768    
17769                            if ((wikiPageModelImpl.getColumnBitmask() &
17770                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S.getColumnBitmask()) != 0) {
17771                                    Object[] args = new Object[] {
17772                                                    wikiPageModelImpl.getOriginalGroupId(),
17773                                                    wikiPageModelImpl.getOriginalUserId(),
17774                                                    wikiPageModelImpl.getOriginalNodeId(),
17775                                                    wikiPageModelImpl.getOriginalStatus()
17776                                            };
17777    
17778                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_N_S, args);
17779                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S,
17780                                            args);
17781    
17782                                    args = new Object[] {
17783                                                    wikiPageModelImpl.getGroupId(),
17784                                                    wikiPageModelImpl.getUserId(),
17785                                                    wikiPageModelImpl.getNodeId(),
17786                                                    wikiPageModelImpl.getStatus()
17787                                            };
17788    
17789                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_N_S, args);
17790                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S,
17791                                            args);
17792                            }
17793    
17794                            if ((wikiPageModelImpl.getColumnBitmask() &
17795                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H.getColumnBitmask()) != 0) {
17796                                    Object[] args = new Object[] {
17797                                                    wikiPageModelImpl.getOriginalGroupId(),
17798                                                    wikiPageModelImpl.getOriginalNodeId(),
17799                                                    wikiPageModelImpl.getOriginalTitle(),
17800                                                    wikiPageModelImpl.getOriginalHead()
17801                                            };
17802    
17803                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_T_H, args);
17804                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H,
17805                                            args);
17806    
17807                                    args = new Object[] {
17808                                                    wikiPageModelImpl.getGroupId(),
17809                                                    wikiPageModelImpl.getNodeId(),
17810                                                    wikiPageModelImpl.getTitle(),
17811                                                    wikiPageModelImpl.getHead()
17812                                            };
17813    
17814                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_T_H, args);
17815                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H,
17816                                            args);
17817                            }
17818    
17819                            if ((wikiPageModelImpl.getColumnBitmask() &
17820                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S.getColumnBitmask()) != 0) {
17821                                    Object[] args = new Object[] {
17822                                                    wikiPageModelImpl.getOriginalGroupId(),
17823                                                    wikiPageModelImpl.getOriginalNodeId(),
17824                                                    wikiPageModelImpl.getOriginalHead(),
17825                                                    wikiPageModelImpl.getOriginalStatus()
17826                                            };
17827    
17828                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_S, args);
17829                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S,
17830                                            args);
17831    
17832                                    args = new Object[] {
17833                                                    wikiPageModelImpl.getGroupId(),
17834                                                    wikiPageModelImpl.getNodeId(),
17835                                                    wikiPageModelImpl.getHead(),
17836                                                    wikiPageModelImpl.getStatus()
17837                                            };
17838    
17839                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_S, args);
17840                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S,
17841                                            args);
17842                            }
17843    
17844                            if ((wikiPageModelImpl.getColumnBitmask() &
17845                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S.getColumnBitmask()) != 0) {
17846                                    Object[] args = new Object[] {
17847                                                    wikiPageModelImpl.getOriginalNodeId(),
17848                                                    wikiPageModelImpl.getOriginalHead(),
17849                                                    wikiPageModelImpl.getOriginalParentTitle(),
17850                                                    wikiPageModelImpl.getOriginalStatus()
17851                                            };
17852    
17853                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P_S, args);
17854                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S,
17855                                            args);
17856    
17857                                    args = new Object[] {
17858                                                    wikiPageModelImpl.getNodeId(),
17859                                                    wikiPageModelImpl.getHead(),
17860                                                    wikiPageModelImpl.getParentTitle(),
17861                                                    wikiPageModelImpl.getStatus()
17862                                            };
17863    
17864                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P_S, args);
17865                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S,
17866                                            args);
17867                            }
17868    
17869                            if ((wikiPageModelImpl.getColumnBitmask() &
17870                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S.getColumnBitmask()) != 0) {
17871                                    Object[] args = new Object[] {
17872                                                    wikiPageModelImpl.getOriginalGroupId(),
17873                                                    wikiPageModelImpl.getOriginalNodeId(),
17874                                                    wikiPageModelImpl.getOriginalHead(),
17875                                                    wikiPageModelImpl.getOriginalParentTitle(),
17876                                                    wikiPageModelImpl.getOriginalStatus()
17877                                            };
17878    
17879                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_P_S,
17880                                            args);
17881                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S,
17882                                            args);
17883    
17884                                    args = new Object[] {
17885                                                    wikiPageModelImpl.getGroupId(),
17886                                                    wikiPageModelImpl.getNodeId(),
17887                                                    wikiPageModelImpl.getHead(),
17888                                                    wikiPageModelImpl.getParentTitle(),
17889                                                    wikiPageModelImpl.getStatus()
17890                                            };
17891    
17892                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_P_S,
17893                                            args);
17894                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S,
17895                                            args);
17896                            }
17897                    }
17898    
17899                    EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
17900                            WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
17901    
17902                    clearUniqueFindersCache(wikiPage);
17903                    cacheUniqueFindersCache(wikiPage);
17904    
17905                    return wikiPage;
17906            }
17907    
17908            protected WikiPage toUnwrappedModel(WikiPage wikiPage) {
17909                    if (wikiPage instanceof WikiPageImpl) {
17910                            return wikiPage;
17911                    }
17912    
17913                    WikiPageImpl wikiPageImpl = new WikiPageImpl();
17914    
17915                    wikiPageImpl.setNew(wikiPage.isNew());
17916                    wikiPageImpl.setPrimaryKey(wikiPage.getPrimaryKey());
17917    
17918                    wikiPageImpl.setUuid(wikiPage.getUuid());
17919                    wikiPageImpl.setPageId(wikiPage.getPageId());
17920                    wikiPageImpl.setResourcePrimKey(wikiPage.getResourcePrimKey());
17921                    wikiPageImpl.setGroupId(wikiPage.getGroupId());
17922                    wikiPageImpl.setCompanyId(wikiPage.getCompanyId());
17923                    wikiPageImpl.setUserId(wikiPage.getUserId());
17924                    wikiPageImpl.setUserName(wikiPage.getUserName());
17925                    wikiPageImpl.setCreateDate(wikiPage.getCreateDate());
17926                    wikiPageImpl.setModifiedDate(wikiPage.getModifiedDate());
17927                    wikiPageImpl.setNodeId(wikiPage.getNodeId());
17928                    wikiPageImpl.setTitle(wikiPage.getTitle());
17929                    wikiPageImpl.setVersion(wikiPage.getVersion());
17930                    wikiPageImpl.setMinorEdit(wikiPage.isMinorEdit());
17931                    wikiPageImpl.setContent(wikiPage.getContent());
17932                    wikiPageImpl.setSummary(wikiPage.getSummary());
17933                    wikiPageImpl.setFormat(wikiPage.getFormat());
17934                    wikiPageImpl.setHead(wikiPage.isHead());
17935                    wikiPageImpl.setParentTitle(wikiPage.getParentTitle());
17936                    wikiPageImpl.setRedirectTitle(wikiPage.getRedirectTitle());
17937                    wikiPageImpl.setStatus(wikiPage.getStatus());
17938                    wikiPageImpl.setStatusByUserId(wikiPage.getStatusByUserId());
17939                    wikiPageImpl.setStatusByUserName(wikiPage.getStatusByUserName());
17940                    wikiPageImpl.setStatusDate(wikiPage.getStatusDate());
17941    
17942                    return wikiPageImpl;
17943            }
17944    
17945            /**
17946             * Returns the wiki page with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
17947             *
17948             * @param primaryKey the primary key of the wiki page
17949             * @return the wiki page
17950             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
17951             * @throws SystemException if a system exception occurred
17952             */
17953            @Override
17954            public WikiPage findByPrimaryKey(Serializable primaryKey)
17955                    throws NoSuchPageException, SystemException {
17956                    WikiPage wikiPage = fetchByPrimaryKey(primaryKey);
17957    
17958                    if (wikiPage == null) {
17959                            if (_log.isWarnEnabled()) {
17960                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
17961                            }
17962    
17963                            throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
17964                                    primaryKey);
17965                    }
17966    
17967                    return wikiPage;
17968            }
17969    
17970            /**
17971             * Returns the wiki page with the primary key or throws a {@link com.liferay.portlet.wiki.NoSuchPageException} if it could not be found.
17972             *
17973             * @param pageId the primary key of the wiki page
17974             * @return the wiki page
17975             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
17976             * @throws SystemException if a system exception occurred
17977             */
17978            public WikiPage findByPrimaryKey(long pageId)
17979                    throws NoSuchPageException, SystemException {
17980                    return findByPrimaryKey((Serializable)pageId);
17981            }
17982    
17983            /**
17984             * Returns the wiki page with the primary key or returns <code>null</code> if it could not be found.
17985             *
17986             * @param primaryKey the primary key of the wiki page
17987             * @return the wiki page, or <code>null</code> if a wiki page with the primary key could not be found
17988             * @throws SystemException if a system exception occurred
17989             */
17990            @Override
17991            public WikiPage fetchByPrimaryKey(Serializable primaryKey)
17992                    throws SystemException {
17993                    WikiPage wikiPage = (WikiPage)EntityCacheUtil.getResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
17994                                    WikiPageImpl.class, primaryKey);
17995    
17996                    if (wikiPage == _nullWikiPage) {
17997                            return null;
17998                    }
17999    
18000                    if (wikiPage == null) {
18001                            Session session = null;
18002    
18003                            try {
18004                                    session = openSession();
18005    
18006                                    wikiPage = (WikiPage)session.get(WikiPageImpl.class, primaryKey);
18007    
18008                                    if (wikiPage != null) {
18009                                            cacheResult(wikiPage);
18010                                    }
18011                                    else {
18012                                            EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
18013                                                    WikiPageImpl.class, primaryKey, _nullWikiPage);
18014                                    }
18015                            }
18016                            catch (Exception e) {
18017                                    EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
18018                                            WikiPageImpl.class, primaryKey);
18019    
18020                                    throw processException(e);
18021                            }
18022                            finally {
18023                                    closeSession(session);
18024                            }
18025                    }
18026    
18027                    return wikiPage;
18028            }
18029    
18030            /**
18031             * Returns the wiki page with the primary key or returns <code>null</code> if it could not be found.
18032             *
18033             * @param pageId the primary key of the wiki page
18034             * @return the wiki page, or <code>null</code> if a wiki page with the primary key could not be found
18035             * @throws SystemException if a system exception occurred
18036             */
18037            public WikiPage fetchByPrimaryKey(long pageId) throws SystemException {
18038                    return fetchByPrimaryKey((Serializable)pageId);
18039            }
18040    
18041            /**
18042             * Returns all the wiki pages.
18043             *
18044             * @return the wiki pages
18045             * @throws SystemException if a system exception occurred
18046             */
18047            public List<WikiPage> findAll() throws SystemException {
18048                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18049            }
18050    
18051            /**
18052             * Returns a range of all the wiki pages.
18053             *
18054             * <p>
18055             * 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.
18056             * </p>
18057             *
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             * @return the range of wiki pages
18061             * @throws SystemException if a system exception occurred
18062             */
18063            public List<WikiPage> findAll(int start, int end) throws SystemException {
18064                    return findAll(start, end, null);
18065            }
18066    
18067            /**
18068             * Returns an ordered range of all the wiki pages.
18069             *
18070             * <p>
18071             * 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.
18072             * </p>
18073             *
18074             * @param start the lower bound of the range of wiki pages
18075             * @param end the upper bound of the range of wiki pages (not inclusive)
18076             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18077             * @return the ordered range of wiki pages
18078             * @throws SystemException if a system exception occurred
18079             */
18080            public List<WikiPage> findAll(int start, int end,
18081                    OrderByComparator orderByComparator) throws SystemException {
18082                    boolean pagination = true;
18083                    FinderPath finderPath = null;
18084                    Object[] finderArgs = null;
18085    
18086                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18087                                    (orderByComparator == null)) {
18088                            pagination = false;
18089                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
18090                            finderArgs = FINDER_ARGS_EMPTY;
18091                    }
18092                    else {
18093                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
18094                            finderArgs = new Object[] { start, end, orderByComparator };
18095                    }
18096    
18097                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
18098                                    finderArgs, this);
18099    
18100                    if (list == null) {
18101                            StringBundler query = null;
18102                            String sql = null;
18103    
18104                            if (orderByComparator != null) {
18105                                    query = new StringBundler(2 +
18106                                                    (orderByComparator.getOrderByFields().length * 3));
18107    
18108                                    query.append(_SQL_SELECT_WIKIPAGE);
18109    
18110                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18111                                            orderByComparator);
18112    
18113                                    sql = query.toString();
18114                            }
18115                            else {
18116                                    sql = _SQL_SELECT_WIKIPAGE;
18117    
18118                                    if (pagination) {
18119                                            sql = sql.concat(WikiPageModelImpl.ORDER_BY_JPQL);
18120                                    }
18121                            }
18122    
18123                            Session session = null;
18124    
18125                            try {
18126                                    session = openSession();
18127    
18128                                    Query q = session.createQuery(sql);
18129    
18130                                    if (!pagination) {
18131                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
18132                                                            start, end, false);
18133    
18134                                            Collections.sort(list);
18135    
18136                                            list = new UnmodifiableList<WikiPage>(list);
18137                                    }
18138                                    else {
18139                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
18140                                                            start, end);
18141                                    }
18142    
18143                                    cacheResult(list);
18144    
18145                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18146                            }
18147                            catch (Exception e) {
18148                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18149    
18150                                    throw processException(e);
18151                            }
18152                            finally {
18153                                    closeSession(session);
18154                            }
18155                    }
18156    
18157                    return list;
18158            }
18159    
18160            /**
18161             * Removes all the wiki pages from the database.
18162             *
18163             * @throws SystemException if a system exception occurred
18164             */
18165            public void removeAll() throws SystemException {
18166                    for (WikiPage wikiPage : findAll()) {
18167                            remove(wikiPage);
18168                    }
18169            }
18170    
18171            /**
18172             * Returns the number of wiki pages.
18173             *
18174             * @return the number of wiki pages
18175             * @throws SystemException if a system exception occurred
18176             */
18177            public int countAll() throws SystemException {
18178                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
18179                                    FINDER_ARGS_EMPTY, this);
18180    
18181                    if (count == null) {
18182                            Session session = null;
18183    
18184                            try {
18185                                    session = openSession();
18186    
18187                                    Query q = session.createQuery(_SQL_COUNT_WIKIPAGE);
18188    
18189                                    count = (Long)q.uniqueResult();
18190    
18191                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
18192                                            FINDER_ARGS_EMPTY, count);
18193                            }
18194                            catch (Exception e) {
18195                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
18196                                            FINDER_ARGS_EMPTY);
18197    
18198                                    throw processException(e);
18199                            }
18200                            finally {
18201                                    closeSession(session);
18202                            }
18203                    }
18204    
18205                    return count.intValue();
18206            }
18207    
18208            /**
18209             * Initializes the wiki page persistence.
18210             */
18211            public void afterPropertiesSet() {
18212                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
18213                                            com.liferay.portal.util.PropsUtil.get(
18214                                                    "value.object.listener.com.liferay.portlet.wiki.model.WikiPage")));
18215    
18216                    if (listenerClassNames.length > 0) {
18217                            try {
18218                                    List<ModelListener<WikiPage>> listenersList = new ArrayList<ModelListener<WikiPage>>();
18219    
18220                                    for (String listenerClassName : listenerClassNames) {
18221                                            listenersList.add((ModelListener<WikiPage>)InstanceFactory.newInstance(
18222                                                            listenerClassName));
18223                                    }
18224    
18225                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
18226                            }
18227                            catch (Exception e) {
18228                                    _log.error(e);
18229                            }
18230                    }
18231            }
18232    
18233            public void destroy() {
18234                    EntityCacheUtil.removeCache(WikiPageImpl.class.getName());
18235                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
18236                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18237                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18238            }
18239    
18240            private static final String _SQL_SELECT_WIKIPAGE = "SELECT wikiPage FROM WikiPage wikiPage";
18241            private static final String _SQL_SELECT_WIKIPAGE_WHERE = "SELECT wikiPage FROM WikiPage wikiPage WHERE ";
18242            private static final String _SQL_COUNT_WIKIPAGE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage";
18243            private static final String _SQL_COUNT_WIKIPAGE_WHERE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage WHERE ";
18244            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "wikiPage.resourcePrimKey";
18245            private static final String _FILTER_SQL_SELECT_WIKIPAGE_WHERE = "SELECT DISTINCT {wikiPage.*} FROM WikiPage wikiPage WHERE ";
18246            private static final String _FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1 =
18247                    "SELECT {WikiPage.*} FROM (SELECT DISTINCT wikiPage.pageId FROM WikiPage wikiPage WHERE ";
18248            private static final String _FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2 =
18249                    ") TEMP_TABLE INNER JOIN WikiPage ON TEMP_TABLE.pageId = WikiPage.pageId";
18250            private static final String _FILTER_SQL_COUNT_WIKIPAGE_WHERE = "SELECT COUNT(DISTINCT wikiPage.pageId) AS COUNT_VALUE FROM WikiPage wikiPage WHERE ";
18251            private static final String _FILTER_ENTITY_ALIAS = "wikiPage";
18252            private static final String _FILTER_ENTITY_TABLE = "WikiPage";
18253            private static final String _ORDER_BY_ENTITY_ALIAS = "wikiPage.";
18254            private static final String _ORDER_BY_ENTITY_TABLE = "WikiPage.";
18255            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiPage exists with the primary key ";
18256            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiPage exists with the key {";
18257            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
18258            private static Log _log = LogFactoryUtil.getLog(WikiPagePersistenceImpl.class);
18259            private static WikiPage _nullWikiPage = new WikiPageImpl() {
18260                            @Override
18261                            public Object clone() {
18262                                    return this;
18263                            }
18264    
18265                            @Override
18266                            public CacheModel<WikiPage> toCacheModel() {
18267                                    return _nullWikiPageCacheModel;
18268                            }
18269                    };
18270    
18271            private static CacheModel<WikiPage> _nullWikiPageCacheModel = new CacheModel<WikiPage>() {
18272                            public WikiPage toEntityModel() {
18273                                    return _nullWikiPage;
18274                            }
18275                    };
18276    }